Webgl / Adapt the points renderer to use custom attributes
Now most attributes will be custom ones defined by the user of the renderer. The hit detection is broken for now and still has to be fixed. Also it is not possible anymore to give a texture to the renderer, this will have to be fixed as well.
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* @module ol/worker/webgl
|
||||
*/
|
||||
import {
|
||||
POINT_INSTRUCTIONS_COUNT,
|
||||
POINT_VERTEX_STRIDE,
|
||||
WebGLWorkerMessageType,
|
||||
writePointFeatureToBuffers
|
||||
} from '../renderer/webgl/Layer.js';
|
||||
@@ -16,13 +14,17 @@ const worker = self;
|
||||
worker.onmessage = event => {
|
||||
const received = event.data;
|
||||
if (received.type === WebGLWorkerMessageType.GENERATE_BUFFERS) {
|
||||
// This is specific to point features
|
||||
const baseVertexAttrsCount = 3;
|
||||
const baseInstructionsCount = 2;
|
||||
|
||||
const customAttrsCount = received.customAttributesCount;
|
||||
const instructionsCount = baseInstructionsCount + customAttrsCount;
|
||||
const renderInstructions = new Float32Array(received.renderInstructions);
|
||||
const customAttributesCount = received.customAttributesCount || 0;
|
||||
const instructionsCount = POINT_INSTRUCTIONS_COUNT + customAttributesCount;
|
||||
|
||||
const elementsCount = renderInstructions.length / instructionsCount;
|
||||
const indicesCount = elementsCount * 6;
|
||||
const verticesCount = elementsCount * 4 * (POINT_VERTEX_STRIDE + customAttributesCount);
|
||||
const verticesCount = elementsCount * 4 * (customAttrsCount + baseVertexAttrsCount);
|
||||
const indexBuffer = new Uint32Array(indicesCount);
|
||||
const vertexBuffer = new Float32Array(verticesCount);
|
||||
|
||||
@@ -33,8 +35,8 @@ worker.onmessage = event => {
|
||||
i,
|
||||
vertexBuffer,
|
||||
indexBuffer,
|
||||
bufferPositions,
|
||||
instructionsCount);
|
||||
customAttrsCount,
|
||||
bufferPositions);
|
||||
}
|
||||
|
||||
/** @type {import('../renderer/webgl/Layer').WebGLWorkerGenerateBuffersMessage} */
|
||||
|
||||
Reference in New Issue
Block a user