WebGL / Address review comments

This commit is contained in:
Olivier Guyot
2022-06-08 10:28:00 +02:00
parent f603ce7456
commit 6848df97f8
4 changed files with 7 additions and 9 deletions

View File

@@ -81,7 +81,7 @@ class AbstractBatchRenderer {
frameState, frameState,
createTransform() createTransform()
); );
this.generateRenderInstructions_(batch); this.generateRenderInstructions(batch);
this.generateBuffers_(batch, geometryType, callback); this.generateBuffers_(batch, geometryType, callback);
} }
@@ -115,7 +115,7 @@ class AbstractBatchRenderer {
* @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch * @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch
* @protected * @protected
*/ */
generateRenderInstructions_(batch) { generateRenderInstructions(batch) {
abstract(); abstract();
} }
@@ -125,7 +125,7 @@ class AbstractBatchRenderer {
* @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch * @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch
* @param {import("../../geom/GeometryType.js").default} geometryType Geometry type * @param {import("../../geom/GeometryType.js").default} geometryType Geometry type
* @param {function(): void} callback Function called once the render buffers are updated * @param {function(): void} callback Function called once the render buffers are updated
* @protected * @private
*/ */
generateBuffers_(batch, geometryType, callback) { generateBuffers_(batch, geometryType, callback) {
const messageId = workerMessageCounter++; const messageId = workerMessageCounter++;
@@ -153,8 +153,6 @@ class AbstractBatchRenderer {
renderInstructionsTransform: batch.renderInstructionsTransform, renderInstructionsTransform: batch.renderInstructionsTransform,
customAttributesCount: this.customAttributes_.length, customAttributesCount: this.customAttributes_.length,
}; };
// additional properties will be sent back as-is by the worker
message['projectionTransform'] = batch.renderInstructionsTransform;
this.worker_.postMessage(message, [batch.renderInstructions.buffer]); this.worker_.postMessage(message, [batch.renderInstructions.buffer]);
// leave ownership of render instructions // leave ownership of render instructions
@@ -177,7 +175,7 @@ class AbstractBatchRenderer {
this.worker_.removeEventListener('message', handleMessage); this.worker_.removeEventListener('message', handleMessage);
// store transform & invert transform for webgl buffers // store transform & invert transform for webgl buffers
batch.verticesBufferTransform = received.projectionTransform; batch.verticesBufferTransform = received.renderInstructionsTransform;
makeInverseTransform( makeInverseTransform(
batch.invertVerticesBufferTransform, batch.invertVerticesBufferTransform,
batch.verticesBufferTransform batch.verticesBufferTransform

View File

@@ -50,7 +50,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
* @param {import("./MixedGeometryBatch.js").LineStringGeometryBatch} batch Linestring geometry batch * @param {import("./MixedGeometryBatch.js").LineStringGeometryBatch} batch Linestring geometry batch
* @override * @override
*/ */
generateRenderInstructions_(batch) { generateRenderInstructions(batch) {
// here we anticipate the amount of render instructions for lines: // here we anticipate the amount of render instructions for lines:
// 2 instructions per vertex for position (x and y) // 2 instructions per vertex for position (x and y)
// + 1 instruction per line per custom attributes // + 1 instruction per line per custom attributes

View File

@@ -46,7 +46,7 @@ class PointBatchRenderer extends AbstractBatchRenderer {
* @param {import("./MixedGeometryBatch.js").PointGeometryBatch} batch Point geometry batch * @param {import("./MixedGeometryBatch.js").PointGeometryBatch} batch Point geometry batch
* @override * @override
*/ */
generateRenderInstructions_(batch) { generateRenderInstructions(batch) {
// here we anticipate the amount of render instructions for points: // here we anticipate the amount of render instructions for points:
// 2 instructions per vertex for position (x and y) // 2 instructions per vertex for position (x and y)
// + 1 instruction per vertex per custom attributes // + 1 instruction per vertex per custom attributes

View File

@@ -40,7 +40,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
* @param {import("./MixedGeometryBatch.js").PolygonGeometryBatch} batch Polygon geometry batch * @param {import("./MixedGeometryBatch.js").PolygonGeometryBatch} batch Polygon geometry batch
* @override * @override
*/ */
generateRenderInstructions_(batch) { generateRenderInstructions(batch) {
// here we anticipate the amount of render instructions for polygons: // here we anticipate the amount of render instructions for polygons:
// 2 instructions per vertex for position (x and y) // 2 instructions per vertex for position (x and y)
// + 1 instruction per polygon per custom attributes // + 1 instruction per polygon per custom attributes