@cesium/engine 16.0.0 → 17.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 (116) hide show
  1. package/Build/Workers/{chunk-ICU72UPR.js → chunk-236N6BJN.js} +2 -2
  2. package/Build/Workers/{chunk-V4Y7C25O.js → chunk-2BJXFXD7.js} +4 -4
  3. package/Build/Workers/{chunk-ILVAXLMC.js → chunk-37PA7GZW.js} +7 -7
  4. package/Build/Workers/{chunk-4LHK6E47.js → chunk-4BGKMM7J.js} +1 -1
  5. package/Build/Workers/{chunk-OWLBD6BL.js → chunk-4TIR5UPL.js} +1 -1
  6. package/Build/Workers/{chunk-KKV6XBF5.js → chunk-5PC577K7.js} +16 -16
  7. package/Build/Workers/{chunk-VXAAIRJ7.js → chunk-5RPUEFSA.js} +6 -6
  8. package/Build/Workers/{chunk-PT6U7UNY.js → chunk-5YEFZMMM.js} +12 -12
  9. package/Build/Workers/{chunk-XMKE4XB2.js → chunk-77MDEA47.js} +5 -5
  10. package/Build/Workers/{chunk-TL5YKZJF.js → chunk-7IIMO7ZZ.js} +16 -16
  11. package/Build/Workers/{chunk-CUJH7PS5.js → chunk-7PHT4JHA.js} +12 -12
  12. package/Build/Workers/{chunk-TEUGW455.js → chunk-C5DCX2YQ.js} +6 -6
  13. package/Build/Workers/{chunk-PB6SE3SZ.js → chunk-CAKU6ZPR.js} +8 -8
  14. package/Build/Workers/{chunk-EOIUWEAK.js → chunk-CBFJVM6I.js} +11 -11
  15. package/Build/Workers/{chunk-ESED7XBA.js → chunk-CC2WKHIW.js} +6 -6
  16. package/Build/Workers/{chunk-OMZGZVHI.js → chunk-CQMXZF4A.js} +6 -6
  17. package/Build/Workers/{chunk-LCSH4ZOB.js → chunk-DRMXU674.js} +5 -5
  18. package/Build/Workers/{chunk-B75OO2DU.js → chunk-E7SMO47Q.js} +5 -5
  19. package/Build/Workers/{chunk-KV6TEHXY.js → chunk-G6JUXZUO.js} +4 -4
  20. package/Build/Workers/{chunk-ZLJDDRGB.js → chunk-GO3RZX2R.js} +9 -9
  21. package/Build/Workers/{chunk-S2NKKWYE.js → chunk-HBNWBMAM.js} +1 -1
  22. package/Build/Workers/{chunk-NB6D74SQ.js → chunk-HGEGZ67N.js} +6 -6
  23. package/Build/Workers/{chunk-EO44CO62.js → chunk-IFIS4CVK.js} +2 -2
  24. package/Build/Workers/{chunk-YFXXUW6U.js → chunk-IKDQX7DY.js} +4 -4
  25. package/Build/Workers/{chunk-RWAFHSX3.js → chunk-J2HTPGC7.js} +2 -2
  26. package/Build/Workers/{chunk-TBSA4MNF.js → chunk-K5JTWJPE.js} +4 -4
  27. package/Build/Workers/{chunk-ORIMMEHO.js → chunk-KE45DUDH.js} +10 -10
  28. package/Build/Workers/{chunk-5TN3LG2T.js → chunk-LPGOAMYH.js} +2 -2
  29. package/Build/Workers/{chunk-CQNYYX3N.js → chunk-LVGYWPEX.js} +4 -4
  30. package/Build/Workers/{chunk-S3IQBSIB.js → chunk-MAIKDIBS.js} +6 -6
  31. package/Build/Workers/{chunk-2TQ64T4I.js → chunk-MS5NWDHH.js} +2 -2
  32. package/Build/Workers/{chunk-VNDECE6N.js → chunk-NZSBSY5K.js} +2 -2
  33. package/Build/Workers/{chunk-EJJDBH5W.js → chunk-OBHLT34A.js} +7 -7
  34. package/Build/Workers/{chunk-YL26OJCG.js → chunk-P2N5IDWU.js} +13 -13
  35. package/Build/Workers/{chunk-COOLDICB.js → chunk-P57PR3WM.js} +5 -5
  36. package/Build/Workers/{chunk-OMFZ4IN6.js → chunk-PM4Q36WX.js} +9 -9
  37. package/Build/Workers/{chunk-SCUQTTCN.js → chunk-PS3OKVOQ.js} +12 -12
  38. package/Build/Workers/{chunk-GQVSADCI.js → chunk-QJTIOB2Z.js} +6 -6
  39. package/Build/Workers/{chunk-FW2OX42E.js → chunk-QUFN3GEO.js} +3 -3
  40. package/Build/Workers/{chunk-XF6EBVKV.js → chunk-RX65FA7X.js} +7 -7
  41. package/Build/Workers/{chunk-EAWYQ44R.js → chunk-SQKTLDSD.js} +12 -12
  42. package/Build/Workers/{chunk-NREPBWCX.js → chunk-SSLK4U3V.js} +4 -4
  43. package/Build/Workers/{chunk-GH6I7PBY.js → chunk-UC7KH56Y.js} +5 -5
  44. package/Build/Workers/{chunk-VVTAI2TN.js → chunk-UFV3YUIN.js} +5 -5
  45. package/Build/Workers/{chunk-M5J3S3HY.js → chunk-UX5JWAC7.js} +10 -10
  46. package/Build/Workers/{chunk-OD4Q7HE5.js → chunk-UZ6KXWCA.js} +4 -4
  47. package/Build/Workers/{chunk-YA4XALD5.js → chunk-VXAKU6EV.js} +5 -5
  48. package/Build/Workers/{chunk-6B7KGA5P.js → chunk-WP3IJYLC.js} +9 -9
  49. package/Build/Workers/{chunk-34EWMUFG.js → chunk-XYGBWBD5.js} +1 -1
  50. package/Build/Workers/{chunk-ERKJ7IWJ.js → chunk-YE6MDFDA.js} +14 -14
  51. package/Build/Workers/{chunk-WGIOUM2S.js → chunk-ZTBZMRQT.js} +8 -8
  52. package/Build/Workers/combineGeometry.js +21 -21
  53. package/Build/Workers/createBoxGeometry.js +15 -15
  54. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  55. package/Build/Workers/createCircleGeometry.js +23 -23
  56. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  57. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  58. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  59. package/Build/Workers/createCorridorGeometry.js +26 -26
  60. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  61. package/Build/Workers/createCylinderGeometry.js +17 -17
  62. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  63. package/Build/Workers/createEllipseGeometry.js +23 -23
  64. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  65. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  66. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  67. package/Build/Workers/createFrustumGeometry.js +15 -15
  68. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  69. package/Build/Workers/createGeometry.js +21 -21
  70. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  71. package/Build/Workers/createPlaneGeometry.js +13 -13
  72. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  73. package/Build/Workers/createPolygonGeometry.js +29 -29
  74. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  75. package/Build/Workers/createPolylineGeometry.js +22 -22
  76. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  77. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  78. package/Build/Workers/createRectangleGeometry.js +24 -24
  79. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  80. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  81. package/Build/Workers/createSphereGeometry.js +16 -16
  82. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  83. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  84. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  85. package/Build/Workers/createVectorTileGeometries.js +21 -21
  86. package/Build/Workers/createVectorTilePoints.js +11 -11
  87. package/Build/Workers/createVectorTilePolygons.js +19 -19
  88. package/Build/Workers/createVectorTilePolylines.js +12 -12
  89. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  90. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  91. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  92. package/Build/Workers/createWallGeometry.js +21 -21
  93. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  94. package/Build/Workers/decodeDraco.js +10 -10
  95. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  96. package/Build/Workers/decodeI3S.js +9 -9
  97. package/Build/Workers/transcodeKTX2.js +6 -6
  98. package/Build/Workers/transferTypedArrayTest.js +1 -1
  99. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  100. package/Source/Core/Check.d.ts +4 -1
  101. package/Source/Core/ITwinPlatform.js +6 -3
  102. package/Source/Core/Ion.js +1 -1
  103. package/Source/Core/PolygonGeometry.js +1 -0
  104. package/Source/Core/RectangleOutlineGeometry.js +1 -1
  105. package/Source/Scene/ArcGisMapService.js +1 -1
  106. package/Source/Scene/Cesium3DTilesVoxelProvider.js +18 -23
  107. package/Source/Scene/ImageryLayer.js +2 -2
  108. package/Source/Scene/QuadtreePrimitive.js +5 -1
  109. package/Source/Scene/VoxelBoxShape.js +38 -81
  110. package/Source/Scene/VoxelCylinderShape.js +128 -262
  111. package/Source/Scene/VoxelPrimitive.js +2 -2
  112. package/Source/Shaders/PolylineCommon.glsl +1 -1
  113. package/Source/Shaders/PolylineCommon.js +1 -1
  114. package/index.d.ts +9 -5
  115. package/index.js +81 -81
  116. package/package.json +1 -1
@@ -9,6 +9,7 @@ import ImplicitSubtree from "./ImplicitSubtree.js";
9
9
  import ImplicitSubtreeCache from "./ImplicitSubtreeCache.js";
10
10
  import ImplicitTileCoordinates from "./ImplicitTileCoordinates.js";
11
11
  import ImplicitTileset from "./ImplicitTileset.js";
12
+ import Matrix3 from "../Core/Matrix3.js";
12
13
  import Matrix4 from "../Core/Matrix4.js";
13
14
  import MetadataSemantic from "./MetadataSemantic.js";
14
15
  import MetadataType from "./MetadataType.js";
@@ -17,7 +18,6 @@ import preprocess3DTileContent from "./preprocess3DTileContent.js";
17
18
  import Resource from "../Core/Resource.js";
18
19
  import ResourceCache from "./ResourceCache.js";
19
20
  import RuntimeError from "../Core/RuntimeError.js";
20
- import VoxelBoxShape from "./VoxelBoxShape.js";
21
21
  import VoxelContent from "./VoxelContent.js";
22
22
  import VoxelMetadataOrder from "./VoxelMetadataOrder.js";
23
23
  import VoxelShapeType from "./VoxelShapeType.js";
@@ -411,6 +411,11 @@ Cesium3DTilesVoxelProvider.fromUrl = async function (url) {
411
411
 
412
412
  const providerOptions = getAttributeInfo(tilesetMetadata, className);
413
413
  Object.assign(providerOptions, getShape(root));
414
+ if (defined(root.transform)) {
415
+ providerOptions.globalTransform = Matrix4.unpack(root.transform);
416
+ } else {
417
+ providerOptions.globalTransform = Matrix4.clone(Matrix4.IDENTITY);
418
+ }
414
419
 
415
420
  providerOptions.dimensions = Cartesian3.unpack(voxel.dimensions);
416
421
  providerOptions.maximumTileCount = getTileCount(tilesetMetadata);
@@ -477,21 +482,13 @@ function validate(tileset) {
477
482
  function getShape(tile) {
478
483
  const boundingVolume = tile.boundingVolume;
479
484
 
480
- let tileTransform;
481
- if (defined(tile.transform)) {
482
- tileTransform = Matrix4.unpack(tile.transform);
483
- } else {
484
- tileTransform = Matrix4.clone(Matrix4.IDENTITY);
485
- }
486
-
487
485
  if (defined(boundingVolume.box)) {
488
- return getBoxShape(boundingVolume.box, tileTransform);
486
+ return getBoxShape(boundingVolume.box);
489
487
  } else if (defined(boundingVolume.region)) {
490
488
  return getEllipsoidShape(boundingVolume.region);
491
489
  } else if (hasExtension(boundingVolume, "3DTILES_bounding_volume_cylinder")) {
492
490
  return getCylinderShape(
493
491
  boundingVolume.extensions["3DTILES_bounding_volume_cylinder"],
494
- tileTransform,
495
492
  );
496
493
  }
497
494
 
@@ -518,27 +515,26 @@ function getEllipsoidShape(region) {
518
515
  minBounds: minBounds,
519
516
  maxBounds: maxBounds,
520
517
  shapeTransform: shapeTransform,
521
- globalTransform: Matrix4.clone(Matrix4.IDENTITY),
522
518
  };
523
519
  }
524
520
 
525
- function getBoxShape(box, tileTransform) {
521
+ const scratchScale = new Cartesian3();
522
+ const scratchRotation = new Matrix3();
523
+
524
+ function getBoxShape(box) {
526
525
  const obb = OrientedBoundingBox.unpack(box);
527
- const shapeTransform = Matrix4.fromRotationTranslation(
528
- obb.halfAxes,
529
- obb.center,
530
- );
526
+ const scale = Matrix3.getScale(obb.halfAxes, scratchScale);
527
+ const rotation = Matrix3.getRotation(obb.halfAxes, scratchRotation);
531
528
 
532
529
  return {
533
530
  shape: VoxelShapeType.BOX,
534
- minBounds: Cartesian3.clone(VoxelBoxShape.DefaultMinBounds),
535
- maxBounds: Cartesian3.clone(VoxelBoxShape.DefaultMaxBounds),
536
- shapeTransform: shapeTransform,
537
- globalTransform: tileTransform,
531
+ minBounds: Cartesian3.negate(scale, new Cartesian3()),
532
+ maxBounds: Cartesian3.clone(scale),
533
+ shapeTransform: Matrix4.fromRotationTranslation(rotation, obb.center),
538
534
  };
539
535
  }
540
536
 
541
- function getCylinderShape(cylinder, tileTransform) {
537
+ function getCylinderShape(cylinder) {
542
538
  const {
543
539
  minRadius,
544
540
  maxRadius,
@@ -565,7 +561,7 @@ function getCylinderShape(cylinder, tileTransform) {
565
561
  const shapeTransform = Matrix4.fromTranslationQuaternionRotationScale(
566
562
  Cartesian3.unpack(translation),
567
563
  Quaternion.unpack(rotation),
568
- new Cartesian3(maxRadius, maxRadius, 0.5 * height),
564
+ Cartesian3.ONE,
569
565
  );
570
566
 
571
567
  return {
@@ -573,7 +569,6 @@ function getCylinderShape(cylinder, tileTransform) {
573
569
  minBounds: Cartesian3.fromElements(minRadius, minAngle, minHeight),
574
570
  maxBounds: Cartesian3.fromElements(maxRadius, maxAngle, maxHeight),
575
571
  shapeTransform: shapeTransform,
576
- globalTransform: tileTransform,
577
572
  };
578
573
  }
579
574
 
@@ -85,7 +85,7 @@ import TileImagery from "./TileImagery.js";
85
85
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
86
86
  * current frame state, this layer, and the x, y, and level coordinates
87
87
  * of the imagery tile for which the hue is required, and it is expected to return
88
- * the contrast value to use for the tile. The function is executed for every
88
+ * the hue value to use for the tile. The function is executed for every
89
89
  * frame and for every tile, so it must be fast.
90
90
  * @property {number|Function} [saturation=1.0] The saturation of this layer. 1.0 uses the unmodified imagery color.
91
91
  * Less than 1.0 reduces the saturation while greater than 1.0 increases it.
@@ -93,7 +93,7 @@ import TileImagery from "./TileImagery.js";
93
93
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
94
94
  * current frame state, this layer, and the x, y, and level coordinates
95
95
  * of the imagery tile for which the saturation is required, and it is expected to return
96
- * the contrast value to use for the tile. The function is executed for every
96
+ * the saturation value to use for the tile. The function is executed for every
97
97
  * frame and for every tile, so it must be fast.
98
98
  * @property {number|Function} [gamma=1.0] The gamma correction to apply to this layer. 1.0 uses the unmodified imagery color.
99
99
  * This can either be a simple number or a function with the signature
@@ -1526,7 +1526,11 @@ function updateHeights(primitive, frameState) {
1526
1526
  }
1527
1527
  if (defined(position)) {
1528
1528
  if (defined(data.callback)) {
1529
- data.callback(position);
1529
+ const positionCarto = ellipsoid.cartesianToCartographic(
1530
+ position,
1531
+ scratchCartographic,
1532
+ );
1533
+ data.callback(positionCarto);
1530
1534
  }
1531
1535
  data.level = tile.level;
1532
1536
  }
@@ -57,22 +57,18 @@ function VoxelBoxShape() {
57
57
  this.shapeTransform = new Matrix4();
58
58
 
59
59
  /**
60
+ * The minimum bounds of the shape.
60
61
  * @type {Cartesian3}
61
62
  * @private
62
63
  */
63
- this._minBounds = Cartesian3.clone(
64
- VoxelBoxShape.DefaultMinBounds,
65
- new Cartesian3(),
66
- );
64
+ this._minBounds = VoxelBoxShape.DefaultMinBounds.clone();
67
65
 
68
66
  /**
67
+ * The maximum bounds of the shape.
69
68
  * @type {Cartesian3}
70
69
  * @private
71
70
  */
72
- this._maxBounds = Cartesian3.clone(
73
- VoxelBoxShape.DefaultMaxBounds,
74
- new Cartesian3(),
75
- );
71
+ this._maxBounds = VoxelBoxShape.DefaultMaxBounds.clone();
76
72
 
77
73
  /**
78
74
  * @private
@@ -125,8 +121,8 @@ const transformLocalToUv = Matrix4.fromRotationTranslation(
125
121
  * @param {Matrix4} modelMatrix The model matrix.
126
122
  * @param {Cartesian3} minBounds The minimum bounds.
127
123
  * @param {Cartesian3} maxBounds The maximum bounds.
128
- * @param {Cartesian3} [clipMinBounds=VoxelBoxShape.DefaultMinBounds] The minimum clip bounds.
129
- * @param {Cartesian3} [clipMaxBounds=VoxelBoxShape.DefaultMaxBounds] The maximum clip bounds.
124
+ * @param {Cartesian3} [clipMinBounds] The minimum clip bounds.
125
+ * @param {Cartesian3} [clipMaxBounds] The maximum clip bounds.
130
126
  * @returns {boolean} Whether the shape is visible.
131
127
  */
132
128
  VoxelBoxShape.prototype.update = function (
@@ -136,44 +132,17 @@ VoxelBoxShape.prototype.update = function (
136
132
  clipMinBounds,
137
133
  clipMaxBounds,
138
134
  ) {
139
- clipMinBounds = clipMinBounds ?? VoxelBoxShape.DefaultMinBounds;
140
- clipMaxBounds = clipMaxBounds ?? VoxelBoxShape.DefaultMaxBounds;
141
135
  //>>includeStart('debug', pragmas.debug);
142
136
  Check.typeOf.object("modelMatrix", modelMatrix);
143
137
  Check.typeOf.object("minBounds", minBounds);
144
138
  Check.typeOf.object("maxBounds", maxBounds);
145
139
  //>>includeEnd('debug');
146
140
 
147
- const defaultMinBounds = VoxelBoxShape.DefaultMinBounds;
148
- const defaultMaxBounds = VoxelBoxShape.DefaultMaxBounds;
141
+ clipMinBounds = clipMinBounds ?? minBounds.clone(scratchClipMinBounds);
142
+ clipMaxBounds = clipMaxBounds ?? maxBounds.clone(scratchClipMaxBounds);
149
143
 
150
- minBounds = this._minBounds = Cartesian3.clamp(
151
- minBounds,
152
- defaultMinBounds,
153
- defaultMaxBounds,
154
- this._minBounds,
155
- );
156
-
157
- maxBounds = this._maxBounds = Cartesian3.clamp(
158
- maxBounds,
159
- defaultMinBounds,
160
- defaultMaxBounds,
161
- this._maxBounds,
162
- );
163
-
164
- clipMinBounds = Cartesian3.clamp(
165
- clipMinBounds,
166
- defaultMinBounds,
167
- defaultMaxBounds,
168
- scratchClipMinBounds,
169
- );
170
-
171
- clipMaxBounds = Cartesian3.clamp(
172
- clipMaxBounds,
173
- defaultMinBounds,
174
- defaultMaxBounds,
175
- scratchClipMaxBounds,
176
- );
144
+ minBounds = Cartesian3.clone(minBounds, this._minBounds);
145
+ maxBounds = Cartesian3.clone(maxBounds, this._maxBounds);
177
146
 
178
147
  const renderMinBounds = Cartesian3.clamp(
179
148
  minBounds,
@@ -181,7 +150,6 @@ VoxelBoxShape.prototype.update = function (
181
150
  clipMaxBounds,
182
151
  scratchRenderMinBounds,
183
152
  );
184
-
185
153
  const renderMaxBounds = Cartesian3.clamp(
186
154
  maxBounds,
187
155
  clipMinBounds,
@@ -189,13 +157,11 @@ VoxelBoxShape.prototype.update = function (
189
157
  scratchRenderMaxBounds,
190
158
  );
191
159
 
192
- const scale = Matrix4.getScale(modelMatrix, scratchScale);
193
-
194
160
  // Box is not visible if:
195
161
  // - any of the min render bounds exceed the max render bounds
196
162
  // - two or more of the min bounds equal the max bounds (line / point)
197
- // - any of the min clip bounds exceed the max clip bounds
198
163
  // - scale is 0 for any component (too annoying to reconstruct rotation matrix)
164
+ const scale = Matrix4.getScale(modelMatrix, scratchScale);
199
165
  if (
200
166
  renderMinBounds.x > renderMaxBounds.x ||
201
167
  renderMinBounds.y > renderMaxBounds.y ||
@@ -204,9 +170,6 @@ VoxelBoxShape.prototype.update = function (
204
170
  (renderMinBounds.y === renderMaxBounds.y) +
205
171
  (renderMinBounds.z === renderMaxBounds.z) >=
206
172
  2 ||
207
- clipMinBounds.x > clipMaxBounds.x ||
208
- clipMinBounds.y > clipMaxBounds.y ||
209
- clipMinBounds.z > clipMaxBounds.z ||
210
173
  scale.x === 0.0 ||
211
174
  scale.y === 0.0 ||
212
175
  scale.z === 0.0
@@ -245,10 +208,6 @@ VoxelBoxShape.prototype.update = function (
245
208
  }
246
209
  }
247
210
 
248
- const hasShapeBounds =
249
- !Cartesian3.equals(minBounds, defaultMinBounds) ||
250
- !Cartesian3.equals(maxBounds, defaultMaxBounds);
251
-
252
211
  // Keep track of how many intersections there are going to be.
253
212
  let intersectionCount = 0;
254
213
 
@@ -266,36 +225,34 @@ VoxelBoxShape.prototype.update = function (
266
225
  shaderUniforms.renderMaxBounds,
267
226
  );
268
227
 
269
- if (hasShapeBounds) {
270
- shaderDefines["BOX_HAS_SHAPE_BOUNDS"] = true;
271
-
272
- const min = minBounds;
273
- const max = maxBounds;
274
-
275
- // Go from UV space to bounded UV space:
276
- // delerp(posUv, minBoundsUv, maxBoundsUv)
277
- // (posUv - minBoundsUv) / (maxBoundsUv - minBoundsUv)
278
- // posUv / (maxBoundsUv - minBoundsUv) - minBoundsUv / (maxBoundsUv - minBoundsUv)
279
- // scale = 1.0 / (maxBoundsUv - minBoundsUv)
280
- // scale = 1.0 / ((maxBounds * 0.5 + 0.5) - (minBounds * 0.5 + 0.5))
281
- // scale = 2.0 / (maxBounds - minBounds)
282
- // offset = -minBoundsUv / ((maxBounds * 0.5 + 0.5) - (minBounds * 0.5 + 0.5))
283
- // offset = -2.0 * (minBounds * 0.5 + 0.5) / (maxBounds - minBounds)
284
- // offset = -scale * (minBounds * 0.5 + 0.5)
285
- shaderUniforms.boxUvToShapeUvScale = Cartesian3.fromElements(
286
- 2.0 / (min.x === max.x ? 1.0 : max.x - min.x),
287
- 2.0 / (min.y === max.y ? 1.0 : max.y - min.y),
288
- 2.0 / (min.z === max.z ? 1.0 : max.z - min.z),
289
- shaderUniforms.boxUvToShapeUvScale,
290
- );
228
+ shaderDefines["BOX_HAS_SHAPE_BOUNDS"] = true;
229
+
230
+ const min = minBounds;
231
+ const max = maxBounds;
232
+
233
+ // Go from UV space to bounded UV space:
234
+ // delerp(posUv, minBoundsUv, maxBoundsUv)
235
+ // (posUv - minBoundsUv) / (maxBoundsUv - minBoundsUv)
236
+ // posUv / (maxBoundsUv - minBoundsUv) - minBoundsUv / (maxBoundsUv - minBoundsUv)
237
+ // scale = 1.0 / (maxBoundsUv - minBoundsUv)
238
+ // scale = 1.0 / ((maxBounds * 0.5 + 0.5) - (minBounds * 0.5 + 0.5))
239
+ // scale = 2.0 / (maxBounds - minBounds)
240
+ // offset = -minBoundsUv / ((maxBounds * 0.5 + 0.5) - (minBounds * 0.5 + 0.5))
241
+ // offset = -2.0 * (minBounds * 0.5 + 0.5) / (maxBounds - minBounds)
242
+ // offset = -scale * (minBounds * 0.5 + 0.5)
243
+ shaderUniforms.boxUvToShapeUvScale = Cartesian3.fromElements(
244
+ 2.0 / (min.x === max.x ? 1.0 : max.x - min.x),
245
+ 2.0 / (min.y === max.y ? 1.0 : max.y - min.y),
246
+ 2.0 / (min.z === max.z ? 1.0 : max.z - min.z),
247
+ shaderUniforms.boxUvToShapeUvScale,
248
+ );
291
249
 
292
- shaderUniforms.boxUvToShapeUvTranslate = Cartesian3.fromElements(
293
- -shaderUniforms.boxUvToShapeUvScale.x * (min.x * 0.5 + 0.5),
294
- -shaderUniforms.boxUvToShapeUvScale.y * (min.y * 0.5 + 0.5),
295
- -shaderUniforms.boxUvToShapeUvScale.z * (min.z * 0.5 + 0.5),
296
- shaderUniforms.boxUvToShapeUvTranslate,
297
- );
298
- }
250
+ shaderUniforms.boxUvToShapeUvTranslate = Cartesian3.fromElements(
251
+ -shaderUniforms.boxUvToShapeUvScale.x * (min.x * 0.5 + 0.5),
252
+ -shaderUniforms.boxUvToShapeUvScale.y * (min.y * 0.5 + 0.5),
253
+ -shaderUniforms.boxUvToShapeUvScale.z * (min.z * 0.5 + 0.5),
254
+ shaderUniforms.boxUvToShapeUvTranslate,
255
+ );
299
256
 
300
257
  this.shaderMaximumIntersectionsLength = intersectionCount;
301
258