ol 7.4.1-dev.1686166152921 → 7.4.1-dev.1686296564657
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/layer/Heatmap.d.ts.map +1 -1
- package/layer/Heatmap.js +10 -43
- package/layer/WebGLPoints.d.ts.map +1 -1
- package/layer/WebGLPoints.js +1 -6
- package/package.json +1 -1
- package/renderer/Layer.d.ts.map +1 -1
- package/renderer/Layer.js +4 -1
- package/renderer/webgl/PointsLayer.d.ts +13 -35
- package/renderer/webgl/PointsLayer.d.ts.map +1 -1
- package/renderer/webgl/PointsLayer.js +86 -181
- package/renderer/webgl/VectorLayer.d.ts +1 -0
- package/renderer/webgl/VectorLayer.d.ts.map +1 -1
- package/util.js +1 -1
- package/webgl/Helper.d.ts +6 -0
- package/webgl/Helper.d.ts.map +1 -1
- package/webgl/Helper.js +11 -1
- package/webgl/ShaderBuilder.d.ts +11 -25
- package/webgl/ShaderBuilder.d.ts.map +1 -1
- package/webgl/ShaderBuilder.js +52 -119
|
@@ -50,8 +50,7 @@ import {listen, unlistenByKey} from '../../events.js';
|
|
|
50
50
|
* Please note that these can only be numerical values.
|
|
51
51
|
* @property {string} vertexShader Vertex shader source, mandatory.
|
|
52
52
|
* @property {string} fragmentShader Fragment shader source, mandatory.
|
|
53
|
-
* @property {
|
|
54
|
-
* @property {string} [hitFragmentShader] Fragment shader source for hit detection rendering.
|
|
53
|
+
* @property {boolean} [hitDetectionEnabled] Whether shader is hit detection aware.
|
|
55
54
|
* @property {Object<string,import("../../webgl/Helper").UniformValue>} [uniforms] Uniform definitions for the post process steps
|
|
56
55
|
* Please note that `u_texture` is reserved for the main texture slot and `u_opacity` is reserved for the layer opacity.
|
|
57
56
|
* @property {Array<import("./Layer").PostProcessesOptions>} [postProcesses] Post-processes definitions
|
|
@@ -138,7 +137,6 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
138
137
|
this.sourceRevision_ = -1;
|
|
139
138
|
|
|
140
139
|
this.verticesBuffer_ = new WebGLArrayBuffer(ARRAY_BUFFER, DYNAMIC_DRAW);
|
|
141
|
-
this.hitVerticesBuffer_ = new WebGLArrayBuffer(ARRAY_BUFFER, DYNAMIC_DRAW);
|
|
142
140
|
this.indicesBuffer_ = new WebGLArrayBuffer(
|
|
143
141
|
ELEMENT_ARRAY_BUFFER,
|
|
144
142
|
DYNAMIC_DRAW
|
|
@@ -164,24 +162,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
164
162
|
* @type {boolean}
|
|
165
163
|
* @private
|
|
166
164
|
*/
|
|
167
|
-
this.hitDetectionEnabled_ =
|
|
168
|
-
options.hitFragmentShader && options.hitVertexShader ? true : false;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @private
|
|
172
|
-
*/
|
|
173
|
-
this.hitVertexShader_ = options.hitVertexShader;
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* @private
|
|
177
|
-
*/
|
|
178
|
-
this.hitFragmentShader_ = options.hitFragmentShader;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @type {WebGLProgram}
|
|
182
|
-
* @private
|
|
183
|
-
*/
|
|
184
|
-
this.hitProgram_;
|
|
165
|
+
this.hitDetectionEnabled_ = options.hitDetectionEnabled ?? true;
|
|
185
166
|
|
|
186
167
|
const customAttributes = options.attributes
|
|
187
168
|
? options.attributes.map(function (attribute) {
|
|
@@ -209,34 +190,21 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
209
190
|
size: 1,
|
|
210
191
|
type: AttributeType.FLOAT,
|
|
211
192
|
},
|
|
212
|
-
]
|
|
193
|
+
];
|
|
213
194
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @type {Array<import('../../webgl/Helper.js').AttributeDescription>}
|
|
217
|
-
*/
|
|
218
|
-
this.hitDetectionAttributes = [
|
|
219
|
-
{
|
|
220
|
-
name: 'a_position',
|
|
221
|
-
size: 2,
|
|
222
|
-
type: AttributeType.FLOAT,
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
name: 'a_index',
|
|
226
|
-
size: 1,
|
|
227
|
-
type: AttributeType.FLOAT,
|
|
228
|
-
},
|
|
229
|
-
{
|
|
195
|
+
if (this.hitDetectionEnabled_) {
|
|
196
|
+
this.attributes.push({
|
|
230
197
|
name: 'a_hitColor',
|
|
231
198
|
size: 4,
|
|
232
199
|
type: AttributeType.FLOAT,
|
|
233
|
-
}
|
|
234
|
-
{
|
|
200
|
+
});
|
|
201
|
+
this.attributes.push({
|
|
235
202
|
name: 'a_featureUid',
|
|
236
203
|
size: 1,
|
|
237
204
|
type: AttributeType.FLOAT,
|
|
238
|
-
}
|
|
239
|
-
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
this.attributes.push(...customAttributes);
|
|
240
208
|
|
|
241
209
|
this.customAttributes = options.attributes ? options.attributes : [];
|
|
242
210
|
|
|
@@ -270,13 +238,6 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
270
238
|
*/
|
|
271
239
|
this.renderInstructions_ = new Float32Array(0);
|
|
272
240
|
|
|
273
|
-
/**
|
|
274
|
-
* These instructions are used for hit detection
|
|
275
|
-
* @type {Float32Array}
|
|
276
|
-
* @private
|
|
277
|
-
*/
|
|
278
|
-
this.hitRenderInstructions_ = new Float32Array(0);
|
|
279
|
-
|
|
280
241
|
/**
|
|
281
242
|
* @type {WebGLRenderTarget}
|
|
282
243
|
* @private
|
|
@@ -304,13 +265,8 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
304
265
|
const received = event.data;
|
|
305
266
|
if (received.type === WebGLWorkerMessageType.GENERATE_POINT_BUFFERS) {
|
|
306
267
|
const projectionTransform = received.projectionTransform;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
this.helper.flushBufferData(this.hitVerticesBuffer_);
|
|
310
|
-
} else {
|
|
311
|
-
this.verticesBuffer_.fromArrayBuffer(received.vertexBuffer);
|
|
312
|
-
this.helper.flushBufferData(this.verticesBuffer_);
|
|
313
|
-
}
|
|
268
|
+
this.verticesBuffer_.fromArrayBuffer(received.vertexBuffer);
|
|
269
|
+
this.helper.flushBufferData(this.verticesBuffer_);
|
|
314
270
|
this.indicesBuffer_.fromArrayBuffer(received.indexBuffer);
|
|
315
271
|
this.helper.flushBufferData(this.indicesBuffer_);
|
|
316
272
|
|
|
@@ -319,19 +275,12 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
319
275
|
this.invertRenderTransform_,
|
|
320
276
|
this.renderTransform_
|
|
321
277
|
);
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
this.renderInstructions_ = new Float32Array(
|
|
328
|
-
event.data.renderInstructions
|
|
329
|
-
);
|
|
330
|
-
if (received.id === this.lastSentId) {
|
|
331
|
-
this.ready = true;
|
|
332
|
-
}
|
|
278
|
+
this.renderInstructions_ = new Float32Array(
|
|
279
|
+
event.data.renderInstructions
|
|
280
|
+
);
|
|
281
|
+
if (received.id === this.lastSentId) {
|
|
282
|
+
this.ready = true;
|
|
333
283
|
}
|
|
334
|
-
|
|
335
284
|
this.getLayer().changed();
|
|
336
285
|
}
|
|
337
286
|
}
|
|
@@ -395,11 +344,6 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
395
344
|
);
|
|
396
345
|
|
|
397
346
|
if (this.hitDetectionEnabled_) {
|
|
398
|
-
this.hitProgram_ = this.helper.getProgram(
|
|
399
|
-
this.hitFragmentShader_,
|
|
400
|
-
this.hitVertexShader_
|
|
401
|
-
);
|
|
402
|
-
|
|
403
347
|
this.hitRenderTarget_ = new WebGLRenderTarget(this.helper);
|
|
404
348
|
}
|
|
405
349
|
}
|
|
@@ -458,6 +402,36 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
458
402
|
const gl = this.helper.getGL();
|
|
459
403
|
this.preRender(gl, frameState);
|
|
460
404
|
|
|
405
|
+
const [startWorld, endWorld, worldWidth] =
|
|
406
|
+
this.getWorldParameters_(frameState);
|
|
407
|
+
|
|
408
|
+
// draw the normal canvas
|
|
409
|
+
this.renderWorlds(frameState, false, startWorld, endWorld, worldWidth);
|
|
410
|
+
|
|
411
|
+
this.helper.finalizeDraw(
|
|
412
|
+
frameState,
|
|
413
|
+
this.dispatchPreComposeEvent,
|
|
414
|
+
this.dispatchPostComposeEvent
|
|
415
|
+
);
|
|
416
|
+
const canvas = this.helper.getCanvas();
|
|
417
|
+
|
|
418
|
+
if (this.hitDetectionEnabled_) {
|
|
419
|
+
this.renderWorlds(frameState, true, startWorld, endWorld, worldWidth);
|
|
420
|
+
this.hitRenderTarget_.clearCachedData();
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
this.postRender(gl, frameState);
|
|
424
|
+
|
|
425
|
+
return canvas;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Compute world params
|
|
430
|
+
* @private
|
|
431
|
+
* @param {import("../../Map.js").FrameState} frameState Frame state.
|
|
432
|
+
* @return {Array<number>} The world start, end and width.
|
|
433
|
+
*/
|
|
434
|
+
getWorldParameters_(frameState) {
|
|
461
435
|
const projection = frameState.viewState.projection;
|
|
462
436
|
const layer = this.getLayer();
|
|
463
437
|
const vectorSource = layer.getSource();
|
|
@@ -475,34 +449,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
475
449
|
? Math.floor((extent[0] - projectionExtent[0]) / worldWidth)
|
|
476
450
|
: 0;
|
|
477
451
|
|
|
478
|
-
|
|
479
|
-
const renderCount = this.indicesBuffer_.getSize();
|
|
480
|
-
|
|
481
|
-
do {
|
|
482
|
-
// apply the current projection transform with the invert of the one used to fill buffers
|
|
483
|
-
this.helper.makeProjectionTransform(frameState, this.currentTransform_);
|
|
484
|
-
translateTransform(this.currentTransform_, world * worldWidth, 0);
|
|
485
|
-
multiplyTransform(this.currentTransform_, this.invertRenderTransform_);
|
|
486
|
-
this.helper.applyUniforms(frameState);
|
|
487
|
-
|
|
488
|
-
this.helper.drawElements(0, renderCount);
|
|
489
|
-
} while (++world < endWorld);
|
|
490
|
-
|
|
491
|
-
this.helper.finalizeDraw(
|
|
492
|
-
frameState,
|
|
493
|
-
this.dispatchPreComposeEvent,
|
|
494
|
-
this.dispatchPostComposeEvent
|
|
495
|
-
);
|
|
496
|
-
const canvas = this.helper.getCanvas();
|
|
497
|
-
|
|
498
|
-
if (this.hitDetectionEnabled_) {
|
|
499
|
-
this.renderHitDetection(frameState, startWorld, endWorld, worldWidth);
|
|
500
|
-
this.hitRenderTarget_.clearCachedData();
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
this.postRender(gl, frameState);
|
|
504
|
-
|
|
505
|
-
return canvas;
|
|
452
|
+
return [startWorld, endWorld, worldWidth];
|
|
506
453
|
}
|
|
507
454
|
|
|
508
455
|
/**
|
|
@@ -558,38 +505,22 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
558
505
|
const projectionTransform = createTransform();
|
|
559
506
|
this.helper.makeProjectionTransform(frameState, projectionTransform);
|
|
560
507
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
const totalInstructionsCount =
|
|
566
|
-
(2 + this.customAttributes.length) * this.featureCount_;
|
|
508
|
+
const baseInstructionLength = this.hitDetectionEnabled_ ? 7 : 2; // see below
|
|
509
|
+
const singleInstructionLength =
|
|
510
|
+
baseInstructionLength + this.customAttributes.length;
|
|
511
|
+
const totalSize = singleInstructionLength * this.featureCount_;
|
|
567
512
|
if (
|
|
568
513
|
!this.renderInstructions_ ||
|
|
569
|
-
this.renderInstructions_.length !==
|
|
514
|
+
this.renderInstructions_.length !== totalSize
|
|
570
515
|
) {
|
|
571
|
-
this.renderInstructions_ = new Float32Array(
|
|
572
|
-
}
|
|
573
|
-
if (this.hitDetectionEnabled_) {
|
|
574
|
-
const totalHitInstructionsCount =
|
|
575
|
-
(7 + this.customAttributes.length) * this.featureCount_;
|
|
576
|
-
if (
|
|
577
|
-
!this.hitRenderInstructions_ ||
|
|
578
|
-
this.hitRenderInstructions_.length !== totalHitInstructionsCount
|
|
579
|
-
) {
|
|
580
|
-
this.hitRenderInstructions_ = new Float32Array(
|
|
581
|
-
totalHitInstructionsCount
|
|
582
|
-
);
|
|
583
|
-
}
|
|
516
|
+
this.renderInstructions_ = new Float32Array(totalSize);
|
|
584
517
|
}
|
|
585
518
|
|
|
586
519
|
// loop on features to fill the buffer
|
|
587
520
|
let featureCache, geometry;
|
|
588
521
|
const tmpCoords = [];
|
|
589
522
|
const tmpColor = [];
|
|
590
|
-
let
|
|
591
|
-
let hitIndex = 0;
|
|
592
|
-
let hitColor;
|
|
523
|
+
let idx = -1;
|
|
593
524
|
for (const featureUid in this.featureCache_) {
|
|
594
525
|
featureCache = this.featureCache_[featureUid];
|
|
595
526
|
geometry = /** @type {import("../../geom").Point} */ (
|
|
@@ -598,39 +529,31 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
598
529
|
if (!geometry || geometry.getType() !== 'Point') {
|
|
599
530
|
continue;
|
|
600
531
|
}
|
|
601
|
-
|
|
602
532
|
tmpCoords[0] = geometry.getFlatCoordinates()[0];
|
|
603
533
|
tmpCoords[1] = geometry.getFlatCoordinates()[1];
|
|
604
534
|
applyTransform(projectionTransform, tmpCoords);
|
|
605
535
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
this.renderInstructions_[renderIndex++] = tmpCoords[0];
|
|
609
|
-
this.renderInstructions_[renderIndex++] = tmpCoords[1];
|
|
536
|
+
this.renderInstructions_[++idx] = tmpCoords[0];
|
|
537
|
+
this.renderInstructions_[++idx] = tmpCoords[1];
|
|
610
538
|
|
|
611
539
|
// for hit detection, the feature uid is saved in the opacity value
|
|
612
540
|
// and the index of the opacity value is encoded in the color values
|
|
613
541
|
if (this.hitDetectionEnabled_) {
|
|
614
|
-
|
|
615
|
-
this.
|
|
616
|
-
this.
|
|
617
|
-
this.
|
|
618
|
-
this.
|
|
619
|
-
this.
|
|
620
|
-
this.hitRenderInstructions_[hitIndex++] = Number(featureUid);
|
|
542
|
+
const hitColor = colorEncodeId(idx + 5, tmpColor);
|
|
543
|
+
this.renderInstructions_[++idx] = hitColor[0];
|
|
544
|
+
this.renderInstructions_[++idx] = hitColor[1];
|
|
545
|
+
this.renderInstructions_[++idx] = hitColor[2];
|
|
546
|
+
this.renderInstructions_[++idx] = hitColor[3];
|
|
547
|
+
this.renderInstructions_[++idx] = Number(featureUid);
|
|
621
548
|
}
|
|
622
549
|
|
|
623
550
|
// pushing custom attributes
|
|
624
|
-
let value;
|
|
625
551
|
for (let j = 0; j < this.customAttributes.length; j++) {
|
|
626
|
-
value = this.customAttributes[j].callback(
|
|
552
|
+
const value = this.customAttributes[j].callback(
|
|
627
553
|
featureCache.feature,
|
|
628
554
|
featureCache.properties
|
|
629
555
|
);
|
|
630
|
-
this.renderInstructions_[
|
|
631
|
-
if (this.hitDetectionEnabled_) {
|
|
632
|
-
this.hitRenderInstructions_[hitIndex++] = value;
|
|
633
|
-
}
|
|
556
|
+
this.renderInstructions_[++idx] = value;
|
|
634
557
|
}
|
|
635
558
|
}
|
|
636
559
|
|
|
@@ -639,29 +562,13 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
639
562
|
id: ++this.lastSentId,
|
|
640
563
|
type: WebGLWorkerMessageType.GENERATE_POINT_BUFFERS,
|
|
641
564
|
renderInstructions: this.renderInstructions_.buffer,
|
|
642
|
-
customAttributesSize:
|
|
565
|
+
customAttributesSize: singleInstructionLength - 2,
|
|
643
566
|
};
|
|
644
567
|
// additional properties will be sent back as-is by the worker
|
|
645
568
|
message['projectionTransform'] = projectionTransform;
|
|
646
569
|
this.ready = false;
|
|
647
570
|
this.worker_.postMessage(message, [this.renderInstructions_.buffer]);
|
|
648
571
|
this.renderInstructions_ = null;
|
|
649
|
-
|
|
650
|
-
/** @type {import('../../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */
|
|
651
|
-
if (this.hitDetectionEnabled_) {
|
|
652
|
-
const hitMessage = {
|
|
653
|
-
id: 0,
|
|
654
|
-
type: WebGLWorkerMessageType.GENERATE_POINT_BUFFERS,
|
|
655
|
-
renderInstructions: this.hitRenderInstructions_.buffer,
|
|
656
|
-
customAttributesSize: 5 + this.customAttributes.length,
|
|
657
|
-
};
|
|
658
|
-
hitMessage['projectionTransform'] = projectionTransform;
|
|
659
|
-
hitMessage['hitDetection'] = true;
|
|
660
|
-
this.worker_.postMessage(hitMessage, [
|
|
661
|
-
this.hitRenderInstructions_.buffer,
|
|
662
|
-
]);
|
|
663
|
-
this.hitRenderInstructions_ = null;
|
|
664
|
-
}
|
|
665
572
|
}
|
|
666
573
|
|
|
667
574
|
/**
|
|
@@ -681,7 +588,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
681
588
|
matches
|
|
682
589
|
) {
|
|
683
590
|
assert(this.hitDetectionEnabled_, 66);
|
|
684
|
-
if (!this.
|
|
591
|
+
if (!this.renderInstructions_ || !this.hitDetectionEnabled_) {
|
|
685
592
|
return undefined;
|
|
686
593
|
}
|
|
687
594
|
|
|
@@ -693,7 +600,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
693
600
|
const data = this.hitRenderTarget_.readPixel(pixel[0] / 2, pixel[1] / 2);
|
|
694
601
|
const color = [data[0] / 255, data[1] / 255, data[2] / 255, data[3] / 255];
|
|
695
602
|
const index = colorDecodeId(color);
|
|
696
|
-
const opacity = this.
|
|
603
|
+
const opacity = this.renderInstructions_[index];
|
|
697
604
|
const uid = Math.floor(opacity).toString();
|
|
698
605
|
|
|
699
606
|
const source = this.getLayer().getSource();
|
|
@@ -705,42 +612,40 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
705
612
|
}
|
|
706
613
|
|
|
707
614
|
/**
|
|
708
|
-
* Render the
|
|
615
|
+
* Render the world, either to the main framebuffer or to the hit framebuffer
|
|
709
616
|
* @param {import("../../Map.js").FrameState} frameState current frame state
|
|
617
|
+
* @param {boolean} forHitDetection whether the rendering is for hit detection
|
|
710
618
|
* @param {number} startWorld the world to render in the first iteration
|
|
711
619
|
* @param {number} endWorld the last world to render
|
|
712
620
|
* @param {number} worldWidth the width of the worlds being rendered
|
|
713
621
|
*/
|
|
714
|
-
|
|
715
|
-
// skip render entirely if vertex buffers not ready/generated yet
|
|
716
|
-
if (!this.hitVerticesBuffer_.getSize()) {
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
|
|
622
|
+
renderWorlds(frameState, forHitDetection, startWorld, endWorld, worldWidth) {
|
|
720
623
|
let world = startWorld;
|
|
721
624
|
|
|
722
|
-
this.
|
|
723
|
-
Math.floor(frameState.size[0] / 2),
|
|
724
|
-
Math.floor(frameState.size[1] / 2),
|
|
725
|
-
]);
|
|
625
|
+
this.helper.useProgram(this.program_, frameState);
|
|
726
626
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
627
|
+
if (forHitDetection) {
|
|
628
|
+
this.hitRenderTarget_.setSize([
|
|
629
|
+
Math.floor(frameState.size[0] / 2),
|
|
630
|
+
Math.floor(frameState.size[1] / 2),
|
|
631
|
+
]);
|
|
632
|
+
this.helper.prepareDrawToRenderTarget(
|
|
633
|
+
frameState,
|
|
634
|
+
this.hitRenderTarget_,
|
|
635
|
+
true
|
|
636
|
+
);
|
|
637
|
+
}
|
|
733
638
|
|
|
734
|
-
this.helper.bindBuffer(this.
|
|
639
|
+
this.helper.bindBuffer(this.verticesBuffer_);
|
|
735
640
|
this.helper.bindBuffer(this.indicesBuffer_);
|
|
736
|
-
this.helper.enableAttributes(this.
|
|
641
|
+
this.helper.enableAttributes(this.attributes);
|
|
737
642
|
|
|
738
643
|
do {
|
|
739
644
|
this.helper.makeProjectionTransform(frameState, this.currentTransform_);
|
|
740
645
|
translateTransform(this.currentTransform_, world * worldWidth, 0);
|
|
741
646
|
multiplyTransform(this.currentTransform_, this.invertRenderTransform_);
|
|
742
647
|
this.helper.applyUniforms(frameState);
|
|
743
|
-
|
|
648
|
+
this.helper.applyHitDetectionUniform(forHitDetection);
|
|
744
649
|
const renderCount = this.indicesBuffer_.getSize();
|
|
745
650
|
this.helper.drawElements(0, renderCount);
|
|
746
651
|
} while (++world < endWorld);
|
|
@@ -9,6 +9,7 @@ export const Uniforms: {
|
|
|
9
9
|
RESOLUTION: string;
|
|
10
10
|
VIEWPORT_SIZE_PX: string;
|
|
11
11
|
PIXEL_RATIO: string;
|
|
12
|
+
HIT_DETECTION: string;
|
|
12
13
|
};
|
|
13
14
|
export default WebGLVectorLayerRenderer;
|
|
14
15
|
export type VectorStyle = import('../../render/webgl/VectorStyleRenderer.js').VectorStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VectorLayer.d.ts","sourceRoot":"","sources":["VectorLayer.js"],"names":[],"mappings":"AAuBA
|
|
1
|
+
{"version":3,"file":"VectorLayer.d.ts","sourceRoot":"","sources":["VectorLayer.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;EAIE;;0BAGW,OAAO,2CAA2C,EAAE,WAAW;;;;;;;;;WAM9D,WAAW,GAAC,MAAM,WAAW,CAAC;;;;;;AAP5C;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;OAGG;IACH,mBAHW,OAAO,sBAAsB,EAAE,OAAO,WACtC,OAAO,EAwFjB;IA3EC,wBAAyB;IAEzB,kDAAoC;IAEpC;;;;;;OAMG;IACH,0BAA0C;IAE1C,wBAAsC;IACtC,mBAA4B;IAE5B;;;OAGG;IACH,oCAAoD;IAEpD;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,wBAAyB;IAEzB;;;OAGG;IACH,iBAAkB;IAIlB;;OAEG;IACH,eAAsC;IAItC,yDAyBC;IAGH;;;OAGG;IACH,sBAIC;IAED;;OAEG;IACH,yBAKC;IAED,0BAMC;IAMD;;;OAGG;IACH,kCAGC;IAED;;;OAGG;IACH,oCAGC;IAED;;;OAGG;IACH,mCAGC;IAED;;OAEG;IACH,kCAEC;IAED;;;OAGG;IACH,uBAQC;IAED;;;;OAIG;IACH,wBAHW,OAAO,cAAc,EAAE,UAAU,GAChC,WAAW,CAoDtB;CAkFF;+BAxW8B,YAAY"}
|
package/util.js
CHANGED
package/webgl/Helper.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export namespace DefaultUniform {
|
|
|
26
26
|
let RESOLUTION: string;
|
|
27
27
|
let VIEWPORT_SIZE_PX: string;
|
|
28
28
|
let PIXEL_RATIO: string;
|
|
29
|
+
let HIT_DETECTION: string;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Attribute types, either `UNSIGNED_BYTE`, `UNSIGNED_SHORT`, `UNSIGNED_INT` or `FLOAT`
|
|
@@ -443,6 +444,11 @@ declare class WebGLHelper extends Disposable {
|
|
|
443
444
|
* @param {import("../Map.js").FrameState} frameState Frame state.
|
|
444
445
|
*/
|
|
445
446
|
applyFrameState(frameState: import("../Map.js").FrameState): void;
|
|
447
|
+
/**
|
|
448
|
+
* Sets the `u_hitDetection` uniform.
|
|
449
|
+
* @param {boolean} enabled Whether to enable the hit detection code path
|
|
450
|
+
*/
|
|
451
|
+
applyHitDetectionUniform(enabled: boolean): void;
|
|
446
452
|
/**
|
|
447
453
|
* Sets the custom uniforms based on what was given in the constructor. This is called internally in `prepareDraw`.
|
|
448
454
|
* @param {import("../Map.js").FrameState} frameState Frame state.
|
package/webgl/Helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["Helper.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Helper.d.ts","sourceRoot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tB;IAED;;;;;OAKG;IACH,iCAJW,MAAM,sBACN,MAAM,GACL,YAAY,CA4CvB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACL,oBAAoB,CAY/B;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,MAAM,CAYjB;IAED;;;;;;OAMG;IACH,oCAJW,OAAO,WAAW,EAAE,UAAU,aAC9B,OAAO,cAAc,EAAE,SAAS,GAC/B,OAAO,cAAc,EAAE,SAAS,CAkB3C;IAED;;;;OAIG;IACH,8BAHW,MAAM,SACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,6BAHW,MAAM,SACN,MAAM,MAAM,CAAC,QAIvB;IAED;;;;OAIG;IACH,6BAHW,MAAM,SACN,MAAM,MAAM,CAAC,QAIvB;IAED;;;;OAIG;IACH,+BAHW,MAAM,SACN,MAAM,MAAM,CAAC,QAIvB;IAED;;;;;;;;;OASG;IACH,8BAQC;IAED;;;;;OAKG;IACH,6BAFW,MAAM,oBAAoB,CAAC,QAgBrC;IAED;;;OAGG;IACH,+BAGC;IAED;;;OAGG;IACH,mCAA+B;IAE/B;;;;;;;;;OASG;IACH,oBALW,MAAM,MAAM,CAAC,4GAGZ,YAAY,CAiCvB;CACF;uBA7jCsB,kBAAkB"}
|
package/webgl/Helper.js
CHANGED
|
@@ -51,6 +51,7 @@ export const DefaultUniform = {
|
|
|
51
51
|
RESOLUTION: 'u_resolution',
|
|
52
52
|
VIEWPORT_SIZE_PX: 'u_viewportSizePx',
|
|
53
53
|
PIXEL_RATIO: 'u_pixelRatio',
|
|
54
|
+
HIT_DETECTION: 'u_hitDetection',
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -713,6 +714,15 @@ class WebGLHelper extends Disposable {
|
|
|
713
714
|
]);
|
|
714
715
|
}
|
|
715
716
|
|
|
717
|
+
/**
|
|
718
|
+
* Sets the `u_hitDetection` uniform.
|
|
719
|
+
* @param {boolean} enabled Whether to enable the hit detection code path
|
|
720
|
+
*/
|
|
721
|
+
applyHitDetectionUniform(enabled) {
|
|
722
|
+
const loc = this.getUniformLocation(DefaultUniform.HIT_DETECTION);
|
|
723
|
+
this.getGL().uniform1i(loc, enabled ? 1 : 0);
|
|
724
|
+
}
|
|
725
|
+
|
|
716
726
|
/**
|
|
717
727
|
* Sets the custom uniforms based on what was given in the constructor. This is called internally in `prepareDraw`.
|
|
718
728
|
* @param {import("../Map.js").FrameState} frameState Frame state.
|
|
@@ -990,7 +1000,7 @@ class WebGLHelper extends Disposable {
|
|
|
990
1000
|
*/
|
|
991
1001
|
enableAttributeArray_(attribName, size, type, stride, offset) {
|
|
992
1002
|
const location = this.getAttributeLocation(attribName);
|
|
993
|
-
// the attribute has not been found in the shaders; do not enable it
|
|
1003
|
+
// the attribute has not been found in the shaders or is not used; do not enable it
|
|
994
1004
|
if (location < 0) {
|
|
995
1005
|
return;
|
|
996
1006
|
}
|
package/webgl/ShaderBuilder.d.ts
CHANGED
|
@@ -191,63 +191,49 @@ export class ShaderBuilder {
|
|
|
191
191
|
/**
|
|
192
192
|
* Generates a symbol vertex shader from the builder parameters
|
|
193
193
|
*
|
|
194
|
-
*
|
|
195
|
-
* `u_offsetRotateMatrix`, `u_time`.
|
|
194
|
+
* The following uniforms are hardcoded in all shaders: `u_projectionMatrix`, `u_offsetScaleMatrix`,
|
|
195
|
+
* `u_offsetRotateMatrix`, `u_time`, `u_zoom`, `u_resolution`, `u_hitDetection`.
|
|
196
196
|
*
|
|
197
197
|
* The following attributes are hardcoded and expected to be present in the vertex buffers:
|
|
198
|
-
* `vec2 a_position`, `float a_index` (being the index of the vertex in the quad, 0 to 3)
|
|
198
|
+
* `vec2 a_position`, `float a_index` (being the index of the vertex in the quad, 0 to 3), `vec4 a_hitColor`.
|
|
199
199
|
*
|
|
200
200
|
* The following varyings are hardcoded and gives the coordinate of the pixel both in the quad and on the texture:
|
|
201
|
-
* `vec2 v_quadCoord`, `vec2 v_texCoord`
|
|
201
|
+
* `vec2 v_quadCoord`, `vec2 v_texCoord`, `vec4 v_hitColor`.
|
|
202
202
|
*
|
|
203
|
-
* @param {boolean} [forHitDetection] If true, the shader will be modified to include hit detection variables
|
|
204
|
-
* (namely, hit color with encoded feature id).
|
|
205
203
|
* @return {string} The full shader as a string.
|
|
206
204
|
*/
|
|
207
|
-
getSymbolVertexShader(
|
|
205
|
+
getSymbolVertexShader(): string;
|
|
208
206
|
/**
|
|
209
207
|
* Generates a symbol fragment shader from the builder parameters
|
|
210
208
|
*
|
|
211
209
|
* Expects the following varyings to be transmitted by the vertex shader:
|
|
212
|
-
* `vec2 v_quadCoord`, `vec2 v_texCoord`
|
|
210
|
+
* `vec2 v_quadCoord`, `vec2 v_texCoord`, `vec4 v_hitColor`.
|
|
213
211
|
*
|
|
214
|
-
* @param {boolean} [forHitDetection] If true, the shader will be modified to include hit detection variables
|
|
215
|
-
* (namely, hit color with encoded feature id).
|
|
216
212
|
* @return {string} The full shader as a string.
|
|
217
213
|
*/
|
|
218
|
-
getSymbolFragmentShader(
|
|
214
|
+
getSymbolFragmentShader(): string;
|
|
219
215
|
/**
|
|
220
216
|
* Generates a stroke vertex shader from the builder parameters
|
|
221
|
-
*
|
|
222
|
-
* @param {boolean} [forHitDetection] If true, the shader will be modified to include hit detection variables
|
|
223
|
-
* (namely, hit color with encoded feature id).
|
|
224
217
|
* @return {string} The full shader as a string.
|
|
225
218
|
*/
|
|
226
|
-
getStrokeVertexShader(
|
|
219
|
+
getStrokeVertexShader(): string;
|
|
227
220
|
/**
|
|
228
221
|
* Generates a stroke fragment shader from the builder parameters
|
|
229
222
|
*
|
|
230
|
-
* @param {boolean} [forHitDetection] If true, the shader will be modified to include hit detection variables
|
|
231
|
-
* (namely, hit color with encoded feature id).
|
|
232
223
|
* @return {string} The full shader as a string.
|
|
233
224
|
*/
|
|
234
|
-
getStrokeFragmentShader(
|
|
225
|
+
getStrokeFragmentShader(): string;
|
|
235
226
|
/**
|
|
236
227
|
* Generates a fill vertex shader from the builder parameters
|
|
237
228
|
*
|
|
238
|
-
* @param {boolean} [forHitDetection] If true, the shader will be modified to include hit detection variables
|
|
239
|
-
* (namely, hit color with encoded feature id).
|
|
240
229
|
* @return {string} The full shader as a string.
|
|
241
230
|
*/
|
|
242
|
-
getFillVertexShader(
|
|
231
|
+
getFillVertexShader(): string;
|
|
243
232
|
/**
|
|
244
233
|
* Generates a fill fragment shader from the builder parameters
|
|
245
|
-
*
|
|
246
|
-
* @param {boolean} [forHitDetection] If true, the shader will be modified to include hit detection variables
|
|
247
|
-
* (namely, hit color with encoded feature id).
|
|
248
234
|
* @return {string} The full shader as a string.
|
|
249
235
|
*/
|
|
250
|
-
getFillFragmentShader(
|
|
236
|
+
getFillFragmentShader(): string;
|
|
251
237
|
}
|
|
252
238
|
export type VaryingDescription = {
|
|
253
239
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AACH;IAEI;;;;OAIG;IACH,kBAAmB;IAEnB;;;;OAIG;IACH,oBAAqB;IAErB;;;;OAIG;IACH,kBAAmB;IAEnB;;;OAGG;IACH,8BAAwC;IAExC;;;OAGG;IACH,kCAAsC;IAEtC;;;OAGG;IACH,gCAA0C;IAE1C;;;OAGG;IACH,+BAAyC;IAEzC;;;OAGG;IACH,4BAAqD;IAErD;;;OAGG;IACH,2BAAiC;IAEjC;;;OAGG;IACH,8BAAkC;IAElC;;;OAGG;IACH,+BAAmC;IAEnC;;;OAGG;IACH,+BAAyC;IAEzC;;;OAGG;IACH,6BAAuC;IAEvC;;;OAGG;IACH,+BAAgC;IAEhC;;;OAGG;IACH,iCAAkC;IAGpC;;;;;OAKG;IACH,iBAHW,MAAM,GACL,aAAa,CAKxB;IAED;;;;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