Fix linting and typechecking errors
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
* @module ol/render/webgl/BatchRenderer
|
||||
*/
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import {WebGLWorkerMessageType} from './constants.js';
|
||||
import {abstract} from '../../util.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
makeInverse as makeInverseTransform,
|
||||
multiply as multiplyTransform,
|
||||
} from '../../transform.js';
|
||||
import {abstract} from '../../util.js';
|
||||
import {WebGLWorkerMessageType} from './constants.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} CustomAttribute A description of a custom attribute to be passed on to the GPU, with a value different
|
||||
@@ -27,11 +27,11 @@ let workerMessageCounter = 0;
|
||||
*/
|
||||
class AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper
|
||||
* @param {Worker} worker
|
||||
* @param {string} vertexShader
|
||||
* @param {string} fragmentShader
|
||||
* @param {Array<CustomAttribute>} customAttributes
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
* @param {Worker} worker WebGL worker instance
|
||||
* @param {string} vertexShader Vertex shader
|
||||
* @param {string} fragmentShader Fragment shader
|
||||
* @param {Array<CustomAttribute>} customAttributes List of custom attributes
|
||||
*/
|
||||
constructor(helper, worker, vertexShader, fragmentShader, customAttributes) {
|
||||
/**
|
||||
@@ -69,9 +69,9 @@ class AbstractBatchRenderer {
|
||||
/**
|
||||
* Rebuild rendering instructions and webgl buffers based on the provided frame state
|
||||
* Note: this is a costly operation.
|
||||
* @param {import("./MixedGeometryBatch.js").AbstractGeometryBatch} batch
|
||||
* @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch
|
||||
* @param {import("../../PluggableMap").FrameState} frameState Frame state.
|
||||
* @param {import("../../geom/GeometryType.js").default} geometryType
|
||||
* @param {import("../../geom/GeometryType.js").default} geometryType Geometry type
|
||||
*/
|
||||
rebuild(batch, frameState, geometryType) {
|
||||
// store transform for rendering instructions
|
||||
@@ -86,12 +86,13 @@ class AbstractBatchRenderer {
|
||||
/**
|
||||
* Render the geometries in the batch. This will also update the current transform used for rendering according to
|
||||
* the invert transform of the webgl buffers
|
||||
* @param {import("./MixedGeometryBatch.js").AbstractGeometryBatch} batch
|
||||
* @param {import("../../transform.js").Transform} currentTransform
|
||||
* @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch
|
||||
* @param {import("../../transform.js").Transform} currentTransform Transform
|
||||
* @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
|
||||
*/
|
||||
render(batch, currentTransform, frameState) {
|
||||
// multiply the current projection transform with the invert of the one used to fill buffers
|
||||
// FIXME: this should probably be done directly in the layer renderer
|
||||
this.helper_.makeProjectionTransform(frameState, currentTransform);
|
||||
multiplyTransform(currentTransform, batch.invertVerticesBufferTransform);
|
||||
|
||||
@@ -108,7 +109,7 @@ class AbstractBatchRenderer {
|
||||
/**
|
||||
* Rebuild rendering instructions based on the provided frame state
|
||||
* This is specific to the geometry type and has to be implemented by subclasses.
|
||||
* @param {import("./MixedGeometryBatch.js").default} batch
|
||||
* @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch
|
||||
* @protected
|
||||
*/
|
||||
generateRenderInstructions_(batch) {
|
||||
@@ -118,8 +119,8 @@ class AbstractBatchRenderer {
|
||||
/**
|
||||
* Rebuild internal webgl buffers for rendering based on the current rendering instructions;
|
||||
* This is asynchronous: webgl buffers wil _not_ be updated right away
|
||||
* @param {import("./MixedGeometryBatch.js").AbstractGeometryBatch} batch
|
||||
* @param {import("../../geom/GeometryType.js").default} geometryType
|
||||
* @param {import("./MixedGeometryBatch.js").GeometryBatch} batch Geometry batch
|
||||
* @param {import("../../geom/GeometryType.js").default} geometryType Geometry type
|
||||
* @protected
|
||||
*/
|
||||
generateBuffers_(batch, geometryType) {
|
||||
@@ -136,6 +137,8 @@ class AbstractBatchRenderer {
|
||||
case GeometryType.LINE_STRING:
|
||||
messageType = WebGLWorkerMessageType.GENERATE_LINE_STRING_BUFFERS;
|
||||
break;
|
||||
default:
|
||||
// pass
|
||||
}
|
||||
|
||||
/** @type {import('./constants.js').WebGLWorkerGenerateBuffersMessage} */
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* @module ol/render/webgl/LineStringBatchRenderer
|
||||
*/
|
||||
import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import {transform2D} from '../../geom/flat/transform.js';
|
||||
import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
|
||||
class LineStringBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper
|
||||
* @param {Worker} worker
|
||||
* @param {string} vertexShader
|
||||
* @param {string} fragmentShader
|
||||
* @param {Array<import('./BatchRenderer.js').CustomAttribute>} customAttributes
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
* @param {Worker} worker WebGL worker instance
|
||||
* @param {string} vertexShader Vertex shader
|
||||
* @param {string} fragmentShader Fragment shader
|
||||
* @param {Array<import('./BatchRenderer.js').CustomAttribute>} customAttributes List of custom attributes
|
||||
*/
|
||||
constructor(helper, worker, vertexShader, fragmentShader, customAttributes) {
|
||||
super(helper, worker, vertexShader, fragmentShader, customAttributes);
|
||||
@@ -47,7 +47,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* Render instructions for lines are structured like so:
|
||||
* [ customAttr0, ... , customAttrN, numberOfVertices0, x0, y0, ... , xN, yN, numberOfVertices1, ... ]
|
||||
* @param {import("./MixedGeometryBatch.js").PointGeometryBatch} batch
|
||||
* @param {import("./MixedGeometryBatch.js").LineStringGeometryBatch} batch Linestring geometry batch
|
||||
* @override
|
||||
*/
|
||||
generateRenderInstructions_(batch) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* @module ol/render/webgl/MixedGeometryBatch
|
||||
*/
|
||||
import {getUid} from '../../util.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import WebGLArrayBuffer from '../../webgl/Buffer.js';
|
||||
import {ARRAY_BUFFER, DYNAMIC_DRAW, ELEMENT_ARRAY_BUFFER} from '../../webgl.js';
|
||||
import {create as createTransform} from '../../transform.js';
|
||||
import {getUid} from '../../util.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} GeometryBatchItem Object that holds a reference to a feature as well as the raw coordinates of its various geometries
|
||||
@@ -18,36 +18,52 @@ import {create as createTransform} from '../../transform.js';
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} AbstractGeometryBatch
|
||||
* @abstract
|
||||
* @typedef {PointGeometryBatch|LineStringGeometryBatch|PolygonGeometryBatch} GeometryBatch
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} PolygonGeometryBatch A geometry batch specific to polygons
|
||||
* @property {Object<string, GeometryBatchItem>} entries Dictionary of all entries in the batch with associated computed values.
|
||||
* One entry corresponds to one feature. Key is feature uid.
|
||||
* @property {number} geometriesCount Amount of geometries in the batch.
|
||||
* @property {Float32Array} renderInstructions Render instructions for polygons are structured like so:
|
||||
* [ numberOfRings, numberOfVerticesInRing0, ..., numberOfVerticesInRingN, x0, y0, customAttr0, ..., xN, yN, customAttrN, numberOfRings,... ]
|
||||
* @property {WebGLArrayBuffer} verticesBuffer
|
||||
* @property {WebGLArrayBuffer} indicesBuffer
|
||||
* @property {WebGLArrayBuffer} verticesBuffer Vertices WebGL buffer
|
||||
* @property {WebGLArrayBuffer} indicesBuffer Indices WebGL buffer
|
||||
* @property {import("../../transform.js").Transform} renderInstructionsTransform Converts world space coordinates to screen space; applies to the rendering instructions
|
||||
* @property {import("../../transform.js").Transform} verticesBufferTransform Converts world space coordinates to screen space; applies to the webgl vertices buffer
|
||||
* @property {import("../../transform.js").Transform} invertVerticesBufferTransform Screen space to world space; applies to the webgl vertices buffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} PolygonGeometryBatch A geometry batch specific to polygons
|
||||
* @extends {AbstractGeometryBatch}
|
||||
* @property {number} verticesCount Amount of vertices from geometries in the batch.
|
||||
* @property {number} ringsCount How many outer and inner rings in this batch.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} LineStringGeometryBatch A geometry batch specific to lines
|
||||
* @extends {AbstractGeometryBatch}
|
||||
* @property {Object<string, GeometryBatchItem>} entries Dictionary of all entries in the batch with associated computed values.
|
||||
* One entry corresponds to one feature. Key is feature uid.
|
||||
* @property {number} geometriesCount Amount of geometries in the batch.
|
||||
* @property {Float32Array} renderInstructions Render instructions for polygons are structured like so:
|
||||
* [ numberOfRings, numberOfVerticesInRing0, ..., numberOfVerticesInRingN, x0, y0, customAttr0, ..., xN, yN, customAttrN, numberOfRings,... ]
|
||||
* @property {WebGLArrayBuffer} verticesBuffer Vertices WebGL buffer
|
||||
* @property {WebGLArrayBuffer} indicesBuffer Indices WebGL buffer
|
||||
* @property {import("../../transform.js").Transform} renderInstructionsTransform Converts world space coordinates to screen space; applies to the rendering instructions
|
||||
* @property {import("../../transform.js").Transform} verticesBufferTransform Converts world space coordinates to screen space; applies to the webgl vertices buffer
|
||||
* @property {import("../../transform.js").Transform} invertVerticesBufferTransform Screen space to world space; applies to the webgl vertices buffer
|
||||
* @property {number} verticesCount Amount of vertices from geometries in the batch.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} PointGeometryBatch A geometry batch specific to points
|
||||
* @extends {AbstractGeometryBatch}
|
||||
* @property {Object<string, GeometryBatchItem>} entries Dictionary of all entries in the batch with associated computed values.
|
||||
* One entry corresponds to one feature. Key is feature uid.
|
||||
* @property {number} geometriesCount Amount of geometries in the batch.
|
||||
* @property {Float32Array} renderInstructions Render instructions for polygons are structured like so:
|
||||
* [ numberOfRings, numberOfVerticesInRing0, ..., numberOfVerticesInRingN, x0, y0, customAttr0, ..., xN, yN, customAttrN, numberOfRings,... ]
|
||||
* @property {WebGLArrayBuffer} verticesBuffer Vertices WebGL buffer
|
||||
* @property {WebGLArrayBuffer} indicesBuffer Indices WebGL buffer
|
||||
* @property {import("../../transform.js").Transform} renderInstructionsTransform Converts world space coordinates to screen space; applies to the rendering instructions
|
||||
* @property {import("../../transform.js").Transform} verticesBufferTransform Converts world space coordinates to screen space; applies to the webgl vertices buffer
|
||||
* @property {import("../../transform.js").Transform} invertVerticesBufferTransform Screen space to world space; applies to the webgl vertices buffer
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -118,7 +134,7 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default[]} features
|
||||
* @param {Array<import("../../Feature").default>} features Array of features to add to the batch
|
||||
*/
|
||||
addFeatures(features) {
|
||||
for (let i = 0; i < features.length; i++) {
|
||||
@@ -127,7 +143,7 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../Feature").default} feature Feature to add to the batch
|
||||
*/
|
||||
addFeature(feature) {
|
||||
const geometry = feature.getGeometry();
|
||||
@@ -138,8 +154,8 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @return {GeometryBatchItem}
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @return {GeometryBatchItem} Batch item added (or existing one)
|
||||
* @private
|
||||
*/
|
||||
addFeatureEntryInPointBatch_(feature) {
|
||||
@@ -155,8 +171,8 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @return {GeometryBatchItem}
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @return {GeometryBatchItem} Batch item added (or existing one)
|
||||
* @private
|
||||
*/
|
||||
addFeatureEntryInLineStringBatch_(feature) {
|
||||
@@ -173,8 +189,8 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @return {GeometryBatchItem}
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @return {GeometryBatchItem} Batch item added (or existing one)
|
||||
* @private
|
||||
*/
|
||||
addFeatureEntryInPolygonBatch_(feature) {
|
||||
@@ -193,35 +209,41 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @private
|
||||
*/
|
||||
clearFeatureEntryInPointBatch_(feature) {
|
||||
const entry = this.pointBatch.entries[getUid(feature)];
|
||||
if (!entry) return;
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
this.pointBatch.geometriesCount -= entry.flatCoordss.length;
|
||||
delete this.pointBatch.entries[getUid(feature)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @private
|
||||
*/
|
||||
clearFeatureEntryInLineStringBatch_(feature) {
|
||||
const entry = this.lineStringBatch.entries[getUid(feature)];
|
||||
if (!entry) return;
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
this.lineStringBatch.verticesCount -= entry.verticesCount;
|
||||
this.lineStringBatch.geometriesCount -= entry.flatCoordss.length;
|
||||
delete this.lineStringBatch.entries[getUid(feature)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @private
|
||||
*/
|
||||
clearFeatureEntryInPolygonBatch_(feature) {
|
||||
const entry = this.polygonBatch.entries[getUid(feature)];
|
||||
if (!entry) return;
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
this.polygonBatch.verticesCount -= entry.verticesCount;
|
||||
this.polygonBatch.ringsCount -= entry.ringsCount;
|
||||
this.polygonBatch.geometriesCount -= entry.flatCoordss.length;
|
||||
@@ -229,8 +251,8 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../geom").Geometry} geometry
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../geom").Geometry} geometry Geometry
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
* @private
|
||||
*/
|
||||
addGeometry_(geometry, feature) {
|
||||
@@ -240,29 +262,34 @@ class MixedGeometryBatch {
|
||||
let batchEntry;
|
||||
switch (type) {
|
||||
case GeometryType.GEOMETRY_COLLECTION:
|
||||
geometry
|
||||
/** @type {import("../../geom").GeometryCollection} */ (geometry)
|
||||
.getGeometries()
|
||||
.map((geom) => this.addGeometry_(geom, feature));
|
||||
break;
|
||||
case GeometryType.MULTI_POLYGON:
|
||||
geometry
|
||||
/** @type {import("../../geom").MultiPolygon} */ (geometry)
|
||||
.getPolygons()
|
||||
.map((polygon) => this.addGeometry_(polygon, feature));
|
||||
break;
|
||||
case GeometryType.MULTI_LINE_STRING:
|
||||
geometry
|
||||
/** @type {import("../../geom").MultiLineString} */ (geometry)
|
||||
.getLineStrings()
|
||||
.map((line) => this.addGeometry_(line, feature));
|
||||
break;
|
||||
case GeometryType.MULTI_POINT:
|
||||
geometry.getPoints().map((point) => this.addGeometry_(point, feature));
|
||||
/** @type {import("../../geom").MultiPoint} */ (geometry)
|
||||
.getPoints()
|
||||
.map((point) => this.addGeometry_(point, feature));
|
||||
break;
|
||||
case GeometryType.POLYGON:
|
||||
const polygonGeom = /** @type {import("../../geom").Polygon} */ (
|
||||
geometry
|
||||
);
|
||||
batchEntry = this.addFeatureEntryInPolygonBatch_(feature);
|
||||
flatCoords = geometry.getFlatCoordinates();
|
||||
flatCoords = polygonGeom.getFlatCoordinates();
|
||||
verticesCount = flatCoords.length / 2;
|
||||
const ringsCount = geometry.getLinearRingCount();
|
||||
const ringsVerticesCount = geometry
|
||||
const ringsCount = polygonGeom.getLinearRingCount();
|
||||
const ringsVerticesCount = polygonGeom
|
||||
.getEnds()
|
||||
.map((end, ind, arr) =>
|
||||
ind > 0 ? (end - arr[ind - 1]) / 2 : end / 2
|
||||
@@ -274,31 +301,37 @@ class MixedGeometryBatch {
|
||||
batchEntry.ringsVerticesCounts.push(ringsVerticesCount);
|
||||
batchEntry.verticesCount += verticesCount;
|
||||
batchEntry.ringsCount += ringsCount;
|
||||
geometry
|
||||
polygonGeom
|
||||
.getLinearRings()
|
||||
.map((ring) => this.addGeometry_(ring, feature));
|
||||
break;
|
||||
case GeometryType.POINT:
|
||||
const pointGeom = /** @type {import("../../geom").Point} */ (geometry);
|
||||
batchEntry = this.addFeatureEntryInPointBatch_(feature);
|
||||
flatCoords = geometry.getFlatCoordinates();
|
||||
flatCoords = pointGeom.getFlatCoordinates();
|
||||
this.pointBatch.geometriesCount++;
|
||||
batchEntry.flatCoordss.push(flatCoords);
|
||||
break;
|
||||
case GeometryType.LINE_STRING:
|
||||
case GeometryType.LINEAR_RING:
|
||||
const lineGeom = /** @type {import("../../geom").LineString} */ (
|
||||
geometry
|
||||
);
|
||||
batchEntry = this.addFeatureEntryInLineStringBatch_(feature);
|
||||
flatCoords = geometry.getFlatCoordinates();
|
||||
flatCoords = lineGeom.getFlatCoordinates();
|
||||
verticesCount = flatCoords.length / 2;
|
||||
this.lineStringBatch.verticesCount += verticesCount;
|
||||
this.lineStringBatch.geometriesCount++;
|
||||
batchEntry.flatCoordss.push(flatCoords);
|
||||
batchEntry.verticesCount += verticesCount;
|
||||
break;
|
||||
default:
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
*/
|
||||
changeFeature(feature) {
|
||||
this.clearFeatureEntryInPointBatch_(feature);
|
||||
@@ -312,7 +345,7 @@ class MixedGeometryBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../Feature").default} feature
|
||||
* @param {import("../../Feature").default} feature Feature
|
||||
*/
|
||||
removeFeature(feature) {
|
||||
this.clearFeatureEntryInPointBatch_(feature);
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
* @module ol/render/webgl/PointBatchRenderer
|
||||
*/
|
||||
|
||||
import {apply as applyTransform} from '../../transform.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import {apply as applyTransform} from '../../transform.js';
|
||||
|
||||
class PointBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper
|
||||
* @param {Worker} worker
|
||||
* @param {string} vertexShader
|
||||
* @param {string} fragmentShader
|
||||
* @param {Array<import('./BatchRenderer.js').CustomAttribute>} customAttributes
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
* @param {Worker} worker WebGL worker instance
|
||||
* @param {string} vertexShader Vertex shader
|
||||
* @param {string} fragmentShader Fragment shader
|
||||
* @param {Array<import('./BatchRenderer.js').CustomAttribute>} customAttributes List of custom attributes
|
||||
*/
|
||||
constructor(helper, worker, vertexShader, fragmentShader, customAttributes) {
|
||||
super(helper, worker, vertexShader, fragmentShader, customAttributes);
|
||||
@@ -43,7 +43,7 @@ class PointBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* Render instructions for lines are structured like so:
|
||||
* [ x0, y0, customAttr0, ... , xN, yN, customAttrN ]
|
||||
* @param {import("./MixedGeometryBatch.js").PointGeometryBatch} batch
|
||||
* @param {import("./MixedGeometryBatch.js").PointGeometryBatch} batch Point geometry batch
|
||||
* @override
|
||||
*/
|
||||
generateRenderInstructions_(batch) {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* @module ol/render/webgl/PolygonBatchRenderer
|
||||
*/
|
||||
import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import {transform2D} from '../../geom/flat/transform.js';
|
||||
import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
|
||||
class PolygonBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper
|
||||
* @param {Worker} worker
|
||||
* @param {string} vertexShader
|
||||
* @param {string} fragmentShader
|
||||
* @param {Array<import('./BatchRenderer.js').CustomAttribute>} customAttributes
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
* @param {Worker} worker WebGL worker instance
|
||||
* @param {string} vertexShader Vertex shader
|
||||
* @param {string} fragmentShader Fragment shader
|
||||
* @param {Array<import('./BatchRenderer.js').CustomAttribute>} customAttributes List of custom attributes
|
||||
*/
|
||||
constructor(helper, worker, vertexShader, fragmentShader, customAttributes) {
|
||||
super(helper, worker, vertexShader, fragmentShader, customAttributes);
|
||||
@@ -37,7 +37,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* Render instructions for polygons are structured like so:
|
||||
* [ customAttr0, ..., customAttrN, numberOfRings, numberOfVerticesInRing0, ..., numberOfVerticesInRingN, x0, y0, ..., xN, yN, numberOfRings,... ]
|
||||
* @param {import("./MixedGeometryBatch.js").PolygonGeometryBatch} batch
|
||||
* @param {import("./MixedGeometryBatch.js").PolygonGeometryBatch} batch Polygon geometry batch
|
||||
* @override
|
||||
*/
|
||||
generateRenderInstructions_(batch) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* @module ol/render/webgl/utils
|
||||
*/
|
||||
import earcut from 'earcut';
|
||||
import {apply as applyTransform} from '../../transform.js';
|
||||
import {clamp} from '../../math.js';
|
||||
import earcut from 'earcut';
|
||||
|
||||
const tmpArray_ = [];
|
||||
|
||||
@@ -103,9 +103,9 @@ export function writePointFeatureToBuffers(
|
||||
* @param {number} segmentEndIndex Index of the segment start point from which render instructions will be read.
|
||||
* @param {number|null} beforeSegmentIndex Index of the point right before the segment (null if none, e.g this is a line start)
|
||||
* @param {number|null} afterSegmentIndex Index of the point right after the segment (null if none, e.g this is a line end)
|
||||
* @param {number[]} vertexArray Array containing vertices.
|
||||
* @param {number[]} indexArray Array containing indices.
|
||||
* @param {number[]} customAttributes Array of custom attributes value
|
||||
* @param {Array<number>} vertexArray Array containing vertices.
|
||||
* @param {Array<number>} indexArray Array containing indices.
|
||||
* @param {Array<number>} customAttributes Array of custom attributes value
|
||||
* @param {import('../../transform.js').Transform} instructionsTransform Transform matrix used to project coordinates in instructions
|
||||
* @param {import('../../transform.js').Transform} invertInstructionsTransform Transform matrix used to project coordinates in instructions
|
||||
* @private
|
||||
@@ -125,7 +125,7 @@ export function writeLineSegmentToBuffers(
|
||||
// compute the stride to determine how many vertices were already pushed
|
||||
const baseVertexAttrsCount = 5; // base attributes: x0, y0, x1, y1, params (vertex number [0-3], join angle 1, join angle 2)
|
||||
const stride = baseVertexAttrsCount + customAttributes.length;
|
||||
let baseIndex = vertexArray.length / stride;
|
||||
const baseIndex = vertexArray.length / stride;
|
||||
|
||||
// The segment is composed of two positions called P0[x0, y0] and P1[x1, y1]
|
||||
// Depending on whether there are points before and after the segment, its final shape
|
||||
@@ -253,8 +253,8 @@ export function writeLineSegmentToBuffers(
|
||||
* Pushes several triangles to form a polygon, including holes
|
||||
* @param {Float32Array} instructions Array of render instructions for lines.
|
||||
* @param {number} polygonStartIndex Index of the polygon start point from which render instructions will be read.
|
||||
* @param {number[]} vertexArray Array containing vertices.
|
||||
* @param {number[]} indexArray Array containing indices.
|
||||
* @param {Array<number>} vertexArray Array containing vertices.
|
||||
* @param {Array<number>} indexArray Array containing indices.
|
||||
* @param {number} customAttributesCount Amount of custom attributes for each element.
|
||||
* @return {number} Next polygon instructions index
|
||||
* @private
|
||||
@@ -279,7 +279,9 @@ export function writePolygonTrianglesToBuffers(
|
||||
const holes = new Array(ringsCount - 1);
|
||||
for (let i = 0; i < ringsCount; i++) {
|
||||
verticesCount += instructions[instructionsIndex++];
|
||||
if (i < ringsCount - 1) holes[i] = verticesCount;
|
||||
if (i < ringsCount - 1) {
|
||||
holes[i] = verticesCount;
|
||||
}
|
||||
}
|
||||
const flatCoords = instructions.slice(
|
||||
instructionsIndex,
|
||||
|
||||
@@ -9,6 +9,7 @@ import WebGLLayerRenderer from './Layer.js';
|
||||
import WebGLRenderTarget from '../../webgl/RenderTarget.js';
|
||||
import {ARRAY_BUFFER, DYNAMIC_DRAW, ELEMENT_ARRAY_BUFFER} from '../../webgl.js';
|
||||
import {AttributeType, DefaultUniform} from '../../webgl/Helper.js';
|
||||
import {WebGLWorkerMessageType} from '../../render/webgl/constants.js';
|
||||
import {
|
||||
apply as applyTransform,
|
||||
create as createTransform,
|
||||
@@ -18,11 +19,10 @@ import {
|
||||
} from '../../transform.js';
|
||||
import {assert} from '../../asserts.js';
|
||||
import {buffer, createEmpty, equals, getWidth} from '../../extent.js';
|
||||
import {colorDecodeId, colorEncodeId} from '../../render/webgl/utils.js';
|
||||
import {create as createWebGLWorker} from '../../worker/webgl.js';
|
||||
import {getUid} from '../../util.js';
|
||||
import {listen, unlistenByKey} from '../../events.js';
|
||||
import {colorDecodeId, colorEncodeId} from '../../render/webgl/utils.js';
|
||||
import {WebGLWorkerMessageType} from '../../render/webgl/constants.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} CustomAttribute A description of a custom attribute to be passed on to the GPU, with a value different
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/**
|
||||
* @module ol/renderer/webgl/VectorLayer
|
||||
*/
|
||||
import WebGLLayerRenderer from './Layer.js';
|
||||
import {create as createTransform} from '../../transform.js';
|
||||
import {DefaultUniform} from '../../webgl/Helper.js';
|
||||
import {buffer, createEmpty, equals} from '../../extent.js';
|
||||
import {create as createWebGLWorker} from '../../worker/webgl.js';
|
||||
import {listen, unlistenByKey} from '../../events.js';
|
||||
import BaseVector from '../../layer/BaseVector.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import LineStringBatchRenderer from '../../render/webgl/LineStringBatchRenderer.js';
|
||||
import MixedGeometryBatch from '../../render/webgl/MixedGeometryBatch.js';
|
||||
import PointBatchRenderer from '../../render/webgl/PointBatchRenderer.js';
|
||||
import PolygonBatchRenderer from '../../render/webgl/PolygonBatchRenderer.js';
|
||||
import VectorEventType from '../../source/VectorEventType.js';
|
||||
import ViewHint from '../../ViewHint.js';
|
||||
import BaseVector from '../../layer/BaseVector.js';
|
||||
import MixedGeometryBatch from '../../render/webgl/MixedGeometryBatch.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import PolygonBatchRenderer from '../../render/webgl/PolygonBatchRenderer.js';
|
||||
import PointBatchRenderer from '../../render/webgl/PointBatchRenderer.js';
|
||||
import LineStringBatchRenderer from '../../render/webgl/LineStringBatchRenderer.js';
|
||||
import WebGLRenderTarget from '../../webgl/RenderTarget.js';
|
||||
import WebGLLayerRenderer from './Layer.js';
|
||||
import {DefaultUniform} from '../../webgl/Helper.js';
|
||||
import {buffer, createEmpty, equals} from '../../extent.js';
|
||||
import {create as createTransform} from '../../transform.js';
|
||||
import {create as createWebGLWorker} from '../../worker/webgl.js';
|
||||
import {listen, unlistenByKey} from '../../events.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} CustomAttribute A description of a custom attribute to be passed on to the GPU, with a value different
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
* A worker that does cpu-heavy tasks related to webgl rendering.
|
||||
* @module ol/worker/webgl
|
||||
*/
|
||||
import {assign} from '../obj.js';
|
||||
import {WebGLWorkerMessageType} from '../render/webgl/constants.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
makeInverse as makeInverseTransform,
|
||||
} from '../transform.js';
|
||||
import {
|
||||
writeLineSegmentToBuffers,
|
||||
writePointFeatureToBuffers,
|
||||
writePolygonTrianglesToBuffers,
|
||||
} from '../render/webgl/utils.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
makeInverse as makeInverseTransform,
|
||||
} from '../transform.js';
|
||||
|
||||
/** @type {any} */
|
||||
const worker = self;
|
||||
@@ -170,6 +170,8 @@ worker.onmessage = (event) => {
|
||||
]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// pass
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import PointBatchRenderer from '../../../../../../src/ol/render/webgl/PointBatchRenderer.js';
|
||||
import WebGLHelper from '../../../../../../src/ol/webgl/Helper.js';
|
||||
import {create as createWebGLWorker} from '../../../../../../src/ol/worker/webgl.js';
|
||||
import MixedGeometryBatch from '../../../../../../src/ol/render/webgl/MixedGeometryBatch.js';
|
||||
import Feature from '../../../../../../src/ol/Feature.js';
|
||||
import Point from '../../../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../../../src/ol/geom/Polygon.js';
|
||||
import LineString from '../../../../../../src/ol/geom/LineString.js';
|
||||
import GeometryType from '../../../../../../src/ol/geom/GeometryType.js';
|
||||
import {create as createTransform} from '../../../../../../src/ol/transform.js';
|
||||
import {WebGLWorkerMessageType} from '../../../../../../src/ol/render/webgl/constants.js';
|
||||
import LineString from '../../../../../../src/ol/geom/LineString.js';
|
||||
import LineStringBatchRenderer from '../../../../../../src/ol/render/webgl/LineStringBatchRenderer.js';
|
||||
import {FLOAT} from '../../../../../../src/ol/webgl.js';
|
||||
import MixedGeometryBatch from '../../../../../../src/ol/render/webgl/MixedGeometryBatch.js';
|
||||
import Point from '../../../../../../src/ol/geom/Point.js';
|
||||
import PointBatchRenderer from '../../../../../../src/ol/render/webgl/PointBatchRenderer.js';
|
||||
import Polygon from '../../../../../../src/ol/geom/Polygon.js';
|
||||
import PolygonBatchRenderer from '../../../../../../src/ol/render/webgl/PolygonBatchRenderer.js';
|
||||
import WebGLHelper from '../../../../../../src/ol/webgl/Helper.js';
|
||||
import {FLOAT} from '../../../../../../src/ol/webgl.js';
|
||||
import {WebGLWorkerMessageType} from '../../../../../../src/ol/render/webgl/constants.js';
|
||||
import {create as createTransform} from '../../../../../../src/ol/transform.js';
|
||||
import {create as createWebGLWorker} from '../../../../../../src/ol/worker/webgl.js';
|
||||
|
||||
const POINT_VERTEX_SHADER = `precision mediump float;
|
||||
void main(void) {}`;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import Feature from '../../../../../../src/ol/Feature.js';
|
||||
import Point from '../../../../../../src/ol/geom/Point.js';
|
||||
import MixedGeometryBatch from '../../../../../../src/ol/render/webgl/MixedGeometryBatch.js';
|
||||
import LineString from '../../../../../../src/ol/geom/LineString.js';
|
||||
import {getUid} from '../../../../../../src/ol/index.js';
|
||||
import Polygon from '../../../../../../src/ol/geom/Polygon.js';
|
||||
import LinearRing from '../../../../../../src/ol/geom/LinearRing.js';
|
||||
import MultiPolygon from '../../../../../../src/ol/geom/MultiPolygon.js';
|
||||
import GeometryCollection from '../../../../../../src/ol/geom/GeometryCollection.js';
|
||||
import LineString from '../../../../../../src/ol/geom/LineString.js';
|
||||
import LinearRing from '../../../../../../src/ol/geom/LinearRing.js';
|
||||
import MixedGeometryBatch from '../../../../../../src/ol/render/webgl/MixedGeometryBatch.js';
|
||||
import MultiLineString from '../../../../../../src/ol/geom/MultiLineString.js';
|
||||
import MultiPoint from '../../../../../../src/ol/geom/MultiPoint.js';
|
||||
import MultiPolygon from '../../../../../../src/ol/geom/MultiPolygon.js';
|
||||
import Point from '../../../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../../../src/ol/geom/Polygon.js';
|
||||
import {getUid} from '../../../../../../src/ol/index.js';
|
||||
|
||||
describe('MixedGeometryBatch', function () {
|
||||
let mixedBatch;
|
||||
|
||||
@@ -8,12 +8,6 @@ import VectorSource from '../../../../../../src/ol/source/Vector.js';
|
||||
import View from '../../../../../../src/ol/View.js';
|
||||
import WebGLLayerRenderer from '../../../../../../src/ol/renderer/webgl/Layer.js';
|
||||
import {getUid} from '../../../../../../src/ol/util.js';
|
||||
import {
|
||||
colorDecodeId,
|
||||
colorEncodeId,
|
||||
getBlankImageData,
|
||||
writePointFeatureToBuffers,
|
||||
} from '../../../../../../src/ol/render/webgl/utils.js';
|
||||
|
||||
describe('ol/renderer/webgl/Layer', function () {
|
||||
describe('constructor', function () {
|
||||
|
||||
Reference in New Issue
Block a user