@cesium/engine 23.0.1 → 24.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 (226) hide show
  1. package/Build/Workers/{chunk-G6MJ3ZW3.js → chunk-2N4KDHS3.js} +10 -10
  2. package/Build/Workers/{chunk-C6HHBKT5.js → chunk-44EMEGKW.js} +5 -5
  3. package/Build/Workers/{chunk-TNXOPEIG.js → chunk-4TIG36AW.js} +12 -12
  4. package/Build/Workers/{chunk-PQTSXJBJ.js → chunk-5A2SW66E.js} +16 -16
  5. package/Build/Workers/{chunk-TXYQNXNW.js → chunk-5GXYJQ2K.js} +3 -3
  6. package/Build/Workers/{chunk-O67UP5YO.js → chunk-63SIWPLS.js} +13 -13
  7. package/Build/Workers/{chunk-CVAAIRNP.js → chunk-6MPGQEHA.js} +2 -2
  8. package/Build/Workers/{chunk-LHFC4R7Z.js → chunk-6RMS4S72.js} +6 -6
  9. package/Build/Workers/{chunk-77DJBHMI.js → chunk-6WLHJFD3.js} +7 -7
  10. package/Build/Workers/{chunk-HXEPZWJN.js → chunk-72VYSVEW.js} +9 -9
  11. package/Build/Workers/{chunk-VPWYHFQA.js → chunk-7MDYBRYJ.js} +4 -4
  12. package/Build/Workers/{chunk-XPMXRJDD.js → chunk-7O5XJTVE.js} +5 -5
  13. package/Build/Workers/{chunk-UEWYSOFD.js → chunk-7QRFIKWQ.js} +2 -2
  14. package/Build/Workers/{chunk-3UQ2YMPP.js → chunk-7TYLCBGK.js} +8 -8
  15. package/Build/Workers/{chunk-GLCPE2BJ.js → chunk-7X322WP2.js} +13 -13
  16. package/Build/Workers/{chunk-2OBWHTIC.js → chunk-A47HVBC5.js} +7 -7
  17. package/Build/Workers/{chunk-CID5SY7L.js → chunk-AF3MU2RL.js} +5 -5
  18. package/Build/Workers/{chunk-BTP3634E.js → chunk-AJLTU6PF.js} +1 -1
  19. package/Build/Workers/{chunk-YSJRB2UZ.js → chunk-AMIHNSST.js} +2 -2
  20. package/Build/Workers/{chunk-QPXGGVHC.js → chunk-B6SCUUFP.js} +10 -10
  21. package/Build/Workers/{chunk-QNABVTTP.js → chunk-BJD6QGXZ.js} +12 -12
  22. package/Build/Workers/{chunk-RZX6LOG6.js → chunk-C6P4IG5P.js} +6 -6
  23. package/Build/Workers/{chunk-4JJQRZYL.js → chunk-D4EJ2NXG.js} +17 -17
  24. package/Build/Workers/{chunk-K7UTK4OM.js → chunk-DHKPFLSJ.js} +1 -1
  25. package/Build/Workers/{chunk-S53HSRT6.js → chunk-DVB56LG7.js} +6 -6
  26. package/Build/Workers/{chunk-PBECJOWF.js → chunk-EDXL4W76.js} +2 -2
  27. package/Build/Workers/{chunk-ALTCIHRH.js → chunk-EV3VGO6Y.js} +17 -17
  28. package/Build/Workers/{chunk-UOQB7XQI.js → chunk-GOQBUCXH.js} +10 -10
  29. package/Build/Workers/{chunk-TMCTZ5E3.js → chunk-GQUNK2XC.js} +14 -14
  30. package/Build/Workers/{chunk-PAFMAR7A.js → chunk-HKUES6UG.js} +12 -12
  31. package/Build/Workers/{chunk-6U5QMZU3.js → chunk-HRHRYFHS.js} +9 -9
  32. package/Build/Workers/{chunk-PUO7BYDY.js → chunk-HXJMS2ZI.js} +1 -1
  33. package/Build/Workers/{chunk-FXSRA5UG.js → chunk-ILMFADZA.js} +4 -4
  34. package/Build/Workers/{chunk-U4SWB6TI.js → chunk-ISY4EZCA.js} +4 -4
  35. package/Build/Workers/{chunk-PGZ3B6CB.js → chunk-J6AW5YHS.js} +14 -14
  36. package/Build/Workers/{chunk-VX774SWE.js → chunk-JCI63T3K.js} +6 -6
  37. package/Build/Workers/{chunk-54O3AGOA.js → chunk-KLPGTXS3.js} +6 -6
  38. package/Build/Workers/{chunk-CNLXMOPM.js → chunk-LIB2H534.js} +10 -10
  39. package/Build/Workers/{chunk-H3TVRJLY.js → chunk-LXMCPFFS.js} +4 -4
  40. package/Build/Workers/{chunk-DNMASBMH.js → chunk-MKM27KGV.js} +2 -2
  41. package/Build/Workers/{chunk-66OWUDO7.js → chunk-N65BAKSH.js} +8 -8
  42. package/Build/Workers/{chunk-ZEMJQKHD.js → chunk-NKT5K3K3.js} +11 -11
  43. package/Build/Workers/{chunk-EIC3VAOZ.js → chunk-NPF7SSHZ.js} +7 -7
  44. package/Build/Workers/{chunk-YDR5LX5Z.js → chunk-PVV64VFW.js} +1 -1
  45. package/Build/Workers/{chunk-FKU77FNM.js → chunk-Q3C6VQH6.js} +4 -4
  46. package/Build/Workers/{chunk-CYOPNGPX.js → chunk-RQNJD3O4.js} +12 -12
  47. package/Build/Workers/{chunk-IJ3SUMK3.js → chunk-UIGVOKKI.js} +1 -1
  48. package/Build/Workers/{chunk-TFPG3ZKW.js → chunk-UQU4RXLT.js} +27 -19
  49. package/Build/Workers/{chunk-N6HRZLS6.js → chunk-VLDEUTOP.js} +2 -2
  50. package/Build/Workers/{chunk-MNSNOONX.js → chunk-VMVOUQ5J.js} +7 -7
  51. package/Build/Workers/{chunk-OZYB3AOR.js → chunk-XJRBB253.js} +11 -11
  52. package/Build/Workers/{chunk-B2VA6IEL.js → chunk-XY6HMDGI.js} +5 -5
  53. package/Build/Workers/{chunk-2M7DKGLW.js → chunk-Y7HNNPNK.js} +10 -10
  54. package/Build/Workers/{chunk-CJ7ZDY77.js → chunk-YAOZMOFL.js} +5 -5
  55. package/Build/Workers/{chunk-FCJQO4NC.js → chunk-YJZGW74L.js} +8 -8
  56. package/Build/Workers/{chunk-JUKGMJX7.js → chunk-YQFTYQMZ.js} +1 -1
  57. package/Build/Workers/{chunk-HNDE73JK.js → chunk-ZBZRTRJB.js} +10 -10
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +25 -25
  100. package/Build/Workers/createWallOutlineGeometry.js +24 -24
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +12 -12
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/BoundingSphere.js +1 -1
  112. package/Source/Core/Cartesian2.js +7 -5
  113. package/Source/Core/Cartesian3.js +8 -6
  114. package/Source/Core/Cartesian4.js +8 -6
  115. package/Source/Core/Color.js +5 -3
  116. package/Source/Core/DeveloperError.js +2 -1
  117. package/Source/Core/ITwinPlatform.js +1 -0
  118. package/Source/Core/Ion.js +1 -1
  119. package/Source/Core/S2Cell.js +2 -2
  120. package/Source/Core/TerrainMesh.js +10 -1
  121. package/Source/Core/TerrainPicker.js +1 -0
  122. package/Source/Core/WallGeometry.js +1 -1
  123. package/Source/Core/WallOutlineGeometry.js +1 -1
  124. package/Source/Core/assert.js +27 -0
  125. package/Source/Core/globalTypes.js +4 -0
  126. package/Source/DataSources/CzmlDataSource.js +9 -0
  127. package/Source/DataSources/PathGraphics.js +13 -0
  128. package/Source/DataSources/PathVisualizer.js +330 -18
  129. package/Source/DataSources/StaticGeometryColorBatch.js +7 -2
  130. package/Source/DataSources/StaticGeometryPerMaterialBatch.js +7 -2
  131. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +3 -1
  132. package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +3 -1
  133. package/Source/Renderer/Context.js +1 -1
  134. package/Source/Renderer/RenderState.js +2 -2
  135. package/Source/Renderer/VertexArray.js +80 -0
  136. package/Source/Scene/ArcGisMapService.js +1 -1
  137. package/Source/Scene/BillboardCollection.js +65 -364
  138. package/Source/Scene/BufferPoint.js +148 -0
  139. package/Source/Scene/BufferPointCollection.js +135 -0
  140. package/Source/Scene/BufferPointMaterial.js +95 -0
  141. package/Source/Scene/BufferPolygon.js +516 -0
  142. package/Source/Scene/BufferPolygonCollection.js +368 -0
  143. package/Source/Scene/BufferPolygonMaterial.js +41 -0
  144. package/Source/Scene/BufferPolyline.js +185 -0
  145. package/Source/Scene/BufferPolylineCollection.js +136 -0
  146. package/Source/Scene/BufferPolylineMaterial.js +93 -0
  147. package/Source/Scene/BufferPrimitive.js +347 -0
  148. package/Source/Scene/BufferPrimitiveCollection.js +702 -0
  149. package/Source/Scene/BufferPrimitiveMaterial.js +140 -0
  150. package/Source/Scene/Cesium3DTileContent.js +5 -1
  151. package/Source/Scene/Cesium3DTileContentFactory.js +9 -0
  152. package/Source/Scene/Cesium3DTileStyle.js +22 -0
  153. package/Source/Scene/Cesium3DTileset.js +1 -0
  154. package/Source/Scene/ClippingPolygonCollection.js +270 -101
  155. package/Source/Scene/CubeMapPanorama.js +4 -4
  156. package/Source/Scene/GaussianSplat3DTileContent.js +40 -46
  157. package/Source/Scene/GaussianSplatPrimitive.js +413 -70
  158. package/Source/Scene/GetFeatureInfoFormat.js +3 -3
  159. package/Source/Scene/GltfLoader.js +215 -34
  160. package/Source/Scene/GltfSpzLoader.js +109 -0
  161. package/Source/Scene/ITwinData.js +1 -0
  162. package/Source/Scene/Label.js +32 -0
  163. package/Source/Scene/LabelCollection.js +14 -13
  164. package/Source/Scene/Material.js +2 -0
  165. package/Source/Scene/Megatexture.js +1 -0
  166. package/Source/Scene/MetadataClassProperty.js +24 -10
  167. package/Source/Scene/MetadataComponentType.js +115 -23
  168. package/Source/Scene/Model/CustomShaderPipelineStage.js +3 -1
  169. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +761 -263
  170. package/Source/Scene/Model/MaterialPipelineStage.js +147 -0
  171. package/Source/Scene/Model/MetadataPipelineStage.js +3 -3
  172. package/Source/Scene/Model/ModelDrawCommand.js +6 -0
  173. package/Source/Scene/Model/ModelReader.js +1 -1
  174. package/Source/Scene/Model/ModelUtility.js +3 -1
  175. package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +330 -0
  176. package/Source/Scene/ModelComponents.js +1632 -1542
  177. package/Source/Scene/PickedMetadataInfo.js +1 -0
  178. package/Source/Scene/ScreenSpaceCameraController.js +13 -0
  179. package/Source/Scene/SkyBox.js +17 -8
  180. package/Source/Scene/TileBoundingRegion.js +1 -1
  181. package/Source/Scene/TileBoundingS2Cell.js +1 -1
  182. package/Source/Scene/TileBoundingSphere.js +1 -1
  183. package/Source/Scene/TweenCollection.js +7 -0
  184. package/Source/Scene/VectorGltf3DTileContent.js +382 -0
  185. package/Source/Scene/VertexAttributeSemantic.js +14 -0
  186. package/Source/Scene/WebMapServiceImageryProvider.js +2 -2
  187. package/Source/Scene/WebMapTileServiceImageryProvider.js +366 -131
  188. package/Source/Scene/parseStructuralMetadata.js +97 -37
  189. package/Source/Scene/renderBufferPointCollection.js +334 -0
  190. package/Source/Scene/renderBufferPolygonCollection.js +386 -0
  191. package/Source/Scene/renderBufferPolylineCollection.js +529 -0
  192. package/Source/Shaders/BillboardCollectionFS.glsl +2 -77
  193. package/Source/Shaders/BillboardCollectionFS.js +2 -77
  194. package/Source/Shaders/BillboardCollectionVS.glsl +2 -60
  195. package/Source/Shaders/BillboardCollectionVS.js +2 -60
  196. package/Source/Shaders/BufferPointMaterialFS.glsl +27 -0
  197. package/Source/Shaders/BufferPointMaterialFS.js +29 -0
  198. package/Source/Shaders/BufferPointMaterialVS.glsl +48 -0
  199. package/Source/Shaders/BufferPointMaterialVS.js +50 -0
  200. package/Source/Shaders/BufferPolygonMaterialFS.glsl +13 -0
  201. package/Source/Shaders/BufferPolygonMaterialFS.js +15 -0
  202. package/Source/Shaders/BufferPolygonMaterialVS.glsl +30 -0
  203. package/Source/Shaders/BufferPolygonMaterialVS.js +32 -0
  204. package/Source/Shaders/BufferPolylineMaterialFS.glsl +13 -0
  205. package/Source/Shaders/BufferPolylineMaterialFS.js +15 -0
  206. package/Source/Shaders/BufferPolylineMaterialVS.glsl +49 -0
  207. package/Source/Shaders/BufferPolylineMaterialVS.js +51 -0
  208. package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +34 -48
  209. package/Source/Shaders/Model/EdgeVisibilityStageFS.js +34 -49
  210. package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +98 -0
  211. package/Source/Shaders/Model/EdgeVisibilityStageVS.js +100 -0
  212. package/Source/Shaders/Model/ModelFS.glsl +15 -0
  213. package/Source/Shaders/Model/ModelFS.js +15 -0
  214. package/Source/Shaders/Model/ModelVS.glsl +8 -0
  215. package/Source/Shaders/Model/ModelVS.js +8 -0
  216. package/Source/Shaders/PolygonSignedDistanceFS.glsl +64 -33
  217. package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
  218. package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +9 -2
  219. package/Source/Shaders/PrimitiveGaussianSplatVS.js +9 -2
  220. package/Source/Shaders/Voxels/VoxelFS.glsl +1 -1
  221. package/Source/Shaders/Voxels/VoxelFS.js +1 -1
  222. package/Source/Workers/decodeDraco.js +3 -0
  223. package/Source/Workers/decodeI3S.js +5 -2
  224. package/index.d.ts +1007 -111
  225. package/index.js +394 -369
  226. package/package.json +2 -2
@@ -0,0 +1,368 @@
1
+ // @ts-check
2
+
3
+ import defined from "../Core/defined.js";
4
+ import BufferPrimitiveCollection from "./BufferPrimitiveCollection.js";
5
+ import BufferPolygon from "./BufferPolygon.js";
6
+ import Frozen from "../Core/Frozen.js";
7
+ import assert from "../Core/assert.js";
8
+ import IndexDatatype from "../Core/IndexDatatype.js";
9
+ import renderPolygons from "./renderBufferPolygonCollection.js";
10
+ import BufferPolygonMaterial from "./BufferPolygonMaterial.js";
11
+
12
+ /** @import { TypedArray } from "../Core/globalTypes.js"; */
13
+ /** @import Matrix4 from "../Core/Matrix4.js"; */
14
+ /** @import FrameState from "./FrameState.js" */
15
+ /** @import ComponentDatatype from "../Core/ComponentDatatype.js"; */
16
+
17
+ const { ERR_CAPACITY } = BufferPrimitiveCollection.Error;
18
+
19
+ /**
20
+ * @typedef {object} BufferPolygonOptions
21
+ * @property {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] Transforms geometry from model to world coordinates.
22
+ * @property {boolean} [show=true]
23
+ * @property {BufferPolygonMaterial} [material=BufferPolygonMaterial.DEFAULT_MATERIAL]
24
+ * @property {TypedArray} [positions]
25
+ * @property {TypedArray} [holes]
26
+ * @property {TypedArray} [triangles]
27
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
28
+ */
29
+
30
+ /**
31
+ * Collection of polygons held in ArrayBuffer storage for performance and memory optimization.
32
+ *
33
+ * <p>Default buffer memory allocation is arbitrary, and collections cannot be resized,
34
+ * so specific per-buffer capacities should be provided in the collection
35
+ * constructor when available.</p>
36
+ *
37
+ * @example
38
+ * import earcut from "earcut";
39
+ *
40
+ * const collection = new BufferPolygonCollection({
41
+ * primitiveCountMax: 1024,
42
+ * vertexCountMax: 4096,
43
+ * holeCountMax: 1024,
44
+ * triangleCountMax: 2048,
45
+ * });
46
+ *
47
+ * const polygon = new BufferPolygon();
48
+ * const positions = [ ... ];
49
+ * const holes = [ ... ];
50
+ * const material = new BufferPolygonMaterial({color: Color.WHITE});
51
+ *
52
+ * // Create a new polygon, temporarily bound to 'polygon' local variable.
53
+ * collection.add({
54
+ * positions: new Float64Array(positions),
55
+ * holes: new Uint32Array(holes),
56
+ * triangles: new Uint32Array(earcut(positions, holes, 3)),
57
+ * material
58
+ * }, polygon);
59
+ *
60
+ * // Iterate over all polygons in collection, temporarily binding 'polygon'
61
+ * // local variable to each, and updating polygon material.
62
+ * for (let i = 0; i < collection.primitiveCount; i++) {
63
+ * collection.get(i, polygon);
64
+ * polygon.setMaterial(material);
65
+ * }
66
+ *
67
+ * @see BufferPolygon
68
+ * @see BufferPolygonMaterial
69
+ * @see BufferPrimitiveCollection
70
+ * @extends BufferPrimitiveCollection<BufferPolygon>
71
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
72
+ */
73
+ class BufferPolygonCollection extends BufferPrimitiveCollection {
74
+ /**
75
+ * @param {object} options
76
+ * @param {number} [options.primitiveCountMax=BufferPrimitiveCollection.DEFAULT_CAPACITY]
77
+ * @param {number} [options.vertexCountMax=BufferPrimitiveCollection.DEFAULT_CAPACITY]
78
+ * @param {number} [options.holeCountMax=BufferPrimitiveCollection.DEFAULT_CAPACITY]
79
+ * @param {number} [options.triangleCountMax=BufferPrimitiveCollection.DEFAULT_CAPACITY]
80
+ * @param {ComponentDatatype} [options.positionDatatype=ComponentDatatype.DOUBLE]
81
+ * @param {boolean} [options.show=true]
82
+ * @param {boolean} [options.allowPicking=true] When <code>true</code>, primitives are pickable with {@link Scene#pick}. When <code>false</code>, memory and initialization cost are lower.
83
+ * @param {boolean} [options.debugShowBoundingVolume=false]
84
+ */
85
+ constructor(options = Frozen.EMPTY_OBJECT) {
86
+ super(options);
87
+
88
+ /**
89
+ * @type {number}
90
+ * @ignore
91
+ */
92
+ this._holeCount = 0;
93
+
94
+ /**
95
+ * @type {number}
96
+ * @protected
97
+ * @ignore
98
+ */
99
+ this._holeCountMax =
100
+ options.holeCountMax ?? BufferPrimitiveCollection.DEFAULT_CAPACITY;
101
+
102
+ /**
103
+ * @type {TypedArray}
104
+ * @ignore
105
+ */
106
+ this._holeIndexView = null;
107
+
108
+ /**
109
+ * @type {number}
110
+ * @ignore
111
+ */
112
+ this._triangleCount = 0;
113
+
114
+ /**
115
+ * @type {number}
116
+ * @protected
117
+ * @ignore
118
+ */
119
+ this._triangleCountMax =
120
+ options.triangleCountMax ?? BufferPrimitiveCollection.DEFAULT_CAPACITY;
121
+
122
+ /**
123
+ * @type {TypedArray}
124
+ * @ignore
125
+ */
126
+ this._triangleIndexView = null;
127
+
128
+ this._allocateHoleIndexBuffer();
129
+ this._allocateTriangleIndexBuffer();
130
+ }
131
+
132
+ _getCollectionClass() {
133
+ return BufferPolygonCollection;
134
+ }
135
+
136
+ _getPrimitiveClass() {
137
+ return BufferPolygon;
138
+ }
139
+
140
+ _getMaterialClass() {
141
+ return BufferPolygonMaterial;
142
+ }
143
+
144
+ /////////////////////////////////////////////////////////////////////////////
145
+ // COLLECTION LIFECYCLE
146
+
147
+ /**
148
+ * @private
149
+ * @ignore
150
+ */
151
+ _allocateHoleIndexBuffer() {
152
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
153
+ this._holeIndexView = IndexDatatype.createTypedArray(
154
+ this._positionCountMax,
155
+ this._holeCountMax,
156
+ );
157
+ }
158
+
159
+ /**
160
+ * @private
161
+ * @ignore
162
+ */
163
+ _allocateTriangleIndexBuffer() {
164
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
165
+ this._triangleIndexView = IndexDatatype.createTypedArray(
166
+ this._positionCountMax,
167
+ this._triangleCountMax * 3,
168
+ );
169
+ }
170
+
171
+ /**
172
+ * Duplicates the contents of this collection into the result collection.
173
+ * Result collection is not resized, and must contain enough space for all
174
+ * primitives in the source collection. Existing polygons in the result
175
+ * collection will be overwritten.
176
+ *
177
+ * <p>Useful when allocating more space for a collection that has reached its
178
+ * capacity, and efficiently transferring polygons to the new collection.</p>
179
+ *
180
+ * @example
181
+ * const result = new BufferPolygonCollection({ ... }); // allocate larger 'result' collection
182
+ * BufferPolygonCollection.clone(collection, result); // copy polygons from 'collection' into 'result'
183
+ *
184
+ * @param {BufferPolygonCollection} collection
185
+ * @param {BufferPolygonCollection} result
186
+ * @returns {BufferPolygonCollection}
187
+ */
188
+ static clone(collection, result) {
189
+ super.clone(collection, result);
190
+
191
+ //>>includeStart('debug', pragmas.debug);
192
+ assert(collection.holeCount <= result.holeCountMax, ERR_CAPACITY);
193
+ assert(collection.triangleCount <= result.triangleCountMax, ERR_CAPACITY);
194
+ //>>includeEnd('debug');
195
+
196
+ this._copySubArray(
197
+ collection._holeIndexView,
198
+ result._holeIndexView,
199
+ collection.holeCount,
200
+ );
201
+
202
+ this._copySubArray(
203
+ collection._triangleIndexView,
204
+ result._triangleIndexView,
205
+ collection._triangleCount * 3,
206
+ );
207
+
208
+ result._holeCount = collection._holeCount;
209
+ result._triangleCount = collection._triangleCount;
210
+
211
+ return result;
212
+ }
213
+
214
+ /**
215
+ * @param {BufferPolygonCollection} collection
216
+ * @returns {BufferPolygonCollection}
217
+ * @override
218
+ * @ignore
219
+ */
220
+ static _cloneEmpty(collection) {
221
+ return new BufferPolygonCollection({
222
+ primitiveCountMax: collection.primitiveCountMax,
223
+ vertexCountMax: collection.vertexCountMax,
224
+ holeCountMax: collection.holeCountMax,
225
+ triangleCountMax: collection.triangleCountMax,
226
+ });
227
+ }
228
+
229
+ /**
230
+ * @param {BufferPolygonCollection} src
231
+ * @param {BufferPolygonCollection} dst
232
+ * @override
233
+ * @ignore
234
+ */
235
+ static _replaceBuffers(src, dst) {
236
+ super._replaceBuffers(src, dst);
237
+ dst._holeIndexView = src._holeIndexView;
238
+ dst._triangleIndexView = src._triangleIndexView;
239
+ }
240
+
241
+ /////////////////////////////////////////////////////////////////////////////
242
+ // PRIMITIVE LIFECYCLE
243
+
244
+ /**
245
+ * Adds a new polygon to the collection, with the specified options. A
246
+ * {@link BufferPolygon} instance is linked to the new polygon, using
247
+ * the 'result' argument if given, or a new instance if not. For repeated
248
+ * calls, prefer to reuse a single BufferPolygon instance rather than
249
+ * allocating a new instance on each call.
250
+ *
251
+ * @param {BufferPolygonOptions} options
252
+ * @param {BufferPolygon} result
253
+ * @returns {BufferPolygon}
254
+ * @override
255
+ */
256
+ add(options, result = new BufferPolygon()) {
257
+ super.add(options, result);
258
+
259
+ const vertexOffset = this._positionCount;
260
+ result._setUint32(BufferPolygon.Layout.POSITION_OFFSET_U32, vertexOffset);
261
+ result._setUint32(BufferPolygon.Layout.POSITION_COUNT_U32, 0);
262
+
263
+ const holeOffset = this._holeCount;
264
+ result._setUint32(BufferPolygon.Layout.HOLE_OFFSET_U32, holeOffset);
265
+ result._setUint32(BufferPolygon.Layout.HOLE_COUNT_U32, 0);
266
+
267
+ const triangleOffset = this._triangleCount;
268
+ result._setUint32(BufferPolygon.Layout.TRIANGLE_OFFSET_U32, triangleOffset);
269
+ result._setUint32(BufferPolygon.Layout.TRIANGLE_COUNT_U32, 0);
270
+
271
+ if (defined(options.positions)) {
272
+ result.setPositions(options.positions);
273
+ }
274
+
275
+ if (defined(options.holes)) {
276
+ result.setHoles(options.holes);
277
+ }
278
+
279
+ if (defined(options.triangles)) {
280
+ result.setTriangles(options.triangles);
281
+ }
282
+
283
+ return result;
284
+ }
285
+
286
+ /////////////////////////////////////////////////////////////////////////////
287
+ // RENDER
288
+
289
+ /**
290
+ * @param {FrameState} frameState
291
+ * @ignore
292
+ */
293
+ update(frameState) {
294
+ super.update(frameState);
295
+
296
+ const passes = frameState.passes;
297
+ if (this.show && (passes.render || passes.pick)) {
298
+ this._renderContext = renderPolygons(
299
+ this,
300
+ frameState,
301
+ this._renderContext,
302
+ );
303
+ }
304
+ }
305
+
306
+ /////////////////////////////////////////////////////////////////////////////
307
+ // ACCESSORS
308
+
309
+ /**
310
+ * Total byte length of buffers owned by this collection. Includes any unused
311
+ * space allocated by {@link primitiveCountMax}, even if no polygons have
312
+ * yet been added in that space.
313
+ *
314
+ * @type {number}
315
+ * @readonly
316
+ * @override
317
+ */
318
+ get byteLength() {
319
+ return (
320
+ super.byteLength +
321
+ this._holeIndexView.byteLength +
322
+ this._triangleIndexView.byteLength
323
+ );
324
+ }
325
+
326
+ /**
327
+ * Number of holes in collection. Must be <= {@link holeCountMax}.
328
+ *
329
+ * @type {number}
330
+ * @readonly
331
+ */
332
+ get holeCount() {
333
+ return this._holeCount;
334
+ }
335
+
336
+ /**
337
+ * Maximum number of holes in collection. Must be >= {@link holeCount}.
338
+ *
339
+ * @type {number}
340
+ * @readonly
341
+ * @default {@link BufferPrimitiveCollection.DEFAULT_CAPACITY}
342
+ */
343
+ get holeCountMax() {
344
+ return this._holeCountMax;
345
+ }
346
+
347
+ /**
348
+ * Number of triangles in collection. Must be <= {@link triangleCountMax}.
349
+ *
350
+ * @type {number}
351
+ * @readonly
352
+ */
353
+ get triangleCount() {
354
+ return this._triangleCount;
355
+ }
356
+
357
+ /**
358
+ * Maximum number of triangles in collection. Must be >= {@link triangleCount}.
359
+ *
360
+ * @type {number}
361
+ * @readonly
362
+ * @default {@link BufferPrimitiveCollection.DEFAULT_CAPACITY}
363
+ */
364
+ get triangleCountMax() {
365
+ return this._triangleCountMax;
366
+ }
367
+ }
368
+ export default BufferPolygonCollection;
@@ -0,0 +1,41 @@
1
+ // @ts-check
2
+
3
+ import Frozen from "../Core/Frozen.js";
4
+ import BufferPrimitiveMaterial from "./BufferPrimitiveMaterial.js";
5
+
6
+ /** @import Color from "../Core/Color.js"; */
7
+ /** @import BufferPolygon from "./BufferPolygon.js"; */
8
+
9
+ /**
10
+ * @typedef {object} BufferPolygonMaterialOptions
11
+ * @property {Color} [color=Color.WHITE] Color of fill.
12
+ * @property {Color} [outlineColor=Color.WHITE] Color of outline.
13
+ * @property {number} [outlineWidth=0.0] Width of outline, 0-255px.
14
+ */
15
+
16
+ /**
17
+ * Material description for a {@link BufferPolygon}.
18
+ *
19
+ * <p>BufferPolygonMaterial objects are {@link Packable|packable}, stored
20
+ * when calling {@link BufferPolygon#setMaterial}. Subsequent changes to the
21
+ * material will not affect the polygon until setMaterial() is called again.</p>
22
+ *
23
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
24
+ * @extends BufferPrimitiveMaterial
25
+ */
26
+ class BufferPolygonMaterial extends BufferPrimitiveMaterial {
27
+ /**
28
+ * @type {BufferPolygonMaterial}
29
+ * @ignore
30
+ */
31
+ static DEFAULT_MATERIAL = Object.freeze(new BufferPolygonMaterial());
32
+
33
+ /**
34
+ * @param {BufferPolygonMaterialOptions} [options]
35
+ */
36
+ constructor(options = Frozen.EMPTY_OBJECT) {
37
+ super(options);
38
+ }
39
+ }
40
+
41
+ export default BufferPolygonMaterial;
@@ -0,0 +1,185 @@
1
+ // @ts-check
2
+
3
+ import BufferPrimitive from "./BufferPrimitive.js";
4
+ import assert from "../Core/assert.js";
5
+ import BufferPrimitiveCollection from "./BufferPrimitiveCollection.js";
6
+ import defined from "../Core/defined.js";
7
+
8
+ /** @import { TypedArray, TypedArrayConstructor } from "../Core/globalTypes.js"; */
9
+ /** @import BufferPolylineCollection from "./BufferPolylineCollection.js"; */
10
+
11
+ const { ERR_RESIZE, ERR_CAPACITY } = BufferPrimitiveCollection.Error;
12
+
13
+ /**
14
+ * View bound to the underlying buffer data of a {@link BufferPolylineCollection}.
15
+ *
16
+ * <p>BufferPolyline instances are {@link https://en.wikipedia.org/wiki/Flyweight_pattern|flyweights}:
17
+ * a single BufferPolyline instance can be temporarily bound to any conceptual
18
+ * "polyline" in a BufferPolylineCollection, allowing very large collections to be
19
+ * iterated and updated with a minimal memory footprint.</p>
20
+ *
21
+ * Represented as two (2) or more positions.
22
+ *
23
+ * @see BufferPolylineCollection
24
+ * @see BufferPolylineMaterial
25
+ * @see BufferPrimitive
26
+ * @extends BufferPrimitive
27
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
28
+ */
29
+ class BufferPolyline extends BufferPrimitive {
30
+ /**
31
+ * @type {BufferPolylineCollection}
32
+ * @ignore
33
+ */
34
+ _collection = null;
35
+
36
+ /** @ignore */
37
+ static Layout = {
38
+ ...BufferPrimitive.Layout,
39
+
40
+ /**
41
+ * Offset in position array to first vertex in polyline, number of VEC3 elements.
42
+ * @type {number}
43
+ * @ignore
44
+ */
45
+ POSITION_OFFSET_U32: BufferPrimitive.Layout.__BYTE_LENGTH,
46
+
47
+ /**
48
+ * Count of positions (vertices) in this polyline, number of VEC3 elements.
49
+ * @type {number}
50
+ * @ignore
51
+ */
52
+ POSITION_COUNT_U32: BufferPrimitive.Layout.__BYTE_LENGTH + 4,
53
+
54
+ /**
55
+ * @type {number}
56
+ * @ignore
57
+ */
58
+ __BYTE_LENGTH: BufferPrimitive.Layout.__BYTE_LENGTH + 8,
59
+ };
60
+
61
+ /////////////////////////////////////////////////////////////////////////////
62
+ // LIFECYCLE
63
+
64
+ /**
65
+ * Copies data from source polyline to result. If the result polyline is not
66
+ * new (the last polyline in the collection) then source and result polylines
67
+ * must have the same vertex counts.
68
+ *
69
+ * @param {BufferPolyline} polyline
70
+ * @param {BufferPolyline} result
71
+ * @return {BufferPolyline}
72
+ * @override
73
+ */
74
+ static clone(polyline, result) {
75
+ super.clone(polyline, result);
76
+ result.setPositions(polyline.getPositions());
77
+ return result;
78
+ }
79
+
80
+ /////////////////////////////////////////////////////////////////////////////
81
+ // GEOMETRY
82
+
83
+ /**
84
+ * Offset in collection position array to first vertex in polyline, number
85
+ * of VEC3 elements.
86
+ *
87
+ * @type {number}
88
+ * @readonly
89
+ * @ignore
90
+ */
91
+ get vertexOffset() {
92
+ return this._getUint32(BufferPolyline.Layout.POSITION_OFFSET_U32);
93
+ }
94
+
95
+ /**
96
+ * Count of positions (vertices) in this polyline, number of VEC3 elements.
97
+ *
98
+ * @type {number}
99
+ * @readonly
100
+ */
101
+ get vertexCount() {
102
+ return this._getUint32(BufferPolyline.Layout.POSITION_COUNT_U32);
103
+ }
104
+
105
+ /**
106
+ * Returns an array view of this polyline's vertex positions. If 'result'
107
+ * argument is given, vertex positions are written to that array and returned.
108
+ * Otherwise, returns an ArrayView on collection memory — changes to this array
109
+ * will not trigger render updates, which requires `.setPositions()`.
110
+ *
111
+ * @param {TypedArray} [result]
112
+ * return {TypedArray}
113
+ */
114
+ getPositions(result) {
115
+ const { vertexOffset, vertexCount } = this;
116
+ const positionView = this._collection._positionView;
117
+
118
+ if (!defined(result)) {
119
+ const byteOffset =
120
+ positionView.byteOffset +
121
+ vertexOffset * 3 * positionView.BYTES_PER_ELEMENT;
122
+ const TypedArray = /** @type {TypedArrayConstructor} */ (
123
+ positionView.constructor
124
+ );
125
+ return new TypedArray(
126
+ /** @type {ArrayBuffer} */ (positionView.buffer),
127
+ byteOffset,
128
+ vertexCount * 3,
129
+ );
130
+ }
131
+
132
+ for (let i = 0; i < vertexCount; i++) {
133
+ result[i * 3] = positionView[(vertexOffset + i) * 3];
134
+ result[i * 3 + 1] = positionView[(vertexOffset + i) * 3 + 1];
135
+ result[i * 3 + 2] = positionView[(vertexOffset + i) * 3 + 2];
136
+ }
137
+ return result;
138
+ }
139
+
140
+ /** @param {TypedArray} positions */
141
+ setPositions(positions) {
142
+ const collection = this._collection;
143
+ const vertexOffset = this.vertexOffset;
144
+ const srcCount = this.vertexCount;
145
+ const dstCount = positions.length / 3;
146
+ const collectionCount = collection._positionCount + dstCount - srcCount;
147
+
148
+ //>>includeStart('debug', pragmas.debug);
149
+ assert(srcCount === dstCount || this._isResizable(), ERR_RESIZE);
150
+ assert(collectionCount <= collection.vertexCountMax, ERR_CAPACITY);
151
+ //>>includeEnd('debug');
152
+
153
+ collection._positionCount = collectionCount;
154
+ this._setUint32(BufferPolyline.Layout.POSITION_COUNT_U32, dstCount);
155
+
156
+ const positionView = collection._positionView;
157
+ for (let i = 0; i < dstCount; i++) {
158
+ positionView[(vertexOffset + i) * 3] = positions[i * 3];
159
+ positionView[(vertexOffset + i) * 3 + 1] = positions[i * 3 + 1];
160
+ positionView[(vertexOffset + i) * 3 + 2] = positions[i * 3 + 2];
161
+ }
162
+
163
+ collection._makeDirtyBoundingVolume();
164
+ }
165
+
166
+ /////////////////////////////////////////////////////////////////////////////
167
+ // DEBUG
168
+
169
+ /**
170
+ * Returns a JSON-serializable object representing the polyline. This encoding
171
+ * is not memory-efficient, and should generally be used for debugging and
172
+ * testing.
173
+ *
174
+ * @returns {Object} JSON-serializable object.
175
+ * @override
176
+ */
177
+ toJSON() {
178
+ return {
179
+ ...super.toJSON(),
180
+ positions: Array.from(this.getPositions()),
181
+ };
182
+ }
183
+ }
184
+
185
+ export default BufferPolyline;