@cesium/engine 17.0.0 → 18.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 (150) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +1 -1
  2. package/Build/Workers/{chunk-4TIR5UPL.js → chunk-2AXPWBJG.js} +1 -1
  3. package/Build/Workers/{chunk-CAKU6ZPR.js → chunk-2CAYUY2B.js} +8 -8
  4. package/Build/Workers/{chunk-PS3OKVOQ.js → chunk-2NKHPWDY.js} +12 -12
  5. package/Build/Workers/{chunk-VXAKU6EV.js → chunk-2QNKQVUT.js} +5 -5
  6. package/Build/Workers/{chunk-ZTBZMRQT.js → chunk-3RKVDGRF.js} +8 -8
  7. package/Build/Workers/{chunk-J2HTPGC7.js → chunk-4DSTDGY3.js} +2 -2
  8. package/Build/Workers/{chunk-P2N5IDWU.js → chunk-4MIY63FM.js} +13 -13
  9. package/Build/Workers/{chunk-XYGBWBD5.js → chunk-5OL6XFNS.js} +1 -1
  10. package/Build/Workers/{chunk-E7SMO47Q.js → chunk-5WVF4BK7.js} +5 -5
  11. package/Build/Workers/{chunk-SQKTLDSD.js → chunk-AEGAQ6FD.js} +12 -12
  12. package/Build/Workers/{chunk-4BGKMM7J.js → chunk-CES6DHHV.js} +1 -1
  13. package/Build/Workers/{chunk-MAIKDIBS.js → chunk-DINSLSJD.js} +6 -6
  14. package/Build/Workers/{chunk-G6JUXZUO.js → chunk-EHB2OCQX.js} +4 -4
  15. package/Build/Workers/{chunk-SSLK4U3V.js → chunk-EXEZHW3P.js} +4 -4
  16. package/Build/Workers/{chunk-236N6BJN.js → chunk-F4ZAKN4V.js} +2 -2
  17. package/Build/Workers/{chunk-HBNWBMAM.js → chunk-FPYBD2P5.js} +1 -1
  18. package/Build/Workers/{chunk-5PC577K7.js → chunk-GAUF4F5A.js} +16 -16
  19. package/Build/Workers/{chunk-YE6MDFDA.js → chunk-GM55YFOB.js} +14 -14
  20. package/Build/Workers/{chunk-HGEGZ67N.js → chunk-GS55WTRX.js} +6 -6
  21. package/Build/Workers/{chunk-LPGOAMYH.js → chunk-HQE7KSR4.js} +2 -2
  22. package/Build/Workers/{chunk-IFIS4CVK.js → chunk-HS76VTVY.js} +2 -2
  23. package/Build/Workers/{chunk-7IIMO7ZZ.js → chunk-I3BAKR4S.js} +16 -16
  24. package/Build/Workers/{chunk-PM4Q36WX.js → chunk-IWGMVQGG.js} +9 -9
  25. package/Build/Workers/{chunk-UFV3YUIN.js → chunk-IWZK2AIH.js} +5 -5
  26. package/Build/Workers/{chunk-QJTIOB2Z.js → chunk-J4MAVE6J.js} +6 -6
  27. package/Build/Workers/{chunk-RX65FA7X.js → chunk-JF4IYQYC.js} +7 -7
  28. package/Build/Workers/{chunk-7PHT4JHA.js → chunk-KGXTCGX3.js} +12 -12
  29. package/Build/Workers/{chunk-K5JTWJPE.js → chunk-KNA65INJ.js} +4 -4
  30. package/Build/Workers/{chunk-CBFJVM6I.js → chunk-LIPZUYNR.js} +11 -11
  31. package/Build/Workers/{chunk-C5DCX2YQ.js → chunk-LWJWWCZ4.js} +6 -6
  32. package/Build/Workers/{chunk-KE45DUDH.js → chunk-LZFUG3GO.js} +10 -10
  33. package/Build/Workers/{chunk-P57PR3WM.js → chunk-MFGVMUN3.js} +5 -5
  34. package/Build/Workers/{chunk-QUFN3GEO.js → chunk-NR7KSD56.js} +3 -3
  35. package/Build/Workers/{chunk-MS5NWDHH.js → chunk-NVJ5JRIM.js} +2 -2
  36. package/Build/Workers/{chunk-CQMXZF4A.js → chunk-NWSAYFZG.js} +6 -6
  37. package/Build/Workers/{chunk-5YEFZMMM.js → chunk-OATG6PKE.js} +12 -12
  38. package/Build/Workers/{chunk-UX5JWAC7.js → chunk-OIHAAHBK.js} +10 -10
  39. package/Build/Workers/{chunk-DRMXU674.js → chunk-QN7JEOQV.js} +5 -5
  40. package/Build/Workers/{chunk-77MDEA47.js → chunk-QUSP3NWA.js} +5 -5
  41. package/Build/Workers/{chunk-GO3RZX2R.js → chunk-RWFYLWSF.js} +9 -9
  42. package/Build/Workers/{chunk-UZ6KXWCA.js → chunk-SIOVJ4L5.js} +4 -4
  43. package/Build/Workers/{chunk-OBHLT34A.js → chunk-T6B6H3GR.js} +7 -7
  44. package/Build/Workers/{chunk-IKDQX7DY.js → chunk-UK33ZN4K.js} +4 -4
  45. package/Build/Workers/{chunk-2BJXFXD7.js → chunk-VGJSKEIB.js} +4 -4
  46. package/Build/Workers/{chunk-5RPUEFSA.js → chunk-W6CPO62M.js} +6 -6
  47. package/Build/Workers/{chunk-37PA7GZW.js → chunk-WGHUCZMX.js} +7 -7
  48. package/Build/Workers/{chunk-UC7KH56Y.js → chunk-WTFZHPUW.js} +5 -5
  49. package/Build/Workers/{chunk-NZSBSY5K.js → chunk-WYCR5DWQ.js} +2 -2
  50. package/Build/Workers/{chunk-WP3IJYLC.js → chunk-YV37YFUM.js} +9 -9
  51. package/Build/Workers/{chunk-LVGYWPEX.js → chunk-ZADJ6FRX.js} +4 -4
  52. package/Build/Workers/{chunk-CC2WKHIW.js → chunk-ZIP27IX6.js} +6 -6
  53. package/Build/Workers/combineGeometry.js +21 -21
  54. package/Build/Workers/createBoxGeometry.js +15 -15
  55. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  56. package/Build/Workers/createCircleGeometry.js +23 -23
  57. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  60. package/Build/Workers/createCorridorGeometry.js +26 -26
  61. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  62. package/Build/Workers/createCylinderGeometry.js +17 -17
  63. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  64. package/Build/Workers/createEllipseGeometry.js +23 -23
  65. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  66. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  68. package/Build/Workers/createFrustumGeometry.js +15 -15
  69. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  70. package/Build/Workers/createGeometry.js +21 -21
  71. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  72. package/Build/Workers/createPlaneGeometry.js +13 -13
  73. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  74. package/Build/Workers/createPolygonGeometry.js +29 -29
  75. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  76. package/Build/Workers/createPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  79. package/Build/Workers/createRectangleGeometry.js +24 -24
  80. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  81. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  82. package/Build/Workers/createSphereGeometry.js +16 -16
  83. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  86. package/Build/Workers/createVectorTileGeometries.js +21 -21
  87. package/Build/Workers/createVectorTilePoints.js +11 -11
  88. package/Build/Workers/createVectorTilePolygons.js +19 -19
  89. package/Build/Workers/createVectorTilePolylines.js +12 -12
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  91. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  93. package/Build/Workers/createWallGeometry.js +21 -21
  94. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  95. package/Build/Workers/decodeDraco.js +10 -10
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +9 -9
  98. package/Build/Workers/transcodeKTX2.js +25 -6
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  101. package/Source/Core/Ion.js +1 -1
  102. package/Source/Core/PixelFormat.js +36 -0
  103. package/Source/Renderer/Texture3D.js +568 -0
  104. package/Source/Renderer/createUniform.js +1 -0
  105. package/Source/Renderer/createUniformArray.js +1 -0
  106. package/Source/Scene/ArcGisMapService.js +1 -1
  107. package/Source/Scene/Cesium3DTileset.js +138 -0
  108. package/Source/Scene/GlobeSurfaceShaderSet.js +4 -5
  109. package/Source/Scene/ImageryLayer.js +19 -4
  110. package/Source/Scene/ImageryLayerCollection.js +3 -2
  111. package/Source/Scene/Model/CartesianRectangle.js +108 -0
  112. package/Source/Scene/Model/ImageryConfiguration.js +25 -0
  113. package/Source/Scene/Model/ImageryCoverage.js +488 -0
  114. package/Source/Scene/Model/ImageryFlags.js +31 -0
  115. package/Source/Scene/Model/ImageryInput.js +60 -0
  116. package/Source/Scene/Model/ImageryPipelineStage.js +1040 -0
  117. package/Source/Scene/Model/MappedPositions.js +84 -0
  118. package/Source/Scene/Model/Model.js +38 -0
  119. package/Source/Scene/Model/ModelImagery.js +403 -0
  120. package/Source/Scene/Model/ModelImageryMapping.js +489 -0
  121. package/Source/Scene/Model/ModelPrimitiveImagery.js +972 -0
  122. package/Source/Scene/Model/ModelReader.js +810 -0
  123. package/Source/Scene/Model/ModelRenderResources.js +13 -0
  124. package/Source/Scene/Model/ModelRuntimePrimitive.js +19 -0
  125. package/Source/Scene/Model/ModelSceneGraph.js +133 -27
  126. package/Source/Scene/Model/NodeRenderResources.js +10 -0
  127. package/Source/Scene/ModelComponents.js +10 -0
  128. package/Source/Scene/VoxelPrimitive.js +22 -37
  129. package/Source/Scene/VoxelRenderResources.js +1 -1
  130. package/Source/Scene/processVoxelProperties.js +41 -100
  131. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +0 -1
  132. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
  133. package/Source/Shaders/GlobeFS.glsl +22 -0
  134. package/Source/Shaders/GlobeFS.js +22 -0
  135. package/Source/Shaders/Model/MaterialStageFS.glsl +4 -0
  136. package/Source/Shaders/Model/MaterialStageFS.js +4 -0
  137. package/Source/Shaders/Model/ModelVS.glsl +4 -0
  138. package/Source/Shaders/Model/ModelVS.js +4 -0
  139. package/Source/Shaders/Voxels/IntersectDepth.glsl +10 -3
  140. package/Source/Shaders/Voxels/IntersectDepth.js +10 -3
  141. package/Source/Shaders/Voxels/Intersection.glsl +1 -3
  142. package/Source/Shaders/Voxels/Intersection.js +1 -3
  143. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -0
  144. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -0
  145. package/Source/Shaders/Voxels/VoxelFS.glsl +37 -24
  146. package/Source/Shaders/Voxels/VoxelFS.js +37 -24
  147. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  148. package/index.d.ts +50 -2
  149. package/index.js +100 -88
  150. package/package.json +3 -3
@@ -101,6 +101,19 @@ function ModelRenderResources(model) {
101
101
  * @private
102
102
  */
103
103
  this.hasSkipLevelOfDetail = false;
104
+
105
+ /**
106
+ * The NodeRenderResources for the nodes of the scene graph.
107
+ *
108
+ * Note that elements of this array may be <code>undefined</code> when
109
+ * there was no runtime node for a certain node.
110
+ *
111
+ * @type {NodeRenderResources[]}
112
+ * @default []
113
+ *
114
+ * @private
115
+ */
116
+ this.nodeRenderResources = [];
104
117
  }
105
118
 
106
119
  export default ModelRenderResources;
@@ -12,6 +12,7 @@ import CustomShaderPipelineStage from "./CustomShaderPipelineStage.js";
12
12
  import DequantizationPipelineStage from "./DequantizationPipelineStage.js";
13
13
  import FeatureIdPipelineStage from "./FeatureIdPipelineStage.js";
14
14
  import GeometryPipelineStage from "./GeometryPipelineStage.js";
15
+ import ImageryPipelineStage from "./ImageryPipelineStage.js";
15
16
  import LightingPipelineStage from "./LightingPipelineStage.js";
16
17
  import MaterialPipelineStage from "./MaterialPipelineStage.js";
17
18
  import MetadataPickingPipelineStage from "./MetadataPickingPipelineStage.js";
@@ -27,6 +28,7 @@ import SelectedFeatureIdPipelineStage from "./SelectedFeatureIdPipelineStage.js"
27
28
  import SkinningPipelineStage from "./SkinningPipelineStage.js";
28
29
  import VerticalExaggerationPipelineStage from "./VerticalExaggerationPipelineStage.js";
29
30
  import WireframePipelineStage from "./WireframePipelineStage.js";
31
+ import oneTimeWarning from "../../Core/oneTimeWarning.js";
30
32
 
31
33
  /**
32
34
  * In memory representation of a single primitive, that is, a primitive
@@ -206,6 +208,12 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) {
206
208
  const hasMorphTargets =
207
209
  defined(primitive.morphTargets) && primitive.morphTargets.length > 0;
208
210
  const hasSkinning = defined(node.skin);
211
+
212
+ // Check whether the model is part of a `Model3DTileContent` that
213
+ // belongs to a tileset that has imagery layers. If this is the
214
+ // case, then the `ImageryPipelineStage` will be required.
215
+ const hasImageryLayers = defined(model.imageryLayers);
216
+
209
217
  const hasCustomShader = defined(customShader);
210
218
  const hasCustomFragmentShader =
211
219
  hasCustomShader && defined(customShader.fragmentShaderText);
@@ -270,6 +278,17 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) {
270
278
  pipelineStages.push(DequantizationPipelineStage);
271
279
  }
272
280
 
281
+ if (hasImageryLayers) {
282
+ if (hasOutlines) {
283
+ oneTimeWarning(
284
+ "outlines-and-draping",
285
+ "Primitive outlines disable imagery draping",
286
+ );
287
+ } else {
288
+ pipelineStages.push(ImageryPipelineStage);
289
+ }
290
+ }
291
+
273
292
  if (materialsEnabled) {
274
293
  pipelineStages.push(MaterialPipelineStage);
275
294
  }
@@ -445,6 +445,7 @@ const scratchModelPositionMin = new Cartesian3();
445
445
  const scratchModelPositionMax = new Cartesian3();
446
446
  const scratchPrimitivePositionMin = new Cartesian3();
447
447
  const scratchPrimitivePositionMax = new Cartesian3();
448
+
448
449
  /**
449
450
  * Generates the {@link ModelDrawCommand} for each primitive in the model.
450
451
  * If the model is used for classification, a {@link ClassificationModelDrawCommand}
@@ -456,6 +457,30 @@ const scratchPrimitivePositionMax = new Cartesian3();
456
457
  * @private
457
458
  */
458
459
  ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
460
+ const modelRenderResources = this.buildRenderResources(frameState);
461
+ this.computeBoundingVolumes(modelRenderResources);
462
+ this.createDrawCommands(modelRenderResources, frameState);
463
+ };
464
+
465
+ /**
466
+ * Generates the {@link ModelRenderResources} for the model.
467
+ *
468
+ * This will traverse the model, nodes and primitives of the scene graph,
469
+ * and perform the following tasks:
470
+ *
471
+ * - configure the pipeline stages by calling `configurePipeline`,
472
+ * `runtimeNode.configurePipeline`, and `runtimePrimitive.configurePipeline`
473
+ * - create the `ModelRenderResources`, `NodeRenderResources`, and
474
+ * `PrimitiveRenderResources`
475
+ * - Process the render resources with the respective pipelines
476
+ *
477
+ * @param {FrameState} frameState The current frame state. This is needed to
478
+ * allocate GPU resources as needed.
479
+ * @returns {ModelRenderResources} The model render resources
480
+ *
481
+ * @private
482
+ */
483
+ ModelSceneGraph.prototype.buildRenderResources = function (frameState) {
459
484
  const model = this._model;
460
485
  const modelRenderResources = new ModelRenderResources(model);
461
486
 
@@ -465,26 +490,12 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
465
490
  this.configurePipeline(frameState);
466
491
  const modelPipelineStages = this.modelPipelineStages;
467
492
 
468
- let i, j, k;
469
- for (i = 0; i < modelPipelineStages.length; i++) {
493
+ for (let i = 0; i < modelPipelineStages.length; i++) {
470
494
  const modelPipelineStage = modelPipelineStages[i];
471
495
  modelPipelineStage.process(modelRenderResources, model, frameState);
472
496
  }
473
497
 
474
- const modelPositionMin = Cartesian3.fromElements(
475
- Number.MAX_VALUE,
476
- Number.MAX_VALUE,
477
- Number.MAX_VALUE,
478
- scratchModelPositionMin,
479
- );
480
- const modelPositionMax = Cartesian3.fromElements(
481
- -Number.MAX_VALUE,
482
- -Number.MAX_VALUE,
483
- -Number.MAX_VALUE,
484
- scratchModelPositionMax,
485
- );
486
-
487
- for (i = 0; i < this._runtimeNodes.length; i++) {
498
+ for (let i = 0; i < this._runtimeNodes.length; i++) {
488
499
  const runtimeNode = this._runtimeNodes[i];
489
500
 
490
501
  // If a node in the model was unreachable from the scene graph, there will
@@ -500,8 +511,9 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
500
511
  modelRenderResources,
501
512
  runtimeNode,
502
513
  );
514
+ modelRenderResources.nodeRenderResources[i] = nodeRenderResources;
503
515
 
504
- for (j = 0; j < nodePipelineStages.length; j++) {
516
+ for (let j = 0; j < nodePipelineStages.length; j++) {
505
517
  const nodePipelineStage = nodePipelineStages[j];
506
518
 
507
519
  nodePipelineStage.process(
@@ -511,8 +523,7 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
511
523
  );
512
524
  }
513
525
 
514
- const nodeTransform = runtimeNode.computedTransform;
515
- for (j = 0; j < runtimeNode.runtimePrimitives.length; j++) {
526
+ for (let j = 0; j < runtimeNode.runtimePrimitives.length; j++) {
516
527
  const runtimePrimitive = runtimeNode.runtimePrimitives[j];
517
528
 
518
529
  runtimePrimitive.configurePipeline(frameState);
@@ -522,16 +533,76 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
522
533
  nodeRenderResources,
523
534
  runtimePrimitive,
524
535
  );
536
+ nodeRenderResources.primitiveRenderResources[j] =
537
+ primitiveRenderResources;
525
538
 
526
- for (k = 0; k < primitivePipelineStages.length; k++) {
539
+ for (let k = 0; k < primitivePipelineStages.length; k++) {
527
540
  const primitivePipelineStage = primitivePipelineStages[k];
528
-
529
541
  primitivePipelineStage.process(
530
542
  primitiveRenderResources,
531
543
  runtimePrimitive.primitive,
532
544
  frameState,
533
545
  );
534
546
  }
547
+ }
548
+ }
549
+ return modelRenderResources;
550
+ };
551
+
552
+ /**
553
+ * Computes the bounding volumes for the scene graph and the model.
554
+ *
555
+ * This will traverse the model, nodes and primitives of the scene graph,
556
+ * and compute the bounding volumes. Specifically, it will compute
557
+ *
558
+ * - this._boundingSphere
559
+ * - model._boundingSphere
560
+ *
561
+ * With the latter being modified as of
562
+ *
563
+ * - model._initialRadius = model._boundingSphere.radius;
564
+ * - model._boundingSphere.radius *= model._clampedScale;
565
+ *
566
+ * NOTE: This contains some bugs. See https://github.com/CesiumGS/cesium/issues/12108
567
+ *
568
+ * @param {ModelRenderResources} modelRenderResources The model render resources
569
+ *
570
+ * @private
571
+ */
572
+ ModelSceneGraph.prototype.computeBoundingVolumes = function (
573
+ modelRenderResources,
574
+ ) {
575
+ const model = this._model;
576
+
577
+ const modelPositionMin = Cartesian3.fromElements(
578
+ Number.MAX_VALUE,
579
+ Number.MAX_VALUE,
580
+ Number.MAX_VALUE,
581
+ scratchModelPositionMin,
582
+ );
583
+ const modelPositionMax = Cartesian3.fromElements(
584
+ -Number.MAX_VALUE,
585
+ -Number.MAX_VALUE,
586
+ -Number.MAX_VALUE,
587
+ scratchModelPositionMax,
588
+ );
589
+
590
+ for (let i = 0; i < this._runtimeNodes.length; i++) {
591
+ const runtimeNode = this._runtimeNodes[i];
592
+
593
+ // If a node in the model was unreachable from the scene graph, there will
594
+ // be no corresponding runtime node and therefore should be skipped.
595
+ if (!defined(runtimeNode)) {
596
+ continue;
597
+ }
598
+
599
+ const nodeRenderResources = modelRenderResources.nodeRenderResources[i];
600
+ const nodeTransform = runtimeNode.computedTransform;
601
+ for (let j = 0; j < runtimeNode.runtimePrimitives.length; j++) {
602
+ const runtimePrimitive = runtimeNode.runtimePrimitives[j];
603
+
604
+ const primitiveRenderResources =
605
+ nodeRenderResources.primitiveRenderResources[j];
535
606
 
536
607
  runtimePrimitive.boundingSphere = BoundingSphere.clone(
537
608
  primitiveRenderResources.boundingSphere,
@@ -559,12 +630,6 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
559
630
  primitivePositionMax,
560
631
  modelPositionMax,
561
632
  );
562
-
563
- const drawCommand = ModelDrawCommands.buildModelDrawCommand(
564
- primitiveRenderResources,
565
- frameState,
566
- );
567
- runtimePrimitive.drawCommand = drawCommand;
568
633
  }
569
634
  }
570
635
 
@@ -596,6 +661,47 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
596
661
  model._boundingSphere.radius *= model._clampedScale;
597
662
  };
598
663
 
664
+ /**
665
+ * Creates the draw commands for the primitives in the scene graph.
666
+ *
667
+ * This will traverse the model, nodes and primitives of the scene graph,
668
+ * and create the respective draw commands for the primitives, storing
669
+ * them as the `runtimePrimitive.drawCommand`, respectively.
670
+ *
671
+ * @param {ModelRenderResources} modelRenderResources The model render resources
672
+ *
673
+ * @private
674
+ */
675
+ ModelSceneGraph.prototype.createDrawCommands = function (
676
+ modelRenderResources,
677
+ frameState,
678
+ ) {
679
+ for (let i = 0; i < this._runtimeNodes.length; i++) {
680
+ const runtimeNode = this._runtimeNodes[i];
681
+
682
+ // If a node in the model was unreachable from the scene graph, there will
683
+ // be no corresponding runtime node and therefore should be skipped.
684
+ if (!defined(runtimeNode)) {
685
+ continue;
686
+ }
687
+
688
+ const nodeRenderResources = modelRenderResources.nodeRenderResources[i];
689
+
690
+ for (let j = 0; j < runtimeNode.runtimePrimitives.length; j++) {
691
+ const runtimePrimitive = runtimeNode.runtimePrimitives[j];
692
+
693
+ const primitiveRenderResources =
694
+ nodeRenderResources.primitiveRenderResources[j];
695
+
696
+ const drawCommand = ModelDrawCommands.buildModelDrawCommand(
697
+ primitiveRenderResources,
698
+ frameState,
699
+ );
700
+ runtimePrimitive.drawCommand = drawCommand;
701
+ }
702
+ }
703
+ };
704
+
599
705
  /**
600
706
  * Configure the model pipeline stages. If the pipeline needs to be re-run, call
601
707
  * this method again to ensure the correct sequence of pipeline stages are
@@ -155,6 +155,16 @@ function NodeRenderResources(modelRenderResources, runtimeNode) {
155
155
  * @private
156
156
  */
157
157
  this.instanceCount = 0;
158
+
159
+ /**
160
+ * The PrimitiveRenderResources for the primitives of the node.
161
+ *
162
+ * @type {PrimitiveRenderResources[]}
163
+ * @default []
164
+ *
165
+ * @private
166
+ */
167
+ this.primitiveRenderResources = [];
158
168
  }
159
169
 
160
170
  export default NodeRenderResources;
@@ -620,6 +620,16 @@ function Primitive() {
620
620
  * @private
621
621
  */
622
622
  this.outlineCoordinates = undefined;
623
+
624
+ /**
625
+ * If the model is part of a Model3DTileContent of a Cesium3DTileset that
626
+ * has 'imageryLayers', then this will represent the information that is
627
+ * required for draping the imagery over this primitive.
628
+ *
629
+ * @type {ModelPrimitiveImagery|undefined}
630
+ * @private
631
+ */
632
+ this.modelPrimitiveImagery = undefined;
623
633
  }
624
634
 
625
635
  /**
@@ -45,6 +45,7 @@ import VoxelMetadataOrder from "./VoxelMetadataOrder.js";
45
45
  * @see VoxelProvider
46
46
  * @see Cesium3DTilesVoxelProvider
47
47
  * @see VoxelShapeType
48
+ * @see {@link https://github.com/CesiumGS/cesium/tree/main/Documentation/CustomShaderGuide|Custom Shader Guide}
48
49
  *
49
50
  * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
50
51
  */
@@ -339,22 +340,22 @@ function VoxelPrimitive(options) {
339
340
  this._transformPositionWorldToUv = new Matrix4();
340
341
 
341
342
  /**
342
- * @type {Matrix4}
343
+ * @type {Matrix3}
343
344
  * @private
344
345
  */
345
- this._transformPositionUvToWorld = new Matrix4();
346
+ this._transformDirectionWorldToUv = new Matrix3();
346
347
 
347
348
  /**
348
- * @type {Matrix3}
349
+ * @type {Matrix4}
349
350
  * @private
350
351
  */
351
- this._transformDirectionWorldToLocal = new Matrix3();
352
+ this._transformPositionUvToWorld = new Matrix4();
352
353
 
353
354
  /**
354
355
  * @type {Matrix3}
355
356
  * @private
356
357
  */
357
- this._transformNormalLocalToWorld = new Matrix3();
358
+ this._transformDirectionWorldToLocal = new Matrix3();
358
359
 
359
360
  // Rendering
360
361
  /**
@@ -442,8 +443,8 @@ function VoxelPrimitive(options) {
442
443
  transformPositionViewToUv: new Matrix4(),
443
444
  transformPositionUvToView: new Matrix4(),
444
445
  transformDirectionViewToLocal: new Matrix3(),
445
- transformNormalLocalToWorld: new Matrix3(),
446
446
  cameraPositionUv: new Cartesian3(),
447
+ cameraDirectionUv: new Cartesian3(),
447
448
  ndcSpaceAxisAlignedBoundingBox: new Cartesian4(),
448
449
  clippingPlanesTexture: undefined,
449
450
  clippingPlanesMatrix: new Matrix4(),
@@ -1075,6 +1076,7 @@ Object.defineProperties(VoxelPrimitive.prototype, {
1075
1076
  *
1076
1077
  * @memberof VoxelPrimitive.prototype
1077
1078
  * @type {CustomShader}
1079
+ * @see {@link https://github.com/CesiumGS/cesium/tree/main/Documentation/CustomShaderGuide|Custom Shader Guide}
1078
1080
  */
1079
1081
  customShader: {
1080
1082
  get: function () {
@@ -1135,10 +1137,6 @@ Object.defineProperties(VoxelPrimitive.prototype, {
1135
1137
 
1136
1138
  const scratchIntersect = new Cartesian4();
1137
1139
  const scratchNdcAabb = new Cartesian4();
1138
- const scratchScale = new Cartesian3();
1139
- const scratchLocalScale = new Cartesian3();
1140
- const scratchRotation = new Matrix3();
1141
- const scratchRotationAndLocalScale = new Matrix3();
1142
1140
  const scratchTransformPositionWorldToLocal = new Matrix4();
1143
1141
  const scratchTransformPositionLocalToWorld = new Matrix4();
1144
1142
  const scratchTransformPositionLocalToProjection = new Matrix4();
@@ -1306,16 +1304,20 @@ VoxelPrimitive.prototype.update = function (frameState) {
1306
1304
  transformDirectionViewToWorld,
1307
1305
  uniforms.transformDirectionViewToLocal,
1308
1306
  );
1309
- uniforms.transformNormalLocalToWorld = Matrix3.clone(
1310
- this._transformNormalLocalToWorld,
1311
- uniforms.transformNormalLocalToWorld,
1312
- );
1313
- const cameraPositionWorld = frameState.camera.positionWC;
1314
1307
  uniforms.cameraPositionUv = Matrix4.multiplyByPoint(
1315
1308
  this._transformPositionWorldToUv,
1316
- cameraPositionWorld,
1309
+ frameState.camera.positionWC,
1317
1310
  uniforms.cameraPositionUv,
1318
1311
  );
1312
+ uniforms.cameraDirectionUv = Matrix3.multiplyByVector(
1313
+ this._transformDirectionWorldToUv,
1314
+ frameState.camera.directionWC,
1315
+ uniforms.cameraDirectionUv,
1316
+ );
1317
+ uniforms.cameraDirectionUv = Cartesian3.normalize(
1318
+ uniforms.cameraDirectionUv,
1319
+ uniforms.cameraDirectionUv,
1320
+ );
1319
1321
  uniforms.stepSize = this._stepSizeMultiplier;
1320
1322
 
1321
1323
  // Render the primitive
@@ -1606,23 +1608,6 @@ function updateShapeAndTransforms(primitive, shape, provider) {
1606
1608
  transformPositionLocalToWorld,
1607
1609
  scratchTransformPositionWorldToLocal,
1608
1610
  );
1609
- const rotation = Matrix4.getRotation(
1610
- transformPositionLocalToWorld,
1611
- scratchRotation,
1612
- );
1613
- // Note that inverse(rotation) is the same as transpose(rotation)
1614
- const scale = Matrix4.getScale(transformPositionLocalToWorld, scratchScale);
1615
- const maximumScaleComponent = Cartesian3.maximumComponent(scale);
1616
- const localScale = Cartesian3.divideByScalar(
1617
- scale,
1618
- maximumScaleComponent,
1619
- scratchLocalScale,
1620
- );
1621
- const rotationAndLocalScale = Matrix3.multiplyByScale(
1622
- rotation,
1623
- localScale,
1624
- scratchRotationAndLocalScale,
1625
- );
1626
1611
 
1627
1612
  // Set member variables when the shape is dirty
1628
1613
  primitive._transformPositionWorldToUv = Matrix4.multiplyTransformation(
@@ -1630,6 +1615,10 @@ function updateShapeAndTransforms(primitive, shape, provider) {
1630
1615
  transformPositionWorldToLocal,
1631
1616
  primitive._transformPositionWorldToUv,
1632
1617
  );
1618
+ primitive._transformDirectionWorldToUv = Matrix4.getMatrix3(
1619
+ primitive._transformPositionWorldToUv,
1620
+ primitive._transformDirectionWorldToUv,
1621
+ );
1633
1622
  primitive._transformPositionUvToWorld = Matrix4.multiplyTransformation(
1634
1623
  transformPositionLocalToWorld,
1635
1624
  transformPositionUvToLocal,
@@ -1639,10 +1628,6 @@ function updateShapeAndTransforms(primitive, shape, provider) {
1639
1628
  transformPositionWorldToLocal,
1640
1629
  primitive._transformDirectionWorldToLocal,
1641
1630
  );
1642
- primitive._transformNormalLocalToWorld = Matrix3.inverseTranspose(
1643
- rotationAndLocalScale,
1644
- primitive._transformNormalLocalToWorld,
1645
- );
1646
1631
 
1647
1632
  return true;
1648
1633
  }
@@ -140,13 +140,13 @@ function VoxelRenderResources(primitive) {
140
140
  }
141
141
  shaderBuilder.addFragmentLines([IntersectClippingPlanes]);
142
142
  }
143
+ shaderBuilder.addFragmentLines([IntersectDepth]);
143
144
  if (primitive._depthTest) {
144
145
  shaderBuilder.addDefine(
145
146
  "DEPTH_TEST",
146
147
  undefined,
147
148
  ShaderDestination.FRAGMENT,
148
149
  );
149
- shaderBuilder.addFragmentLines([IntersectDepth]);
150
150
  }
151
151
 
152
152
  if (shapeType === "BOX") {