@cesium/engine 16.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.
- package/Build/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Build/Workers/{chunk-OWLBD6BL.js → chunk-2AXPWBJG.js} +1 -1
- package/Build/Workers/{chunk-PB6SE3SZ.js → chunk-2CAYUY2B.js} +8 -8
- package/Build/Workers/{chunk-SCUQTTCN.js → chunk-2NKHPWDY.js} +12 -12
- package/Build/Workers/{chunk-YA4XALD5.js → chunk-2QNKQVUT.js} +5 -5
- package/Build/Workers/{chunk-WGIOUM2S.js → chunk-3RKVDGRF.js} +8 -8
- package/Build/Workers/{chunk-RWAFHSX3.js → chunk-4DSTDGY3.js} +2 -2
- package/Build/Workers/{chunk-YL26OJCG.js → chunk-4MIY63FM.js} +13 -13
- package/Build/Workers/{chunk-34EWMUFG.js → chunk-5OL6XFNS.js} +1 -1
- package/Build/Workers/{chunk-B75OO2DU.js → chunk-5WVF4BK7.js} +5 -5
- package/Build/Workers/{chunk-EAWYQ44R.js → chunk-AEGAQ6FD.js} +12 -12
- package/Build/Workers/{chunk-4LHK6E47.js → chunk-CES6DHHV.js} +1 -1
- package/Build/Workers/{chunk-S3IQBSIB.js → chunk-DINSLSJD.js} +6 -6
- package/Build/Workers/{chunk-KV6TEHXY.js → chunk-EHB2OCQX.js} +4 -4
- package/Build/Workers/{chunk-NREPBWCX.js → chunk-EXEZHW3P.js} +4 -4
- package/Build/Workers/{chunk-ICU72UPR.js → chunk-F4ZAKN4V.js} +2 -2
- package/Build/Workers/{chunk-S2NKKWYE.js → chunk-FPYBD2P5.js} +1 -1
- package/Build/Workers/{chunk-KKV6XBF5.js → chunk-GAUF4F5A.js} +16 -16
- package/Build/Workers/{chunk-ERKJ7IWJ.js → chunk-GM55YFOB.js} +14 -14
- package/Build/Workers/{chunk-NB6D74SQ.js → chunk-GS55WTRX.js} +6 -6
- package/Build/Workers/{chunk-5TN3LG2T.js → chunk-HQE7KSR4.js} +2 -2
- package/Build/Workers/{chunk-EO44CO62.js → chunk-HS76VTVY.js} +2 -2
- package/Build/Workers/{chunk-TL5YKZJF.js → chunk-I3BAKR4S.js} +16 -16
- package/Build/Workers/{chunk-OMFZ4IN6.js → chunk-IWGMVQGG.js} +9 -9
- package/Build/Workers/{chunk-VVTAI2TN.js → chunk-IWZK2AIH.js} +5 -5
- package/Build/Workers/{chunk-GQVSADCI.js → chunk-J4MAVE6J.js} +6 -6
- package/Build/Workers/{chunk-XF6EBVKV.js → chunk-JF4IYQYC.js} +7 -7
- package/Build/Workers/{chunk-CUJH7PS5.js → chunk-KGXTCGX3.js} +12 -12
- package/Build/Workers/{chunk-TBSA4MNF.js → chunk-KNA65INJ.js} +4 -4
- package/Build/Workers/{chunk-EOIUWEAK.js → chunk-LIPZUYNR.js} +11 -11
- package/Build/Workers/{chunk-TEUGW455.js → chunk-LWJWWCZ4.js} +6 -6
- package/Build/Workers/{chunk-ORIMMEHO.js → chunk-LZFUG3GO.js} +10 -10
- package/Build/Workers/{chunk-COOLDICB.js → chunk-MFGVMUN3.js} +5 -5
- package/Build/Workers/{chunk-FW2OX42E.js → chunk-NR7KSD56.js} +3 -3
- package/Build/Workers/{chunk-2TQ64T4I.js → chunk-NVJ5JRIM.js} +2 -2
- package/Build/Workers/{chunk-OMZGZVHI.js → chunk-NWSAYFZG.js} +6 -6
- package/Build/Workers/{chunk-PT6U7UNY.js → chunk-OATG6PKE.js} +12 -12
- package/Build/Workers/{chunk-M5J3S3HY.js → chunk-OIHAAHBK.js} +10 -10
- package/Build/Workers/{chunk-LCSH4ZOB.js → chunk-QN7JEOQV.js} +5 -5
- package/Build/Workers/{chunk-XMKE4XB2.js → chunk-QUSP3NWA.js} +5 -5
- package/Build/Workers/{chunk-ZLJDDRGB.js → chunk-RWFYLWSF.js} +9 -9
- package/Build/Workers/{chunk-OD4Q7HE5.js → chunk-SIOVJ4L5.js} +4 -4
- package/Build/Workers/{chunk-EJJDBH5W.js → chunk-T6B6H3GR.js} +7 -7
- package/Build/Workers/{chunk-YFXXUW6U.js → chunk-UK33ZN4K.js} +4 -4
- package/Build/Workers/{chunk-V4Y7C25O.js → chunk-VGJSKEIB.js} +4 -4
- package/Build/Workers/{chunk-VXAAIRJ7.js → chunk-W6CPO62M.js} +6 -6
- package/Build/Workers/{chunk-ILVAXLMC.js → chunk-WGHUCZMX.js} +7 -7
- package/Build/Workers/{chunk-GH6I7PBY.js → chunk-WTFZHPUW.js} +5 -5
- package/Build/Workers/{chunk-VNDECE6N.js → chunk-WYCR5DWQ.js} +2 -2
- package/Build/Workers/{chunk-6B7KGA5P.js → chunk-YV37YFUM.js} +9 -9
- package/Build/Workers/{chunk-CQNYYX3N.js → chunk-ZADJ6FRX.js} +4 -4
- package/Build/Workers/{chunk-ESED7XBA.js → chunk-ZIP27IX6.js} +6 -6
- package/Build/Workers/combineGeometry.js +21 -21
- package/Build/Workers/createBoxGeometry.js +15 -15
- package/Build/Workers/createBoxOutlineGeometry.js +13 -13
- package/Build/Workers/createCircleGeometry.js +23 -23
- package/Build/Workers/createCircleOutlineGeometry.js +16 -16
- package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createCorridorGeometry.js +26 -26
- package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
- package/Build/Workers/createCylinderGeometry.js +17 -17
- package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
- package/Build/Workers/createEllipseGeometry.js +23 -23
- package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipsoidGeometry.js +16 -16
- package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
- package/Build/Workers/createFrustumGeometry.js +15 -15
- package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
- package/Build/Workers/createGeometry.js +21 -21
- package/Build/Workers/createGroundPolylineGeometry.js +19 -19
- package/Build/Workers/createPlaneGeometry.js +13 -13
- package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
- package/Build/Workers/createPolygonGeometry.js +29 -29
- package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
- package/Build/Workers/createPolylineGeometry.js +22 -22
- package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
- package/Build/Workers/createRectangleGeometry.js +24 -24
- package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
- package/Build/Workers/createSimplePolylineGeometry.js +20 -20
- package/Build/Workers/createSphereGeometry.js +16 -16
- package/Build/Workers/createSphereOutlineGeometry.js +15 -15
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
- package/Build/Workers/createVectorTileGeometries.js +21 -21
- package/Build/Workers/createVectorTilePoints.js +11 -11
- package/Build/Workers/createVectorTilePolygons.js +19 -19
- package/Build/Workers/createVectorTilePolylines.js +12 -12
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
- package/Build/Workers/createVerticesFromHeightmap.js +19 -19
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
- package/Build/Workers/createWallGeometry.js +21 -21
- package/Build/Workers/createWallOutlineGeometry.js +20 -20
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +25 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
- package/Source/Core/Check.d.ts +4 -1
- package/Source/Core/ITwinPlatform.js +6 -3
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +36 -0
- package/Source/Core/PolygonGeometry.js +1 -0
- package/Source/Core/RectangleOutlineGeometry.js +1 -1
- package/Source/Renderer/Texture3D.js +568 -0
- package/Source/Renderer/createUniform.js +1 -0
- package/Source/Renderer/createUniformArray.js +1 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +18 -23
- package/Source/Scene/Cesium3DTileset.js +138 -0
- package/Source/Scene/GlobeSurfaceShaderSet.js +4 -5
- package/Source/Scene/ImageryLayer.js +21 -6
- package/Source/Scene/ImageryLayerCollection.js +3 -2
- package/Source/Scene/Model/CartesianRectangle.js +108 -0
- package/Source/Scene/Model/ImageryConfiguration.js +25 -0
- package/Source/Scene/Model/ImageryCoverage.js +488 -0
- package/Source/Scene/Model/ImageryFlags.js +31 -0
- package/Source/Scene/Model/ImageryInput.js +60 -0
- package/Source/Scene/Model/ImageryPipelineStage.js +1040 -0
- package/Source/Scene/Model/MappedPositions.js +84 -0
- package/Source/Scene/Model/Model.js +38 -0
- package/Source/Scene/Model/ModelImagery.js +403 -0
- package/Source/Scene/Model/ModelImageryMapping.js +489 -0
- package/Source/Scene/Model/ModelPrimitiveImagery.js +972 -0
- package/Source/Scene/Model/ModelReader.js +810 -0
- package/Source/Scene/Model/ModelRenderResources.js +13 -0
- package/Source/Scene/Model/ModelRuntimePrimitive.js +19 -0
- package/Source/Scene/Model/ModelSceneGraph.js +133 -27
- package/Source/Scene/Model/NodeRenderResources.js +10 -0
- package/Source/Scene/ModelComponents.js +10 -0
- package/Source/Scene/QuadtreePrimitive.js +5 -1
- package/Source/Scene/VoxelBoxShape.js +38 -81
- package/Source/Scene/VoxelCylinderShape.js +128 -262
- package/Source/Scene/VoxelPrimitive.js +24 -39
- package/Source/Scene/VoxelRenderResources.js +1 -1
- package/Source/Scene/processVoxelProperties.js +41 -100
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +0 -1
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
- package/Source/Shaders/GlobeFS.glsl +22 -0
- package/Source/Shaders/GlobeFS.js +22 -0
- package/Source/Shaders/Model/MaterialStageFS.glsl +4 -0
- package/Source/Shaders/Model/MaterialStageFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/PolylineCommon.glsl +1 -1
- package/Source/Shaders/PolylineCommon.js +1 -1
- package/Source/Shaders/Voxels/IntersectDepth.glsl +10 -3
- package/Source/Shaders/Voxels/IntersectDepth.js +10 -3
- package/Source/Shaders/Voxels/Intersection.glsl +1 -3
- package/Source/Shaders/Voxels/Intersection.js +1 -3
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -0
- package/Source/Shaders/Voxels/IntersectionUtils.js +1 -0
- package/Source/Shaders/Voxels/VoxelFS.glsl +37 -24
- package/Source/Shaders/Voxels/VoxelFS.js +37 -24
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/index.d.ts +59 -7
- package/index.js +74 -62
- 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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -1526,7 +1526,11 @@ function updateHeights(primitive, frameState) {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
if (defined(position)) {
|
|
1528
1528
|
if (defined(data.callback)) {
|
|
1529
|
-
|
|
1529
|
+
const positionCarto = ellipsoid.cartesianToCartographic(
|
|
1530
|
+
position,
|
|
1531
|
+
scratchCartographic,
|
|
1532
|
+
);
|
|
1533
|
+
data.callback(positionCarto);
|
|
1530
1534
|
}
|
|
1531
1535
|
data.level = tile.level;
|
|
1532
1536
|
}
|
|
@@ -57,22 +57,18 @@ function VoxelBoxShape() {
|
|
|
57
57
|
this.shapeTransform = new Matrix4();
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
+
* The minimum bounds of the shape.
|
|
60
61
|
* @type {Cartesian3}
|
|
61
62
|
* @private
|
|
62
63
|
*/
|
|
63
|
-
this._minBounds =
|
|
64
|
-
VoxelBoxShape.DefaultMinBounds,
|
|
65
|
-
new Cartesian3(),
|
|
66
|
-
);
|
|
64
|
+
this._minBounds = VoxelBoxShape.DefaultMinBounds.clone();
|
|
67
65
|
|
|
68
66
|
/**
|
|
67
|
+
* The maximum bounds of the shape.
|
|
69
68
|
* @type {Cartesian3}
|
|
70
69
|
* @private
|
|
71
70
|
*/
|
|
72
|
-
this._maxBounds =
|
|
73
|
-
VoxelBoxShape.DefaultMaxBounds,
|
|
74
|
-
new Cartesian3(),
|
|
75
|
-
);
|
|
71
|
+
this._maxBounds = VoxelBoxShape.DefaultMaxBounds.clone();
|
|
76
72
|
|
|
77
73
|
/**
|
|
78
74
|
* @private
|
|
@@ -125,8 +121,8 @@ const transformLocalToUv = Matrix4.fromRotationTranslation(
|
|
|
125
121
|
* @param {Matrix4} modelMatrix The model matrix.
|
|
126
122
|
* @param {Cartesian3} minBounds The minimum bounds.
|
|
127
123
|
* @param {Cartesian3} maxBounds The maximum bounds.
|
|
128
|
-
* @param {Cartesian3} [clipMinBounds
|
|
129
|
-
* @param {Cartesian3} [clipMaxBounds
|
|
124
|
+
* @param {Cartesian3} [clipMinBounds] The minimum clip bounds.
|
|
125
|
+
* @param {Cartesian3} [clipMaxBounds] The maximum clip bounds.
|
|
130
126
|
* @returns {boolean} Whether the shape is visible.
|
|
131
127
|
*/
|
|
132
128
|
VoxelBoxShape.prototype.update = function (
|
|
@@ -136,44 +132,17 @@ VoxelBoxShape.prototype.update = function (
|
|
|
136
132
|
clipMinBounds,
|
|
137
133
|
clipMaxBounds,
|
|
138
134
|
) {
|
|
139
|
-
clipMinBounds = clipMinBounds ?? VoxelBoxShape.DefaultMinBounds;
|
|
140
|
-
clipMaxBounds = clipMaxBounds ?? VoxelBoxShape.DefaultMaxBounds;
|
|
141
135
|
//>>includeStart('debug', pragmas.debug);
|
|
142
136
|
Check.typeOf.object("modelMatrix", modelMatrix);
|
|
143
137
|
Check.typeOf.object("minBounds", minBounds);
|
|
144
138
|
Check.typeOf.object("maxBounds", maxBounds);
|
|
145
139
|
//>>includeEnd('debug');
|
|
146
140
|
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
clipMinBounds = clipMinBounds ?? minBounds.clone(scratchClipMinBounds);
|
|
142
|
+
clipMaxBounds = clipMaxBounds ?? maxBounds.clone(scratchClipMaxBounds);
|
|
149
143
|
|
|
150
|
-
minBounds = this._minBounds
|
|
151
|
-
|
|
152
|
-
defaultMinBounds,
|
|
153
|
-
defaultMaxBounds,
|
|
154
|
-
this._minBounds,
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
maxBounds = this._maxBounds = Cartesian3.clamp(
|
|
158
|
-
maxBounds,
|
|
159
|
-
defaultMinBounds,
|
|
160
|
-
defaultMaxBounds,
|
|
161
|
-
this._maxBounds,
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
clipMinBounds = Cartesian3.clamp(
|
|
165
|
-
clipMinBounds,
|
|
166
|
-
defaultMinBounds,
|
|
167
|
-
defaultMaxBounds,
|
|
168
|
-
scratchClipMinBounds,
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
clipMaxBounds = Cartesian3.clamp(
|
|
172
|
-
clipMaxBounds,
|
|
173
|
-
defaultMinBounds,
|
|
174
|
-
defaultMaxBounds,
|
|
175
|
-
scratchClipMaxBounds,
|
|
176
|
-
);
|
|
144
|
+
minBounds = Cartesian3.clone(minBounds, this._minBounds);
|
|
145
|
+
maxBounds = Cartesian3.clone(maxBounds, this._maxBounds);
|
|
177
146
|
|
|
178
147
|
const renderMinBounds = Cartesian3.clamp(
|
|
179
148
|
minBounds,
|
|
@@ -181,7 +150,6 @@ VoxelBoxShape.prototype.update = function (
|
|
|
181
150
|
clipMaxBounds,
|
|
182
151
|
scratchRenderMinBounds,
|
|
183
152
|
);
|
|
184
|
-
|
|
185
153
|
const renderMaxBounds = Cartesian3.clamp(
|
|
186
154
|
maxBounds,
|
|
187
155
|
clipMinBounds,
|
|
@@ -189,13 +157,11 @@ VoxelBoxShape.prototype.update = function (
|
|
|
189
157
|
scratchRenderMaxBounds,
|
|
190
158
|
);
|
|
191
159
|
|
|
192
|
-
const scale = Matrix4.getScale(modelMatrix, scratchScale);
|
|
193
|
-
|
|
194
160
|
// Box is not visible if:
|
|
195
161
|
// - any of the min render bounds exceed the max render bounds
|
|
196
162
|
// - two or more of the min bounds equal the max bounds (line / point)
|
|
197
|
-
// - any of the min clip bounds exceed the max clip bounds
|
|
198
163
|
// - scale is 0 for any component (too annoying to reconstruct rotation matrix)
|
|
164
|
+
const scale = Matrix4.getScale(modelMatrix, scratchScale);
|
|
199
165
|
if (
|
|
200
166
|
renderMinBounds.x > renderMaxBounds.x ||
|
|
201
167
|
renderMinBounds.y > renderMaxBounds.y ||
|
|
@@ -204,9 +170,6 @@ VoxelBoxShape.prototype.update = function (
|
|
|
204
170
|
(renderMinBounds.y === renderMaxBounds.y) +
|
|
205
171
|
(renderMinBounds.z === renderMaxBounds.z) >=
|
|
206
172
|
2 ||
|
|
207
|
-
clipMinBounds.x > clipMaxBounds.x ||
|
|
208
|
-
clipMinBounds.y > clipMaxBounds.y ||
|
|
209
|
-
clipMinBounds.z > clipMaxBounds.z ||
|
|
210
173
|
scale.x === 0.0 ||
|
|
211
174
|
scale.y === 0.0 ||
|
|
212
175
|
scale.z === 0.0
|
|
@@ -245,10 +208,6 @@ VoxelBoxShape.prototype.update = function (
|
|
|
245
208
|
}
|
|
246
209
|
}
|
|
247
210
|
|
|
248
|
-
const hasShapeBounds =
|
|
249
|
-
!Cartesian3.equals(minBounds, defaultMinBounds) ||
|
|
250
|
-
!Cartesian3.equals(maxBounds, defaultMaxBounds);
|
|
251
|
-
|
|
252
211
|
// Keep track of how many intersections there are going to be.
|
|
253
212
|
let intersectionCount = 0;
|
|
254
213
|
|
|
@@ -266,36 +225,34 @@ VoxelBoxShape.prototype.update = function (
|
|
|
266
225
|
shaderUniforms.renderMaxBounds,
|
|
267
226
|
);
|
|
268
227
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
);
|
|
228
|
+
shaderDefines["BOX_HAS_SHAPE_BOUNDS"] = true;
|
|
229
|
+
|
|
230
|
+
const min = minBounds;
|
|
231
|
+
const max = maxBounds;
|
|
232
|
+
|
|
233
|
+
// Go from UV space to bounded UV space:
|
|
234
|
+
// delerp(posUv, minBoundsUv, maxBoundsUv)
|
|
235
|
+
// (posUv - minBoundsUv) / (maxBoundsUv - minBoundsUv)
|
|
236
|
+
// posUv / (maxBoundsUv - minBoundsUv) - minBoundsUv / (maxBoundsUv - minBoundsUv)
|
|
237
|
+
// scale = 1.0 / (maxBoundsUv - minBoundsUv)
|
|
238
|
+
// scale = 1.0 / ((maxBounds * 0.5 + 0.5) - (minBounds * 0.5 + 0.5))
|
|
239
|
+
// scale = 2.0 / (maxBounds - minBounds)
|
|
240
|
+
// offset = -minBoundsUv / ((maxBounds * 0.5 + 0.5) - (minBounds * 0.5 + 0.5))
|
|
241
|
+
// offset = -2.0 * (minBounds * 0.5 + 0.5) / (maxBounds - minBounds)
|
|
242
|
+
// offset = -scale * (minBounds * 0.5 + 0.5)
|
|
243
|
+
shaderUniforms.boxUvToShapeUvScale = Cartesian3.fromElements(
|
|
244
|
+
2.0 / (min.x === max.x ? 1.0 : max.x - min.x),
|
|
245
|
+
2.0 / (min.y === max.y ? 1.0 : max.y - min.y),
|
|
246
|
+
2.0 / (min.z === max.z ? 1.0 : max.z - min.z),
|
|
247
|
+
shaderUniforms.boxUvToShapeUvScale,
|
|
248
|
+
);
|
|
291
249
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
250
|
+
shaderUniforms.boxUvToShapeUvTranslate = Cartesian3.fromElements(
|
|
251
|
+
-shaderUniforms.boxUvToShapeUvScale.x * (min.x * 0.5 + 0.5),
|
|
252
|
+
-shaderUniforms.boxUvToShapeUvScale.y * (min.y * 0.5 + 0.5),
|
|
253
|
+
-shaderUniforms.boxUvToShapeUvScale.z * (min.z * 0.5 + 0.5),
|
|
254
|
+
shaderUniforms.boxUvToShapeUvTranslate,
|
|
255
|
+
);
|
|
299
256
|
|
|
300
257
|
this.shaderMaximumIntersectionsLength = intersectionCount;
|
|
301
258
|
|