@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,148 @@
1
+ // @ts-check
2
+
3
+ import BufferPrimitive from "./BufferPrimitive.js";
4
+ import Cartesian3 from "../Core/Cartesian3.js";
5
+ import assert from "../Core/assert.js";
6
+ import BufferPrimitiveCollection from "./BufferPrimitiveCollection.js";
7
+
8
+ /** @import BufferPointCollection from "./BufferPointCollection.js"; */
9
+
10
+ const { ERR_CAPACITY } = BufferPrimitiveCollection.Error;
11
+
12
+ const scratchCartesian = new Cartesian3();
13
+
14
+ /**
15
+ * View bound to the underlying buffer data of a {@link BufferPointCollection}.
16
+ *
17
+ * <p>BufferPoint instances are {@link https://en.wikipedia.org/wiki/Flyweight_pattern|flyweights}:
18
+ * a single BufferPoint instance can be temporarily bound to any conceptual
19
+ * "point" in a BufferPointCollection, allowing very large collections to be
20
+ * iterated and updated with a minimal memory footprint.</p>
21
+ *
22
+ * Represented as one (1) position.
23
+ *
24
+ * @see BufferPointCollection
25
+ * @see BufferPointMaterial
26
+ * @see BufferPrimitive
27
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
28
+ * @extends BufferPrimitive
29
+ */
30
+ class BufferPoint extends BufferPrimitive {
31
+ /**
32
+ * @type {BufferPointCollection}
33
+ * @ignore
34
+ */
35
+ _collection = null;
36
+
37
+ /** @ignore */
38
+ static Layout = {
39
+ ...BufferPrimitive.Layout,
40
+
41
+ /**
42
+ * Offset in position array to current point vertex, number of VEC3 elements.
43
+ * @type {number}
44
+ * @ignore
45
+ */
46
+ POSITION_OFFSET_U32: BufferPrimitive.Layout.__BYTE_LENGTH,
47
+
48
+ /**
49
+ * @type {number}
50
+ * @ignore
51
+ */
52
+ __BYTE_LENGTH: BufferPrimitive.Layout.__BYTE_LENGTH + 4,
53
+ };
54
+
55
+ /////////////////////////////////////////////////////////////////////////////
56
+ // LIFECYCLE
57
+
58
+ /**
59
+ * Copies data from source point to result.
60
+ *
61
+ * @param {BufferPoint} point
62
+ * @param {BufferPoint} result
63
+ * @return {BufferPoint}
64
+ * @override
65
+ */
66
+ static clone(point, result) {
67
+ super.clone(point, result);
68
+ result.setPosition(point.getPosition(scratchCartesian));
69
+ return result;
70
+ }
71
+
72
+ /////////////////////////////////////////////////////////////////////////////
73
+ // GEOMETRY
74
+
75
+ /**
76
+ * Offset in collection position array to position of this point, number
77
+ * of VEC3 elements.
78
+ *
79
+ * @type {number}
80
+ * @readonly
81
+ * @ignore
82
+ */
83
+ get vertexOffset() {
84
+ return this._getUint32(BufferPoint.Layout.POSITION_OFFSET_U32);
85
+ }
86
+
87
+ /**
88
+ * Count of positions (vertices) in this primitive. Always 1.
89
+ *
90
+ * @type {number}
91
+ * @readonly
92
+ */
93
+ get vertexCount() {
94
+ return 1;
95
+ }
96
+
97
+ /**
98
+ * Gets the position of this point.
99
+ *
100
+ * @param {Cartesian3} [result]
101
+ * @returns {Cartesian3}
102
+ */
103
+ getPosition(result) {
104
+ const positionF64 = this._collection._positionView;
105
+ // @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
106
+ return Cartesian3.fromArray(positionF64, this.vertexOffset * 3, result);
107
+ }
108
+
109
+ /**
110
+ * Sets the position of this point.
111
+ *
112
+ * @param {Cartesian3} position
113
+ */
114
+ setPosition(position) {
115
+ const collection = this._collection;
116
+ const vertexOffset = this.vertexOffset;
117
+
118
+ //>>includeStart('debug', pragmas.debug);
119
+ assert(vertexOffset < collection.vertexCountMax, ERR_CAPACITY);
120
+ //>>includeEnd('debug');
121
+
122
+ collection._positionView[vertexOffset * 3] = position.x;
123
+ collection._positionView[vertexOffset * 3 + 1] = position.y;
124
+ collection._positionView[vertexOffset * 3 + 2] = position.z;
125
+
126
+ collection._makeDirtyBoundingVolume();
127
+ }
128
+
129
+ /////////////////////////////////////////////////////////////////////////////
130
+ // DEBUG
131
+
132
+ /**
133
+ * Returns a JSON-serializable object representing the point. This encoding
134
+ * is not memory-efficient, and should generally be used for debugging and
135
+ * testing.
136
+ *
137
+ * @returns {Object} JSON-serializable object.
138
+ * @override
139
+ */
140
+ toJSON() {
141
+ return {
142
+ ...super.toJSON(),
143
+ position: Cartesian3.pack(this.getPosition(), []),
144
+ };
145
+ }
146
+ }
147
+
148
+ export default BufferPoint;
@@ -0,0 +1,135 @@
1
+ // @ts-check
2
+
3
+ import BufferPrimitiveCollection from "./BufferPrimitiveCollection.js";
4
+ import BufferPoint from "./BufferPoint.js";
5
+ import Cartesian3 from "../Core/Cartesian3.js";
6
+ import Frozen from "../Core/Frozen.js";
7
+ import renderPoints from "./renderBufferPointCollection.js";
8
+ import BufferPointMaterial from "./BufferPointMaterial.js";
9
+
10
+ /** @import Matrix4 from "../Core/Matrix4.js"; */
11
+ /** @import FrameState from "./FrameState.js"; */
12
+
13
+ /**
14
+ * @typedef {object} BufferPointOptions
15
+ * @property {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] Transforms geometry from model to world coordinates.
16
+ * @property {boolean} [show=true]
17
+ * @property {BufferPointMaterial} [material=BufferPointMaterial.DEFAULT_MATERIAL]
18
+ * @property {Cartesian3} [position=Cartesian3.ZERO]
19
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
20
+ */
21
+
22
+ /**
23
+ * Collection of points held in ArrayBuffer storage for performance and memory optimization.
24
+ *
25
+ * <p>Default buffer memory allocation is arbitrary, and collections cannot be resized,
26
+ * so specific per-buffer capacities should be provided in the collection
27
+ * constructor when available.</p>
28
+ *
29
+ * @example
30
+ * const collection = new BufferPointCollection({primitiveCountMax: 1024});
31
+ *
32
+ * const point = new BufferPoint();
33
+ * const material = new BufferPointMaterial({color: Color.WHITE});
34
+ *
35
+ * // Create a new point, temporarily bound to 'point' local variable.
36
+ * collection.add({
37
+ * position: new Cartesian3(0.0, 0.0, 0.0),
38
+ * material
39
+ * }, point);
40
+ *
41
+ * // Iterate over all points in collection, temporarily binding 'point'
42
+ * // local variable to each, and updating point material.
43
+ * for (let i = 0; i < collection.primitiveCount; i++) {
44
+ * collection.get(i, point);
45
+ * point.setMaterial(material);
46
+ * }
47
+ *
48
+ * @see BufferPoint
49
+ * @see BufferPrimitiveCollection
50
+ * @extends BufferPrimitiveCollection<BufferPoint>
51
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
52
+ */
53
+ class BufferPointCollection extends BufferPrimitiveCollection {
54
+ /**
55
+ * @param {object} options
56
+ * @param {number} [options.primitiveCountMax=BufferPrimitiveCollection.DEFAULT_CAPACITY]
57
+ * @param {boolean} [options.show=true]
58
+ * @param {boolean} [options.debugShowBoundingVolume=false]
59
+ */
60
+ constructor(options = Frozen.EMPTY_OBJECT) {
61
+ super({ ...options, vertexCountMax: options.primitiveCountMax });
62
+ }
63
+
64
+ _getCollectionClass() {
65
+ return BufferPointCollection;
66
+ }
67
+
68
+ _getPrimitiveClass() {
69
+ return BufferPoint;
70
+ }
71
+
72
+ _getMaterialClass() {
73
+ return BufferPointMaterial;
74
+ }
75
+
76
+ /////////////////////////////////////////////////////////////////////////////
77
+ // COLLECTION LIFECYCLE
78
+
79
+ /**
80
+ * @param {BufferPointCollection} collection
81
+ * @returns {BufferPointCollection}
82
+ * @override
83
+ * @ignore
84
+ */
85
+ static _cloneEmpty(collection) {
86
+ return new BufferPointCollection({
87
+ primitiveCountMax: collection.primitiveCountMax,
88
+ });
89
+ }
90
+
91
+ /////////////////////////////////////////////////////////////////////////////
92
+ // PRIMITIVE LIFECYCLE
93
+
94
+ /**
95
+ * Adds a new point to the collection, with the specified options. A
96
+ * {@link BufferPoint} instance is linked to the new point, using
97
+ * the 'result' argument if given, or a new instance if not. For repeated
98
+ * calls, prefer to reuse a single BufferPoint instance rather than
99
+ * allocating a new instance on each call.
100
+ *
101
+ * @param {BufferPointOptions} options
102
+ * @param {BufferPoint} result
103
+ * @returns {BufferPoint}
104
+ * @override
105
+ */
106
+ add(options, result = new BufferPoint()) {
107
+ super.add(options, result);
108
+
109
+ result._setUint32(
110
+ BufferPoint.Layout.POSITION_OFFSET_U32,
111
+ this._positionCount++,
112
+ );
113
+ result.setPosition(options.position ?? Cartesian3.ZERO);
114
+
115
+ return result;
116
+ }
117
+
118
+ /////////////////////////////////////////////////////////////////////////////
119
+ // RENDER
120
+
121
+ /**
122
+ * @param {FrameState} frameState
123
+ * @ignore
124
+ */
125
+ update(frameState) {
126
+ super.update(frameState);
127
+
128
+ const passes = frameState.passes;
129
+ if (this.show && (passes.render || passes.pick)) {
130
+ this._renderContext = renderPoints(this, frameState, this._renderContext);
131
+ }
132
+ }
133
+ }
134
+
135
+ export default BufferPointCollection;
@@ -0,0 +1,95 @@
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 BufferPoint from "./BufferPoint.js"; */
8
+
9
+ /**
10
+ * @typedef {object} BufferPointMaterialOptions
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
+ * @property {number} [size=1.0] Size of point, 0-255px.
15
+ */
16
+
17
+ /**
18
+ * Material description for a {@link BufferPoint}.
19
+ *
20
+ * <p>BufferPointMaterial objects are {@link Packable|packable}, stored
21
+ * when calling {@link BufferPoint#setMaterial}. Subsequent changes to the
22
+ * material will not affect the point until setMaterial() is called again.</p>
23
+ *
24
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
25
+ * @extends BufferPrimitiveMaterial
26
+ */
27
+ class BufferPointMaterial extends BufferPrimitiveMaterial {
28
+ /** @ignore */
29
+ static Layout = {
30
+ ...BufferPrimitiveMaterial.Layout,
31
+ SIZE_U8: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH,
32
+ __BYTE_LENGTH: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH + 4,
33
+ };
34
+
35
+ /**
36
+ * @type {BufferPointMaterial}
37
+ * @ignore
38
+ */
39
+ static DEFAULT_MATERIAL = Object.freeze(new BufferPointMaterial());
40
+
41
+ /**
42
+ * @param {BufferPointMaterialOptions} [options]
43
+ */
44
+ constructor(options = Frozen.EMPTY_OBJECT) {
45
+ super(options);
46
+
47
+ /**
48
+ * Size of point, 0-255px.
49
+ * @type {number}
50
+ */
51
+ this.size = options.size ?? 1;
52
+ }
53
+
54
+ /**
55
+ * @override
56
+ * @param {BufferPointMaterial} material
57
+ * @param {DataView} view
58
+ * @param {number} byteOffset
59
+ * @override
60
+ */
61
+ static pack(material, view, byteOffset) {
62
+ super.pack(material, view, byteOffset);
63
+ view.setUint8(this.Layout.SIZE_U8 + byteOffset, material.size);
64
+ }
65
+
66
+ /**
67
+ * @override
68
+ * @param {DataView} view
69
+ * @param {number} byteOffset
70
+ * @param {BufferPointMaterial} result
71
+ * @returns {BufferPointMaterial}
72
+ * @override
73
+ */
74
+ static unpack(view, byteOffset, result) {
75
+ super.unpack(view, byteOffset, result);
76
+ result.size = view.getUint8(this.Layout.SIZE_U8 + byteOffset);
77
+ return result;
78
+ }
79
+
80
+ /////////////////////////////////////////////////////////////////////////////
81
+ // DEBUG
82
+
83
+ /**
84
+ * Returns a JSON-serializable object representing the material. This encoding
85
+ * is not memory-efficient, and should generally be used for debugging and
86
+ * testing.
87
+ *
88
+ * @returns {Object} JSON-serializable object.
89
+ */
90
+ toJSON() {
91
+ return { ...super.toJSON(), size: this.size };
92
+ }
93
+ }
94
+
95
+ export default BufferPointMaterial;