@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
@@ -0,0 +1,84 @@
1
+ import Check from "../../Core/Check.js";
2
+
3
+ /**
4
+ * A collection of cartographic positions (and their bounding rectangle) that
5
+ * have been computed from cartesian positions, for a specific ellipsoid.
6
+ *
7
+ * This is used in the <code>ModelPrimitiveImagery</code> class, and stores
8
+ * the positions of the primitive, mapped to an ellipsoid that was used
9
+ * on one of the imagery layers. This avoids recomputing the transform
10
+ * of the primitive POSITION attribute values into ECEF, and the subsequent
11
+ * conversion of these positions into cartographic positions.
12
+ *
13
+ * @private
14
+ */
15
+ class MappedPositions {
16
+ /**
17
+ * Creates a new instance
18
+ *
19
+ * @param {Iterable<Cartographic>} cartographicPositions The positions
20
+ * @param {number} numPositions The number of positions
21
+ * @param {Rectangle} cartographicBoundingRectangle The bounding
22
+ * rectangle of the positions
23
+ * @param {Ellipsoid} ellipsoid The ellipsoid
24
+ */
25
+ constructor(
26
+ cartographicPositions,
27
+ numPositions,
28
+ cartographicBoundingRectangle,
29
+ ellipsoid,
30
+ ) {
31
+ //>>includeStart('debug', pragmas.debug);
32
+ Check.defined("cartographicPositions", cartographicPositions);
33
+ Check.typeOf.number.greaterThanOrEquals("numPositions", numPositions, 0);
34
+ Check.defined(
35
+ "cartographicBoundingRectangle",
36
+ cartographicBoundingRectangle,
37
+ );
38
+ Check.defined("ellipsoid", ellipsoid);
39
+ //>>includeEnd('debug');
40
+
41
+ this._cartographicPositions = cartographicPositions;
42
+ this._numPositions = numPositions;
43
+ this._cartographicBoundingRectangle = cartographicBoundingRectangle;
44
+ this._ellipsoid = ellipsoid;
45
+ }
46
+
47
+ /**
48
+ * Returns the cartographic positions
49
+ *
50
+ * @returns {Iterable<Cartographic>} The positions
51
+ */
52
+ get cartographicPositions() {
53
+ return this._cartographicPositions;
54
+ }
55
+
56
+ /**
57
+ * Returns the number of positions
58
+ *
59
+ * @returns {number} The number of positions
60
+ */
61
+ get numPositions() {
62
+ return this._numPositions;
63
+ }
64
+
65
+ /**
66
+ * Returns the cartographic bounding rectangle
67
+ *
68
+ * @returns {Rectangle} The rectangle
69
+ */
70
+ get cartographicBoundingRectangle() {
71
+ return this._cartographicBoundingRectangle;
72
+ }
73
+
74
+ /**
75
+ * Returns the ellipsoid for which these positions have been created
76
+ *
77
+ * @returns {Ellipsoid} The ellipsoid
78
+ */
79
+ get ellipsoid() {
80
+ return this._ellipsoid;
81
+ }
82
+ }
83
+
84
+ export default MappedPositions;
@@ -43,6 +43,7 @@ import oneTimeWarning from "../../Core/oneTimeWarning.js";
43
43
  import PntsLoader from "./PntsLoader.js";
44
44
  import StyleCommandsNeeded from "./StyleCommandsNeeded.js";
45
45
  import pickModel from "./pickModel.js";
46
+ import ModelImagery from "./ModelImagery.js";
46
47
 
47
48
  /**
48
49
  * <div class="notice">
@@ -382,6 +383,8 @@ function Model(options) {
382
383
  }
383
384
  this._clippingPolygonsState = 0; // If this value changes, the shaders need to be regenerated.
384
385
 
386
+ this._modelImagery = new ModelImagery(this);
387
+
385
388
  this._lightColor = Cartesian3.clone(options.lightColor);
386
389
 
387
390
  this._imageBasedLighting = defined(options.imageBasedLighting)
@@ -1375,6 +1378,28 @@ Object.defineProperties(Model.prototype, {
1375
1378
  },
1376
1379
  },
1377
1380
 
1381
+ /**
1382
+ * If this model is part of a <code>Model3DTileContent</code> of a tileset,
1383
+ * then this will return the <code>ImageryLayerCollection</code>
1384
+ * of that tileset. Otherwise, <code>undefined</code> is returned.
1385
+ *
1386
+ * @memberof Model.prototype
1387
+ * @type {ImageryLayerCollection|undefined}
1388
+ * @readonly
1389
+ * @private
1390
+ */
1391
+ imageryLayers: {
1392
+ get: function () {
1393
+ if (defined(this._content)) {
1394
+ const tileset = this._content.tileset;
1395
+ if (defined(tileset)) {
1396
+ return tileset.imageryLayers;
1397
+ }
1398
+ }
1399
+ return undefined;
1400
+ },
1401
+ },
1402
+
1378
1403
  /**
1379
1404
  * The directional light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
1380
1405
  * <p>
@@ -1928,6 +1953,19 @@ Model.prototype.update = function (frameState) {
1928
1953
  return;
1929
1954
  }
1930
1955
 
1956
+ const modelImagery = this._modelImagery;
1957
+ modelImagery.update(frameState);
1958
+ if (!modelImagery.ready) {
1959
+ // If the imagery loading should not happen asynchronously,
1960
+ // then do not let the model count as 'ready' until the
1961
+ // modelImagery is 'ready'
1962
+ const asynchronouslyLoadImagery =
1963
+ this._content?.tileset?._asynchronouslyLoadImagery ?? false;
1964
+ if (!asynchronouslyLoadImagery) {
1965
+ return;
1966
+ }
1967
+ }
1968
+
1931
1969
  updateFeatureTableId(this);
1932
1970
  updateStyle(this);
1933
1971
  updateFeatureTables(this, frameState);
@@ -0,0 +1,403 @@
1
+ import Check from "../../Core/Check.js";
2
+ import defined from "../../Core/defined.js";
3
+ import destroyObject from "../../Core/destroyObject.js";
4
+ import DeveloperError from "../../Core/DeveloperError.js";
5
+
6
+ import ImageryConfiguration from "./ImageryConfiguration.js";
7
+ import ModelPrimitiveImagery from "./ModelPrimitiveImagery.js";
8
+
9
+ /**
10
+ * A class managing the draping of imagery on a <code>Model</code>.
11
+ *
12
+ * An instance of this class is created in the Model constructor. It will
13
+ * create the data structures that carry the information that is required
14
+ * for mapping imagery textures on model primitives.
15
+ *
16
+ * It offers two functions for managing the lifecycle of this draping process:
17
+ *
18
+ * The <code>update</code> function is called from the <code>Model.update</code>
19
+ * function in each frame. It will create one <code>ModelPrimitiveImagery</code>
20
+ * instance for each primitive that appears in the model, and call the
21
+ * <code>update</code> function of these instances, respectively.
22
+ *
23
+ * The <code>ready</code> getter will be used to determine whether the
24
+ * draping computations are done, and the update process of the <code>Model</code>
25
+ * can continue, eventually causing the <code>model.ready</code> flag to
26
+ * become <code>true</code>. The model imagery counts as "ready" when all
27
+ * the imagery layers of the model are <code>ready</code>, and all the
28
+ * <code>ModelPrimitiveImagery</code> instances are <code>ready</code>.
29
+ *
30
+ * @private
31
+ */
32
+ class ModelImagery {
33
+ /**
34
+ * Creates a new instance
35
+ *
36
+ * @param {Model} model The model
37
+ * @throws {DeveloperError} If the model is not defined
38
+ */
39
+ constructor(model) {
40
+ //>>includeStart('debug', pragmas.debug);
41
+ Check.defined("model", model);
42
+ //>>includeEnd('debug');
43
+
44
+ /**
45
+ * The model that this instance was created for.
46
+ *
47
+ * @type {Model}
48
+ * @readonly
49
+ * @private
50
+ */
51
+ this._model = model;
52
+
53
+ /**
54
+ * One <code<ModelPrimitiveImagery</code> for each primitive
55
+ * that appears in the model.
56
+ *
57
+ * Initially, this is <code>undefined</code>. When the <code>update</code>
58
+ * function is called and all imagery layers that are associated with the
59
+ * model are <code>ready</code>, this is initialized with one instance
60
+ * of a <code>ModelPrimitiveImagery</code> per runtime primitive (i.e. one for
61
+ * each <code>model.sceneGraph._runtimeNodes[n]._runtimePrimitives[p]</code>)
62
+ *
63
+ * @type {ModelPrimitiveImagery[]|undefined}
64
+ * @private
65
+ */
66
+ this._modelPrimitiveImageries = undefined;
67
+
68
+ /**
69
+ * One <code>ImageryConfiguration</code> object for each <code>ImageryLayer</code>
70
+ * that is associated with the model.
71
+ *
72
+ * This is used for determining whether the configuration (relevant property
73
+ * values) of an imagery layer has been changed since the previous
74
+ * <code>update</code> call, which should cause the draw commands of the
75
+ * model to be reset.
76
+ *
77
+ * @type {ImageryConfiguration[]}
78
+ * @private
79
+ */
80
+ this._imageryConfigurations = [];
81
+ }
82
+
83
+ /**
84
+ * The update function that is called from <code>Model.update</code> in
85
+ * each frame.
86
+ *
87
+ * This checks whether the imagery layer objects that are associated
88
+ * with the model are all <code>ready</code>. If they are not yet
89
+ * ready, then nothing is done.
90
+ *
91
+ * Otherwise, this just calls the <code>update</code> function of
92
+ * the <code>_modelPrimitiveImageries</code> (creating them if they had
93
+ * not been created yet).
94
+ *
95
+ * @param {FrameState} frameState The frame state
96
+ */
97
+ update(frameState) {
98
+ //>>includeStart('debug', pragmas.debug);
99
+ Check.defined("frameState", frameState);
100
+ //>>includeEnd('debug');
101
+
102
+ if (!this._hasImagery) {
103
+ return;
104
+ }
105
+
106
+ if (!this._allImageryLayersReady) {
107
+ return;
108
+ }
109
+
110
+ if (!defined(this._modelPrimitiveImageries)) {
111
+ this._modelPrimitiveImageries = this._createModelPrimitiveImageries();
112
+ }
113
+ this._updateModelPrimitiveImageries(frameState);
114
+
115
+ this._checkForModifiedImageryConfigurations();
116
+ }
117
+
118
+ /**
119
+ * Creates the <code>ModelPrimitiveImagery</code> array that contains
120
+ * one <code>ModelPrimitiveImagery</code> for each primitive that is
121
+ * contained in the model.
122
+ *
123
+ * @returns {ModelPrimitiveImagery[]} The model primitive imageries
124
+ * @private
125
+ */
126
+ _createModelPrimitiveImageries() {
127
+ const model = this._model;
128
+ const runtimeNodesAndPrimitives = this._collectRuntimeNodesAndPrimitives();
129
+ const modelPrimitiveImageries = [];
130
+ const length = runtimeNodesAndPrimitives.length;
131
+ for (let i = 0; i < length; i++) {
132
+ const runtimeNodeAndPrimitive = runtimeNodesAndPrimitives[i];
133
+ const runtimeNode = runtimeNodeAndPrimitive.runtimeNode;
134
+ const runtimePrimitive = runtimeNodeAndPrimitive.runtimePrimitive;
135
+ const modelPrimitiveImagery = new ModelPrimitiveImagery(
136
+ model,
137
+ runtimeNode,
138
+ runtimePrimitive,
139
+ );
140
+ runtimePrimitive.primitive.modelPrimitiveImagery = modelPrimitiveImagery;
141
+ modelPrimitiveImageries.push(modelPrimitiveImagery);
142
+ }
143
+ return modelPrimitiveImageries;
144
+ }
145
+
146
+ /**
147
+ * Computes all runtime nodes and primitives of the model.
148
+ *
149
+ * This is just the array that contains a
150
+ * <code>{ runtimeNode, runtimePrimitive }</code>
151
+ * for each
152
+ * <code>model.sceneGraph._runtimeNodes[n]._runtimePrimitives[p]</code>.
153
+ *
154
+ * @returns {object[]} The runtime nodes and primitives
155
+ * @private
156
+ */
157
+ _collectRuntimeNodesAndPrimitives() {
158
+ const model = this._model;
159
+ const sceneGraph = model.sceneGraph;
160
+ const runtimeNodes = sceneGraph._runtimeNodes;
161
+ const runtimeNodesAndPrimitives = [];
162
+ for (let i = 0; i < runtimeNodes.length; i++) {
163
+ const runtimeNode = runtimeNodes[i];
164
+ if (!defined(runtimeNode)) {
165
+ continue;
166
+ }
167
+ for (let j = 0; j < runtimeNode.runtimePrimitives.length; j++) {
168
+ const runtimePrimitive = runtimeNode.runtimePrimitives[j];
169
+ runtimeNodesAndPrimitives.push({
170
+ runtimeNode: runtimeNode,
171
+ runtimePrimitive: runtimePrimitive,
172
+ });
173
+ }
174
+ }
175
+ return runtimeNodesAndPrimitives;
176
+ }
177
+
178
+ /**
179
+ * Just calls <code>update</code> on each <code>ModelPrimitiveImagery</code>
180
+ * as part of the <code>update</code> of this class.
181
+ *
182
+ * @private
183
+ */
184
+ _updateModelPrimitiveImageries(frameState) {
185
+ //>>includeStart('debug', pragmas.debug);
186
+ Check.defined("frameState", frameState);
187
+ //>>includeEnd('debug');
188
+
189
+ if (!defined(this._modelPrimitiveImageries)) {
190
+ throw new DeveloperError(
191
+ "The modelPrimitiveImageries have not been created",
192
+ );
193
+ }
194
+
195
+ const modelPrimitiveImageries = this._modelPrimitiveImageries;
196
+ const length = modelPrimitiveImageries.length;
197
+ for (let i = 0; i < length; i++) {
198
+ const modelPrimitiveImagery = modelPrimitiveImageries[i];
199
+ modelPrimitiveImagery.update(frameState);
200
+ }
201
+ }
202
+
203
+ /**
204
+ * Destroy and delete all <code>ModelPrimitiveImagery</code> instances
205
+ * if they already have been created.
206
+ */
207
+ _deleteModelPrimitiveImageries() {
208
+ const modelPrimitiveImageries = this._modelPrimitiveImageries;
209
+ if (!defined(modelPrimitiveImageries)) {
210
+ return;
211
+ }
212
+ const length = modelPrimitiveImageries.length;
213
+ for (let i = 0; i < length; i++) {
214
+ const modelPrimitiveImagery = modelPrimitiveImageries[i];
215
+ modelPrimitiveImagery.destroy();
216
+ }
217
+ delete this._modelPrimitiveImageries;
218
+ }
219
+
220
+ /**
221
+ * Returns whether this instance is "ready".
222
+ *
223
+ * This means that all imagery layers that are associated with the model
224
+ * are <code>ready</code>, and all <code>ModelPrimitiveImagery</code>
225
+ * instances are <code>ready</code>.
226
+ *
227
+ * When this is <code>true</code>, then the mapping computations are
228
+ * complete and the structures containing the mapping information have
229
+ * been initialized. Otherwise, subsequent calls to <code>update</code>
230
+ * will perform the necessary computation until this getter eventually
231
+ * returns <code>true</code>.
232
+ *
233
+ * @returns {boolean} Whether this instance is "ready"
234
+ */
235
+ get ready() {
236
+ if (!this._hasImagery) {
237
+ return true;
238
+ }
239
+ if (!this._allImageryLayersReady) {
240
+ return false;
241
+ }
242
+ if (!this._allModelPrimitiveImageriesReady) {
243
+ return false;
244
+ }
245
+ return true;
246
+ }
247
+
248
+ /**
249
+ * Returns whether the model has imagery layers associated with it.
250
+ *
251
+ * @private
252
+ */
253
+ get _hasImagery() {
254
+ const model = this._model;
255
+ const imageryLayers = model.imageryLayers;
256
+ return defined(imageryLayers) && imageryLayers.length > 0;
257
+ }
258
+
259
+ /**
260
+ * Returns whether all imagery layers that are associated with the
261
+ * model are <code>ready</code>.
262
+ *
263
+ * If the model does not have imagery, then this always returns
264
+ * <code>true</code>. Otherwise, it returns whether each imagery
265
+ * layer is <code>ready</code>.
266
+ *
267
+ * @private
268
+ */
269
+ get _allImageryLayersReady() {
270
+ if (!this._hasImagery) {
271
+ return true;
272
+ }
273
+ const imageryLayers = this._model.imageryLayers;
274
+ const length = imageryLayers.length;
275
+ for (let i = 0; i < length; i++) {
276
+ const imageryLayer = imageryLayers.get(i);
277
+ if (!imageryLayer.ready) {
278
+ return false;
279
+ }
280
+ }
281
+ return true;
282
+ }
283
+
284
+ /**
285
+ * Returns whether all <code>ModelPrimitiveImagery</code> instances
286
+ * are are <code>ready</code>.
287
+ *
288
+ * @private
289
+ */
290
+ get _allModelPrimitiveImageriesReady() {
291
+ const modelPrimitiveImageries = this._modelPrimitiveImageries;
292
+ if (!defined(modelPrimitiveImageries)) {
293
+ return false;
294
+ }
295
+ const length = modelPrimitiveImageries.length;
296
+ for (let i = 0; i < length; i++) {
297
+ const modelPrimitiveImagery = modelPrimitiveImageries[i];
298
+ if (!modelPrimitiveImagery.ready) {
299
+ return false;
300
+ }
301
+ }
302
+ return true;
303
+ }
304
+
305
+ /**
306
+ * Check whether any of the settings of any imagery layer (like alpha
307
+ * or hue) has been changed since the last call to the <code>update</code>
308
+ * function.
309
+ *
310
+ * If this is the case, the draw commands of the model will be reset.
311
+ */
312
+ _checkForModifiedImageryConfigurations() {
313
+ if (this._imageryConfigurationsModified()) {
314
+ this._updateImageryConfigurations();
315
+ const model = this._model;
316
+ model.resetDrawCommands();
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Returns whether any setting of an imagery layer (like alpha or hue) has
322
+ * been changed since the last time the <code>ImageryConfiguration</code>
323
+ * objects have been updated.
324
+ *
325
+ * @returns {boolean} Whether there was a modification
326
+ */
327
+ _imageryConfigurationsModified() {
328
+ const model = this._model;
329
+ const imageryLayers = model.imageryLayers;
330
+ const imageryConfigurations = this._imageryConfigurations;
331
+ if (imageryLayers.length !== imageryConfigurations.length) {
332
+ return true;
333
+ }
334
+ for (let i = 0; i < imageryLayers.length; i++) {
335
+ const imageryLayer = imageryLayers.get(i);
336
+ const imageryConfiguration = imageryConfigurations[i];
337
+
338
+ if (imageryLayer.alpha !== imageryConfiguration.alpha) {
339
+ return true;
340
+ }
341
+ if (imageryLayer.brightness !== imageryConfiguration.brightness) {
342
+ return true;
343
+ }
344
+ if (imageryLayer.contrast !== imageryConfiguration.contrast) {
345
+ return true;
346
+ }
347
+ if (imageryLayer.hue !== imageryConfiguration.hue) {
348
+ return true;
349
+ }
350
+ if (imageryLayer.saturation !== imageryConfiguration.saturation) {
351
+ return true;
352
+ }
353
+ if (imageryLayer.gamma !== imageryConfiguration.gamma) {
354
+ return true;
355
+ }
356
+ if (imageryLayer.colorToAlpha !== imageryConfiguration.colorToAlpha) {
357
+ return true;
358
+ }
359
+ }
360
+ return false;
361
+ }
362
+
363
+ /**
364
+ * Create one <code>ImageryConfiguration</code> object for each imagery
365
+ * layer that appears in the model, and store them as the
366
+ * <code>_imageryConfigurations</code>.
367
+ */
368
+ _updateImageryConfigurations() {
369
+ const model = this._model;
370
+ const imageryLayers = model.imageryLayers;
371
+ const imageryConfigurations = this._imageryConfigurations;
372
+ imageryConfigurations.length = imageryLayers.length;
373
+ for (let i = 0; i < imageryLayers.length; i++) {
374
+ const imageryLayer = imageryLayers.get(i);
375
+ imageryConfigurations[i] = new ImageryConfiguration(imageryLayer);
376
+ }
377
+ }
378
+
379
+ /**
380
+ * Returns whether this object was destroyed.
381
+ *
382
+ * If this object was destroyed, calling any function other than
383
+ * <code>isDestroyed</code> will result in a {@link DeveloperError}.
384
+ *
385
+ * @returns {boolean} Whether this object was destroyed
386
+ */
387
+ isDestroyed() {
388
+ return false;
389
+ }
390
+
391
+ /**
392
+ * Destroys this object and all its resources.
393
+ */
394
+ destroy() {
395
+ if (this.isDestroyed()) {
396
+ return;
397
+ }
398
+ this._deleteModelPrimitiveImageries();
399
+ return destroyObject(this);
400
+ }
401
+ }
402
+
403
+ export default ModelImagery;