@mapwhit/tilerenderer 0.52.0 → 1.0.0

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.
Files changed (142) hide show
  1. package/README.md +7 -0
  2. package/build/min/package.json +1 -1
  3. package/build/min/src/shaders/_prelude.fragment.glsl.js +2 -2
  4. package/build/min/src/shaders/_prelude.vertex.glsl.js +2 -2
  5. package/build/min/src/shaders/background.fragment.glsl.js +2 -2
  6. package/build/min/src/shaders/background.vertex.glsl.js +1 -1
  7. package/build/min/src/shaders/background_pattern.fragment.glsl.js +2 -2
  8. package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
  9. package/build/min/src/shaders/circle.fragment.glsl.js +2 -2
  10. package/build/min/src/shaders/circle.vertex.glsl.js +2 -2
  11. package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
  12. package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
  13. package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
  14. package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
  15. package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
  16. package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
  17. package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
  18. package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
  19. package/build/min/src/shaders/fill.fragment.glsl.js +2 -2
  20. package/build/min/src/shaders/fill.vertex.glsl.js +2 -2
  21. package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +2 -2
  22. package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +2 -2
  23. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +2 -2
  24. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +2 -2
  25. package/build/min/src/shaders/fill_outline.fragment.glsl.js +2 -2
  26. package/build/min/src/shaders/fill_outline.vertex.glsl.js +2 -2
  27. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +2 -2
  28. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +2 -2
  29. package/build/min/src/shaders/fill_pattern.fragment.glsl.js +2 -2
  30. package/build/min/src/shaders/fill_pattern.vertex.glsl.js +2 -2
  31. package/build/min/src/shaders/heatmap.fragment.glsl.js +2 -2
  32. package/build/min/src/shaders/heatmap.vertex.glsl.js +2 -2
  33. package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +2 -2
  34. package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
  35. package/build/min/src/shaders/hillshade.fragment.glsl.js +2 -2
  36. package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
  37. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +2 -2
  38. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
  39. package/build/min/src/shaders/line.fragment.glsl.js +2 -2
  40. package/build/min/src/shaders/line.vertex.glsl.js +2 -2
  41. package/build/min/src/shaders/line_gradient.fragment.glsl.js +2 -2
  42. package/build/min/src/shaders/line_gradient.vertex.glsl.js +2 -2
  43. package/build/min/src/shaders/line_pattern.fragment.glsl.js +2 -2
  44. package/build/min/src/shaders/line_pattern.vertex.glsl.js +2 -2
  45. package/build/min/src/shaders/line_sdf.fragment.glsl.js +2 -2
  46. package/build/min/src/shaders/line_sdf.vertex.glsl.js +2 -2
  47. package/build/min/src/shaders/raster.fragment.glsl.js +2 -2
  48. package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
  49. package/build/min/src/shaders/symbol_icon.fragment.glsl.js +2 -2
  50. package/build/min/src/shaders/symbol_icon.vertex.glsl.js +2 -2
  51. package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +2 -2
  52. package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +2 -2
  53. package/package.json +3 -3
  54. package/src/data/array_types.js +1 -36
  55. package/src/data/bucket/circle_bucket.js +8 -5
  56. package/src/data/bucket/fill_bucket.js +8 -5
  57. package/src/data/bucket/fill_extrusion_bucket.js +8 -5
  58. package/src/data/bucket/heatmap_bucket.js +0 -4
  59. package/src/data/bucket/line_bucket.js +9 -6
  60. package/src/data/bucket/pattern_bucket_features.js +2 -2
  61. package/src/data/bucket/symbol_bucket.js +99 -129
  62. package/src/data/bucket.js +26 -21
  63. package/src/data/dem_data.js +0 -3
  64. package/src/data/feature_index.js +3 -8
  65. package/src/data/program_configuration.js +24 -33
  66. package/src/data/segment.js +0 -4
  67. package/src/render/draw_background.js +3 -3
  68. package/src/render/draw_circle.js +4 -4
  69. package/src/render/draw_fill.js +8 -8
  70. package/src/render/draw_fill_extrusion.js +8 -8
  71. package/src/render/draw_heatmap.js +4 -4
  72. package/src/render/draw_line.js +6 -6
  73. package/src/render/draw_raster.js +6 -6
  74. package/src/render/draw_symbol.js +16 -16
  75. package/src/render/glyph_atlas.js +0 -3
  76. package/src/render/glyph_manager.js +1 -2
  77. package/src/render/image_atlas.js +0 -4
  78. package/src/render/image_manager.js +33 -19
  79. package/src/render/painter.js +13 -14
  80. package/src/render/program/circle_program.js +4 -4
  81. package/src/render/program/fill_extrusion_program.js +1 -1
  82. package/src/render/program/heatmap_program.js +1 -1
  83. package/src/render/program/hillshade_program.js +6 -6
  84. package/src/render/program/line_program.js +3 -3
  85. package/src/render/program/raster_program.js +6 -6
  86. package/src/source/geojson_source.js +15 -24
  87. package/src/source/geojson_worker_source.js +40 -68
  88. package/src/source/geojson_wrapper.js +9 -1
  89. package/src/source/image_source.js +6 -16
  90. package/src/source/query_features.js +4 -5
  91. package/src/source/raster_dem_tile_source.js +45 -64
  92. package/src/source/raster_tile_source.js +1 -6
  93. package/src/source/resources/glyphs.js +2 -2
  94. package/src/source/resources/index.js +3 -9
  95. package/src/source/rtl_text_plugin.js +58 -31
  96. package/src/source/source.js +11 -13
  97. package/src/source/source_cache.js +135 -151
  98. package/src/source/source_state.js +101 -12
  99. package/src/source/tile.js +32 -46
  100. package/src/source/tile_bounds.js +26 -26
  101. package/src/source/tile_id.js +2 -5
  102. package/src/source/vector_tile_source.js +14 -14
  103. package/src/source/vector_tile_worker_source.js +19 -23
  104. package/src/source/worker_tile.js +122 -119
  105. package/src/style/create_style_layer.js +1 -1
  106. package/src/style/pauseable_placement.js +4 -5
  107. package/src/style/properties.js +1 -8
  108. package/src/style/query_utils.js +3 -3
  109. package/src/style/style.js +286 -216
  110. package/src/style/style_layer/circle_style_layer.js +13 -11
  111. package/src/style/style_layer/fill_extrusion_style_layer.js +42 -27
  112. package/src/style/style_layer/fill_style_layer.js +5 -5
  113. package/src/style/style_layer/heatmap_style_layer.js +1 -1
  114. package/src/style/style_layer/hillshade_style_layer.js +1 -1
  115. package/src/style/style_layer/line_style_layer.js +23 -19
  116. package/src/style/style_layer/symbol_style_layer.js +13 -13
  117. package/src/style/style_layer.js +71 -30
  118. package/src/style/style_layer_index.js +16 -41
  119. package/src/symbol/anchor.js +0 -4
  120. package/src/symbol/cross_tile_symbol_index.js +2 -5
  121. package/src/symbol/opacity_state.js +0 -4
  122. package/src/symbol/placement.js +3 -3
  123. package/src/symbol/quads.js +4 -4
  124. package/src/symbol/symbol_layout.js +7 -7
  125. package/src/symbol/transform_text.js +1 -1
  126. package/src/ui/map.js +52 -15
  127. package/src/util/group_layers.js +41 -0
  128. package/src/util/image.js +0 -5
  129. package/src/util/key.js +21 -0
  130. package/src/util/object.js +8 -53
  131. package/src/worker.js +1 -4
  132. package/src/source/resources/images.js +0 -68
  133. package/src/source/worker.js +0 -110
  134. package/src/source/worker_source.js +0 -14
  135. package/src/style-spec/deref.js +0 -51
  136. package/src/style-spec/group_by_layout.js +0 -46
  137. package/src/util/actor.js +0 -108
  138. package/src/util/dispatcher.js +0 -65
  139. package/src/util/global_worker_pool.js +0 -15
  140. package/src/util/transfer_registry.js +0 -168
  141. package/src/util/web_worker_transfer.js +0 -43
  142. package/src/util/worker_pool.js +0 -41
@@ -18,7 +18,6 @@ const {
18
18
  GlyphOffsetArray,
19
19
  SymbolLineVertexArray
20
20
  } = require('../array_types');
21
- const { default: Point } = require('@mapbox/point-geometry');
22
21
  const SegmentVector = require('../segment');
23
22
  const { ProgramConfigurationSet } = require('../program_configuration');
24
23
  const { TriangleIndexArray, LineIndexArray } = require('../index_array_type');
@@ -30,7 +29,6 @@ const mvt = require('@mapwhit/vector-tile');
30
29
  const vectorTileFeatureTypes = mvt.VectorTileFeature.types;
31
30
  const { verticalizedCharacterMap } = require('../../util/verticalize_punctuation');
32
31
  const { getSizeData } = require('../../symbol/symbol_size');
33
- const { register } = require('../../util/transfer_registry');
34
32
  const EvaluationParameters = require('../../style/evaluation_parameters');
35
33
  const { Formatted } = require('@mapwhit/style-expressions');
36
34
 
@@ -108,8 +106,6 @@ class SymbolBuffers {
108
106
  }
109
107
  }
110
108
 
111
- register('SymbolBuffers', SymbolBuffers);
112
-
113
109
  class CollisionBuffers {
114
110
  constructor(LayoutArray, layoutAttributes, IndexArray) {
115
111
  this.layoutVertexArray = new LayoutArray();
@@ -138,8 +134,6 @@ class CollisionBuffers {
138
134
  }
139
135
  }
140
136
 
141
- register('CollisionBuffers', CollisionBuffers);
142
-
143
137
  /**
144
138
  * Unlike other buckets, which simply implement #addFeature with type-specific
145
139
  * logic for (essentially) triangulating feature geometries, SymbolBucket
@@ -191,7 +185,7 @@ class SymbolBucket {
191
185
  this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);
192
186
  this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);
193
187
 
194
- const layout = this.layers[0].layout;
188
+ const layout = this.layers[0]._layout;
195
189
  const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y';
196
190
  this.sortFeaturesByY =
197
191
  zOrderByViewportY &&
@@ -241,7 +235,7 @@ class SymbolBucket {
241
235
 
242
236
  populate(features, options) {
243
237
  const layer = this.layers[0];
244
- const layout = layer.layout;
238
+ const layout = layer._layout;
245
239
 
246
240
  const textFont = layout.get('text-font');
247
241
  const textField = layout.get('text-field');
@@ -328,8 +322,14 @@ class SymbolBucket {
328
322
 
329
323
  update(states, vtLayer, imagePositions) {
330
324
  if (!this.stateDependentLayers.length) return;
331
- this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
332
- this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
325
+ this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, {
326
+ imagePositions,
327
+ globalState: this.globalState
328
+ });
329
+ this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, {
330
+ imagePositions,
331
+ globalState: this.globalState
332
+ });
333
333
  }
334
334
 
335
335
  isEmpty() {
@@ -458,76 +458,31 @@ class SymbolBucket {
458
458
  false
459
459
  );
460
460
 
461
- arrays.programConfigurations.populatePaintArrays(arrays.layoutVertexArray.length, feature, feature.index, {});
462
- }
463
-
464
- _addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, point, anchorX, anchorY, extrude) {
465
- collisionVertexArray.emplaceBack(0, 0);
466
- return layoutVertexArray.emplaceBack(
467
- // pos
468
- point.x,
469
- point.y,
470
- // a_anchor_pos
471
- anchorX,
472
- anchorY,
473
- // extrude
474
- Math.round(extrude.x),
475
- Math.round(extrude.y)
476
- );
461
+ arrays.programConfigurations.populatePaintArrays(arrays.layoutVertexArray.length, feature, feature.index, {
462
+ imagePositions: {},
463
+ globalState: this.globalState
464
+ });
477
465
  }
478
466
 
479
467
  addCollisionDebugVertices(x1, y1, x2, y2, arrays, boxAnchorPoint, symbolInstance, isCircle) {
480
- const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);
468
+ const { layoutVertexArray, collisionVertexArray, indexArray } = arrays;
469
+ const { anchorX, anchorY } = symbolInstance;
470
+
471
+ const segment = arrays.segments.prepareSegment(4, layoutVertexArray, indexArray);
481
472
  const index = segment.vertexLength;
482
473
 
483
- const layoutVertexArray = arrays.layoutVertexArray;
484
- const collisionVertexArray = arrays.collisionVertexArray;
485
-
486
- const anchorX = symbolInstance.anchorX;
487
- const anchorY = symbolInstance.anchorY;
488
-
489
- this._addCollisionDebugVertex(
490
- layoutVertexArray,
491
- collisionVertexArray,
492
- boxAnchorPoint,
493
- anchorX,
494
- anchorY,
495
- new Point(x1, y1)
496
- );
497
- this._addCollisionDebugVertex(
498
- layoutVertexArray,
499
- collisionVertexArray,
500
- boxAnchorPoint,
501
- anchorX,
502
- anchorY,
503
- new Point(x2, y1)
504
- );
505
- this._addCollisionDebugVertex(
506
- layoutVertexArray,
507
- collisionVertexArray,
508
- boxAnchorPoint,
509
- anchorX,
510
- anchorY,
511
- new Point(x2, y2)
512
- );
513
- this._addCollisionDebugVertex(
514
- layoutVertexArray,
515
- collisionVertexArray,
516
- boxAnchorPoint,
517
- anchorX,
518
- anchorY,
519
- new Point(x1, y2)
520
- );
474
+ addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, x1, y1);
475
+ addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, x2, y1);
476
+ addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, x2, y2);
477
+ addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, x1, y2);
521
478
 
522
479
  segment.vertexLength += 4;
523
480
  if (isCircle) {
524
- const indexArray = arrays.indexArray;
525
481
  indexArray.emplaceBack(index, index + 1, index + 2);
526
482
  indexArray.emplaceBack(index, index + 2, index + 3);
527
483
 
528
484
  segment.primitiveLength += 2;
529
485
  } else {
530
- const indexArray = arrays.indexArray;
531
486
  indexArray.emplaceBack(index, index + 1);
532
487
  indexArray.emplaceBack(index + 1, index + 2);
533
488
  indexArray.emplaceBack(index + 2, index + 3);
@@ -569,68 +524,16 @@ class SymbolBucket {
569
524
  }
570
525
  }
571
526
 
572
- // These flat arrays are meant to be quicker to iterate over than the source
573
- // CollisionBoxArray
574
- _deserializeCollisionBoxesForSymbol(collisionBoxArray, textStartIndex, textEndIndex, iconStartIndex, iconEndIndex) {
575
- const collisionArrays = {};
576
- for (let k = textStartIndex; k < textEndIndex; k++) {
577
- const box = collisionBoxArray.get(k);
578
- if (box.radius === 0) {
579
- collisionArrays.textBox = {
580
- x1: box.x1,
581
- y1: box.y1,
582
- x2: box.x2,
583
- y2: box.y2,
584
- anchorPointX: box.anchorPointX,
585
- anchorPointY: box.anchorPointY
586
- };
587
- collisionArrays.textFeatureIndex = box.featureIndex;
588
- break; // Only one box allowed per instance
589
- }
590
- if (!collisionArrays.textCircles) {
591
- collisionArrays.textCircles = [];
592
- collisionArrays.textFeatureIndex = box.featureIndex;
593
- }
594
- const used = 1; // May be updated at collision detection time
595
- collisionArrays.textCircles.push(
596
- box.anchorPointX,
597
- box.anchorPointY,
598
- box.radius,
599
- box.signedDistanceFromAnchor,
600
- used
601
- );
602
- }
603
- for (let k = iconStartIndex; k < iconEndIndex; k++) {
604
- // An icon can only have one box now, so this indexing is a bit vestigial...
605
- const box = collisionBoxArray.get(k);
606
- if (box.radius === 0) {
607
- collisionArrays.iconBox = {
608
- x1: box.x1,
609
- y1: box.y1,
610
- x2: box.x2,
611
- y2: box.y2,
612
- anchorPointX: box.anchorPointX,
613
- anchorPointY: box.anchorPointY
614
- };
615
- collisionArrays.iconFeatureIndex = box.featureIndex;
616
- break; // Only one box allowed per instance
617
- }
618
- }
619
- return collisionArrays;
620
- }
621
-
622
527
  deserializeCollisionBoxes(collisionBoxArray) {
623
- this.collisionArrays = [];
528
+ this.collisionArrays = new Array(this.symbolInstances.length);
624
529
  for (let i = 0; i < this.symbolInstances.length; i++) {
625
530
  const symbolInstance = this.symbolInstances.get(i);
626
- this.collisionArrays.push(
627
- this._deserializeCollisionBoxesForSymbol(
628
- collisionBoxArray,
629
- symbolInstance.textBoxStartIndex,
630
- symbolInstance.textBoxEndIndex,
631
- symbolInstance.iconBoxStartIndex,
632
- symbolInstance.iconBoxEndIndex
633
- )
531
+ this.collisionArrays[i] = deserializeCollisionBoxesForSymbol(
532
+ collisionBoxArray,
533
+ symbolInstance.textBoxStartIndex,
534
+ symbolInstance.textBoxEndIndex,
535
+ symbolInstance.iconBoxStartIndex,
536
+ symbolInstance.iconBoxEndIndex
634
537
  );
635
538
  }
636
539
  }
@@ -725,9 +628,76 @@ class SymbolBucket {
725
628
  }
726
629
  }
727
630
 
728
- register('SymbolBucket', SymbolBucket, {
729
- omit: ['layers', 'collisionBoxArray', 'features', 'compareText']
730
- });
631
+ function addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, point, anchorX, anchorY, extrudeX, extrudeY) {
632
+ collisionVertexArray.emplaceBack(0, 0);
633
+ return layoutVertexArray.emplaceBack(
634
+ // pos
635
+ point.x,
636
+ point.y,
637
+ // a_anchor_pos
638
+ anchorX,
639
+ anchorY,
640
+ // extrude
641
+ Math.round(extrudeX),
642
+ Math.round(extrudeY)
643
+ );
644
+ }
645
+
646
+ // These flat arrays are meant to be quicker to iterate over than the source
647
+ // CollisionBoxArray
648
+ function deserializeCollisionBoxesForSymbol(
649
+ collisionBoxArray,
650
+ textStartIndex,
651
+ textEndIndex,
652
+ iconStartIndex,
653
+ iconEndIndex
654
+ ) {
655
+ const collisionArrays = {};
656
+ for (let k = textStartIndex; k < textEndIndex; k++) {
657
+ const box = collisionBoxArray.get(k);
658
+ if (box.radius === 0) {
659
+ collisionArrays.textBox = {
660
+ x1: box.x1,
661
+ y1: box.y1,
662
+ x2: box.x2,
663
+ y2: box.y2,
664
+ anchorPointX: box.anchorPointX,
665
+ anchorPointY: box.anchorPointY
666
+ };
667
+ collisionArrays.textFeatureIndex = box.featureIndex;
668
+ break; // Only one box allowed per instance
669
+ }
670
+ if (!collisionArrays.textCircles) {
671
+ collisionArrays.textCircles = [];
672
+ collisionArrays.textFeatureIndex = box.featureIndex;
673
+ }
674
+ const used = 1; // May be updated at collision detection time
675
+ collisionArrays.textCircles.push(
676
+ box.anchorPointX,
677
+ box.anchorPointY,
678
+ box.radius,
679
+ box.signedDistanceFromAnchor,
680
+ used
681
+ );
682
+ }
683
+ for (let k = iconStartIndex; k < iconEndIndex; k++) {
684
+ // An icon can only have one box now, so this indexing is a bit vestigial...
685
+ const box = collisionBoxArray.get(k);
686
+ if (box.radius === 0) {
687
+ collisionArrays.iconBox = {
688
+ x1: box.x1,
689
+ y1: box.y1,
690
+ x2: box.x2,
691
+ y2: box.y2,
692
+ anchorPointX: box.anchorPointX,
693
+ anchorPointY: box.anchorPointY
694
+ };
695
+ collisionArrays.iconFeatureIndex = box.featureIndex;
696
+ break; // Only one box allowed per instance
697
+ }
698
+ }
699
+ return collisionArrays;
700
+ }
731
701
 
732
702
  // this constant is based on the size of StructArray indexes used in a symbol
733
703
  // bucket--namely, glyphOffsetArrayStart
@@ -11,43 +11,48 @@
11
11
  * properties and the zoom level to populate the attributes needed for
12
12
  * data-driven styling.
13
13
  *
14
- * Buckets are designed to be built on a worker thread and then serialized and
15
- * transferred back to the main thread for rendering. On the worker side, a
16
- * bucket's vertex, index, and attribute data is stored in `bucket.arrays:
17
- * ArrayGroup`. When a bucket's data is serialized and sent back to the main
18
- * thread, is gets deserialized (using `new Bucket(serializedBucketData)`, with
19
- * the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups
20
- * hold the same data as ArrayGroups, but are tuned for consumption by WebGL.
14
+ * Buckets are designed to be built when tile is loaded and then converted (uploaded)
15
+ * to tune bucket's vertex, index, and attribute data for consumption by WebGL.
21
16
  *
22
17
  * @private
23
18
  */
24
19
 
25
- function deserialize(input, style) {
26
- const output = {};
27
-
20
+ // style may have changed between creating a bucket when tile was loaded and rendering it
21
+ function updateBuckets(buckets, style) {
22
+ if (!style._changed) {
23
+ return;
24
+ }
28
25
  // Guard against the case where the map's style has been set to null while
29
26
  // this bucket has been parsing.
30
- if (!style) return output;
27
+ if (!style) {
28
+ for (const bucket of buckets.values()) {
29
+ bucket.destroy();
30
+ }
31
+ buckets.clear();
32
+ return;
33
+ }
34
+
35
+ const updatedAlready = new Set();
36
+ for (const [id, bucket] of buckets) {
37
+ if (updatedAlready.has(id)) {
38
+ continue;
39
+ }
40
+ updatedAlready.add(id);
31
41
 
32
- for (const bucket of input) {
33
42
  const layers = bucket.layerIds.map(id => style.getLayer(id)).filter(Boolean);
34
43
 
35
44
  if (layers.length === 0) {
45
+ bucket.destroy();
46
+ buckets.delete(id);
36
47
  continue;
37
48
  }
38
49
 
39
- // look up StyleLayer objects from layer ids (since we don't
40
- // want to waste time serializing/copying them from the worker)
50
+ // swap out the layers in the bucket with the current style layers
41
51
  bucket.layers = layers;
42
- bucket.stateDependentLayers = layers.filter(l => l.isStateDependent());
43
- for (const layer of layers) {
44
- output[layer.id] = bucket;
45
- }
52
+ bucket.stateDependentLayers = layers.filter(layer => layer.isStateDependent());
46
53
  }
47
-
48
- return output;
49
54
  }
50
55
 
51
56
  module.exports = {
52
- deserialize
57
+ updateBuckets
53
58
  };
@@ -1,7 +1,6 @@
1
1
  const { RGBAImage } = require('../util/image');
2
2
 
3
3
  const warn = require('../util/warn');
4
- const { register } = require('../util/transfer_registry');
5
4
 
6
5
  // DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders
7
6
  // data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially
@@ -121,6 +120,4 @@ class DEMData {
121
120
  }
122
121
  }
123
122
 
124
- register('DEMData', DEMData);
125
-
126
123
  module.exports = DEMData;
@@ -3,11 +3,8 @@ const EXTENT = require('./extent');
3
3
  const featureFilter = require('../style-spec/feature_filter');
4
4
  const Grid = require('grid-index');
5
5
  const dictionaryCoder = require('../util/dictionary_coder');
6
- const vt = require('@mapwhit/vector-tile');
7
- const Protobuf = require('@mapwhit/pbf');
8
6
  const GeoJSONFeature = require('../util/vectortile_to_geojson');
9
7
  const { arraysIntersect } = require('../util/object');
10
- const { register } = require('../util/transfer_registry');
11
8
  const EvaluationParameters = require('../style/evaluation_parameters');
12
9
  const { polygonIntersectsBox } = require('../util/intersection_tests');
13
10
 
@@ -37,7 +34,7 @@ class FeatureIndex {
37
34
 
38
35
  loadVTLayers() {
39
36
  if (!this.vtLayers) {
40
- this.vtLayers = new vt.VectorTile(new Protobuf(this.rawTileData)).layers;
37
+ this.vtLayers = this.vectorTile?.layers;
41
38
  this.sourceLayerCoder = dictionaryCoder(this.vtLayers ? Object.keys(this.vtLayers) : ['_geojsonTileLayer']);
42
39
  }
43
40
  return this.vtLayers;
@@ -153,7 +150,7 @@ class FeatureIndex {
153
150
  continue;
154
151
  }
155
152
 
156
- const styleLayer = styleLayers[layerID];
153
+ const styleLayer = styleLayers.get(layerID);
157
154
  if (!styleLayer) continue;
158
155
 
159
156
  const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer);
@@ -163,7 +160,7 @@ class FeatureIndex {
163
160
  }
164
161
 
165
162
  const geojsonFeature = new GeoJSONFeature(feature, z, x, y);
166
- geojsonFeature.layer = styleLayer.serialize();
163
+ geojsonFeature.layer = styleLayer;
167
164
  const layerResult = (result[layerID] ??= []);
168
165
  layerResult.push({ featureIndex, feature: geojsonFeature, intersectionZ });
169
166
  }
@@ -192,8 +189,6 @@ class FeatureIndex {
192
189
  }
193
190
  }
194
191
 
195
- register('FeatureIndex', FeatureIndex, { omit: ['rawTileData', 'sourceLayerCoder'] });
196
-
197
192
  module.exports = FeatureIndex;
198
193
 
199
194
  function getBounds(geometry) {
@@ -1,6 +1,5 @@
1
1
  const { packUint8ToFloat } = require('../shaders/encode_attribute');
2
2
  const { supportsPropertyExpression } = require('@mapwhit/style-expressions');
3
- const { register } = require('../util/transfer_registry');
4
3
  const { PossiblyEvaluatedPropertyValue } = require('../style/properties');
5
4
  const {
6
5
  StructArrayLayout1f4,
@@ -128,13 +127,13 @@ class SourceExpressionBinder {
128
127
 
129
128
  setConstantPatternPositions() {}
130
129
 
131
- populatePaintArray(newLength, feature, imagePositions) {
130
+ populatePaintArray(newLength, feature, options) {
132
131
  const paintArray = this.paintVertexArray;
133
132
 
134
133
  const start = paintArray.length;
135
134
  paintArray.reserve(newLength);
136
135
 
137
- const value = this.expression.evaluate(new EvaluationParameters(0), feature, {});
136
+ const value = this.expression.evaluate(new EvaluationParameters(0, options), feature, {});
138
137
 
139
138
  if (this.type === 'color') {
140
139
  const color = packColor(value);
@@ -150,9 +149,9 @@ class SourceExpressionBinder {
150
149
  }
151
150
  }
152
151
 
153
- updatePaintArray(start, end, feature, featureState, imagePositions) {
152
+ updatePaintArray(start, end, feature, featureState, options) {
154
153
  const paintArray = this.paintVertexArray;
155
- const value = this.expression.evaluate({ zoom: 0 }, feature, featureState);
154
+ const value = this.expression.evaluate(new EvaluationParameters(0, options), feature, featureState);
156
155
 
157
156
  if (this.type === 'color') {
158
157
  const color = packColor(value);
@@ -224,14 +223,14 @@ class CompositeExpressionBinder {
224
223
 
225
224
  setConstantPatternPositions() {}
226
225
 
227
- populatePaintArray(newLength, feature) {
226
+ populatePaintArray(newLength, feature, options) {
228
227
  const paintArray = this.paintVertexArray;
229
228
 
230
229
  const start = paintArray.length;
231
230
  paintArray.reserve(newLength);
232
231
 
233
- const min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {});
234
- const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {});
232
+ const min = this.expression.evaluate(new EvaluationParameters(this.zoom, options), feature, {});
233
+ const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1, options), feature, {});
235
234
 
236
235
  if (this.type === 'color') {
237
236
  const minColor = packColor(min);
@@ -247,11 +246,11 @@ class CompositeExpressionBinder {
247
246
  }
248
247
  }
249
248
 
250
- updatePaintArray(start, end, feature, featureState) {
249
+ updatePaintArray(start, end, feature, featureState, options) {
251
250
  const paintArray = this.paintVertexArray;
252
251
 
253
- const min = this.expression.evaluate({ zoom: this.zoom }, feature, featureState);
254
- const max = this.expression.evaluate({ zoom: this.zoom + 1 }, feature, featureState);
252
+ const min = this.expression.evaluate(new EvaluationParameters(this.zoom, options), feature, featureState);
253
+ const max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1, options), feature, featureState);
255
254
 
256
255
  if (this.type === 'color') {
257
256
  const minColor = packColor(min);
@@ -331,7 +330,7 @@ class CrossFadedCompositeBinder {
331
330
 
332
331
  setConstantPatternPositions() {}
333
332
 
334
- populatePaintArray(length, feature, imagePositions) {
333
+ populatePaintArray(length, feature, { imagePositions }) {
335
334
  // We populate two paint arrays because, for cross-faded properties, we don't know which direction
336
335
  // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass
337
336
  // unnecessary vertex data to the shaders, we determine which to upload at draw time.
@@ -379,7 +378,7 @@ class CrossFadedCompositeBinder {
379
378
  }
380
379
  }
381
380
 
382
- updatePaintArray(start, end, feature, featureState, imagePositions) {
381
+ updatePaintArray(start, end, feature, featureState, { imagePositions }) {
383
382
  // We populate two paint arrays because, for cross-faded properties, we don't know which direction
384
383
  // we're cross-fading to at layout time. In order to keep vertex attributes to a minimum and not pass
385
384
  // unnecessary vertex data to the shaders, we determine which to upload at draw time.
@@ -486,9 +485,9 @@ class ProgramConfiguration {
486
485
  const self = new ProgramConfiguration();
487
486
  const keys = [];
488
487
 
489
- for (const property in layer.paint._values) {
488
+ for (const property in layer._paint._values) {
490
489
  if (!filterProperties(property)) continue;
491
- const value = layer.paint.get(property);
490
+ const value = layer._paint.get(property);
492
491
  if (
493
492
  !(value instanceof PossiblyEvaluatedPropertyValue) ||
494
493
  !supportsPropertyExpression(value.property.specification)
@@ -546,12 +545,12 @@ class ProgramConfiguration {
546
545
  return self;
547
546
  }
548
547
 
549
- populatePaintArrays(newLength, feature, index, imagePositions) {
548
+ populatePaintArrays(newLength, feature, index, options) {
550
549
  for (const property in this.binders) {
551
550
  const binder = this.binders[property];
552
- binder.populatePaintArray(newLength, feature, imagePositions);
551
+ binder.populatePaintArray(newLength, feature, options);
553
552
  }
554
- if (feature.id) {
553
+ if (feature.id !== undefined) {
555
554
  const featureId = String(feature.id);
556
555
  this._idMap[featureId] = this._idMap[featureId] || [];
557
556
  this._idMap[featureId].push({
@@ -571,7 +570,7 @@ class ProgramConfiguration {
571
570
  }
572
571
  }
573
572
 
574
- updatePaintArrays(featureStates, vtLayer, layer, imagePositions) {
573
+ updatePaintArrays(featureStates, vtLayer, layer, options) {
575
574
  let dirty = false;
576
575
  for (const id in featureStates) {
577
576
  const posArray = this._idMap[id];
@@ -586,9 +585,9 @@ class ProgramConfiguration {
586
585
  if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) continue;
587
586
  if (binder.expression.isStateDependent === true) {
588
587
  //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255
589
- const value = layer.paint.get(property);
588
+ const value = layer._paint.get(property);
590
589
  binder.expression = value.value;
591
- binder.updatePaintArray(pos.start, pos.end, feature, featureState, imagePositions);
590
+ binder.updatePaintArray(pos.start, pos.end, feature, featureState, options);
592
591
  dirty = true;
593
592
  }
594
593
  }
@@ -687,17 +686,17 @@ class ProgramConfigurationSet {
687
686
  this.needsUpload = false;
688
687
  }
689
688
 
690
- populatePaintArrays(length, feature, index, imagePositions) {
689
+ populatePaintArrays(length, feature, index, options) {
691
690
  for (const key in this.programConfigurations) {
692
- this.programConfigurations[key].populatePaintArrays(length, feature, index, imagePositions);
691
+ this.programConfigurations[key].populatePaintArrays(length, feature, index, options);
693
692
  }
694
693
  this.needsUpload = true;
695
694
  }
696
695
 
697
- updatePaintArrays(featureStates, vtLayer, layers, imagePositions) {
696
+ updatePaintArrays(featureStates, vtLayer, layers, options) {
698
697
  for (const layer of layers) {
699
698
  this.needsUpload =
700
- this.programConfigurations[layer.id].updatePaintArrays(featureStates, vtLayer, layer, imagePositions) ||
699
+ this.programConfigurations[layer.id].updatePaintArrays(featureStates, vtLayer, layer, options) ||
701
700
  this.needsUpload;
702
701
  }
703
702
  }
@@ -777,14 +776,6 @@ function layoutType(property, type, binderType) {
777
776
  return layoutException?.[binderType] || defaultLayouts[type][binderType];
778
777
  }
779
778
 
780
- register('ConstantBinder', ConstantBinder);
781
- register('CrossFadedConstantBinder', CrossFadedConstantBinder);
782
- register('SourceExpressionBinder', SourceExpressionBinder);
783
- register('CrossFadedCompositeBinder', CrossFadedCompositeBinder);
784
- register('CompositeExpressionBinder', CompositeExpressionBinder);
785
- register('ProgramConfiguration', ProgramConfiguration, { omit: ['_buffers'] });
786
- register('ProgramConfigurationSet', ProgramConfigurationSet);
787
-
788
779
  ProgramConfiguration.ProgramConfigurationSet = ProgramConfigurationSet;
789
780
 
790
781
  module.exports = ProgramConfiguration;
@@ -1,7 +1,5 @@
1
1
  const warn = require('../util/warn');
2
2
 
3
- const { register } = require('../util/transfer_registry');
4
-
5
3
  class SegmentVector {
6
4
  constructor(segments = []) {
7
5
  this.segments = segments;
@@ -58,6 +56,4 @@ class SegmentVector {
58
56
  */
59
57
  SegmentVector.MAX_VERTEX_ARRAY_LENGTH = 2 ** 16 - 1;
60
58
 
61
- register('SegmentVector', SegmentVector);
62
-
63
59
  module.exports = SegmentVector;
@@ -6,8 +6,8 @@ const { backgroundUniformValues, backgroundPatternUniformValues } = require('./p
6
6
  module.exports = drawBackground;
7
7
 
8
8
  function drawBackground(painter, sourceCache, layer) {
9
- const color = layer.paint.get('background-color');
10
- const opacity = layer.paint.get('background-opacity');
9
+ const color = layer._paint.get('background-color');
10
+ const opacity = layer._paint.get('background-opacity');
11
11
 
12
12
  if (opacity === 0) return;
13
13
 
@@ -15,7 +15,7 @@ function drawBackground(painter, sourceCache, layer) {
15
15
  const gl = context.gl;
16
16
  const transform = painter.transform;
17
17
  const tileSize = transform.tileSize;
18
- const image = layer.paint.get('background-pattern');
18
+ const image = layer._paint.get('background-pattern');
19
19
  if (painter.isPatternMissing(image)) return;
20
20
 
21
21
  const pass =
@@ -8,9 +8,9 @@ module.exports = drawCircles;
8
8
  function drawCircles(painter, sourceCache, layer, coords) {
9
9
  if (painter.renderPass !== 'translucent') return;
10
10
 
11
- const opacity = layer.paint.get('circle-opacity');
12
- const strokeWidth = layer.paint.get('circle-stroke-width');
13
- const strokeOpacity = layer.paint.get('circle-stroke-opacity');
11
+ const opacity = layer._paint.get('circle-opacity');
12
+ const strokeWidth = layer._paint.get('circle-stroke-width');
13
+ const strokeOpacity = layer._paint.get('circle-stroke-opacity');
14
14
 
15
15
  if (opacity.constantOr(1) === 0 && (strokeWidth.constantOr(1) === 0 || strokeOpacity.constantOr(1) === 0)) {
16
16
  return;
@@ -47,7 +47,7 @@ function drawCircles(painter, sourceCache, layer, coords) {
47
47
  bucket.layoutVertexBuffer,
48
48
  bucket.indexBuffer,
49
49
  bucket.segments,
50
- layer.paint,
50
+ layer._paint,
51
51
  painter.transform.zoom,
52
52
  programConfiguration
53
53
  );