diff --git a/src/ol/render/webgl/BatchRenderer.js b/src/ol/render/webgl/BatchRenderer.js index e8554757e8..5745e4c502 100644 --- a/src/ol/render/webgl/BatchRenderer.js +++ b/src/ol/render/webgl/BatchRenderer.js @@ -36,19 +36,19 @@ class AbstractBatchRenderer { constructor(helper, worker, vertexShader, fragmentShader, customAttributes) { /** * @type {import("../../webgl/Helper.js").default} - * @protected + * @private */ this.helper_ = helper; /** * @type {Worker} - * @protected + * @private */ this.worker_ = worker; /** * @type {WebGLProgram} - * @protected + * @private */ this.program_ = this.helper_.getProgram(fragmentShader, vertexShader); @@ -57,13 +57,13 @@ class AbstractBatchRenderer { * @type {Array} * @protected */ - this.attributes_ = []; + this.attributes = []; /** * @type {Array} * @protected */ - this.customAttributes_ = customAttributes; + this.customAttributes = customAttributes; } /** @@ -102,7 +102,7 @@ class AbstractBatchRenderer { this.helper_.useProgram(this.program_, frameState); this.helper_.bindBuffer(batch.verticesBuffer); this.helper_.bindBuffer(batch.indicesBuffer); - this.helper_.enableAttributes(this.attributes_); + this.helper_.enableAttributes(this.attributes); const renderCount = batch.indicesBuffer.getSize(); this.helper_.drawElements(0, renderCount); @@ -150,7 +150,7 @@ class AbstractBatchRenderer { type: messageType, renderInstructions: batch.renderInstructions.buffer, renderInstructionsTransform: batch.renderInstructionsTransform, - customAttributesCount: this.customAttributes_.length, + customAttributesCount: this.customAttributes.length, }; this.worker_.postMessage(message, [batch.renderInstructions.buffer]); diff --git a/src/ol/render/webgl/LineStringBatchRenderer.js b/src/ol/render/webgl/LineStringBatchRenderer.js index 1ec065ade9..7698e835c7 100644 --- a/src/ol/render/webgl/LineStringBatchRenderer.js +++ b/src/ol/render/webgl/LineStringBatchRenderer.js @@ -28,7 +28,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer { super(helper, worker, vertexShader, fragmentShader, customAttributes); // vertices for lines must hold both a position (x,y) and an offset (dx,dy) - this.attributes_ = [ + this.attributes = [ { name: Attributes.SEGMENT_START, size: 2, @@ -68,7 +68,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer { // + 1 instruction per line (for vertices count) const totalInstructionsCount = 2 * batch.verticesCount + - (1 + this.customAttributes_.length) * batch.geometriesCount; + (1 + this.customAttributes.length) * batch.geometriesCount; if ( !batch.renderInstructions || batch.renderInstructions.length !== totalInstructionsCount @@ -95,8 +95,8 @@ class LineStringBatchRenderer extends AbstractBatchRenderer { ); // custom attributes - for (let k = 0, kk = this.customAttributes_.length; k < kk; k++) { - value = this.customAttributes_[k].callback( + for (let k = 0, kk = this.customAttributes.length; k < kk; k++) { + value = this.customAttributes[k].callback( batchEntry.feature, batchEntry.properties ); diff --git a/src/ol/render/webgl/PointBatchRenderer.js b/src/ol/render/webgl/PointBatchRenderer.js index 3565989770..d593499f69 100644 --- a/src/ol/render/webgl/PointBatchRenderer.js +++ b/src/ol/render/webgl/PointBatchRenderer.js @@ -28,7 +28,7 @@ class PointBatchRenderer extends AbstractBatchRenderer { super(helper, worker, vertexShader, fragmentShader, customAttributes); // vertices for point must hold both a position (x,y) and an index (their position in the quad) - this.attributes_ = [ + this.attributes = [ { name: Attributes.POSITION, size: 2, @@ -61,7 +61,7 @@ class PointBatchRenderer extends AbstractBatchRenderer { // 2 instructions per vertex for position (x and y) // + 1 instruction per vertex per custom attributes const totalInstructionsCount = - (2 + this.customAttributes_.length) * batch.geometriesCount; + (2 + this.customAttributes.length) * batch.geometriesCount; if ( !batch.renderInstructions || batch.renderInstructions.length !== totalInstructionsCount @@ -85,8 +85,8 @@ class PointBatchRenderer extends AbstractBatchRenderer { batch.renderInstructions[renderIndex++] = tmpCoords[1]; // pushing custom attributes - for (let j = 0, jj = this.customAttributes_.length; j < jj; j++) { - value = this.customAttributes_[j].callback( + for (let j = 0, jj = this.customAttributes.length; j < jj; j++) { + value = this.customAttributes[j].callback( batchEntry.feature, batchEntry.properties ); diff --git a/src/ol/render/webgl/PolygonBatchRenderer.js b/src/ol/render/webgl/PolygonBatchRenderer.js index 15a4378ccb..b102840e1a 100644 --- a/src/ol/render/webgl/PolygonBatchRenderer.js +++ b/src/ol/render/webgl/PolygonBatchRenderer.js @@ -26,7 +26,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer { super(helper, worker, vertexShader, fragmentShader, customAttributes); // By default only a position attribute is required to render polygons - this.attributes_ = [ + this.attributes = [ { name: Attributes.POSITION, size: 2, @@ -57,7 +57,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer { // + 1 instruction per ring (for vertices count in ring) const totalInstructionsCount = 2 * batch.verticesCount + - (1 + this.customAttributes_.length) * batch.geometriesCount + + (1 + this.customAttributes.length) * batch.geometriesCount + batch.ringsCount; if ( !batch.renderInstructions || @@ -85,8 +85,8 @@ class PolygonBatchRenderer extends AbstractBatchRenderer { ); // custom attributes - for (let k = 0, kk = this.customAttributes_.length; k < kk; k++) { - value = this.customAttributes_[k].callback( + for (let k = 0, kk = this.customAttributes.length; k < kk; k++) { + value = this.customAttributes[k].callback( batchEntry.feature, batchEntry.properties ); diff --git a/src/ol/renderer/webgl/PointsLayer.js b/src/ol/renderer/webgl/PointsLayer.js index 3553d6121f..c7eca3db00 100644 --- a/src/ol/renderer/webgl/PointsLayer.js +++ b/src/ol/renderer/webgl/PointsLayer.js @@ -292,7 +292,11 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer { */ this.generateBuffersRun_ = 0; + /** + * @private + */ this.worker_ = createWebGLWorker(); + this.worker_.addEventListener( 'message', /** diff --git a/src/ol/renderer/webgl/VectorLayer.js b/src/ol/renderer/webgl/VectorLayer.js index 635db2f67d..f6704b04b9 100644 --- a/src/ol/renderer/webgl/VectorLayer.js +++ b/src/ol/renderer/webgl/VectorLayer.js @@ -156,8 +156,14 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer { DEFAULT_POINT_FRAGMENT; this.pointAttributes_ = toAttributesArray(pointAttributesWithDefault); + /** + * @private + */ this.worker_ = createWebGLWorker(); + /** + * @private + */ this.batch_ = new MixedGeometryBatch(); const source = this.getLayer().getSource(); diff --git a/test/browser/spec/ol/render/webgl/batchrenderer.test.js b/test/browser/spec/ol/render/webgl/BatchRenderer.test.js similarity index 98% rename from test/browser/spec/ol/render/webgl/batchrenderer.test.js rename to test/browser/spec/ol/render/webgl/BatchRenderer.test.js index 08050c091d..f4bdfdaa57 100644 --- a/test/browser/spec/ol/render/webgl/batchrenderer.test.js +++ b/test/browser/spec/ol/render/webgl/BatchRenderer.test.js @@ -89,7 +89,7 @@ describe('Batch renderers', function () { }); describe('constructor', function () { it('generates the attributes list', function () { - expect(batchRenderer.attributes_).to.eql([ + expect(batchRenderer.attributes).to.eql([ {name: 'a_position', size: 2, type: FLOAT}, {name: 'a_index', size: 1, type: FLOAT}, {name: 'a_test', size: 1, type: FLOAT}, @@ -192,7 +192,7 @@ describe('Batch renderers', function () { }); describe('constructor', function () { it('generates the attributes list', function () { - expect(batchRenderer.attributes_).to.eql([ + expect(batchRenderer.attributes).to.eql([ {name: 'a_segmentStart', size: 2, type: FLOAT}, {name: 'a_segmentEnd', size: 2, type: FLOAT}, {name: 'a_parameters', size: 1, type: FLOAT}, @@ -257,7 +257,7 @@ describe('Batch renderers', function () { }); describe('constructor', function () { it('generates the attributes list', function () { - expect(batchRenderer.attributes_).to.eql([ + expect(batchRenderer.attributes).to.eql([ {name: 'a_position', size: 2, type: FLOAT}, {name: 'a_test', size: 1, type: FLOAT}, ]); diff --git a/test/browser/spec/ol/render/webgl/mixedgeometrybatch.test.js b/test/browser/spec/ol/render/webgl/MixedGeometryBatch.test.js similarity index 100% rename from test/browser/spec/ol/render/webgl/mixedgeometrybatch.test.js rename to test/browser/spec/ol/render/webgl/MixedGeometryBatch.test.js