@cesium/engine 7.0.0 → 9.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 (200) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +1 -5
  2. package/Build/Workers/{chunk-7XEAYGZK.js → chunk-24YTYWNB.js} +10 -10
  3. package/Build/Workers/{chunk-IQBYFRVW.js → chunk-2632RVPI.js} +7 -7
  4. package/Build/Workers/chunk-2KACWKS4.js +501 -0
  5. package/Build/Workers/{chunk-QZAD5O7I.js → chunk-2XPLH3JY.js} +7 -7
  6. package/Build/Workers/{chunk-JY5YEZFA.js → chunk-2ZBL3MVO.js} +8 -8
  7. package/Build/Workers/{chunk-ZK5JOS3D.js → chunk-3NCVAGDA.js} +14 -14
  8. package/Build/Workers/{chunk-AR5DNBJ4.js → chunk-5R6VWLMH.js} +6 -6
  9. package/Build/Workers/{chunk-PTQQUQC3.js → chunk-5TIV3L26.js} +13 -13
  10. package/Build/Workers/{chunk-BZP4T2JJ.js → chunk-6WF3KIF5.js} +10 -10
  11. package/Build/Workers/{chunk-5WQ523AW.js → chunk-73FKKY52.js} +5 -5
  12. package/Build/Workers/{chunk-F6SE42BK.js → chunk-7COR472O.js} +15 -472
  13. package/Build/Workers/{chunk-72SANQJV.js → chunk-ADOVHYWO.js} +9 -5
  14. package/Build/Workers/{chunk-5YLJ77FF.js → chunk-BCU2LH5T.js} +12 -11
  15. package/Build/Workers/{chunk-4EBHOMFX.js → chunk-C3XBUYBO.js} +17 -17
  16. package/Build/Workers/{chunk-IX2JCCNM.js → chunk-C6OI26DR.js} +1 -1
  17. package/Build/Workers/{chunk-2HJWSU7B.js → chunk-CO35JNNE.js} +4 -4
  18. package/Build/Workers/{chunk-OVLG3FRS.js → chunk-DGDUKCJJ.js} +6 -6
  19. package/Build/Workers/{chunk-DTAIXKTO.js → chunk-DPUSFA7S.js} +6 -6
  20. package/Build/Workers/{chunk-R5X4OQT4.js → chunk-E6WXPSJS.js} +7 -7
  21. package/Build/Workers/{chunk-VK3EJHWI.js → chunk-EOXYZ34O.js} +2 -2
  22. package/Build/Workers/{chunk-RAEV7K66.js → chunk-EPKE7GE3.js} +5 -5
  23. package/Build/Workers/{chunk-GV56Q4LU.js → chunk-GFA4SMXV.js} +11 -11
  24. package/Build/Workers/{chunk-NKPBIX7F.js → chunk-GXUXEOE2.js} +1 -1
  25. package/Build/Workers/{chunk-NY3K4IM3.js → chunk-HBQPB6IH.js} +12 -12
  26. package/Build/Workers/{chunk-6HZQPRUS.js → chunk-I37B3MZ2.js} +1 -1
  27. package/Build/Workers/{chunk-VRGFV2UO.js → chunk-L4BW3RUA.js} +10 -10
  28. package/Build/Workers/{chunk-6VJVYK2V.js → chunk-LAQP3SCC.js} +2 -2
  29. package/Build/Workers/{chunk-PNBGBETF.js → chunk-LQJ5FFFR.js} +10 -10
  30. package/Build/Workers/{chunk-UAEW6HKG.js → chunk-M2AYBTNH.js} +13 -13
  31. package/Build/Workers/{chunk-YUCVWAY6.js → chunk-MWV7IZK4.js} +7 -7
  32. package/Build/Workers/{chunk-JXDC723O.js → chunk-N4KXMWQU.js} +2 -2
  33. package/Build/Workers/{chunk-XWXM2O2R.js → chunk-NP2GYYE5.js} +6 -6
  34. package/Build/Workers/{chunk-GEJTYLCO.js → chunk-NZWNZA6S.js} +5 -5
  35. package/Build/Workers/{chunk-LZGHD6NY.js → chunk-P2YAAMT2.js} +15 -15
  36. package/Build/Workers/{chunk-S6SKF6DT.js → chunk-P4XKB3QZ.js} +5 -5
  37. package/Build/Workers/{chunk-U2VCRRQW.js → chunk-PXB7T27O.js} +6 -6
  38. package/Build/Workers/{chunk-RV7ZYPFT.js → chunk-QCQUZGXI.js} +4 -4
  39. package/Build/Workers/{chunk-JJ4VBOQ3.js → chunk-QKBGRKKG.js} +4 -4
  40. package/Build/Workers/{chunk-ODW7WYM4.js → chunk-RMOEYCZW.js} +2 -2
  41. package/Build/Workers/{chunk-ZUA2UUNV.js → chunk-RSJXEO2A.js} +2 -2
  42. package/Build/Workers/{chunk-UDO6BFSF.js → chunk-RV7ZOSS6.js} +13 -13
  43. package/Build/Workers/{chunk-LZ7JIV3K.js → chunk-SE4PXOEA.js} +17 -17
  44. package/Build/Workers/{chunk-S4MAZ3SS.js → chunk-SS4ESNE3.js} +2 -2
  45. package/Build/Workers/{chunk-AIPU2VSX.js → chunk-TJBU6GML.js} +6 -6
  46. package/Build/Workers/{chunk-5M3U6ZMA.js → chunk-TZORKRNK.js} +1 -1
  47. package/Build/Workers/{chunk-MY3VNFGQ.js → chunk-VR5RBW52.js} +7 -7
  48. package/Build/Workers/{chunk-FP6GYBFX.js → chunk-WHUSTDIB.js} +10 -10
  49. package/Build/Workers/{chunk-5HDYHG3F.js → chunk-X2F6BEPY.js} +13 -13
  50. package/Build/Workers/{chunk-WZU2YLWG.js → chunk-X6XOMPWL.js} +3 -3
  51. package/Build/Workers/{chunk-UGK3FCDY.js → chunk-YDVSBWEO.js} +1 -1
  52. package/Build/Workers/{chunk-46UD5ABS.js → chunk-YV4H2Y7M.js} +4 -4
  53. package/Build/Workers/{chunk-WBQCVXR3.js → chunk-Z7FQLK6N.js} +4 -4
  54. package/Build/Workers/{chunk-L2ZN645J.js → chunk-ZNVSKMQ2.js} +6 -6
  55. package/Build/Workers/{chunk-JCNXK6EL.js → chunk-ZYPTP7GS.js} +11 -11
  56. package/Build/Workers/combineGeometry.js +24 -23
  57. package/Build/Workers/createBoxGeometry.js +18 -17
  58. package/Build/Workers/createBoxOutlineGeometry.js +16 -15
  59. package/Build/Workers/createCircleGeometry.js +26 -25
  60. package/Build/Workers/createCircleOutlineGeometry.js +19 -18
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -32
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
  63. package/Build/Workers/createCorridorGeometry.js +29 -28
  64. package/Build/Workers/createCorridorOutlineGeometry.js +28 -27
  65. package/Build/Workers/createCylinderGeometry.js +20 -19
  66. package/Build/Workers/createCylinderOutlineGeometry.js +18 -17
  67. package/Build/Workers/createEllipseGeometry.js +26 -25
  68. package/Build/Workers/createEllipseOutlineGeometry.js +19 -18
  69. package/Build/Workers/createEllipsoidGeometry.js +19 -18
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -17
  71. package/Build/Workers/createFrustumGeometry.js +18 -17
  72. package/Build/Workers/createFrustumOutlineGeometry.js +18 -17
  73. package/Build/Workers/createGeometry.js +54 -33
  74. package/Build/Workers/createGroundPolylineGeometry.js +22 -21
  75. package/Build/Workers/createPlaneGeometry.js +16 -15
  76. package/Build/Workers/createPlaneOutlineGeometry.js +15 -14
  77. package/Build/Workers/createPolygonGeometry.js +33 -32
  78. package/Build/Workers/createPolygonOutlineGeometry.js +30 -29
  79. package/Build/Workers/createPolylineGeometry.js +25 -24
  80. package/Build/Workers/createPolylineVolumeGeometry.js +31 -30
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -26
  82. package/Build/Workers/createRectangleGeometry.js +27 -26
  83. package/Build/Workers/createRectangleOutlineGeometry.js +20 -19
  84. package/Build/Workers/createSimplePolylineGeometry.js +23 -22
  85. package/Build/Workers/createSphereGeometry.js +19 -18
  86. package/Build/Workers/createSphereOutlineGeometry.js +18 -17
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  89. package/Build/Workers/createVectorTileGeometries.js +24 -23
  90. package/Build/Workers/createVectorTilePoints.js +12 -12
  91. package/Build/Workers/createVectorTilePolygons.js +22 -21
  92. package/Build/Workers/createVectorTilePolylines.js +14 -14
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
  94. package/Build/Workers/createVerticesFromHeightmap.js +22 -21
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
  96. package/Build/Workers/createWallGeometry.js +24 -23
  97. package/Build/Workers/createWallOutlineGeometry.js +23 -22
  98. package/Build/Workers/decodeDraco.js +11 -11
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  100. package/Build/Workers/decodeI3S.js +601 -92
  101. package/Build/Workers/transcodeKTX2.js +7 -7
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -21
  104. package/Source/Core/Check.d.ts +127 -0
  105. package/Source/Core/Check.js +0 -1
  106. package/Source/Core/Ellipsoid.js +6 -0
  107. package/Source/Core/Geometry.js +1 -1
  108. package/Source/Core/IntersectionTests.js +6 -3
  109. package/Source/Core/Ion.js +1 -1
  110. package/Source/Core/PixelFormat.js +5 -0
  111. package/Source/Core/PolygonGeometry.js +1 -1
  112. package/Source/Core/Transforms.js +3 -0
  113. package/Source/Core/VerticalExaggeration.js +2 -1
  114. package/Source/Core/srgbToLinear.js +32 -0
  115. package/Source/DataSources/CzmlDataSource.js +51 -23
  116. package/Source/DataSources/DataSourceDisplay.js +27 -0
  117. package/Source/DataSources/Entity.js +20 -2
  118. package/Source/DataSources/GeometryUpdaterSet.js +114 -0
  119. package/Source/DataSources/GeometryVisualizer.js +19 -83
  120. package/Source/Renderer/Context.js +10 -0
  121. package/Source/Renderer/ContextLimits.js +2 -0
  122. package/Source/Renderer/demodernizeShader.js +4 -1
  123. package/Source/Scene/ArcGisMapService.js +1 -1
  124. package/Source/Scene/Axis.js +12 -7
  125. package/Source/Scene/Billboard.js +32 -0
  126. package/Source/Scene/BillboardCollection.js +1 -1
  127. package/Source/Scene/BingMapsImageryProvider.js +4 -0
  128. package/Source/Scene/Camera.js +46 -4
  129. package/Source/Scene/Cesium3DTilesVoxelProvider.js +2 -9
  130. package/Source/Scene/Cesium3DTileset.js +10 -7
  131. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +2 -4
  132. package/Source/Scene/FrameState.js +5 -0
  133. package/Source/Scene/Globe.js +0 -67
  134. package/Source/Scene/GlobeTranslucencyState.js +1 -1
  135. package/Source/Scene/GltfPipeline/updateVersion.js +69 -68
  136. package/Source/Scene/I3SDataProvider.js +270 -53
  137. package/Source/Scene/I3SDecoder.js +8 -1
  138. package/Source/Scene/I3SFeature.js +2 -5
  139. package/Source/Scene/I3SField.js +136 -31
  140. package/Source/Scene/I3SGeometry.js +70 -2
  141. package/Source/Scene/I3SLayer.js +55 -10
  142. package/Source/Scene/I3SNode.js +175 -18
  143. package/Source/Scene/I3SStatistics.js +94 -0
  144. package/Source/Scene/I3SSublayer.js +176 -0
  145. package/Source/Scene/I3SSymbology.js +337 -0
  146. package/Source/Scene/KeyframeNode.js +1 -1
  147. package/Source/Scene/Label.js +33 -0
  148. package/Source/Scene/LabelCollection.js +2 -1
  149. package/Source/Scene/Model/pickModel.js +25 -7
  150. package/Source/Scene/PickFramebuffer.js +37 -2
  151. package/Source/Scene/Picking.js +113 -39
  152. package/Source/Scene/Primitive.js +6 -5
  153. package/Source/Scene/Scene.js +126 -42
  154. package/Source/Scene/ScreenSpaceCameraController.js +21 -7
  155. package/Source/Scene/SensorVolumePortionToDisplay.js +69 -0
  156. package/Source/Scene/SpatialNode.js +12 -19
  157. package/Source/Scene/StructuralMetadata.js +1 -1
  158. package/Source/Scene/VoxelBoxShape.js +67 -6
  159. package/Source/Scene/VoxelCell.js +273 -0
  160. package/Source/Scene/VoxelCylinderShape.js +117 -163
  161. package/Source/Scene/VoxelEllipsoidShape.js +255 -304
  162. package/Source/Scene/VoxelPrimitive.js +109 -15
  163. package/Source/Scene/VoxelRenderResources.js +12 -3
  164. package/Source/Scene/VoxelShape.js +7 -4
  165. package/Source/Scene/VoxelTraversal.js +76 -54
  166. package/Source/Scene/buildVoxelDrawCommands.js +23 -0
  167. package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -0
  168. package/Source/Scene/processVoxelProperties.js +3 -0
  169. package/Source/Shaders/Voxels/IntersectBox.glsl +21 -47
  170. package/Source/Shaders/Voxels/IntersectBox.js +21 -47
  171. package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +1 -1
  172. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +1 -1
  173. package/Source/Shaders/Voxels/IntersectCylinder.glsl +76 -203
  174. package/Source/Shaders/Voxels/IntersectCylinder.js +76 -203
  175. package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +220 -229
  176. package/Source/Shaders/Voxels/IntersectEllipsoid.js +220 -229
  177. package/Source/Shaders/Voxels/IntersectLongitude.glsl +102 -0
  178. package/Source/Shaders/Voxels/IntersectLongitude.js +104 -0
  179. package/Source/Shaders/Voxels/IntersectionUtils.glsl +33 -11
  180. package/Source/Shaders/Voxels/IntersectionUtils.js +33 -11
  181. package/Source/Shaders/Voxels/Megatexture.glsl +1 -2
  182. package/Source/Shaders/Voxels/Megatexture.js +1 -2
  183. package/Source/Shaders/Voxels/Octree.glsl +14 -9
  184. package/Source/Shaders/Voxels/Octree.js +14 -9
  185. package/Source/Shaders/Voxels/VoxelFS.glsl +128 -40
  186. package/Source/Shaders/Voxels/VoxelFS.js +128 -40
  187. package/Source/Shaders/Voxels/VoxelUtils.glsl +31 -0
  188. package/Source/Shaders/Voxels/VoxelUtils.js +33 -0
  189. package/Source/Shaders/Voxels/convertUvToBox.glsl +24 -3
  190. package/Source/Shaders/Voxels/convertUvToBox.js +24 -4
  191. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +64 -40
  192. package/Source/Shaders/Voxels/convertUvToCylinder.js +64 -40
  193. package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +100 -91
  194. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +100 -91
  195. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  196. package/Source/Workers/createGeometry.js +40 -11
  197. package/Source/Workers/decodeI3S.js +720 -94
  198. package/index.d.ts +542 -40
  199. package/index.js +75 -66
  200. package/package.json +2 -2
@@ -95,16 +95,16 @@ function VoxelEllipsoidShape() {
95
95
  */
96
96
  this.shaderUniforms = {
97
97
  ellipsoidRadiiUv: new Cartesian3(),
98
+ eccentricitySquared: 0.0,
99
+ evoluteScale: new Cartesian2(),
98
100
  ellipsoidInverseRadiiSquaredUv: new Cartesian3(),
99
101
  ellipsoidRenderLongitudeMinMax: new Cartesian2(),
100
102
  ellipsoidShapeUvLongitudeMinMaxMid: new Cartesian3(),
101
103
  ellipsoidUvToShapeUvLongitude: new Cartesian2(),
102
104
  ellipsoidUvToShapeUvLatitude: new Cartesian2(),
103
- ellipsoidRenderLatitudeCosSqrHalfMinMax: new Cartesian2(),
105
+ ellipsoidRenderLatitudeSinMinMax: new Cartesian2(),
104
106
  ellipsoidInverseHeightDifferenceUv: 0.0,
105
- ellipseInnerRadiiUv: new Cartesian2(),
106
- ellipsoidInverseInnerScaleUv: 0.0,
107
- ellipsoidInverseOuterScaleUv: 0.0,
107
+ clipMinMaxHeight: new Cartesian2(),
108
108
  };
109
109
 
110
110
  /**
@@ -115,29 +115,18 @@ function VoxelEllipsoidShape() {
115
115
  ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE: undefined,
116
116
  ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO: undefined,
117
117
  ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_UNDER_HALF: undefined,
118
- ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_HALF: undefined,
119
118
  ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF: undefined,
120
119
  ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY: undefined,
121
120
  ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY: undefined,
122
121
  ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE: undefined,
123
- ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO: undefined,
124
122
  ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED: undefined,
125
- ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE: undefined,
126
123
  ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF: undefined,
127
124
  ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_EQUAL_HALF: undefined,
128
125
  ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF: undefined,
129
126
  ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF: undefined,
130
127
  ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF: undefined,
131
128
  ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF: undefined,
132
- ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_RANGE_EQUAL_ZERO: undefined,
133
129
  ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE: undefined,
134
- ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE_RANGE_EQUAL_ZERO: undefined,
135
- ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MAX: undefined,
136
- ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MIN: undefined,
137
- ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_FLAT: undefined,
138
- ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_MIN: undefined,
139
- ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_FLAT: undefined,
140
- ELLIPSOID_IS_SPHERE: undefined,
141
130
  ELLIPSOID_INTERSECTION_INDEX_LONGITUDE: undefined,
142
131
  ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX: undefined,
143
132
  ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN: undefined,
@@ -153,12 +142,17 @@ function VoxelEllipsoidShape() {
153
142
  this.shaderMaximumIntersectionsLength = 0; // not known until update
154
143
  }
155
144
 
145
+ const scratchActualMinBounds = new Cartesian3();
146
+ const scratchShapeMinBounds = new Cartesian3();
147
+ const scratchShapeMaxBounds = new Cartesian3();
148
+ const scratchClipMinBounds = new Cartesian3();
149
+ const scratchClipMaxBounds = new Cartesian3();
150
+ const scratchRenderMinBounds = new Cartesian3();
151
+ const scratchRenderMaxBounds = new Cartesian3();
156
152
  const scratchScale = new Cartesian3();
157
153
  const scratchRotationScale = new Matrix3();
158
154
  const scratchShapeOuterExtent = new Cartesian3();
159
- const scratchShapeInnerExtent = new Cartesian3();
160
155
  const scratchRenderOuterExtent = new Cartesian3();
161
- const scratchRenderInnerExtent = new Cartesian3();
162
156
  const scratchRenderRectangle = new Rectangle();
163
157
 
164
158
  /**
@@ -178,132 +172,83 @@ VoxelEllipsoidShape.prototype.update = function (
178
172
  clipMinBounds,
179
173
  clipMaxBounds
180
174
  ) {
181
- clipMinBounds = defaultValue(
182
- clipMinBounds,
183
- VoxelEllipsoidShape.DefaultMinBounds
184
- );
185
- clipMaxBounds = defaultValue(
186
- clipMaxBounds,
187
- VoxelEllipsoidShape.DefaultMaxBounds
188
- );
175
+ const { DefaultMinBounds, DefaultMaxBounds } = VoxelEllipsoidShape;
176
+ clipMinBounds = defaultValue(clipMinBounds, DefaultMinBounds);
177
+ clipMaxBounds = defaultValue(clipMaxBounds, DefaultMaxBounds);
189
178
  //>>includeStart('debug', pragmas.debug);
190
179
  Check.typeOf.object("modelMatrix", modelMatrix);
191
180
  Check.typeOf.object("minBounds", minBounds);
192
181
  Check.typeOf.object("maxBounds", maxBounds);
193
182
  //>>includeEnd('debug');
194
183
 
195
- const defaultMinLongitude = VoxelEllipsoidShape.DefaultMinBounds.x;
196
- const defaultMaxLongitude = VoxelEllipsoidShape.DefaultMaxBounds.x;
197
- const defaultLongitudeRange = defaultMaxLongitude - defaultMinLongitude;
198
- const defaultLongitudeRangeHalf = 0.5 * defaultLongitudeRange;
199
- const defaultMinLatitude = VoxelEllipsoidShape.DefaultMinBounds.y;
200
- const defaultMaxLatitude = VoxelEllipsoidShape.DefaultMaxBounds.y;
201
- const defaultLatitudeRange = defaultMaxLatitude - defaultMinLatitude;
202
-
203
184
  const epsilonZeroScale = CesiumMath.EPSILON10;
204
185
  const epsilonLongitudeDiscontinuity = CesiumMath.EPSILON3; // 0.001 radians = 0.05729578 degrees
205
186
  const epsilonLongitude = CesiumMath.EPSILON10;
206
187
  const epsilonLatitude = CesiumMath.EPSILON10;
207
188
  const epsilonLatitudeFlat = CesiumMath.EPSILON3; // 0.001 radians = 0.05729578 degrees
208
189
 
209
- // Clamp the longitude / latitude to the valid range
210
- const shapeMinLongitude = CesiumMath.clamp(
211
- minBounds.x,
212
- defaultMinLongitude,
213
- defaultMaxLongitude
214
- );
215
- const shapeMaxLongitude = CesiumMath.clamp(
216
- maxBounds.x,
217
- defaultMinLongitude,
218
- defaultMaxLongitude
190
+ // Don't let the height go below the center of the ellipsoid.
191
+ const radii = Matrix4.getScale(modelMatrix, scratchScale);
192
+ const actualMinBounds = Cartesian3.clone(
193
+ DefaultMinBounds,
194
+ scratchActualMinBounds
219
195
  );
220
- const clipMinLongitude = CesiumMath.clamp(
221
- clipMinBounds.x,
222
- defaultMinLongitude,
223
- defaultMaxLongitude
196
+ actualMinBounds.z = -Cartesian3.minimumComponent(radii);
197
+
198
+ const shapeMinBounds = Cartesian3.clamp(
199
+ minBounds,
200
+ actualMinBounds,
201
+ DefaultMaxBounds,
202
+ scratchShapeMinBounds
224
203
  );
225
- const clipMaxLongitude = CesiumMath.clamp(
226
- clipMaxBounds.x,
227
- defaultMinLongitude,
228
- defaultMaxLongitude
204
+ const shapeMaxBounds = Cartesian3.clamp(
205
+ maxBounds,
206
+ actualMinBounds,
207
+ DefaultMaxBounds,
208
+ scratchShapeMaxBounds
229
209
  );
230
- const renderMinLongitude = Math.max(shapeMinLongitude, clipMinLongitude);
231
- const renderMaxLongitude = Math.min(shapeMaxLongitude, clipMaxLongitude);
232
-
233
- const shapeMinLatitude = CesiumMath.clamp(
234
- minBounds.y,
235
- defaultMinLatitude,
236
- defaultMaxLatitude
210
+ const clampedClipMinBounds = Cartesian3.clamp(
211
+ clipMinBounds,
212
+ actualMinBounds,
213
+ DefaultMaxBounds,
214
+ scratchClipMinBounds
237
215
  );
238
- const shapeMaxLatitude = CesiumMath.clamp(
239
- maxBounds.y,
240
- defaultMinLatitude,
241
- defaultMaxLatitude
216
+ const clampedClipMaxBounds = Cartesian3.clamp(
217
+ clipMaxBounds,
218
+ actualMinBounds,
219
+ DefaultMaxBounds,
220
+ scratchClipMaxBounds
242
221
  );
243
- const clipMinLatitude = CesiumMath.clamp(
244
- clipMinBounds.y,
245
- defaultMinLatitude,
246
- defaultMaxLatitude
222
+ const renderMinBounds = Cartesian3.maximumByComponent(
223
+ shapeMinBounds,
224
+ clampedClipMinBounds,
225
+ scratchRenderMinBounds
247
226
  );
248
- const clipMaxLatitude = CesiumMath.clamp(
249
- clipMaxBounds.y,
250
- defaultMinLatitude,
251
- defaultMaxLatitude
227
+ const renderMaxBounds = Cartesian3.minimumByComponent(
228
+ shapeMaxBounds,
229
+ clampedClipMaxBounds,
230
+ scratchRenderMaxBounds
252
231
  );
253
232
 
254
- const renderMinLatitude = Math.max(shapeMinLatitude, clipMinLatitude);
255
- const renderMaxLatitude = Math.min(shapeMaxLatitude, clipMaxLatitude);
256
-
257
- // Don't let the height go below the center of the ellipsoid.
258
- const radii = Matrix4.getScale(modelMatrix, scratchScale);
259
- const isSphere = radii.x === radii.y && radii.y === radii.z;
260
- const minRadius = Cartesian3.minimumComponent(radii);
261
- const shapeMinHeight = Math.max(minBounds.z, -minRadius);
262
- const shapeMaxHeight = Math.max(maxBounds.z, -minRadius);
263
- const clipMinHeight = Math.max(clipMinBounds.z, -minRadius);
264
- const clipMaxHeight = Math.max(clipMaxBounds.z, -minRadius);
265
- const renderMinHeight = Math.max(shapeMinHeight, clipMinHeight);
266
- const renderMaxHeight = Math.min(shapeMaxHeight, clipMaxHeight);
267
-
268
- // Compute the closest and farthest a point can be from the center of the ellipsoid.
269
- const shapeInnerExtent = Cartesian3.add(
270
- radii,
271
- Cartesian3.fromElements(
272
- shapeMinHeight,
273
- shapeMinHeight,
274
- shapeMinHeight,
275
- scratchShapeInnerExtent
276
- ),
277
- scratchShapeInnerExtent
278
- );
233
+ // Compute the farthest a point can be from the center of the ellipsoid.
279
234
  const shapeOuterExtent = Cartesian3.add(
280
235
  radii,
281
236
  Cartesian3.fromElements(
282
- shapeMaxHeight,
283
- shapeMaxHeight,
284
- shapeMaxHeight,
237
+ shapeMaxBounds.z,
238
+ shapeMaxBounds.z,
239
+ shapeMaxBounds.z,
285
240
  scratchShapeOuterExtent
286
241
  ),
287
242
  scratchShapeOuterExtent
288
243
  );
289
244
  const shapeMaxExtent = Cartesian3.maximumComponent(shapeOuterExtent);
290
245
 
291
- const renderInnerExtent = Cartesian3.add(
292
- radii,
293
- Cartesian3.fromElements(
294
- renderMinHeight,
295
- renderMinHeight,
296
- renderMinHeight,
297
- scratchRenderInnerExtent
298
- ),
299
- scratchRenderInnerExtent
300
- );
301
246
  const renderOuterExtent = Cartesian3.add(
302
247
  radii,
303
248
  Cartesian3.fromElements(
304
- renderMaxHeight,
305
- renderMaxHeight,
306
- renderMaxHeight,
249
+ renderMaxBounds.z,
250
+ renderMaxBounds.z,
251
+ renderMaxBounds.z,
307
252
  scratchRenderOuterExtent
308
253
  ),
309
254
  scratchRenderOuterExtent
@@ -312,10 +257,10 @@ VoxelEllipsoidShape.prototype.update = function (
312
257
  // Exit early if the shape is not visible.
313
258
  // Note that minLongitude may be greater than maxLongitude when crossing the 180th meridian.
314
259
  if (
315
- renderMinLatitude > renderMaxLatitude ||
316
- renderMinLatitude === defaultMaxLatitude ||
317
- renderMaxLatitude === defaultMinLatitude ||
318
- renderMinHeight > renderMaxHeight ||
260
+ renderMinBounds.y > renderMaxBounds.y ||
261
+ renderMinBounds.y === DefaultMaxBounds.y ||
262
+ renderMaxBounds.y === DefaultMinBounds.y ||
263
+ renderMinBounds.z > renderMaxBounds.z ||
319
264
  CesiumMath.equalsEpsilon(
320
265
  renderOuterExtent,
321
266
  Cartesian3.ZERO,
@@ -327,29 +272,29 @@ VoxelEllipsoidShape.prototype.update = function (
327
272
  }
328
273
 
329
274
  this._rectangle = Rectangle.fromRadians(
330
- shapeMinLongitude,
331
- shapeMinLatitude,
332
- shapeMaxLongitude,
333
- shapeMaxLatitude
275
+ shapeMinBounds.x,
276
+ shapeMinBounds.y,
277
+ shapeMaxBounds.x,
278
+ shapeMaxBounds.y
334
279
  );
335
280
  this._translation = Matrix4.getTranslation(modelMatrix, this._translation);
336
281
  this._rotation = Matrix4.getRotation(modelMatrix, this._rotation);
337
282
  this._ellipsoid = Ellipsoid.fromCartesian3(radii, this._ellipsoid);
338
- this._minimumHeight = shapeMinHeight;
339
- this._maximumHeight = shapeMaxHeight;
283
+ this._minimumHeight = shapeMinBounds.z;
284
+ this._maximumHeight = shapeMaxBounds.z;
340
285
 
341
286
  const renderRectangle = Rectangle.fromRadians(
342
- renderMinLongitude,
343
- renderMinLatitude,
344
- renderMaxLongitude,
345
- renderMaxLatitude,
287
+ renderMinBounds.x,
288
+ renderMinBounds.y,
289
+ renderMaxBounds.x,
290
+ renderMaxBounds.y,
346
291
  scratchRenderRectangle
347
292
  );
348
293
 
349
294
  this.orientedBoundingBox = getEllipsoidChunkObb(
350
295
  renderRectangle,
351
- renderMinHeight,
352
- renderMaxHeight,
296
+ renderMinBounds.z,
297
+ renderMaxBounds.z,
353
298
  this._ellipsoid,
354
299
  this._translation,
355
300
  this._rotation,
@@ -374,33 +319,30 @@ VoxelEllipsoidShape.prototype.update = function (
374
319
  );
375
320
 
376
321
  // Longitude
377
- const renderIsLongitudeReversed = renderMaxLongitude < renderMinLongitude;
322
+ const defaultLongitudeRange = DefaultMaxBounds.x - DefaultMinBounds.x;
323
+ const defaultLongitudeRangeHalf = 0.5 * defaultLongitudeRange;
324
+ const renderIsLongitudeReversed = renderMaxBounds.x < renderMinBounds.x;
378
325
  const renderLongitudeRange =
379
- renderMaxLongitude -
380
- renderMinLongitude +
326
+ renderMaxBounds.x -
327
+ renderMinBounds.x +
381
328
  renderIsLongitudeReversed * defaultLongitudeRange;
382
329
  const renderIsLongitudeRangeZero = renderLongitudeRange <= epsilonLongitude;
383
330
  const renderIsLongitudeRangeUnderHalf =
384
- renderLongitudeRange > defaultLongitudeRangeHalf + epsilonLongitude &&
385
- renderLongitudeRange < defaultLongitudeRange - epsilonLongitude;
386
- const renderIsLongitudeRangeHalf =
387
331
  renderLongitudeRange >= defaultLongitudeRangeHalf - epsilonLongitude &&
388
- renderLongitudeRange <= defaultLongitudeRangeHalf + epsilonLongitude;
332
+ renderLongitudeRange < defaultLongitudeRange - epsilonLongitude;
389
333
  const renderIsLongitudeRangeOverHalf =
390
334
  renderLongitudeRange > epsilonLongitude &&
391
335
  renderLongitudeRange < defaultLongitudeRangeHalf - epsilonLongitude;
392
336
  const renderHasLongitude =
393
337
  renderIsLongitudeRangeZero ||
394
338
  renderIsLongitudeRangeUnderHalf ||
395
- renderIsLongitudeRangeHalf ||
396
339
  renderIsLongitudeRangeOverHalf;
397
340
 
398
- const shapeIsLongitudeReversed = shapeMaxLongitude < shapeMinLongitude;
341
+ const shapeIsLongitudeReversed = shapeMaxBounds.x < shapeMinBounds.x;
399
342
  const shapeLongitudeRange =
400
- shapeMaxLongitude -
401
- shapeMinLongitude +
343
+ shapeMaxBounds.x -
344
+ shapeMinBounds.x +
402
345
  shapeIsLongitudeReversed * defaultLongitudeRange;
403
- const shapeIsLongitudeRangeZero = shapeLongitudeRange <= epsilonLongitude;
404
346
  const shapeIsLongitudeRangeUnderHalf =
405
347
  shapeLongitudeRange > defaultLongitudeRangeHalf + epsilonLongitude &&
406
348
  shapeLongitudeRange < defaultLongitudeRange - epsilonLongitude;
@@ -408,87 +350,63 @@ VoxelEllipsoidShape.prototype.update = function (
408
350
  shapeLongitudeRange >= defaultLongitudeRangeHalf - epsilonLongitude &&
409
351
  shapeLongitudeRange <= defaultLongitudeRangeHalf + epsilonLongitude;
410
352
  const shapeIsLongitudeRangeOverHalf =
411
- shapeLongitudeRange > epsilonLongitude &&
412
353
  shapeLongitudeRange < defaultLongitudeRangeHalf - epsilonLongitude;
413
354
  const shapeHasLongitude =
414
- shapeIsLongitudeRangeZero ||
415
355
  shapeIsLongitudeRangeUnderHalf ||
416
356
  shapeIsLongitudeRangeHalf ||
417
357
  shapeIsLongitudeRangeOverHalf;
418
358
 
419
359
  // Latitude
420
- const renderIsLatitudeMaxUnderHalf = renderMaxLatitude < -epsilonLatitudeFlat;
360
+ const renderIsLatitudeMaxUnderHalf = renderMaxBounds.y < -epsilonLatitudeFlat;
421
361
  const renderIsLatitudeMaxHalf =
422
- renderMaxLatitude >= -epsilonLatitudeFlat &&
423
- renderMaxLatitude <= +epsilonLatitudeFlat;
362
+ renderMaxBounds.y >= -epsilonLatitudeFlat &&
363
+ renderMaxBounds.y <= +epsilonLatitudeFlat;
424
364
  const renderIsLatitudeMaxOverHalf =
425
- renderMaxLatitude > +epsilonLatitudeFlat &&
426
- renderMaxLatitude < defaultMaxLatitude - epsilonLatitude;
365
+ renderMaxBounds.y > +epsilonLatitudeFlat &&
366
+ renderMaxBounds.y < DefaultMaxBounds.y - epsilonLatitude;
427
367
  const renderHasLatitudeMax =
428
368
  renderIsLatitudeMaxUnderHalf ||
429
369
  renderIsLatitudeMaxHalf ||
430
370
  renderIsLatitudeMaxOverHalf;
431
371
  const renderIsLatitudeMinUnderHalf =
432
- renderMinLatitude > defaultMinLatitude + epsilonLatitude &&
433
- renderMinLatitude < -epsilonLatitudeFlat;
372
+ renderMinBounds.y > DefaultMinBounds.y + epsilonLatitude &&
373
+ renderMinBounds.y < -epsilonLatitudeFlat;
434
374
  const renderIsLatitudeMinHalf =
435
- renderMinLatitude >= -epsilonLatitudeFlat &&
436
- renderMinLatitude <= +epsilonLatitudeFlat;
437
- const renderIsLatitudeMinOverHalf = renderMinLatitude > +epsilonLatitudeFlat;
375
+ renderMinBounds.y >= -epsilonLatitudeFlat &&
376
+ renderMinBounds.y <= +epsilonLatitudeFlat;
377
+ const renderIsLatitudeMinOverHalf = renderMinBounds.y > +epsilonLatitudeFlat;
438
378
  const renderHasLatitudeMin =
439
379
  renderIsLatitudeMinUnderHalf ||
440
380
  renderIsLatitudeMinHalf ||
441
381
  renderIsLatitudeMinOverHalf;
442
382
  const renderHasLatitude = renderHasLatitudeMax || renderHasLatitudeMin;
443
383
 
444
- const shapeLatitudeRange = shapeMaxLatitude - shapeMinLatitude;
445
- const shapeIsLatitudeMaxUnderHalf = shapeMaxLatitude < -epsilonLatitudeFlat;
384
+ const shapeLatitudeRange = shapeMaxBounds.y - shapeMinBounds.y;
385
+ const shapeIsLatitudeMaxUnderHalf = shapeMaxBounds.y < -epsilonLatitudeFlat;
446
386
  const shapeIsLatitudeMaxHalf =
447
- shapeMaxLatitude >= -epsilonLatitudeFlat &&
448
- shapeMaxLatitude <= +epsilonLatitudeFlat;
387
+ shapeMaxBounds.y >= -epsilonLatitudeFlat &&
388
+ shapeMaxBounds.y <= +epsilonLatitudeFlat;
449
389
  const shapeIsLatitudeMaxOverHalf =
450
- shapeMaxLatitude > +epsilonLatitudeFlat &&
451
- shapeMaxLatitude < defaultMaxLatitude - epsilonLatitude;
390
+ shapeMaxBounds.y > +epsilonLatitudeFlat &&
391
+ shapeMaxBounds.y < DefaultMaxBounds.y - epsilonLatitude;
452
392
  const shapeHasLatitudeMax =
453
393
  shapeIsLatitudeMaxUnderHalf ||
454
394
  shapeIsLatitudeMaxHalf ||
455
395
  shapeIsLatitudeMaxOverHalf;
456
396
  const shapeIsLatitudeMinUnderHalf =
457
- shapeMinLatitude > defaultMinLatitude + epsilonLatitude &&
458
- shapeMinLatitude < -epsilonLatitudeFlat;
397
+ shapeMinBounds.y > DefaultMinBounds.y + epsilonLatitude &&
398
+ shapeMinBounds.y < -epsilonLatitudeFlat;
459
399
  const shapeIsLatitudeMinHalf =
460
- shapeMinLatitude >= -epsilonLatitudeFlat &&
461
- shapeMinLatitude <= +epsilonLatitudeFlat;
462
- const shapeIsLatitudeMinOverHalf = shapeMinLatitude > +epsilonLatitudeFlat;
400
+ shapeMinBounds.y >= -epsilonLatitudeFlat &&
401
+ shapeMinBounds.y <= +epsilonLatitudeFlat;
402
+ const shapeIsLatitudeMinOverHalf = shapeMinBounds.y > +epsilonLatitudeFlat;
463
403
  const shapeHasLatitudeMin =
464
404
  shapeIsLatitudeMinUnderHalf ||
465
405
  shapeIsLatitudeMinHalf ||
466
406
  shapeIsLatitudeMinOverHalf;
467
407
  const shapeHasLatitude = shapeHasLatitudeMax || shapeHasLatitudeMin;
468
408
 
469
- // Height
470
- const renderHasMinHeight = !Cartesian3.equals(
471
- renderInnerExtent,
472
- Cartesian3.ZERO
473
- );
474
- const renderHasMaxHeight = !Cartesian3.equals(
475
- renderOuterExtent,
476
- Cartesian3.ZERO
477
- );
478
- const renderHasHeight = renderHasMinHeight || renderHasMaxHeight;
479
- const renderHeightRange = renderMaxHeight - renderMinHeight;
480
- const shapeHasMinHeight = !Cartesian3.equals(
481
- shapeInnerExtent,
482
- Cartesian3.ZERO
483
- );
484
- const shapeHasMaxHeight = !Cartesian3.equals(
485
- shapeOuterExtent,
486
- Cartesian3.ZERO
487
- );
488
- const shapeHasHeight = shapeHasMinHeight || shapeHasMaxHeight;
489
-
490
- const shaderUniforms = this.shaderUniforms;
491
- const shaderDefines = this.shaderDefines;
409
+ const { shaderUniforms, shaderDefines } = this;
492
410
 
493
411
  // To keep things simple, clear the defines every time
494
412
  for (const key in shaderDefines) {
@@ -503,6 +421,14 @@ VoxelEllipsoidShape.prototype.update = function (
503
421
  shapeMaxExtent,
504
422
  shaderUniforms.ellipsoidRadiiUv
505
423
  );
424
+ const { x: radiiUvX, z: radiiUvZ } = shaderUniforms.ellipsoidRadiiUv;
425
+ const axisRatio = radiiUvZ / radiiUvX;
426
+ shaderUniforms.eccentricitySquared = 1.0 - axisRatio * axisRatio;
427
+ shaderUniforms.evoluteScale = Cartesian2.fromElements(
428
+ (radiiUvX * radiiUvX - radiiUvZ * radiiUvZ) / radiiUvX,
429
+ (radiiUvZ * radiiUvZ - radiiUvX * radiiUvX) / radiiUvZ,
430
+ shaderUniforms.evoluteScale
431
+ );
506
432
 
507
433
  // Used to compute geodetic surface normal.
508
434
  shaderUniforms.ellipsoidInverseRadiiSquaredUv = Cartesian3.divideComponents(
@@ -518,53 +444,23 @@ VoxelEllipsoidShape.prototype.update = function (
518
444
  // Keep track of how many intersections there are going to be.
519
445
  let intersectionCount = 0;
520
446
 
521
- // Intersects an outer ellipsoid for the max height.
447
+ // Intersects outer and inner ellipsoid for the max and min height.
522
448
  shaderDefines["ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MAX"] = intersectionCount;
523
449
  intersectionCount += 1;
450
+ shaderDefines["ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN"] = intersectionCount;
451
+ intersectionCount += 1;
524
452
 
525
- if (renderHasHeight) {
526
- if (renderHeightRange === 0.0) {
527
- shaderDefines["ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_FLAT"] = true;
528
- }
529
-
530
- if (renderHasMinHeight) {
531
- shaderDefines["ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MIN"] = true;
532
- shaderDefines[
533
- "ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN"
534
- ] = intersectionCount;
535
- intersectionCount += 1;
536
-
537
- // The inverse of the percent of space that is taken up by the inner ellipsoid, relative to the shape bounds
538
- // 1.0 / (1.0 - thickness) // thickness = percent of space that is between the min and max height.
539
- // 1.0 / (1.0 - (shapeMaxHeight - renderMinHeight) / shapeMaxExtent)
540
- // shapeMaxExtent / (shapeMaxExtent - (shapeMaxHeight - renderMinHeight))
541
- shaderUniforms.ellipsoidInverseInnerScaleUv =
542
- shapeMaxExtent / (shapeMaxExtent - (shapeMaxHeight - renderMinHeight));
543
- }
544
-
545
- if (renderHasMaxHeight) {
546
- shaderDefines["ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MAX"] = true;
547
- shaderUniforms.ellipsoidInverseOuterScaleUv =
548
- shapeMaxExtent / (shapeMaxExtent - (shapeMaxHeight - renderMaxHeight));
549
- }
550
- }
453
+ shaderUniforms.clipMinMaxHeight = Cartesian2.fromElements(
454
+ (renderMinBounds.z - shapeMaxBounds.z) / shapeMaxExtent,
455
+ (renderMaxBounds.z - shapeMaxBounds.z) / shapeMaxExtent,
456
+ shaderUniforms.clipMinMaxHeight
457
+ );
551
458
 
552
- if (shapeHasHeight) {
553
- if (shapeHasMinHeight) {
554
- shaderDefines["ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_MIN"] = true;
555
-
556
- // The percent of space that is between the inner and outer ellipsoid.
557
- const thickness = (shapeMaxHeight - shapeMinHeight) / shapeMaxExtent;
558
- shaderUniforms.ellipsoidInverseHeightDifferenceUv = 1.0 / thickness;
559
- shaderUniforms.ellipseInnerRadiiUv = Cartesian2.fromElements(
560
- shaderUniforms.ellipsoidRadiiUv.x * (1.0 - thickness),
561
- shaderUniforms.ellipsoidRadiiUv.z * (1.0 - thickness),
562
- shaderUniforms.ellipseInnerRadiiUv
563
- );
564
- }
565
- if (shapeMinHeight === shapeMaxHeight) {
566
- shaderDefines["ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_FLAT"] = true;
567
- }
459
+ // The percent of space that is between the inner and outer ellipsoid.
460
+ const thickness = (shapeMaxBounds.z - shapeMinBounds.z) / shapeMaxExtent;
461
+ shaderUniforms.ellipsoidInverseHeightDifferenceUv = 1.0 / thickness;
462
+ if (shapeMinBounds.z === shapeMaxBounds.z) {
463
+ shaderUniforms.ellipsoidInverseHeightDifferenceUv = 0.0;
568
464
  }
569
465
 
570
466
  // Intersects a wedge for the min and max longitude.
@@ -582,11 +478,6 @@ VoxelEllipsoidShape.prototype.update = function (
582
478
  "ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF"
583
479
  ] = true;
584
480
  intersectionCount += 2;
585
- } else if (renderIsLongitudeRangeHalf) {
586
- shaderDefines[
587
- "ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_HALF"
588
- ] = true;
589
- intersectionCount += 1;
590
481
  } else if (renderIsLongitudeRangeZero) {
591
482
  shaderDefines[
592
483
  "ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO"
@@ -595,8 +486,8 @@ VoxelEllipsoidShape.prototype.update = function (
595
486
  }
596
487
 
597
488
  shaderUniforms.ellipsoidRenderLongitudeMinMax = Cartesian2.fromElements(
598
- renderMinLongitude,
599
- renderMaxLongitude,
489
+ renderMinBounds.x,
490
+ renderMaxBounds.x,
600
491
  shaderUniforms.ellipsoidRenderLongitudeMinMax
601
492
  );
602
493
  }
@@ -604,7 +495,7 @@ VoxelEllipsoidShape.prototype.update = function (
604
495
  if (shapeHasLongitude) {
605
496
  shaderDefines["ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE"] = true;
606
497
 
607
- const shapeIsLongitudeReversed = shapeMaxLongitude < shapeMinLongitude;
498
+ const shapeIsLongitudeReversed = shapeMaxBounds.x < shapeMinBounds.x;
608
499
 
609
500
  if (shapeIsLongitudeReversed) {
610
501
  shaderDefines[
@@ -621,26 +512,34 @@ VoxelEllipsoidShape.prototype.update = function (
621
512
  // offset = -minLongitudeUv / (maxLongitudeUv - minLongitudeUv)
622
513
  // offset = -((minLongitude - pi) / (2.0 * pi)) / (((maxLongitude - pi) / (2.0 * pi)) - ((minLongitude - pi) / (2.0 * pi)))
623
514
  // offset = -(minLongitude - pi) / (maxLongitude - minLongitude)
624
- const scale = defaultLongitudeRange / shapeLongitudeRange;
625
- const offset =
626
- -(shapeMinLongitude - defaultMinLongitude) / shapeLongitudeRange;
627
- shaderUniforms.ellipsoidUvToShapeUvLongitude = Cartesian2.fromElements(
628
- scale,
629
- offset,
630
- shaderUniforms.ellipsoidUvToShapeUvLongitude
631
- );
515
+ if (shapeLongitudeRange <= epsilonLongitude) {
516
+ shaderUniforms.ellipsoidUvToShapeUvLongitude = Cartesian2.fromElements(
517
+ 0.0,
518
+ 1.0,
519
+ shaderUniforms.ellipsoidUvToShapeUvLongitude
520
+ );
521
+ } else {
522
+ const scale = defaultLongitudeRange / shapeLongitudeRange;
523
+ const offset =
524
+ -(shapeMinBounds.x - DefaultMinBounds.x) / shapeLongitudeRange;
525
+ shaderUniforms.ellipsoidUvToShapeUvLongitude = Cartesian2.fromElements(
526
+ scale,
527
+ offset,
528
+ shaderUniforms.ellipsoidUvToShapeUvLongitude
529
+ );
530
+ }
632
531
  }
633
532
 
634
533
  if (renderHasLongitude) {
635
534
  const renderIsMinLongitudeDiscontinuity = CesiumMath.equalsEpsilon(
636
- renderMinLongitude,
637
- defaultMinLongitude,
535
+ renderMinBounds.x,
536
+ DefaultMinBounds.x,
638
537
  undefined,
639
538
  epsilonLongitudeDiscontinuity
640
539
  );
641
540
  const renderIsMaxLongitudeDiscontinuity = CesiumMath.equalsEpsilon(
642
- renderMaxLongitude,
643
- defaultMaxLongitude,
541
+ renderMaxBounds.x,
542
+ DefaultMaxBounds.x,
644
543
  undefined,
645
544
  epsilonLongitudeDiscontinuity
646
545
  );
@@ -656,12 +555,12 @@ VoxelEllipsoidShape.prototype.update = function (
656
555
  ] = true;
657
556
  }
658
557
  const uvShapeMinLongitude =
659
- (shapeMinLongitude - defaultMinLongitude) / defaultLongitudeRange;
558
+ (shapeMinBounds.x - DefaultMinBounds.x) / defaultLongitudeRange;
660
559
  const uvShapeMaxLongitude =
661
- (shapeMaxLongitude - defaultMinLongitude) / defaultLongitudeRange;
560
+ (shapeMaxBounds.x - DefaultMinBounds.x) / defaultLongitudeRange;
662
561
 
663
562
  const uvRenderMaxLongitude =
664
- (renderMaxLongitude - defaultMinLongitude) / defaultLongitudeRange;
563
+ (renderMaxBounds.x - DefaultMinBounds.x) / defaultLongitudeRange;
665
564
  const uvRenderLongitudeRangeZero =
666
565
  1.0 - renderLongitudeRange / defaultLongitudeRange;
667
566
  const uvRenderLongitudeRangeZeroMid =
@@ -676,8 +575,6 @@ VoxelEllipsoidShape.prototype.update = function (
676
575
  }
677
576
 
678
577
  if (renderHasLatitude) {
679
- shaderDefines["ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE"] = true;
680
-
681
578
  // Intersects a cone for min latitude
682
579
  if (renderHasLatitudeMin) {
683
580
  shaderDefines["ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN"] = true;
@@ -728,36 +625,16 @@ VoxelEllipsoidShape.prototype.update = function (
728
625
  }
729
626
  }
730
627
 
731
- if (renderMinLatitude === renderMaxLatitude) {
732
- shaderDefines[
733
- "ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_RANGE_EQUAL_ZERO"
734
- ] = true;
735
- }
736
-
737
- const minCosHalfAngleSqr = Math.pow(
738
- Math.cos(CesiumMath.PI_OVER_TWO - Math.abs(renderMinLatitude)),
739
- 2.0
740
- );
741
- const maxCosHalfAngleSqr = Math.pow(
742
- Math.cos(CesiumMath.PI_OVER_TWO - Math.abs(renderMaxLatitude)),
743
- 2.0
744
- );
745
- shaderUniforms.ellipsoidRenderLatitudeCosSqrHalfMinMax = Cartesian2.fromElements(
746
- minCosHalfAngleSqr,
747
- maxCosHalfAngleSqr,
748
- shaderUniforms.ellipsoidRenderLatitudeCosSqrHalfMinMax
628
+ shaderUniforms.ellipsoidRenderLatitudeSinMinMax = Cartesian2.fromElements(
629
+ Math.sin(renderMinBounds.y),
630
+ Math.sin(renderMaxBounds.y),
631
+ shaderUniforms.ellipsoidRenderLatitudeSinMinMax
749
632
  );
750
633
  }
751
634
 
752
635
  if (shapeHasLatitude) {
753
636
  shaderDefines["ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE"] = true;
754
637
 
755
- if (shapeMinLatitude === shapeMaxLatitude) {
756
- shaderDefines[
757
- "ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE_RANGE_EQUAL_ZERO"
758
- ] = true;
759
- }
760
-
761
638
  // delerp(latitudeUv, minLatitudeUv, maxLatitudeUv)
762
639
  // (latitudeUv - minLatitudeUv) / (maxLatitudeUv - minLatitudeUv)
763
640
  // latitudeUv / (maxLatitudeUv - minLatitudeUv) - minLatitudeUv / (maxLatitudeUv - minLatitudeUv)
@@ -768,17 +645,23 @@ VoxelEllipsoidShape.prototype.update = function (
768
645
  // offset = -((minLatitude - -pi) / (2.0 * pi)) / (((maxLatitude - pi) / (2.0 * pi)) - ((minLatitude - pi) / (2.0 * pi)))
769
646
  // offset = -(minLatitude - -pi) / (maxLatitude - minLatitude)
770
647
  // offset = (-pi - minLatitude) / (maxLatitude - minLatitude)
771
- const scale = defaultLatitudeRange / shapeLatitudeRange;
772
- const offset = (defaultMinLatitude - shapeMinLatitude) / shapeLatitudeRange;
773
- shaderUniforms.ellipsoidUvToShapeUvLatitude = Cartesian2.fromElements(
774
- scale,
775
- offset,
776
- shaderUniforms.ellipsoidUvToShapeUvLatitude
777
- );
778
- }
779
-
780
- if (isSphere) {
781
- shaderDefines["ELLIPSOID_IS_SPHERE"] = true;
648
+ if (shapeLatitudeRange < epsilonLatitude) {
649
+ shaderUniforms.ellipsoidUvToShapeUvLatitude = Cartesian2.fromElements(
650
+ 0.0,
651
+ 1.0,
652
+ shaderUniforms.ellipsoidUvToShapeUvLatitude
653
+ );
654
+ } else {
655
+ const defaultLatitudeRange = DefaultMaxBounds.y - DefaultMinBounds.y;
656
+ const scale = defaultLatitudeRange / shapeLatitudeRange;
657
+ const offset =
658
+ (DefaultMinBounds.y - shapeMinBounds.y) / shapeLatitudeRange;
659
+ shaderUniforms.ellipsoidUvToShapeUvLatitude = Cartesian2.fromElements(
660
+ scale,
661
+ offset,
662
+ shaderUniforms.ellipsoidUvToShapeUvLatitude
663
+ );
664
+ }
782
665
  }
783
666
 
784
667
  this.shaderMaximumIntersectionsLength = intersectionCount;
@@ -854,29 +737,89 @@ VoxelEllipsoidShape.prototype.computeOrientedBoundingBoxForTile = function (
854
737
  );
855
738
  };
856
739
 
740
+ const sampleSizeScratch = new Cartesian3();
741
+ const scratchTileMinBounds = new Cartesian3();
742
+ const scratchTileMaxBounds = new Cartesian3();
743
+
857
744
  /**
858
- * Computes an approximate step size for raymarching the root tile of a voxel grid.
745
+ * Computes an oriented bounding box for a specified sample within a specified tile.
859
746
  * The update function must be called before calling this function.
860
747
  *
861
- * @param {Cartesian3} dimensions The voxel grid dimensions for a tile.
862
- * @returns {number} The step size.
748
+ * @param {SpatialNode} spatialNode The spatial node containing the sample
749
+ * @param {Cartesian3} tileDimensions The size of the tile in number of samples, before padding
750
+ * @param {Cartesian3} tileUv The sample coordinate within the tile
751
+ * @param {OrientedBoundingBox} result The oriented bounding box that will be set to enclose the specified sample
752
+ * @returns {OrientedBoundingBox} The oriented bounding box.
863
753
  */
864
- VoxelEllipsoidShape.prototype.computeApproximateStepSize = function (
865
- dimensions
754
+ VoxelEllipsoidShape.prototype.computeOrientedBoundingBoxForSample = function (
755
+ spatialNode,
756
+ tileDimensions,
757
+ tileUv,
758
+ result
866
759
  ) {
867
760
  //>>includeStart('debug', pragmas.debug);
868
- Check.typeOf.object("dimensions", dimensions);
761
+ Check.typeOf.object("spatialNode", spatialNode);
762
+ Check.typeOf.object("tileDimensions", tileDimensions);
763
+ Check.typeOf.object("tileUv", tileUv);
764
+ Check.typeOf.object("result", result);
869
765
  //>>includeEnd('debug');
870
766
 
871
- const ellipsoid = this._ellipsoid;
872
- const ellipsoidMaximumRadius = ellipsoid.maximumRadius;
873
- const minimumHeight = this._minimumHeight;
874
- const maximumHeight = this._maximumHeight;
767
+ const tileSizeAtLevel = 1.0 / Math.pow(2.0, spatialNode.level);
768
+ const sampleSize = Cartesian3.divideComponents(
769
+ Cartesian3.ONE,
770
+ tileDimensions,
771
+ sampleSizeScratch
772
+ );
773
+ const sampleSizeAtLevel = Cartesian3.multiplyByScalar(
774
+ sampleSize,
775
+ tileSizeAtLevel,
776
+ sampleSizeScratch
777
+ );
875
778
 
876
- const shellToEllipsoidRatio =
877
- (maximumHeight - minimumHeight) / (ellipsoidMaximumRadius + maximumHeight);
878
- const stepSize = (0.5 * shellToEllipsoidRatio) / dimensions.z;
879
- return stepSize;
779
+ const minLerp = Cartesian3.multiplyByScalar(
780
+ Cartesian3.fromElements(
781
+ spatialNode.x + tileUv.x,
782
+ spatialNode.y + tileUv.y,
783
+ spatialNode.z + tileUv.z,
784
+ scratchTileMinBounds
785
+ ),
786
+ tileSizeAtLevel,
787
+ scratchTileMinBounds
788
+ );
789
+ const maxLerp = Cartesian3.add(
790
+ minLerp,
791
+ sampleSizeAtLevel,
792
+ scratchTileMaxBounds
793
+ );
794
+
795
+ const rectangle = Rectangle.subsection(
796
+ this._rectangle,
797
+ minLerp.x,
798
+ minLerp.y,
799
+ maxLerp.x,
800
+ maxLerp.y,
801
+ scratchRectangle
802
+ );
803
+ const minHeight = CesiumMath.lerp(
804
+ this._minimumHeight,
805
+ this._maximumHeight,
806
+ minLerp.z
807
+ );
808
+ const maxHeight = CesiumMath.lerp(
809
+ this._minimumHeight,
810
+ this._maximumHeight,
811
+ maxLerp.z
812
+ );
813
+
814
+ return getEllipsoidChunkObb(
815
+ rectangle,
816
+ minHeight,
817
+ maxHeight,
818
+ this._ellipsoid,
819
+ this._translation,
820
+ this._rotation,
821
+ result
822
+ );
880
823
  };
881
824
 
882
825
  /**
@@ -928,7 +871,11 @@ function getEllipsoidChunkObb(
928
871
  * @readonly
929
872
  */
930
873
  VoxelEllipsoidShape.DefaultMinBounds = Object.freeze(
931
- new Cartesian3(-CesiumMath.PI, -CesiumMath.PI_OVER_TWO, -Number.MAX_VALUE)
874
+ new Cartesian3(
875
+ -CesiumMath.PI,
876
+ -CesiumMath.PI_OVER_TWO,
877
+ -Ellipsoid.WGS84.minimumRadius
878
+ )
932
879
  );
933
880
 
934
881
  /**
@@ -939,7 +886,11 @@ VoxelEllipsoidShape.DefaultMinBounds = Object.freeze(
939
886
  * @readonly
940
887
  */
941
888
  VoxelEllipsoidShape.DefaultMaxBounds = Object.freeze(
942
- new Cartesian3(+CesiumMath.PI, +CesiumMath.PI_OVER_TWO, +Number.MAX_VALUE)
889
+ new Cartesian3(
890
+ CesiumMath.PI,
891
+ CesiumMath.PI_OVER_TWO,
892
+ 10.0 * Ellipsoid.WGS84.maximumRadius
893
+ )
943
894
  );
944
895
 
945
896
  export default VoxelEllipsoidShape;