@cesium/engine 20.0.2-ion.0 → 21.0.1-ion.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 (182) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +637 -0
  2. package/Build/Workers/{chunk-AFKNTEMH.js → chunk-26ZRRKTU.js} +16 -16
  3. package/Build/Workers/{chunk-NKKNQMEH.js → chunk-2PX2ULSM.js} +3 -3
  4. package/Build/Workers/{chunk-OIMV4OE5.js → chunk-3K4DRV7Y.js} +9 -9
  5. package/Build/Workers/{chunk-IS5FETN7.js → chunk-3XTJC4CV.js} +5 -5
  6. package/Build/Workers/{chunk-Z2W7ZIGV.js → chunk-6KX3IUUT.js} +2 -2
  7. package/Build/Workers/{chunk-BHAATGZA.js → chunk-75UG66GR.js} +5 -5
  8. package/Build/Workers/{chunk-YXTWHLJA.js → chunk-ADADBRLI.js} +4 -4
  9. package/Build/Workers/{chunk-CUU3WGXJ.js → chunk-AGT6W3JS.js} +6 -6
  10. package/Build/Workers/{chunk-QID3DXQA.js → chunk-AQ4A5CMC.js} +7 -7
  11. package/Build/Workers/{chunk-MTBXKKSQ.js → chunk-B56XVJRS.js} +12 -12
  12. package/Build/Workers/{chunk-VODCZKV2.js → chunk-DTYIUWZU.js} +4 -4
  13. package/Build/Workers/{chunk-VSMKMGX4.js → chunk-E6T4LSM6.js} +5 -5
  14. package/Build/Workers/{chunk-WZKTQZUW.js → chunk-EEDSGIH7.js} +6 -6
  15. package/Build/Workers/{chunk-FNUSHLOY.js → chunk-EHMAKCWQ.js} +1 -1
  16. package/Build/Workers/{chunk-CYC7JX3P.js → chunk-ESPNIYL5.js} +8 -8
  17. package/Build/Workers/{chunk-LS63ERFB.js → chunk-EZJXK2UP.js} +4 -4
  18. package/Build/Workers/{chunk-Q3OWKSC5.js → chunk-G5RX7BPJ.js} +10 -10
  19. package/Build/Workers/{chunk-FAQ2XNFV.js → chunk-G74UMFQ4.js} +5 -5
  20. package/Build/Workers/{chunk-YUHWFX5H.js → chunk-H3G7OYZY.js} +2 -2
  21. package/Build/Workers/{chunk-6LULWCX3.js → chunk-HDBIC7IL.js} +1 -1
  22. package/Build/Workers/{chunk-WORBFT5H.js → chunk-JESBYOH5.js} +9 -9
  23. package/Build/Workers/{chunk-P2V7PVDH.js → chunk-KGL66RWW.js} +8 -8
  24. package/Build/Workers/{chunk-USK6ZAY2.js → chunk-L73TRTIG.js} +1 -1
  25. package/Build/Workers/{chunk-VA7LWA5Q.js → chunk-LEFV6H2V.js} +9 -9
  26. package/Build/Workers/{chunk-23B3EYUM.js → chunk-LK7H6V2E.js} +4 -4
  27. package/Build/Workers/{chunk-JVG6T2WE.js → chunk-LSNF6CIP.js} +12 -12
  28. package/Build/Workers/{chunk-ABTG74AR.js → chunk-MBIUW42A.js} +1 -1
  29. package/Build/Workers/{chunk-VZNF2GT7.js → chunk-MFPT34BC.js} +4 -4
  30. package/Build/Workers/{chunk-X6GXYB3M.js → chunk-MIFUV36K.js} +1 -1
  31. package/Build/Workers/{chunk-K6THSIDU.js → chunk-MJWRSKJV.js} +2 -2
  32. package/Build/Workers/{chunk-FYYP46TF.js → chunk-NWJRIJQG.js} +2 -2
  33. package/Build/Workers/{chunk-H5IQLAJP.js → chunk-OLH67Z2S.js} +82 -54
  34. package/Build/Workers/{chunk-FHLPYFIW.js → chunk-OWCFUM4Z.js} +13 -13
  35. package/Build/Workers/{chunk-66MGJQFZ.js → chunk-PQW63B2T.js} +2 -2
  36. package/Build/Workers/{chunk-UR36KLNW.js → chunk-RFZAUDYZ.js} +4 -4
  37. package/Build/Workers/{chunk-XWRUYDF6.js → chunk-SDFGZML6.js} +2 -2
  38. package/Build/Workers/{chunk-AHFTST3Q.js → chunk-SF2XXYOB.js} +12 -12
  39. package/Build/Workers/{chunk-QZGZIAK2.js → chunk-SGEAS4NZ.js} +6 -6
  40. package/Build/Workers/{chunk-MFXTB5I4.js → chunk-T7WXNKIA.js} +11 -11
  41. package/Build/Workers/{chunk-H7HFDM3G.js → chunk-TXK2FF6N.js} +5 -5
  42. package/Build/Workers/{chunk-D4XRQNUO.js → chunk-UTL4WVC3.js} +5 -5
  43. package/Build/Workers/{chunk-V6ZGOX4I.js → chunk-UTTKH2UG.js} +7 -7
  44. package/Build/Workers/{chunk-X55ZOYMS.js → chunk-VIDWZGD6.js} +12 -12
  45. package/Build/Workers/{chunk-TZDR2BAP.js → chunk-WIPOMPA5.js} +6 -6
  46. package/Build/Workers/{chunk-CEA3L7M7.js → chunk-WJV24LAS.js} +4 -4
  47. package/Build/Workers/{chunk-F4PS6RFF.js → chunk-WMG6UOCJ.js} +10 -10
  48. package/Build/Workers/{chunk-XIDMFHR4.js → chunk-XFS2ORSO.js} +14 -14
  49. package/Build/Workers/{chunk-VLGVUVJY.js → chunk-XPTKQIVN.js} +6 -6
  50. package/Build/Workers/{chunk-D5X2LOJ2.js → chunk-XYBFMHXA.js} +7 -7
  51. package/Build/Workers/{chunk-YNPZU55A.js → chunk-YFZMB6FZ.js} +6 -6
  52. package/Build/Workers/{chunk-YSDOO7AG.js → chunk-ZOVMWDPW.js} +5 -5
  53. package/Build/Workers/{chunk-5DF5RVIO.js → chunk-ZTGZMKAB.js} +16 -16
  54. package/Build/Workers/combineGeometry.js +21 -21
  55. package/Build/Workers/createBoxGeometry.js +15 -15
  56. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  57. package/Build/Workers/createCircleGeometry.js +23 -23
  58. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  59. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  60. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  61. package/Build/Workers/createCorridorGeometry.js +26 -26
  62. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  63. package/Build/Workers/createCylinderGeometry.js +17 -17
  64. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  65. package/Build/Workers/createEllipseGeometry.js +23 -23
  66. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  67. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  68. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  69. package/Build/Workers/createFrustumGeometry.js +15 -15
  70. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  71. package/Build/Workers/createGeometry.js +21 -21
  72. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  73. package/Build/Workers/createPlaneGeometry.js +13 -13
  74. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  75. package/Build/Workers/createPolygonGeometry.js +29 -29
  76. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  77. package/Build/Workers/createPolylineGeometry.js +22 -22
  78. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  79. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  80. package/Build/Workers/createRectangleGeometry.js +24 -24
  81. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  82. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  83. package/Build/Workers/createSphereGeometry.js +16 -16
  84. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  85. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  86. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  87. package/Build/Workers/createVectorTileGeometries.js +21 -21
  88. package/Build/Workers/createVectorTilePoints.js +11 -11
  89. package/Build/Workers/createVectorTilePolygons.js +19 -19
  90. package/Build/Workers/createVectorTilePolylines.js +12 -12
  91. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  92. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  93. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  94. package/Build/Workers/createWallGeometry.js +21 -21
  95. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  96. package/Build/Workers/decodeDraco.js +10 -10
  97. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  98. package/Build/Workers/decodeI3S.js +9 -9
  99. package/Build/Workers/gaussianSplatSorter.js +4 -4
  100. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  101. package/Build/Workers/transcodeKTX2.js +6 -6
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  104. package/Source/Core/Event.js +94 -53
  105. package/Source/Core/GoogleMaps.js +2 -2
  106. package/Source/Core/Ion.js +1 -1
  107. package/Source/Core/IonResource.js +30 -4
  108. package/Source/Core/Resource.js +5 -1
  109. package/Source/DataSources/KmlDataSource.js +62 -63
  110. package/Source/DataSources/exportKml.js +27 -30
  111. package/Source/Scene/ArcGisMapService.js +1 -1
  112. package/Source/Scene/Azure2DImageryProvider.js +308 -0
  113. package/Source/Scene/Billboard.js +4 -0
  114. package/Source/Scene/BillboardCollection.js +9 -2
  115. package/Source/Scene/ClippingPlaneCollection.js +3 -3
  116. package/Source/Scene/ClippingPolygon.js +91 -2
  117. package/Source/Scene/CreditDisplay.js +1 -1
  118. package/Source/Scene/GaussianSplat3DTileContent.js +54 -9
  119. package/Source/Scene/GaussianSplatPrimitive.js +49 -50
  120. package/Source/Scene/Google2DImageryProvider.js +614 -0
  121. package/Source/Scene/IonImageryProvider.js +22 -1
  122. package/Source/Scene/LabelCollection.js +1 -0
  123. package/Source/Scene/Material.js +248 -80
  124. package/Source/Scene/Primitive.js +6 -0
  125. package/Source/Scene/PrimitiveState.js +123 -0
  126. package/Source/Scene/Scene.js +2 -2
  127. package/Source/Scene/VoxelBoundsCollection.js +494 -0
  128. package/Source/Scene/VoxelBoxShape.js +236 -101
  129. package/Source/Scene/VoxelCylinderShape.js +315 -204
  130. package/Source/Scene/VoxelEllipsoidShape.js +402 -119
  131. package/Source/Scene/VoxelPrimitive.js +119 -84
  132. package/Source/Scene/VoxelRenderResources.js +17 -10
  133. package/Source/Scene/VoxelShape.js +21 -6
  134. package/Source/Scene/buildVoxelDrawCommands.js +61 -20
  135. package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -1
  136. package/Source/Scene/getClippingFunction.js +79 -88
  137. package/Source/Shaders/BillboardCollectionVS.glsl +2 -0
  138. package/Source/Shaders/BillboardCollectionVS.js +2 -0
  139. package/Source/Shaders/Voxels/IntersectBox.glsl +20 -33
  140. package/Source/Shaders/Voxels/IntersectBox.js +20 -33
  141. package/Source/Shaders/Voxels/IntersectCylinder.glsl +28 -32
  142. package/Source/Shaders/Voxels/IntersectCylinder.js +28 -32
  143. package/Source/Shaders/Voxels/IntersectDepth.glsl +1 -4
  144. package/Source/Shaders/Voxels/IntersectDepth.js +1 -4
  145. package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +12 -20
  146. package/Source/Shaders/Voxels/IntersectEllipsoid.js +12 -20
  147. package/Source/Shaders/Voxels/IntersectLongitude.glsl +21 -9
  148. package/Source/Shaders/Voxels/IntersectLongitude.js +21 -9
  149. package/Source/Shaders/Voxels/{IntersectClippingPlanes.glsl → IntersectPlane.glsl} +5 -3
  150. package/Source/Shaders/Voxels/{IntersectClippingPlanes.js → IntersectPlane.js} +5 -3
  151. package/Source/Shaders/Voxels/Intersection.glsl +3 -3
  152. package/Source/Shaders/Voxels/Intersection.js +3 -3
  153. package/Source/Shaders/Voxels/Octree.glsl +46 -51
  154. package/Source/Shaders/Voxels/Octree.js +46 -51
  155. package/Source/Shaders/Voxels/VoxelFS.glsl +50 -48
  156. package/Source/Shaders/Voxels/VoxelFS.js +50 -48
  157. package/Source/Shaders/Voxels/VoxelUtils.glsl +0 -19
  158. package/Source/Shaders/Voxels/VoxelUtils.js +0 -19
  159. package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +30 -0
  160. package/Source/Shaders/Voxels/convertLocalToBoxUv.js +32 -0
  161. package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +97 -0
  162. package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +99 -0
  163. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +193 -0
  164. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +195 -0
  165. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -0
  166. package/Source/ThirdParty/zip-module.wasm +0 -0
  167. package/index.d.ts +317 -14
  168. package/index.js +177 -175
  169. package/package.json +2 -2
  170. package/Build/ThirdParty/Workers/pako_deflate.min.js +0 -503
  171. package/Build/ThirdParty/Workers/pako_inflate.min.js +0 -698
  172. package/Build/ThirdParty/Workers/z-worker-pako.js +0 -601
  173. package/Source/Core/defaultValue.js +0 -48
  174. package/Source/Shaders/Voxels/convertUvToBox.glsl +0 -45
  175. package/Source/Shaders/Voxels/convertUvToBox.js +0 -46
  176. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +0 -99
  177. package/Source/Shaders/Voxels/convertUvToCylinder.js +0 -101
  178. package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +0 -139
  179. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +0 -141
  180. package/Source/ThirdParty/Workers/pako_deflate.min.js +0 -2
  181. package/Source/ThirdParty/Workers/pako_inflate.min.js +0 -2
  182. package/Source/ThirdParty/Workers/z-worker-pako.js +0 -1
@@ -5,6 +5,8 @@ import Check from "../Core/Check.js";
5
5
  import Matrix3 from "../Core/Matrix3.js";
6
6
  import Matrix4 from "../Core/Matrix4.js";
7
7
  import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
8
+ import VoxelBoundsCollection from "./VoxelBoundsCollection.js";
9
+ import ClippingPlane from "./ClippingPlane.js";
8
10
 
9
11
  /**
10
12
  * A box {@link VoxelShape}.
@@ -20,100 +22,186 @@ import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
20
22
  * @private
21
23
  */
22
24
  function VoxelBoxShape() {
25
+ this._orientedBoundingBox = new OrientedBoundingBox();
26
+ this._boundingSphere = new BoundingSphere();
27
+ this._boundTransform = new Matrix4();
28
+ this._shapeTransform = new Matrix4();
29
+
23
30
  /**
24
- * An oriented bounding box containing the bounded shape.
25
- * The update function must be called before accessing this value.
31
+ * The minimum bounds of the shape.
32
+ * @type {Cartesian3}
26
33
  * @private
27
- * @type {OrientedBoundingBox}
28
- * @readonly
29
34
  */
30
- this.orientedBoundingBox = new OrientedBoundingBox();
35
+ this._minBounds = VoxelBoxShape.DefaultMinBounds.clone();
31
36
 
32
37
  /**
33
- * A bounding sphere containing the bounded shape.
34
- * The update function must be called before accessing this value.
38
+ * The maximum bounds of the shape.
39
+ * @type {Cartesian3}
35
40
  * @private
36
- * @type {BoundingSphere}
37
- * @readonly
38
41
  */
39
- this.boundingSphere = new BoundingSphere();
42
+ this._maxBounds = VoxelBoxShape.DefaultMaxBounds.clone();
40
43
 
41
44
  /**
42
- * A transformation matrix containing the bounded shape.
43
- * The update function must be called before accessing this value.
45
+ * The minimum render bounds of the shape.
46
+ * @type {Cartesian3}
44
47
  * @private
45
- * @type {Matrix4}
46
- * @readonly
47
48
  */
48
- this.boundTransform = new Matrix4();
49
+ this._renderMinBounds = VoxelBoxShape.DefaultMinBounds.clone();
49
50
 
50
51
  /**
51
- * A transformation matrix containing the shape, ignoring the bounds.
52
- * The update function must be called before accessing this value.
52
+ * The maximum render bounds of the shape.
53
+ * @type {Cartesian3}
53
54
  * @private
54
- * @type {Matrix4}
55
+ */
56
+ this._renderMaxBounds = VoxelBoxShape.DefaultMaxBounds.clone();
57
+
58
+ const { DefaultMinBounds, DefaultMaxBounds } = VoxelBoxShape;
59
+ const boundPlanes = [
60
+ new ClippingPlane(
61
+ Cartesian3.negate(Cartesian3.UNIT_X, new Cartesian3()),
62
+ DefaultMinBounds.x,
63
+ ),
64
+ new ClippingPlane(
65
+ Cartesian3.negate(Cartesian3.UNIT_Y, new Cartesian3()),
66
+ DefaultMinBounds.y,
67
+ ),
68
+ new ClippingPlane(
69
+ Cartesian3.negate(Cartesian3.UNIT_Z, new Cartesian3()),
70
+ DefaultMinBounds.z,
71
+ ),
72
+ new ClippingPlane(Cartesian3.UNIT_X, -DefaultMaxBounds.x),
73
+ new ClippingPlane(Cartesian3.UNIT_Y, -DefaultMaxBounds.y),
74
+ new ClippingPlane(Cartesian3.UNIT_Z, -DefaultMaxBounds.z),
75
+ ];
76
+
77
+ this._renderBoundPlanes = new VoxelBoundsCollection({ planes: boundPlanes });
78
+
79
+ this._shaderUniforms = {
80
+ boxEcToXyz: new Matrix3(),
81
+ boxLocalToShapeUvScale: new Cartesian3(),
82
+ boxLocalToShapeUvTranslate: new Cartesian3(),
83
+ };
84
+
85
+ this._shaderDefines = {
86
+ BOX_INTERSECTION_INDEX: undefined,
87
+ };
88
+
89
+ this._shaderMaximumIntersectionsLength = 0; // not known until update
90
+ }
91
+
92
+ Object.defineProperties(VoxelBoxShape.prototype, {
93
+ /**
94
+ * An oriented bounding box containing the bounded shape.
95
+ *
96
+ * @memberof VoxelBoxShape.prototype
97
+ * @type {OrientedBoundingBox}
55
98
  * @readonly
99
+ * @private
56
100
  */
57
- this.shapeTransform = new Matrix4();
101
+ orientedBoundingBox: {
102
+ get: function () {
103
+ return this._orientedBoundingBox;
104
+ },
105
+ },
58
106
 
59
107
  /**
60
- * The minimum bounds of the shape.
61
- * @type {Cartesian3}
108
+ * A collection of planes used for the render bounds
109
+ * @memberof VoxelBoxShape.prototype
110
+ * @type {VoxelBoundsCollection}
111
+ * @readonly
62
112
  * @private
63
113
  */
64
- this._minBounds = VoxelBoxShape.DefaultMinBounds.clone();
114
+ renderBoundPlanes: {
115
+ get: function () {
116
+ return this._renderBoundPlanes;
117
+ },
118
+ },
65
119
 
66
120
  /**
67
- * The maximum bounds of the shape.
68
- * @type {Cartesian3}
121
+ * A bounding sphere containing the bounded shape.
122
+ *
123
+ * @memberof VoxelBoxShape.prototype
124
+ * @type {BoundingSphere}
125
+ * @readonly
69
126
  * @private
70
127
  */
71
- this._maxBounds = VoxelBoxShape.DefaultMaxBounds.clone();
128
+ boundingSphere: {
129
+ get: function () {
130
+ return this._boundingSphere;
131
+ },
132
+ },
72
133
 
73
134
  /**
135
+ * A transformation matrix containing the bounded shape.
136
+ *
137
+ * @memberof VoxelBoxShape.prototype
138
+ * @type {Matrix4}
139
+ * @readonly
74
140
  * @private
75
- * @type {Object<string, any>}
141
+ */
142
+ boundTransform: {
143
+ get: function () {
144
+ return this._boundTransform;
145
+ },
146
+ },
147
+
148
+ /**
149
+ * A transformation matrix containing the shape, ignoring the bounds.
150
+ *
151
+ * @memberof VoxelBoxShape.prototype
152
+ * @type {Matrix4}
76
153
  * @readonly
154
+ * @private
77
155
  */
78
- this.shaderUniforms = {
79
- renderMinBounds: new Cartesian3(),
80
- renderMaxBounds: new Cartesian3(),
81
- boxUvToShapeUvScale: new Cartesian3(),
82
- boxUvToShapeUvTranslate: new Cartesian3(),
83
- };
156
+ shapeTransform: {
157
+ get: function () {
158
+ return this._shapeTransform;
159
+ },
160
+ },
84
161
 
85
162
  /**
163
+ * @memberof VoxelBoxShape.prototype
164
+ * @type {Object<string, any>}
165
+ * @readonly
86
166
  * @private
167
+ */
168
+ shaderUniforms: {
169
+ get: function () {
170
+ return this._shaderUniforms;
171
+ },
172
+ },
173
+
174
+ /**
175
+ * @memberof VoxelBoxShape.prototype
87
176
  * @type {Object<string, any>}
88
177
  * @readonly
178
+ * @private
89
179
  */
90
- this.shaderDefines = {
91
- BOX_INTERSECTION_INDEX: undefined,
92
- BOX_HAS_SHAPE_BOUNDS: undefined,
93
- };
180
+ shaderDefines: {
181
+ get: function () {
182
+ return this._shaderDefines;
183
+ },
184
+ },
94
185
 
95
186
  /**
96
187
  * The maximum number of intersections against the shape for any ray direction.
97
- * @private
188
+ * @memberof VoxelBoxShape.prototype
98
189
  * @type {number}
99
190
  * @readonly
191
+ * @private
100
192
  */
101
- this.shaderMaximumIntersectionsLength = 0; // not known until update
102
- }
193
+ shaderMaximumIntersectionsLength: {
194
+ get: function () {
195
+ return this._shaderMaximumIntersectionsLength;
196
+ },
197
+ },
198
+ });
103
199
 
104
200
  const scratchCenter = new Cartesian3();
105
201
  const scratchScale = new Cartesian3();
106
202
  const scratchRotation = new Matrix3();
107
203
  const scratchClipMinBounds = new Cartesian3();
108
204
  const scratchClipMaxBounds = new Cartesian3();
109
- const scratchRenderMinBounds = new Cartesian3();
110
- const scratchRenderMaxBounds = new Cartesian3();
111
-
112
- const transformLocalToUv = Matrix4.fromRotationTranslation(
113
- Matrix3.fromUniformScale(0.5, new Matrix3()),
114
- new Cartesian3(0.5, 0.5, 0.5),
115
- new Matrix4(),
116
- );
117
205
 
118
206
  /**
119
207
  * Update the shape's state.
@@ -148,13 +236,13 @@ VoxelBoxShape.prototype.update = function (
148
236
  minBounds,
149
237
  clipMinBounds,
150
238
  clipMaxBounds,
151
- scratchRenderMinBounds,
239
+ this._renderMinBounds,
152
240
  );
153
241
  const renderMaxBounds = Cartesian3.clamp(
154
242
  maxBounds,
155
243
  clipMinBounds,
156
244
  clipMaxBounds,
157
- scratchRenderMaxBounds,
245
+ this._renderMaxBounds,
158
246
  );
159
247
 
160
248
  // Box is not visible if:
@@ -177,29 +265,39 @@ VoxelBoxShape.prototype.update = function (
177
265
  return false;
178
266
  }
179
267
 
180
- this.shapeTransform = Matrix4.clone(modelMatrix, this.shapeTransform);
268
+ // Update the render bounds planes
269
+ const renderBoundPlanes = this._renderBoundPlanes;
270
+ renderBoundPlanes.get(0).distance = renderMinBounds.x;
271
+ renderBoundPlanes.get(1).distance = renderMinBounds.y;
272
+ renderBoundPlanes.get(2).distance = renderMinBounds.z;
273
+ renderBoundPlanes.get(3).distance = -renderMaxBounds.x;
274
+ renderBoundPlanes.get(4).distance = -renderMaxBounds.y;
275
+ renderBoundPlanes.get(5).distance = -renderMaxBounds.z;
181
276
 
182
- this.orientedBoundingBox = getBoxChunkObb(
277
+ this._shapeTransform = Matrix4.clone(modelMatrix, this._shapeTransform);
278
+
279
+ this._orientedBoundingBox = getBoxChunkObb(
183
280
  renderMinBounds,
184
281
  renderMaxBounds,
185
- this.shapeTransform,
186
- this.orientedBoundingBox,
282
+ this._shapeTransform,
283
+ this._orientedBoundingBox,
187
284
  );
188
285
 
189
286
  // All of the box bounds go from -1 to +1, so the model matrix scale can be
190
287
  // used as the oriented bounding box half axes.
191
- this.boundTransform = Matrix4.fromRotationTranslation(
192
- this.orientedBoundingBox.halfAxes,
193
- this.orientedBoundingBox.center,
194
- this.boundTransform,
288
+ this._boundTransform = Matrix4.fromRotationTranslation(
289
+ this._orientedBoundingBox.halfAxes,
290
+ this._orientedBoundingBox.center,
291
+ this._boundTransform,
195
292
  );
196
293
 
197
- this.boundingSphere = BoundingSphere.fromOrientedBoundingBox(
198
- this.orientedBoundingBox,
199
- this.boundingSphere,
294
+ this._boundingSphere = BoundingSphere.fromOrientedBoundingBox(
295
+ this._orientedBoundingBox,
296
+ this._boundingSphere,
200
297
  );
201
298
 
202
- const { shaderUniforms, shaderDefines } = this;
299
+ const shaderUniforms = this._shaderUniforms;
300
+ const shaderDefines = this._shaderDefines;
203
301
 
204
302
  // To keep things simple, clear the defines every time
205
303
  for (const key in shaderDefines) {
@@ -214,49 +312,87 @@ VoxelBoxShape.prototype.update = function (
214
312
  shaderDefines["BOX_INTERSECTION_INDEX"] = intersectionCount;
215
313
  intersectionCount += 1;
216
314
 
217
- shaderUniforms.renderMinBounds = Matrix4.multiplyByPoint(
218
- transformLocalToUv,
219
- renderMinBounds,
220
- shaderUniforms.renderMinBounds,
315
+ // Compute scale and translation to transform from UV space to bounded UV space
316
+ const min = minBounds;
317
+ const max = maxBounds;
318
+ const boxLocalToShapeUvScale = Cartesian3.fromElements(
319
+ boundScale(min.x, max.x),
320
+ boundScale(min.y, max.y),
321
+ boundScale(min.z, max.z),
322
+ shaderUniforms.boxLocalToShapeUvScale,
221
323
  );
222
- shaderUniforms.renderMaxBounds = Matrix4.multiplyByPoint(
223
- transformLocalToUv,
224
- renderMaxBounds,
225
- shaderUniforms.renderMaxBounds,
324
+ shaderUniforms.boxLocalToShapeUvTranslate = Cartesian3.negate(
325
+ Cartesian3.multiplyComponents(
326
+ boxLocalToShapeUvScale,
327
+ min,
328
+ shaderUniforms.boxLocalToShapeUvTranslate,
329
+ ),
330
+ shaderUniforms.boxLocalToShapeUvTranslate,
226
331
  );
227
332
 
228
- shaderDefines["BOX_HAS_SHAPE_BOUNDS"] = true;
333
+ this._shaderMaximumIntersectionsLength = intersectionCount;
229
334
 
230
- const min = minBounds;
231
- const max = maxBounds;
335
+ return true;
336
+ };
232
337
 
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
- );
338
+ function boundScale(minBound, maxBound) {
339
+ return CesiumMath.equalsEpsilon(minBound, maxBound, CesiumMath.EPSILON7)
340
+ ? 1.0
341
+ : 1.0 / (maxBound - minBound);
342
+ }
249
343
 
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,
344
+ const scratchTransformPositionWorldToLocal = new Matrix4();
345
+ /**
346
+ * Update any view-dependent transforms.
347
+ * @private
348
+ * @param {FrameState} frameState The frame state.
349
+ */
350
+ VoxelBoxShape.prototype.updateViewTransforms = function (frameState) {
351
+ const shaderUniforms = this._shaderUniforms;
352
+ const transformPositionWorldToLocal = Matrix4.inverse(
353
+ this._shapeTransform,
354
+ scratchTransformPositionWorldToLocal,
355
+ );
356
+ const transformDirectionWorldToLocal = Matrix4.getMatrix3(
357
+ transformPositionWorldToLocal,
358
+ shaderUniforms.boxEcToXyz,
255
359
  );
360
+ const rotateViewToWorld = frameState.context.uniformState.inverseViewRotation;
361
+ Matrix3.multiply(
362
+ transformDirectionWorldToLocal,
363
+ rotateViewToWorld,
364
+ shaderUniforms.boxEcToXyz,
365
+ );
366
+ };
256
367
 
257
- this.shaderMaximumIntersectionsLength = intersectionCount;
368
+ /**
369
+ * Convert a local coordinate to the shape's UV space.
370
+ * @private
371
+ * @param {Cartesian3} positionLocal The local coordinate to convert.
372
+ * @param {Cartesian3} result The Cartesian3 to store the result in.
373
+ * @returns {Cartesian3} The converted UV coordinate.
374
+ */
375
+ VoxelBoxShape.prototype.convertLocalToShapeUvSpace = function (
376
+ positionLocal,
377
+ result,
378
+ ) {
379
+ //>>includeStart('debug', pragmas.debug);
380
+ Check.typeOf.object("positionLocal", positionLocal);
381
+ Check.typeOf.object("result", result);
382
+ //>>includeEnd('debug');
258
383
 
259
- return true;
384
+ const { boxLocalToShapeUvScale, boxLocalToShapeUvTranslate } =
385
+ this._shaderUniforms;
386
+
387
+ return Cartesian3.add(
388
+ Cartesian3.multiplyComponents(
389
+ positionLocal,
390
+ boxLocalToShapeUvScale,
391
+ result,
392
+ ),
393
+ boxLocalToShapeUvTranslate,
394
+ result,
395
+ );
260
396
  };
261
397
 
262
398
  const scratchTileMinBounds = new Cartesian3();
@@ -264,7 +400,6 @@ const scratchTileMaxBounds = new Cartesian3();
264
400
 
265
401
  /**
266
402
  * Computes an oriented bounding box for a specified tile.
267
- * The update function must be called before calling this function.
268
403
  * @private
269
404
  * @param {number} tileLevel The tile's level.
270
405
  * @param {number} tileX The tile's x coordinate.
@@ -309,7 +444,7 @@ VoxelBoxShape.prototype.computeOrientedBoundingBoxForTile = function (
309
444
  return getBoxChunkObb(
310
445
  tileMinBounds,
311
446
  tileMaxBounds,
312
- this.shapeTransform,
447
+ this._shapeTransform,
313
448
  result,
314
449
  );
315
450
  };
@@ -318,7 +453,6 @@ const sampleSizeScratch = new Cartesian3();
318
453
 
319
454
  /**
320
455
  * Computes an oriented bounding box for a specified sample within a specified tile.
321
- * The update function must be called before calling this function.
322
456
  * @private
323
457
  * @param {SpatialNode} spatialNode The spatial node containing the sample
324
458
  * @param {Cartesian3} tileDimensions The size of the tile in number of samples, before padding
@@ -385,7 +519,7 @@ VoxelBoxShape.prototype.computeOrientedBoundingBoxForSample = function (
385
519
  return getBoxChunkObb(
386
520
  sampleMinBounds,
387
521
  sampleMaxBounds,
388
- this.shapeTransform,
522
+ this._shapeTransform,
389
523
  result,
390
524
  );
391
525
  };
@@ -412,6 +546,7 @@ VoxelBoxShape.DefaultMaxBounds = Object.freeze(
412
546
  new Cartesian3(+1.0, +1.0, +1.0),
413
547
  );
414
548
 
549
+ const scratchBoxScale = new Cartesian3();
415
550
  /**
416
551
  * Computes an {@link OrientedBoundingBox} for a subregion of the shape.
417
552
  *
@@ -437,7 +572,7 @@ function getBoxChunkObb(minimumBounds, maximumBounds, matrix, result) {
437
572
  result.center = Matrix4.getTranslation(matrix, result.center);
438
573
  result.halfAxes = Matrix4.getMatrix3(matrix, result.halfAxes);
439
574
  } else {
440
- let scale = Matrix4.getScale(matrix, scratchScale);
575
+ let scale = Matrix4.getScale(matrix, scratchBoxScale);
441
576
  const localCenter = Cartesian3.midpoint(
442
577
  minimumBounds,
443
578
  maximumBounds,
@@ -448,7 +583,7 @@ function getBoxChunkObb(minimumBounds, maximumBounds, matrix, result) {
448
583
  scale.x * 0.5 * (maximumBounds.x - minimumBounds.x),
449
584
  scale.y * 0.5 * (maximumBounds.y - minimumBounds.y),
450
585
  scale.z * 0.5 * (maximumBounds.z - minimumBounds.z),
451
- scratchScale,
586
+ scratchBoxScale,
452
587
  );
453
588
  const rotation = Matrix4.getRotation(matrix, scratchRotation);
454
589
  result.halfAxes = Matrix3.setScale(rotation, scale, result.halfAxes);