@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
@@ -8,6 +8,7 @@ import MaterialStageFS from "../../Shaders/Model/MaterialStageFS.js";
8
8
  import AlphaMode from "../AlphaMode.js";
9
9
  import ModelComponents from "../ModelComponents.js";
10
10
  import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
11
+ import PrimitiveType from "../../Core/PrimitiveType.js";
11
12
  import LightingModel from "./LightingModel.js";
12
13
  import ModelUtility from "./ModelUtility.js";
13
14
 
@@ -184,6 +185,16 @@ MaterialPipelineStage.process = function (
184
185
  };
185
186
  }
186
187
 
188
+ if (defined(material.lineStyle)) {
189
+ processLineStyleUniforms(
190
+ material.lineStyle,
191
+ primitive,
192
+ frameState,
193
+ uniformMap,
194
+ shaderBuilder,
195
+ );
196
+ }
197
+
187
198
  shaderBuilder.addFragmentLines(MaterialStageFS);
188
199
 
189
200
  if (material.doubleSided) {
@@ -195,6 +206,142 @@ MaterialPipelineStage.process = function (
195
206
  }
196
207
  };
197
208
 
209
+ /**
210
+ * Add uniforms and defines for the BENTLEY_materials_line_style extension.
211
+ *
212
+ * @param {ModelComponents.LineStyle} lineStyle The line style properties.
213
+ * @param {ModelComponents.Primitive} primitive The primitive being processed.
214
+ * @param {FrameState} frameState The frame state.
215
+ * @param {object} uniformMap The uniform map for the primitive.
216
+ * @param {ShaderBuilder} shaderBuilder The shader builder to modify.
217
+ * @private
218
+ */
219
+ function processLineStyleUniforms(
220
+ lineStyle,
221
+ primitive,
222
+ frameState,
223
+ uniformMap,
224
+ shaderBuilder,
225
+ ) {
226
+ const { width, pattern } = lineStyle;
227
+
228
+ if (defined(width)) {
229
+ shaderBuilder.addUniform("float", "u_lineWidth", ShaderDestination.VERTEX);
230
+ uniformMap.u_lineWidth = function () {
231
+ return width * frameState.pixelRatio;
232
+ };
233
+ }
234
+
235
+ if (defined(pattern)) {
236
+ shaderBuilder.addDefine(
237
+ "HAS_LINE_PATTERN",
238
+ undefined,
239
+ ShaderDestination.BOTH,
240
+ );
241
+ shaderBuilder.addUniform(
242
+ "float",
243
+ "u_linePattern",
244
+ ShaderDestination.FRAGMENT,
245
+ );
246
+ shaderBuilder.addVarying("float", "v_lineCoord");
247
+ uniformMap.u_linePattern = function () {
248
+ return pattern;
249
+ };
250
+ }
251
+
252
+ const cumDistAttribute = ModelUtility.getAttributeBySemantic(
253
+ primitive,
254
+ VertexAttributeSemantic.CUMULATIVE_DISTANCE,
255
+ );
256
+ if (
257
+ defined(pattern) &&
258
+ defined(cumDistAttribute) &&
259
+ (primitive.primitiveType === PrimitiveType.LINES ||
260
+ primitive.primitiveType === PrimitiveType.TRIANGLE_STRIP)
261
+ ) {
262
+ shaderBuilder.addDefine(
263
+ "HAS_LINE_CUMULATIVE_DISTANCE",
264
+ undefined,
265
+ ShaderDestination.VERTEX,
266
+ );
267
+
268
+ if (cumDistAttribute.normalized) {
269
+ shaderBuilder.addDefine(
270
+ "LINE_CUM_DIST_NORMALIZED",
271
+ undefined,
272
+ ShaderDestination.VERTEX,
273
+ );
274
+ }
275
+
276
+ shaderBuilder.addUniform(
277
+ "float",
278
+ "u_cumulativeDistanceMax",
279
+ ShaderDestination.VERTEX,
280
+ );
281
+ shaderBuilder.addUniform(
282
+ "float",
283
+ "u_pixelsPerWorld",
284
+ ShaderDestination.VERTEX,
285
+ );
286
+
287
+ const cumDistMax = defined(cumDistAttribute.max)
288
+ ? cumDistAttribute.max
289
+ : 1.0;
290
+ uniformMap.u_cumulativeDistanceMax = function () {
291
+ return cumDistMax;
292
+ };
293
+ uniformMap.u_pixelsPerWorld = function () {
294
+ // Match iTwin behavior: stable pattern scaling in orthographic views.
295
+ const frustum = frameState.camera.frustum;
296
+ let pixelsPerWorld = 1.0;
297
+ let worldWidth;
298
+ if (defined(frustum.right) && defined(frustum.left)) {
299
+ worldWidth = frustum.right - frustum.left;
300
+ } else if (defined(frustum.width)) {
301
+ worldWidth = frustum.width;
302
+ }
303
+ if (defined(worldWidth) && worldWidth > 0) {
304
+ pixelsPerWorld = frameState.context.drawingBufferWidth / worldWidth;
305
+ }
306
+
307
+ return pixelsPerWorld;
308
+ };
309
+
310
+ const cumDistVar =
311
+ ModelUtility.getAttributeInfo(cumDistAttribute).variableName;
312
+ shaderBuilder.addVertexLines(`
313
+ #ifdef HAS_LINE_CUMULATIVE_DISTANCE
314
+ void lineStyleStageVS(in ProcessedAttributes attributes)
315
+ {
316
+ float cumDist = attributes.${cumDistVar};
317
+ #ifdef LINE_CUM_DIST_NORMALIZED
318
+ cumDist *= u_cumulativeDistanceMax;
319
+ #endif
320
+ const float textureCoordinateBase = 8192.0;
321
+ v_lineCoord = textureCoordinateBase + cumDist * u_pixelsPerWorld;
322
+ }
323
+ #endif
324
+ `);
325
+ } else if (defined(pattern)) {
326
+ shaderBuilder.addVertexLines(`
327
+ #ifdef HAS_LINE_PATTERN
328
+ void lineStyleStageVS(in ProcessedAttributes attributes)
329
+ {
330
+ vec4 posClip = gl_Position;
331
+ vec2 screenPos = ((posClip.xy / posClip.w) * 0.5 + 0.5) * czm_viewport.zw;
332
+
333
+ const float textureCoordinateBase = 8192.0;
334
+ if (czm_viewport.z > czm_viewport.w) {
335
+ v_lineCoord = textureCoordinateBase + screenPos.x;
336
+ } else {
337
+ v_lineCoord = textureCoordinateBase + screenPos.y;
338
+ }
339
+ }
340
+ #endif
341
+ `);
342
+ }
343
+ }
344
+
198
345
  /**
199
346
  * Process a single texture transformation and add it to the shader and uniform map.
200
347
  *
@@ -1030,20 +1030,20 @@ function collectMetadataUsedInPointCloudStyling(
1030
1030
  return;
1031
1031
  }
1032
1032
 
1033
- const colorVariables = style.color?.getVariables() ?? [];
1033
+ const colorVariables = style.color?.getVariables?.() ?? [];
1034
1034
  for (const propertyId of colorVariables) {
1035
1035
  usedInVertex.add(propertyId);
1036
1036
  usedInFragment.add(propertyId);
1037
1037
  }
1038
1038
 
1039
- const showVariables = style.show?.getVariables() ?? [];
1039
+ const showVariables = style.show?.getVariables?.() ?? [];
1040
1040
  for (const propertyId of showVariables) {
1041
1041
  usedInVertex.add(propertyId);
1042
1042
  usedInFragment.add(propertyId);
1043
1043
  }
1044
1044
 
1045
1045
  // Only used in vertex shader
1046
- const pointSizeVariables = style.pointSize?.getVariables() ?? [];
1046
+ const pointSizeVariables = style.pointSize?.getVariables?.() ?? [];
1047
1047
  for (const propertyId of pointSizeVariables) {
1048
1048
  usedInVertex.add(propertyId);
1049
1049
  }
@@ -574,6 +574,11 @@ ModelDrawCommand.prototype.pushCommands = function (frameState, result) {
574
574
 
575
575
  pushCommand(result, this._originalCommand, use2D);
576
576
 
577
+ // Push edge commands after the original command
578
+ if (this._needsEdgeCommands) {
579
+ pushCommand(result, this._edgeCommand, use2D);
580
+ }
581
+
577
582
  return result;
578
583
  };
579
584
 
@@ -815,6 +820,7 @@ function deriveEdgeCommand(command, renderResources) {
815
820
  };
816
821
  edgeCommand.uniformMap = uniformMap;
817
822
 
823
+ edgeCommand.uniformMap = uniformMap;
818
824
  edgeCommand.castShadows = false;
819
825
  edgeCommand.receiveShadows = false;
820
826
 
@@ -53,7 +53,7 @@ class ModelReader {
53
53
  *
54
54
  * The result will be THE actual attribute data.
55
55
  *
56
- * @param {ModelComponents.Attribute} attribute The attribute
56
+ * @param {Attribute} attribute The attribute
57
57
  * @returns {TypedArray} The attribute data
58
58
  */
59
59
  static readAttributeAsTypedArray(attribute) {
@@ -10,6 +10,8 @@ import CullFace from "../CullFace.js";
10
10
  import PrimitiveType from "../../Core/PrimitiveType.js";
11
11
  import Matrix3 from "../../Core/Matrix3.js";
12
12
 
13
+ /** @import {Attribute} from "../ModelComponents.js"; */
14
+
13
15
  /**
14
16
  * Utility functions for {@link Model}.
15
17
  *
@@ -69,7 +71,7 @@ ModelUtility.getNodeTransform = function (node) {
69
71
  * @param {ModelComponents.Primitive|ModelComponents.Instances} object The primitive components or instances object
70
72
  * @param {VertexAttributeSemantic|InstanceAttributeSemantic} semantic The semantic to search for
71
73
  * @param {number} [setIndex] The set index of the semantic. May be undefined for some semantics (POSITION, NORMAL, TRANSLATION, ROTATION, for example)
72
- * @return {ModelComponents.Attribute} The selected attribute, or undefined if not found.
74
+ * @return {Attribute} The selected attribute, or undefined if not found.
73
75
  *
74
76
  * @private
75
77
  */
@@ -0,0 +1,330 @@
1
+ // @ts-check
2
+
3
+ import Cartesian3 from "../../Core/Cartesian3.js";
4
+ import assert from "../../Core/assert.js";
5
+ import defined from "../../Core/defined.js";
6
+ import Matrix4 from "../../Core/Matrix4.js";
7
+ import PrimitiveType from "../../Core/PrimitiveType.js";
8
+ import RuntimeError from "../../Core/RuntimeError.js";
9
+ import BufferPoint from "../BufferPoint.js";
10
+ import BufferPointCollection from "../BufferPointCollection.js";
11
+ import BufferPolygon from "../BufferPolygon.js";
12
+ import BufferPolygonCollection from "../BufferPolygonCollection.js";
13
+ import BufferPolyline from "../BufferPolyline.js";
14
+ import BufferPolylineCollection from "../BufferPolylineCollection.js";
15
+ import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
16
+ import ModelReader from "./ModelReader.js";
17
+ import ModelUtility from "./ModelUtility.js";
18
+ import ModelComponents from "../ModelComponents.js";
19
+
20
+ /** @import { TypedArray } from "../../Core/globalTypes.js"; */
21
+ /** @import BufferPrimitive from "../BufferPrimitive.js"; */
22
+ /** @import BufferPrimitiveCollection from "../BufferPrimitiveCollection.js"; */
23
+ /** @import VectorGltf3DTileContent from "../VectorGltf3DTileContent.js"; */
24
+ /** @import {Attribute, Components, Node, Primitive} from "../ModelComponents.js"; */
25
+
26
+ /**
27
+ * @typedef {object} VectorTileResult
28
+ * @property {Array<BufferPrimitiveCollection<BufferPrimitive>>} collections
29
+ * @property {Array<Matrix4>} collectionLocalMatrices
30
+ * @ignore
31
+ */
32
+
33
+ const scratchPosition = new Cartesian3();
34
+ const scratchPoint = new BufferPoint();
35
+ const scratchPolyline = new BufferPolyline();
36
+ const scratchPolygon = new BufferPolygon();
37
+
38
+ /**
39
+ * Creates vector buffers from model components.
40
+ *
41
+ * @param {VectorGltf3DTileContent} content
42
+ * @param {Components} components
43
+ * @returns {VectorTileResult}
44
+ *
45
+ * @ignore
46
+ */
47
+ function createVectorTileBuffersFromModelComponents(content, components) {
48
+ const rootNodes = components.scene.nodes;
49
+
50
+ /** @type {VectorTileResult} */
51
+ const result = { collections: [], collectionLocalMatrices: [] };
52
+
53
+ for (let i = 0; i < rootNodes.length; i++) {
54
+ appendNodeToBuffers(content, rootNodes[i], Matrix4.IDENTITY, result);
55
+ }
56
+
57
+ return result;
58
+ }
59
+
60
+ /**
61
+ * @param {TypedArray} indices
62
+ * @ignore
63
+ */
64
+ function getPrimitiveRestartIndex(indices) {
65
+ const bits = indices.BYTES_PER_ELEMENT * 8;
66
+ return Math.pow(2, bits) - 1;
67
+ }
68
+
69
+ /**
70
+ * @param {TypedArray} indices
71
+ * @param {Function} callback
72
+ * @ignore
73
+ */
74
+ function forEachLineStripSegment(indices, callback) {
75
+ const restart = getPrimitiveRestartIndex(indices);
76
+ let segmentStart = 0;
77
+ for (let i = 0; i <= indices.length; i++) {
78
+ if (i === indices.length || indices[i] === restart) {
79
+ const segmentCount = i - segmentStart;
80
+ if (segmentCount > 0) {
81
+ callback(segmentStart, segmentCount);
82
+ }
83
+ segmentStart = i + 1;
84
+ }
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @param {Primitive} primitive
90
+ * @ignore
91
+ */
92
+ function gatherPrimitiveStats(primitive) {
93
+ const stats = {
94
+ pointPrimitiveCount: 0,
95
+ pointVertexCount: 0,
96
+ polylinePrimitiveCount: 0,
97
+ polylineVertexCount: 0,
98
+ polygonPrimitiveCount: 0,
99
+ polygonVertexCount: 0,
100
+ polygonHoleCount: 0,
101
+ polygonTriangleCount: 0,
102
+ };
103
+
104
+ const vector = primitive.vector;
105
+ const primitiveType = primitive.primitiveType;
106
+ const positionAttribute = ModelUtility.getAttributeBySemantic(
107
+ primitive,
108
+ VertexAttributeSemantic.POSITION,
109
+ );
110
+ const positionCount = positionAttribute.count;
111
+
112
+ const indices = primitive.indices
113
+ ? ModelReader.readIndicesAsTypedArray(primitive.indices)
114
+ : undefined;
115
+
116
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
117
+ if (primitiveType === PrimitiveType.POINTS) {
118
+ stats.pointPrimitiveCount += vector.count;
119
+ stats.pointVertexCount += vector.count;
120
+
121
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
122
+ } else if (primitiveType === PrimitiveType.LINE_STRIP) {
123
+ //>>includeStart('debug', pragmas.debug);
124
+ assert(defined(indices), "Vector LINE_STRIP primitive must be indexed.");
125
+ //>>includeEnd('debug');
126
+
127
+ stats.polylinePrimitiveCount += vector.count;
128
+ stats.polylineVertexCount += indices.length - (vector.count - 1);
129
+
130
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
131
+ } else if (primitiveType === PrimitiveType.TRIANGLES) {
132
+ //>>includeStart('debug', pragmas.debug);
133
+ assert(defined(indices), "Vector TRIANGLES primitive must be indexed.");
134
+ //>>includeEnd('debug');
135
+
136
+ stats.polygonPrimitiveCount += vector.count;
137
+ stats.polygonVertexCount += positionCount;
138
+ stats.polygonTriangleCount += indices.length / 3;
139
+
140
+ const polygonHoleCounts = vector.polygonHoleCounts;
141
+ if (polygonHoleCounts) {
142
+ for (let i = 0; i < polygonHoleCounts.length; i++) {
143
+ stats.polygonHoleCount += polygonHoleCounts[i];
144
+ }
145
+ }
146
+ } else {
147
+ throw new RuntimeError(`Unexpected primitive type: ${primitiveType}`);
148
+ }
149
+
150
+ return stats;
151
+ }
152
+
153
+ /**
154
+ * @param {VectorGltf3DTileContent} content
155
+ * @param {Primitive} primitive
156
+ * @param {BufferPrimitiveCollection<BufferPrimitive>} collection
157
+ * @ignore
158
+ */
159
+ function appendPrimitiveToBuffers(content, primitive, collection) {
160
+ const vector = primitive.vector;
161
+ const positionAttribute = ModelUtility.getAttributeBySemantic(
162
+ primitive,
163
+ VertexAttributeSemantic.POSITION,
164
+ );
165
+ /** @type {TypedArray} */
166
+ const collectionPositions =
167
+ positionAttribute.typedArray ??
168
+ ModelReader.readAttributeAsTypedArray(positionAttribute);
169
+ const vertexCount = collectionPositions.length / 3;
170
+
171
+ /** @type {TypedArray} */
172
+ const indices = primitive.indices
173
+ ? ModelReader.readIndicesAsTypedArray(primitive.indices)
174
+ : undefined;
175
+
176
+ const featureIdComponent = primitive.featureIds?.[0];
177
+ /** @type {Attribute} */
178
+ let featureIdAttribute;
179
+ /** @type {TypedArray} */
180
+ let featureIdArray;
181
+ if (featureIdComponent instanceof ModelComponents.FeatureIdAttribute) {
182
+ featureIdAttribute = ModelUtility.getAttributeBySemantic(
183
+ primitive,
184
+ VertexAttributeSemantic.FEATURE_ID,
185
+ featureIdComponent.setIndex,
186
+ );
187
+ featureIdArray =
188
+ featureIdAttribute.typedArray ??
189
+ ModelReader.readAttributeAsTypedArray(featureIdAttribute);
190
+ }
191
+
192
+ if (collection instanceof BufferPointCollection) {
193
+ for (let i = 0, il = indices ? indices.length : vertexCount; i < il; i++) {
194
+ const vertexOffset = indices ? indices[i] : i;
195
+ Cartesian3.fromArray(
196
+ // @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
197
+ collectionPositions,
198
+ vertexOffset * 3,
199
+ scratchPosition,
200
+ );
201
+ collection.add({ position: scratchPosition }, scratchPoint);
202
+
203
+ const featureId = Math.trunc(featureIdArray[vertexOffset]);
204
+ if (featureId !== featureIdComponent.nullFeatureId) {
205
+ scratchPoint.featureId = featureId;
206
+ }
207
+ }
208
+ } else if (collection instanceof BufferPolylineCollection) {
209
+ // @ts-expect-error TODO
210
+ forEachLineStripSegment(indices, (indexOffset, indexCount) => {
211
+ const vertexOffset = indices[indexOffset];
212
+ const positions = collectionPositions.subarray(
213
+ vertexOffset * 3,
214
+ (vertexOffset + indexCount) * 3,
215
+ );
216
+ collection.add({ positions }, scratchPolyline);
217
+
218
+ const featureId = Math.trunc(featureIdArray[vertexOffset]);
219
+ if (featureId !== featureIdComponent.nullFeatureId) {
220
+ scratchPolyline.featureId = featureId;
221
+ }
222
+ });
223
+ } else if (collection instanceof BufferPolygonCollection) {
224
+ const polygonAttributeOffsets = vector.polygonAttributeOffsets;
225
+ const polygonIndicesOffsets = vector.polygonIndicesOffsets;
226
+ const polygonHoleCounts = vector.polygonHoleCounts;
227
+ const polygonHoleOffsets = vector.polygonHoleOffsets;
228
+
229
+ const polygonCount = polygonAttributeOffsets.length;
230
+ for (let i = 0; i < polygonCount; i++) {
231
+ const polygonVertexStart = polygonAttributeOffsets[i];
232
+ const polygonVertexEnd =
233
+ i + 1 < polygonCount ? polygonAttributeOffsets[i + 1] : vertexCount;
234
+
235
+ const positions = collectionPositions.subarray(
236
+ polygonVertexStart * 3,
237
+ polygonVertexEnd * 3,
238
+ );
239
+
240
+ let holes;
241
+ if (defined(polygonHoleCounts) && polygonHoleCounts[i] > 0) {
242
+ const holeCount = polygonHoleCounts[i];
243
+ holes = polygonHoleOffsets.slice(i, i + holeCount);
244
+ for (let h = 0; h < holeCount; h++) {
245
+ holes[i] -= polygonVertexStart;
246
+ }
247
+ }
248
+
249
+ const triangleIndexStart = polygonIndicesOffsets[i];
250
+ const triangleIndexEnd =
251
+ i + 1 < polygonCount ? polygonIndicesOffsets[i + 1] : indices.length;
252
+ const triangles = indices.slice(triangleIndexStart, triangleIndexEnd);
253
+ for (let t = 0; t < triangleIndexEnd; t++) {
254
+ triangles[t] -= polygonVertexStart;
255
+ }
256
+
257
+ collection.add({ positions, triangles, holes }, scratchPolygon);
258
+
259
+ const featureId = Math.trunc(featureIdArray[polygonVertexStart]);
260
+ if (featureId !== featureIdComponent.nullFeatureId) {
261
+ scratchPolygon.featureId = featureId;
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ /**
268
+ * @param {VectorGltf3DTileContent} content
269
+ * @param {Node} node
270
+ * @param {Matrix4} parentTransform
271
+ * @param {VectorTileResult} result
272
+ * @ignore
273
+ */
274
+ function appendNodeToBuffers(content, node, parentTransform, result) {
275
+ const localTransform = ModelUtility.getNodeTransform(node);
276
+ const nodeTransform = Matrix4.multiplyTransformation(
277
+ parentTransform,
278
+ localTransform,
279
+ new Matrix4(),
280
+ );
281
+
282
+ const primitives = node.primitives;
283
+ for (let i = 0; i < primitives.length; i++) {
284
+ const primitive = primitives[i];
285
+ const primitiveType = primitive.primitiveType;
286
+ if (!primitive.vector) {
287
+ continue;
288
+ }
289
+
290
+ /** @type {BufferPrimitiveCollection<BufferPrimitive>} */
291
+ let collection;
292
+
293
+ const stats = gatherPrimitiveStats(primitive);
294
+
295
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
296
+ if (primitiveType === PrimitiveType.POINTS) {
297
+ collection = new BufferPointCollection({
298
+ primitiveCountMax: stats.pointPrimitiveCount,
299
+ });
300
+
301
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
302
+ } else if (primitiveType === PrimitiveType.LINE_STRIP) {
303
+ collection = new BufferPolylineCollection({
304
+ primitiveCountMax: stats.polylinePrimitiveCount,
305
+ vertexCountMax: stats.polylineVertexCount,
306
+ });
307
+
308
+ // @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
309
+ } else if (primitiveType === PrimitiveType.TRIANGLES) {
310
+ collection = new BufferPolygonCollection({
311
+ primitiveCountMax: stats.polygonPrimitiveCount,
312
+ vertexCountMax: stats.polygonVertexCount,
313
+ holeCountMax: stats.polygonHoleCount,
314
+ triangleCountMax: stats.polygonTriangleCount,
315
+ });
316
+ }
317
+
318
+ result.collections.push(collection);
319
+ result.collectionLocalMatrices.push(Matrix4.clone(nodeTransform));
320
+
321
+ appendPrimitiveToBuffers(content, primitive, collection);
322
+ }
323
+
324
+ const children = node.children;
325
+ for (let i = 0; i < children.length; i++) {
326
+ appendNodeToBuffers(content, children[i], nodeTransform, result);
327
+ }
328
+ }
329
+
330
+ export default createVectorTileBuffersFromModelComponents;