@cesium/engine 22.2.0 → 22.3.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 (215) hide show
  1. package/Build/Workers/{chunk-C35SJ4QP.js → chunk-2MLJ46ZZ.js} +13 -13
  2. package/Build/Workers/{chunk-JERDRSEI.js → chunk-4BBANFU6.js} +1 -1
  3. package/Build/Workers/{chunk-JONWM4IO.js → chunk-4O2ARYS7.js} +1 -1
  4. package/Build/Workers/{chunk-VGH2CSC7.js → chunk-4R6FGUFP.js} +9 -9
  5. package/Build/Workers/{chunk-IVN5HSOI.js → chunk-5PJB7ASO.js} +6 -6
  6. package/Build/Workers/{chunk-35J4D6PX.js → chunk-6GBGEUWR.js} +2 -2
  7. package/Build/Workers/{chunk-DCR62BCO.js → chunk-6WDMPXQ7.js} +12 -12
  8. package/Build/Workers/{chunk-4ZQN7M7E.js → chunk-7ATKQRBM.js} +10 -10
  9. package/Build/Workers/{chunk-FPRM6PCE.js → chunk-7SLNBIZS.js} +5 -34
  10. package/Build/Workers/{chunk-VSZ5DB2W.js → chunk-7U5YNLF3.js} +1 -1
  11. package/Build/Workers/{chunk-I4D5IP46.js → chunk-AFGP5BXS.js} +7 -7
  12. package/Build/Workers/{chunk-IWOSJVFQ.js → chunk-AWELU5C6.js} +14 -14
  13. package/Build/Workers/{chunk-LDSQMLRC.js → chunk-BO22JHBX.js} +3 -3
  14. package/Build/Workers/{chunk-2YVTOY5Z.js → chunk-D2PEV362.js} +10 -10
  15. package/Build/Workers/{chunk-PSHZAHFE.js → chunk-D63Z7KKL.js} +11 -11
  16. package/Build/Workers/{chunk-AMWXJ5A7.js → chunk-D6OKR3BQ.js} +2 -2
  17. package/Build/Workers/{chunk-I45CATZK.js → chunk-E4YDCSQK.js} +9 -9
  18. package/Build/Workers/{chunk-YFEZPDAY.js → chunk-EAAH543Q.js} +11 -11
  19. package/Build/Workers/{chunk-SDUH3N6G.js → chunk-EOSX23OS.js} +4 -4
  20. package/Build/Workers/{chunk-A3NUMZBG.js → chunk-EUDHHS7K.js} +6 -6
  21. package/Build/Workers/{chunk-BKYJBTHW.js → chunk-EY5HOJFQ.js} +5 -5
  22. package/Build/Workers/{chunk-64PJ4MTB.js → chunk-FDOLXORR.js} +7 -7
  23. package/Build/Workers/{chunk-WH4HDRGN.js → chunk-FS42VX2H.js} +2 -2
  24. package/Build/Workers/{chunk-ED4UXMYY.js → chunk-FUDC3KOT.js} +5 -5
  25. package/Build/Workers/{chunk-CQCEPC6N.js → chunk-HWGP4GVC.js} +13 -13
  26. package/Build/Workers/{chunk-QO6Z5UJE.js → chunk-IHFAFGR2.js} +2 -2
  27. package/Build/Workers/{chunk-72LZ3FN6.js → chunk-IXL46IYV.js} +12 -12
  28. package/Build/Workers/{chunk-JFN2DQHY.js → chunk-K2PLKJJG.js} +5 -5
  29. package/Build/Workers/{chunk-NY3CWLIZ.js → chunk-K4PGSAR5.js} +8 -8
  30. package/Build/Workers/{chunk-UBJYWGMV.js → chunk-KIJR26N3.js} +16 -16
  31. package/Build/Workers/{chunk-MWGB6DLR.js → chunk-L4OFWHNI.js} +1 -1
  32. package/Build/Workers/{chunk-XPNY2VY3.js → chunk-LK7GEFGB.js} +2 -2
  33. package/Build/Workers/{chunk-3JB2X2PR.js → chunk-LWZHJWYK.js} +6 -6
  34. package/Build/Workers/{chunk-ZGWX2R5I.js → chunk-LYBNPUEI.js} +4 -4
  35. package/Build/Workers/{chunk-4I7BCCNU.js → chunk-M5DVYXJJ.js} +6 -6
  36. package/Build/Workers/{chunk-4MCPC4TE.js → chunk-MASEF4OV.js} +8 -8
  37. package/Build/Workers/{chunk-FM5XPC2E.js → chunk-N66PIK46.js} +4 -4
  38. package/Build/Workers/{chunk-C6FTHSJA.js → chunk-N6XBJBI7.js} +6 -6
  39. package/Build/Workers/{chunk-7OPRTZBT.js → chunk-NO3LMU7T.js} +7 -7
  40. package/Build/Workers/{chunk-DIJ7IG5D.js → chunk-NVL7JXAQ.js} +10 -10
  41. package/Build/Workers/{chunk-O3GWUTWM.js → chunk-OOYICVOK.js} +1 -1
  42. package/Build/Workers/{chunk-K6BXEBAF.js → chunk-PJLRXIMS.js} +17 -17
  43. package/Build/Workers/{chunk-7CDQUIP5.js → chunk-S2KVL7OJ.js} +8 -8
  44. package/Build/Workers/{chunk-PMDPP22G.js → chunk-T5MJDW43.js} +7 -7
  45. package/Build/Workers/{chunk-GMHDOQPH.js → chunk-TCOUGKXF.js} +4 -4
  46. package/Build/Workers/{chunk-ZUWF63QU.js → chunk-TMGLPEZW.js} +4 -4
  47. package/Build/Workers/{chunk-JUOSYFXT.js → chunk-TY5JXMVO.js} +1 -1
  48. package/Build/Workers/{chunk-3HUEBDFC.js → chunk-VIQIKMTZ.js} +14 -14
  49. package/Build/Workers/{chunk-N5MNKWED.js → chunk-VRAAQ3FS.js} +2 -2
  50. package/Build/Workers/{chunk-K64RQCRK.js → chunk-W5NV72VR.js} +17 -17
  51. package/Build/Workers/{chunk-G6WQA27G.js → chunk-WHLGBMBC.js} +5 -5
  52. package/Build/Workers/{chunk-2JNPWPLE.js → chunk-WUWPKBOZ.js} +6 -6
  53. package/Build/Workers/{chunk-MSTAVM2N.js → chunk-XLIJV3YZ.js} +10 -10
  54. package/Build/Workers/{chunk-V26Y7ZQL.js → chunk-Y5MRBKQN.js} +37 -27
  55. package/Build/Workers/{chunk-L2FSBEW2.js → chunk-YHPBT4I5.js} +5 -5
  56. package/Build/Workers/{chunk-7MGTX4WP.js → chunk-ZGGVEGTA.js} +12 -12
  57. package/Build/Workers/{chunk-P7ISUYLW.js → chunk-ZWWN2CQH.js} +4 -4
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/BoxGeometry.js +1 -1
  112. package/Source/Core/CornerType.js +1 -1
  113. package/Source/Core/CorridorGeometry.js +1 -1
  114. package/Source/Core/FeatureDetection.js +1 -32
  115. package/Source/Core/Geometry.js +1 -1
  116. package/Source/Core/IntersectionTests.js +2 -2
  117. package/Source/Core/Ion.js +1 -1
  118. package/Source/Core/PinBuilder.js +1 -1
  119. package/Source/Core/PolygonGeometry.js +1 -1
  120. package/Source/Core/PolylineGeometry.js +1 -1
  121. package/Source/Core/PolylineVolumeGeometry.js +1 -1
  122. package/Source/Core/RectangleGeometry.js +1 -1
  123. package/Source/Core/ScreenSpaceEventHandler.js +4 -8
  124. package/Source/Core/TerrainMesh.js +11 -8
  125. package/Source/Core/TerrainPicker.js +24 -7
  126. package/Source/Core/VideoSynchronizer.js +1 -1
  127. package/Source/Core/WallGeometry.js +1 -1
  128. package/Source/Core/writeTextToCanvas.js +40 -86
  129. package/Source/DataSources/BillboardGraphics.js +1 -1
  130. package/Source/DataSources/BoxGraphics.js +1 -1
  131. package/Source/DataSources/CallbackPositionProperty.js +1 -1
  132. package/Source/DataSources/CorridorGraphics.js +1 -1
  133. package/Source/DataSources/CzmlDataSource.js +1 -1
  134. package/Source/DataSources/EllipseGraphics.js +1 -1
  135. package/Source/DataSources/EllipsoidGraphics.js +1 -1
  136. package/Source/DataSources/Entity.js +1 -1
  137. package/Source/DataSources/EntityCluster.js +2 -2
  138. package/Source/DataSources/GeoJsonDataSource.js +2 -2
  139. package/Source/DataSources/GpxDataSource.js +1 -1
  140. package/Source/DataSources/KmlDataSource.js +1 -1
  141. package/Source/DataSources/KmlTour.js +1 -1
  142. package/Source/DataSources/LabelGraphics.js +1 -1
  143. package/Source/DataSources/ModelGraphics.js +1 -1
  144. package/Source/DataSources/PlaneGraphics.js +1 -1
  145. package/Source/DataSources/PolygonGraphics.js +1 -1
  146. package/Source/DataSources/PolylineGraphics.js +1 -1
  147. package/Source/DataSources/PolylineVolumeGraphics.js +1 -1
  148. package/Source/DataSources/RectangleGraphics.js +1 -1
  149. package/Source/DataSources/WallGraphics.js +1 -1
  150. package/Source/DataSources/exportKml.js +1 -1
  151. package/Source/Renderer/Context.js +11 -10
  152. package/Source/Renderer/ContextLimits.js +66 -33
  153. package/Source/Renderer/ShaderSource.js +19 -18
  154. package/Source/Renderer/Texture.js +1 -1
  155. package/Source/Renderer/Texture3D.js +166 -7
  156. package/Source/Renderer/TextureAtlas.js +2 -2
  157. package/Source/Scene/Appearance.js +1 -1
  158. package/Source/Scene/ArcGisMapService.js +1 -1
  159. package/Source/Scene/Billboard.js +1 -1
  160. package/Source/Scene/BillboardCollection.js +1 -1
  161. package/Source/Scene/BillboardTexture.js +4 -1
  162. package/Source/Scene/Camera.js +13 -2
  163. package/Source/Scene/ClippingPlaneCollection.js +2 -2
  164. package/Source/Scene/CloudCollection.js +2 -2
  165. package/Source/Scene/CumulusCloud.js +1 -1
  166. package/Source/Scene/DynamicEnvironmentMapManager.js +41 -26
  167. package/Source/Scene/Fog.js +1 -1
  168. package/Source/Scene/GaussianSplatPrimitive.js +1 -1
  169. package/Source/Scene/Globe.js +3 -10
  170. package/Source/Scene/GltfLoader.js +10 -0
  171. package/Source/Scene/ImageBasedLighting.js +2 -2
  172. package/Source/Scene/ImageryLayerCollection.js +2 -2
  173. package/Source/Scene/ImageryProvider.js +2 -2
  174. package/Source/Scene/Label.js +1 -1
  175. package/Source/Scene/LabelCollection.js +1 -1
  176. package/Source/Scene/Material.js +1 -1
  177. package/Source/Scene/MaterialAppearance.js +1 -1
  178. package/Source/Scene/Megatexture.js +174 -242
  179. package/Source/Scene/Model/MaterialPipelineStage.js +17 -0
  180. package/Source/Scene/Model/Model.js +1 -1
  181. package/Source/Scene/ModelComponents.js +10 -0
  182. package/Source/Scene/ParticleSystem.js +2 -2
  183. package/Source/Scene/PointPrimitive.js +1 -1
  184. package/Source/Scene/Polyline.js +0 -1
  185. package/Source/Scene/PolylineCollection.js +1 -4
  186. package/Source/Scene/PolylineColorAppearance.js +1 -6
  187. package/Source/Scene/PolylineMaterialAppearance.js +1 -6
  188. package/Source/Scene/PostProcessStageCollection.js +1 -1
  189. package/Source/Scene/QuadtreePrimitive.js +6 -3
  190. package/Source/Scene/ShadowMap.js +1 -2
  191. package/Source/Scene/Vector3DTileClampedPolylines.js +1 -5
  192. package/Source/Scene/Vector3DTilePolylines.js +1 -5
  193. package/Source/Scene/VoxelPrimitive.js +16 -33
  194. package/Source/Scene/VoxelRenderResources.js +1 -8
  195. package/Source/Scene/VoxelTraversal.js +16 -61
  196. package/Source/Scene/WebMapTileServiceImageryProvider.js +1 -1
  197. package/Source/Scene/createElevationBandMaterial.js +1 -1
  198. package/Source/Scene/processVoxelProperties.js +1 -1
  199. package/Source/Shaders/Builtin/Functions/columbusViewMorph.glsl +8 -1
  200. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  201. package/Source/Shaders/Model/ModelFS.glsl +8 -0
  202. package/Source/Shaders/Model/ModelFS.js +8 -0
  203. package/Source/Shaders/Model/ModelVS.glsl +2 -0
  204. package/Source/Shaders/Model/ModelVS.js +2 -0
  205. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -1
  206. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -1
  207. package/Source/Shaders/Voxels/Megatexture.glsl +15 -83
  208. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  209. package/Source/Shaders/Voxels/Octree.glsl +6 -9
  210. package/Source/Shaders/Voxels/Octree.js +6 -9
  211. package/Source/Widget/CesiumWidget.js +1 -1
  212. package/Source/Workers/incrementallyBuildTerrainPicker.js +16 -2
  213. package/index.d.ts +18 -4
  214. package/index.js +90 -90
  215. package/package.json +2 -1
@@ -1,18 +1,13 @@
1
1
  import Frozen from "../Core/Frozen.js";
2
- import FeatureDetection from "../Core/FeatureDetection.js";
3
2
  import VertexFormat from "../Core/VertexFormat.js";
4
3
  import PerInstanceFlatColorAppearanceFS from "../Shaders/Appearances/PerInstanceFlatColorAppearanceFS.js";
5
4
  import PolylineColorAppearanceVS from "../Shaders/Appearances/PolylineColorAppearanceVS.js";
6
5
  import PolylineCommon from "../Shaders/PolylineCommon.js";
7
6
  import Appearance from "./Appearance.js";
8
7
 
9
- let defaultVertexShaderSource = `${PolylineCommon}\n${PolylineColorAppearanceVS}`;
8
+ const defaultVertexShaderSource = `#define CLIP_POLYLINE \n${PolylineCommon}\n${PolylineColorAppearanceVS}`;
10
9
  const defaultFragmentShaderSource = PerInstanceFlatColorAppearanceFS;
11
10
 
12
- if (!FeatureDetection.isInternetExplorer()) {
13
- defaultVertexShaderSource = `#define CLIP_POLYLINE \n${defaultVertexShaderSource}`;
14
- }
15
-
16
11
  /**
17
12
  * An appearance for {@link GeometryInstance} instances with color attributes and
18
13
  * {@link PolylineGeometry} or {@link GroundPolylineGeometry}.
@@ -1,6 +1,5 @@
1
1
  import Frozen from "../Core/Frozen.js";
2
2
  import defined from "../Core/defined.js";
3
- import FeatureDetection from "../Core/FeatureDetection.js";
4
3
  import VertexFormat from "../Core/VertexFormat.js";
5
4
  import PolylineMaterialAppearanceVS from "../Shaders/Appearances/PolylineMaterialAppearanceVS.js";
6
5
  import PolylineCommon from "../Shaders/PolylineCommon.js";
@@ -8,13 +7,9 @@ import PolylineFS from "../Shaders/PolylineFS.js";
8
7
  import Appearance from "./Appearance.js";
9
8
  import Material from "./Material.js";
10
9
 
11
- let defaultVertexShaderSource = `${PolylineCommon}\n${PolylineMaterialAppearanceVS}`;
10
+ const defaultVertexShaderSource = `#define CLIP_POLYLINE \n${PolylineCommon}\n${PolylineMaterialAppearanceVS}`;
12
11
  const defaultFragmentShaderSource = PolylineFS;
13
12
 
14
- if (!FeatureDetection.isInternetExplorer()) {
15
- defaultVertexShaderSource = `#define CLIP_POLYLINE \n${defaultVertexShaderSource}`;
16
- }
17
-
18
13
  /**
19
14
  * An appearance for {@link PolylineGeometry} that supports shading with materials.
20
15
  *
@@ -303,7 +303,7 @@ Object.defineProperties(PostProcessStageCollection.prototype, {
303
303
 
304
304
  /**
305
305
  * Specifies the tonemapping algorithm used when rendering with high dynamic range.
306
- * {@link https://sandcastle.cesium.com/?src=High%20Dynamic%20Range.html|Sandcastle Demo}
306
+ * {@link https://sandcastle.cesium.com/?id=high-dynamic-range|Sandcastle Demo}
307
307
  *
308
308
  * @example viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.ACES;
309
309
  *
@@ -77,6 +77,7 @@ function QuadtreePrimitive(options) {
77
77
  const tilingScheme = this._tileProvider.tilingScheme;
78
78
  const ellipsoid = tilingScheme.ellipsoid;
79
79
 
80
+ this._tilesRenderedThisFrame = new Set(); // collect all tiles selected to render (useful when multiple render calls are made in a single frame (as in 2D mode))
80
81
  this._tilesToRender = [];
81
82
  this._tileLoadQueueHigh = []; // high priority tiles are preventing refinement
82
83
  this._tileLoadQueueMedium = []; // medium priority tiles are being rendered
@@ -256,9 +257,9 @@ QuadtreePrimitive.prototype.forEachLoadedTile = function (tileFunction) {
256
257
  * function is passed a reference to the tile as its only parameter.
257
258
  */
258
259
  QuadtreePrimitive.prototype.forEachRenderedTile = function (tileFunction) {
259
- const tilesRendered = this._tilesToRender;
260
- for (let i = 0, len = tilesRendered.length; i < len; ++i) {
261
- tileFunction(tilesRendered[i]);
260
+ const tilesRendered = this._tilesRenderedThisFrame;
261
+ for (const tile of tilesRendered) {
262
+ tileFunction(tile);
262
263
  }
263
264
  };
264
265
 
@@ -347,6 +348,7 @@ QuadtreePrimitive.prototype.beginFrame = function (frameState) {
347
348
  }
348
349
 
349
350
  this._tileReplacementQueue.markStartOfRenderFrame();
351
+ this._tilesRenderedThisFrame.clear();
350
352
  };
351
353
 
352
354
  /**
@@ -1303,6 +1305,7 @@ function screenSpaceError2D(primitive, frameState, tile) {
1303
1305
 
1304
1306
  function addTileToRenderList(primitive, tile) {
1305
1307
  primitive._tilesToRender.push(tile);
1308
+ primitive._tilesRenderedThisFrame.add(tile);
1306
1309
  }
1307
1310
 
1308
1311
  function processTileLoadQueue(primitive, frameState) {
@@ -76,7 +76,7 @@ import ShadowMapShader from "./ShadowMapShader.js";
76
76
  *
77
77
  * @exception {DeveloperError} Only one or four cascades are supported.
78
78
  *
79
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Shadows.html|Cesium Sandcastle Shadows Demo}
79
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=shadows|Cesium Sandcastle Shadows Demo}
80
80
  */
81
81
  function ShadowMap(options) {
82
82
  options = options ?? Frozen.EMPTY_OBJECT;
@@ -145,7 +145,6 @@ function ShadowMap(options) {
145
145
  // Re-enable once https://github.com/CesiumGS/cesium/issues/4560 is resolved.
146
146
  let polygonOffsetSupported = true;
147
147
  if (
148
- FeatureDetection.isInternetExplorer() ||
149
148
  FeatureDetection.isEdge() ||
150
149
  ((FeatureDetection.isChrome() || FeatureDetection.isFirefox()) &&
151
150
  FeatureDetection.isWindows() &&
@@ -6,7 +6,6 @@ import ComponentDatatype from "../Core/ComponentDatatype.js";
6
6
  import defined from "../Core/defined.js";
7
7
  import destroyObject from "../Core/destroyObject.js";
8
8
  import Ellipsoid from "../Core/Ellipsoid.js";
9
- import FeatureDetection from "../Core/FeatureDetection.js";
10
9
  import IndexDatatype from "../Core/IndexDatatype.js";
11
10
  import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
12
11
  import Matrix4 from "../Core/Matrix4.js";
@@ -557,10 +556,7 @@ function createShaders(primitive, context) {
557
556
  )(Vector3DTileClampedPolylinesFS);
558
557
 
559
558
  const vs = new ShaderSource({
560
- defines: [
561
- "VECTOR_TILE",
562
- !FeatureDetection.isInternetExplorer() ? "CLIP_POLYLINE" : "",
563
- ],
559
+ defines: ["VECTOR_TILE", "CLIP_POLYLINE"],
564
560
  sources: [PolylineCommon, vsSource],
565
561
  });
566
562
  const fs = new ShaderSource({
@@ -4,7 +4,6 @@ import ComponentDatatype from "../Core/ComponentDatatype.js";
4
4
  import defined from "../Core/defined.js";
5
5
  import destroyObject from "../Core/destroyObject.js";
6
6
  import Ellipsoid from "../Core/Ellipsoid.js";
7
- import FeatureDetection from "../Core/FeatureDetection.js";
8
7
  import IndexDatatype from "../Core/IndexDatatype.js";
9
8
  import Matrix4 from "../Core/Matrix4.js";
10
9
  import Rectangle from "../Core/Rectangle.js";
@@ -456,10 +455,7 @@ function createShaders(primitive, context) {
456
455
  )(PolylineFS);
457
456
 
458
457
  const vs = new ShaderSource({
459
- defines: [
460
- "VECTOR_TILE",
461
- !FeatureDetection.isInternetExplorer() ? "CLIP_POLYLINE" : "",
462
- ],
458
+ defines: ["VECTOR_TILE", "CLIP_POLYLINE"],
463
459
  sources: [PolylineCommon, vsSource],
464
460
  });
465
461
  const fs = new ShaderSource({
@@ -405,11 +405,7 @@ function VoxelPrimitive(options) {
405
405
  octreeLeafNodeTilesPerRow: 0,
406
406
  octreeLeafNodeTexelSizeUv: new Cartesian2(),
407
407
  megatextureTextures: [],
408
- megatextureSliceDimensions: new Cartesian2(),
409
- megatextureTileDimensions: new Cartesian2(),
410
- megatextureVoxelSizeUv: new Cartesian2(),
411
- megatextureSliceSizeUv: new Cartesian2(),
412
- megatextureTileSizeUv: new Cartesian2(),
408
+ megatextureTileCounts: new Cartesian3(),
413
409
  dimensions: new Cartesian3(),
414
410
  inputDimensions: new Cartesian3(),
415
411
  paddingBefore: new Cartesian3(),
@@ -855,10 +851,7 @@ Object.defineProperties(VoxelPrimitive.prototype, {
855
851
  Check.typeOf.bool("nearestSampling", nearestSampling);
856
852
  //>>includeEnd('debug');
857
853
 
858
- if (this._nearestSampling !== nearestSampling) {
859
- this._nearestSampling = nearestSampling;
860
- this._shaderDirty = true;
861
- }
854
+ this._nearestSampling = nearestSampling;
862
855
  },
863
856
  },
864
857
 
@@ -1282,6 +1275,7 @@ VoxelPrimitive.prototype.update = function (frameState) {
1282
1275
  );
1283
1276
  uniforms.stepSize = this._stepSizeMultiplier;
1284
1277
 
1278
+ updateNearestSampling(this);
1285
1279
  updateRenderBoundPlanes(this, frameState);
1286
1280
 
1287
1281
  // Render the primitive
@@ -1294,6 +1288,13 @@ VoxelPrimitive.prototype.update = function (frameState) {
1294
1288
  frameState.commandList.push(command);
1295
1289
  };
1296
1290
 
1291
+ function updateNearestSampling(primitive) {
1292
+ const { megatextures } = primitive._traversal;
1293
+ for (let i = 0; i < megatextures.length; ++i) {
1294
+ megatextures[i].nearestSampling = primitive._nearestSampling;
1295
+ }
1296
+ }
1297
+
1297
1298
  function updateRenderBoundPlanes(primitive, frameState) {
1298
1299
  const uniforms = primitive._uniforms;
1299
1300
  const { renderBoundPlanes } = primitive._shape;
@@ -1689,33 +1690,15 @@ function setTraversalUniforms(traversal, uniforms) {
1689
1690
  );
1690
1691
  uniforms.octreeInternalNodeTilesPerRow = traversal.internalNodeTilesPerRow;
1691
1692
 
1692
- const megatextures = traversal.megatextures;
1693
+ const { megatextures } = traversal;
1693
1694
  const megatexture = megatextures[0];
1694
- const megatextureLength = megatextures.length;
1695
- uniforms.megatextureTextures = new Array(megatextureLength);
1696
- for (let i = 0; i < megatextureLength; i++) {
1695
+ uniforms.megatextureTextures = new Array(megatextures.length);
1696
+ for (let i = 0; i < megatextures.length; i++) {
1697
1697
  uniforms.megatextureTextures[i] = megatextures[i].texture;
1698
1698
  }
1699
-
1700
- uniforms.megatextureSliceDimensions = Cartesian2.clone(
1701
- megatexture.sliceCountPerRegion,
1702
- uniforms.megatextureSliceDimensions,
1703
- );
1704
- uniforms.megatextureTileDimensions = Cartesian2.clone(
1705
- megatexture.regionCountPerMegatexture,
1706
- uniforms.megatextureTileDimensions,
1707
- );
1708
- uniforms.megatextureVoxelSizeUv = Cartesian2.clone(
1709
- megatexture.voxelSizeUv,
1710
- uniforms.megatextureVoxelSizeUv,
1711
- );
1712
- uniforms.megatextureSliceSizeUv = Cartesian2.clone(
1713
- megatexture.sliceSizeUv,
1714
- uniforms.megatextureSliceSizeUv,
1715
- );
1716
- uniforms.megatextureTileSizeUv = Cartesian2.clone(
1717
- megatexture.regionSizeUv,
1718
- uniforms.megatextureTileSizeUv,
1699
+ uniforms.megatextureTileCounts = Cartesian3.clone(
1700
+ megatexture.tileCounts,
1701
+ uniforms.megatextureTileCounts,
1719
1702
  );
1720
1703
  }
1721
1704
 
@@ -62,7 +62,7 @@ function VoxelRenderResources(primitive) {
62
62
  // The reason this uniform is added by shader builder is because some of the
63
63
  // dynamically generated shader code reads from it.
64
64
  shaderBuilder.addUniform(
65
- "sampler2D",
65
+ "sampler3D",
66
66
  "u_megatextureTextures[METADATA_COUNT]",
67
67
  ShaderDestination.FRAGMENT,
68
68
  );
@@ -241,13 +241,6 @@ function VoxelRenderResources(primitive) {
241
241
  ShaderDestination.FRAGMENT,
242
242
  );
243
243
  }
244
- if (primitive._nearestSampling) {
245
- shaderBuilder.addDefine(
246
- "NEAREST_SAMPLING",
247
- undefined,
248
- ShaderDestination.FRAGMENT,
249
- );
250
- }
251
244
  const traversal = primitive._traversal;
252
245
  shaderBuilder.addDefine(
253
246
  "SAMPLE_COUNT",
@@ -1,5 +1,4 @@
1
1
  import Cartesian2 from "../Core/Cartesian2.js";
2
- import Cartesian3 from "../Core/Cartesian3.js";
3
2
  import CesiumMath from "../Core/Math.js";
4
3
  import CullingVolume from "../Core/CullingVolume.js";
5
4
  import defined from "../Core/defined.js";
@@ -16,7 +15,6 @@ import SpatialNode from "./SpatialNode.js";
16
15
  import Texture from "../Renderer/Texture.js";
17
16
  import TextureMagnificationFilter from "../Renderer/TextureMagnificationFilter.js";
18
17
  import TextureMinificationFilter from "../Renderer/TextureMinificationFilter.js";
19
- import VoxelMetadataOrder from "./VoxelMetadataOrder.js";
20
18
 
21
19
  /**
22
20
  * Handles tileset traversal, tile requests, and GPU resources. Intended to be
@@ -28,7 +26,7 @@ import VoxelMetadataOrder from "./VoxelMetadataOrder.js";
28
26
  * @param {VoxelPrimitive} primitive The voxel primitive for which this traversal will be used.
29
27
  * @param {Context} context The context in which to create GPU resources.
30
28
  * @param {number} keyframeCount The number of keyframes in the tileset.
31
- * @param {number} [maximumTextureMemoryByteLength] The maximum amount of memory to use for textures.
29
+ * @param {number} [maximumTextureMemoryByteLength=536870912] The maximum amount of memory to use for textures.
32
30
  *
33
31
  * @private
34
32
  */
@@ -38,32 +36,16 @@ function VoxelTraversal(
38
36
  keyframeCount,
39
37
  maximumTextureMemoryByteLength,
40
38
  ) {
41
- const { provider, dimensions, paddingBefore, paddingAfter } = primitive;
42
- const { types, componentTypes, metadataOrder } = provider;
39
+ const { provider, dimensions, inputDimensions } = primitive;
40
+ const { types, componentTypes } = provider;
43
41
 
44
- const inputDimensions = Cartesian3.add(
45
- dimensions,
46
- paddingBefore,
47
- new Cartesian3(),
48
- );
49
- Cartesian3.add(inputDimensions, paddingAfter, inputDimensions);
50
-
51
- if (metadataOrder === VoxelMetadataOrder.Y_UP) {
52
- const inputDimensionsY = inputDimensions.y;
53
- inputDimensions.y = inputDimensions.z;
54
- inputDimensions.z = inputDimensionsY;
55
- }
56
-
57
- if (
58
- !defined(maximumTextureMemoryByteLength) &&
59
- defined(provider.maximumTileCount)
60
- ) {
61
- maximumTextureMemoryByteLength = getApproximateTextureMemoryByteLength(
62
- provider.maximumTileCount,
63
- inputDimensions,
64
- types,
65
- componentTypes,
42
+ if (defined(maximumTextureMemoryByteLength)) {
43
+ maximumTextureMemoryByteLength = Math.min(
44
+ Math.max(0, maximumTextureMemoryByteLength),
45
+ 512 * 1024 * 1024,
66
46
  );
47
+ } else {
48
+ maximumTextureMemoryByteLength = 128 * 1024 * 1024;
67
49
  }
68
50
 
69
51
  /**
@@ -84,7 +66,12 @@ function VoxelTraversal(
84
66
  */
85
67
  this.megatextures = new Array(types.length);
86
68
 
87
- // TODO make sure to split the maximumTextureMemoryByteLength across all the megatextures
69
+ const providerTileCount = defined(provider.maximumTileCount)
70
+ ? provider.maximumTileCount
71
+ : defined(provider.availableLevels)
72
+ ? (8 ** provider.availableLevels - 1) / 7
73
+ : undefined;
74
+
88
75
  for (let i = 0; i < types.length; i++) {
89
76
  const type = types[i];
90
77
  const componentCount = MetadataType.getComponentCount(type);
@@ -96,6 +83,7 @@ function VoxelTraversal(
96
83
  componentCount,
97
84
  componentType,
98
85
  maximumTextureMemoryByteLength,
86
+ providerTileCount,
99
87
  );
100
88
 
101
89
  this.textureMemoryByteLength +=
@@ -1228,37 +1216,4 @@ function copyToLeafNodeTexture(data, texelsPerTile, tilesPerRow, texture) {
1228
1216
  texture.copyFrom(copyOptions);
1229
1217
  }
1230
1218
 
1231
- /**
1232
- * @param {number} tileCount
1233
- * @param {Cartesian3} dimensions
1234
- * @param {MetadataType[]} types
1235
- * @param {MetadataComponentType[]} componentTypes
1236
- * @private
1237
- */
1238
- function getApproximateTextureMemoryByteLength(
1239
- tileCount,
1240
- dimensions,
1241
- types,
1242
- componentTypes,
1243
- ) {
1244
- let textureMemoryByteLength = 0;
1245
-
1246
- const length = types.length;
1247
- for (let i = 0; i < length; i++) {
1248
- const type = types[i];
1249
- const componentType = componentTypes[i];
1250
- const componentCount = MetadataType.getComponentCount(type);
1251
-
1252
- textureMemoryByteLength +=
1253
- Megatexture.getApproximateTextureMemoryByteLength(
1254
- tileCount,
1255
- dimensions,
1256
- componentCount,
1257
- componentType,
1258
- );
1259
- }
1260
-
1261
- return textureMemoryByteLength;
1262
- }
1263
-
1264
1219
  export default VoxelTraversal;
@@ -51,7 +51,7 @@ const defaultParameters = Object.freeze({
51
51
  *
52
52
  * @param {WebMapTileServiceImageryProvider.ConstructorOptions} options Object describing initialization options
53
53
  *
54
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Web%20Map%20Tile%20Service%20with%20Time.html|Cesium Sandcastle Web Map Tile Service with Time Demo}
54
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=web-map-tile-service-with-time|Cesium Sandcastle Web Map Tile Service with Time Demo}
55
55
  *
56
56
  * @example
57
57
  * // Example 1. USGS shaded relief tiles (KVP)
@@ -435,7 +435,7 @@ function createLayeredEntries(layers) {
435
435
  * @param {createElevationBandMaterialBand[]} options.layers A list of bands ordered from lowest to highest precedence.
436
436
  * @returns {Material} A new {@link Material} instance.
437
437
  *
438
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Elevation%20Band%20Material.html|Cesium Sandcastle Elevation Band Demo}
438
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=elevation-band-material|Cesium Sandcastle Elevation Band Demo}
439
439
  *
440
440
  * @example
441
441
  * scene.globe.material = Cesium.createElevationBandMaterial({
@@ -294,7 +294,7 @@ function processVoxelProperties(renderResources, primitive) {
294
294
  const functionId = "getPropertiesFromMegatextureAtUv";
295
295
  shaderBuilder.addFunction(
296
296
  functionId,
297
- `${propertiesStructName} getPropertiesFromMegatextureAtUv(vec2 texcoord)`,
297
+ `${propertiesStructName} getPropertiesFromMegatextureAtUv(vec3 texcoord)`,
298
298
  ShaderDestination.FRAGMENT,
299
299
  );
300
300
  shaderBuilder.addFunctionLines(functionId, [
@@ -7,6 +7,13 @@
7
7
  vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)
8
8
  {
9
9
  // Just linear for now.
10
- vec3 p = mix(position2D.xyz, position3D.xyz, time);
10
+ // We're manually doing the equivalent of a `mix` here because, some GPUs
11
+ // (NVidia GeForce 3070 Ti and Intel Arc A750, to name two), `mix` seems to
12
+ // use an alternate formulation that introduces jitter even when `time` is
13
+ // 0.0 or 1.0. That is, the value of `p` won't be exactly `position2D.xyz`
14
+ // when `time` is 0.0 and it won't be exactly `position3D.xyz` when `time` is
15
+ // 1.0. The "textbook" formulation here, while probably a bit slower,
16
+ // does not have this problem.
17
+ vec3 p = position2D.xyz * (1.0 - time) + position3D.xyz * time;
11
18
  return vec4(p, 1.0);
12
19
  }
@@ -8,7 +8,14 @@ export default "/**\n\
8
8
  vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)\n\
9
9
  {\n\
10
10
  // Just linear for now.\n\
11
- vec3 p = mix(position2D.xyz, position3D.xyz, time);\n\
11
+ // We're manually doing the equivalent of a `mix` here because, some GPUs\n\
12
+ // (NVidia GeForce 3070 Ti and Intel Arc A750, to name two), `mix` seems to\n\
13
+ // use an alternate formulation that introduces jitter even when `time` is\n\
14
+ // 0.0 or 1.0. That is, the value of `p` won't be exactly `position2D.xyz`\n\
15
+ // when `time` is 0.0 and it won't be exactly `position3D.xyz` when `time` is\n\
16
+ // 1.0. The \"textbook\" formulation here, while probably a bit slower,\n\
17
+ // does not have this problem.\n\
18
+ vec3 p = position2D.xyz * (1.0 - time) + position3D.xyz * time;\n\
12
19
  return vec4(p, 1.0);\n\
13
20
  }\n\
14
21
  ";
@@ -29,6 +29,14 @@ SelectedFeature selectedFeature;
29
29
 
30
30
  void main()
31
31
  {
32
+ #ifdef PRIMITIVE_TYPE_POINTS
33
+ // Render points as circles
34
+ float distanceToCenter = length(gl_PointCoord - vec2(0.5));
35
+ if (distanceToCenter > 0.5) {
36
+ discard;
37
+ }
38
+ #endif
39
+
32
40
  #ifdef HAS_POINT_CLOUD_SHOW_STYLE
33
41
  if (v_pointCloudShow == 0.0)
34
42
  {
@@ -30,6 +30,14 @@ SelectedFeature selectedFeature;\n\
30
30
  \n\
31
31
  void main()\n\
32
32
  {\n\
33
+ #ifdef PRIMITIVE_TYPE_POINTS\n\
34
+ // Render points as circles\n\
35
+ float distanceToCenter = length(gl_PointCoord - vec2(0.5));\n\
36
+ if (distanceToCenter > 0.5) {\n\
37
+ discard;\n\
38
+ }\n\
39
+ #endif\n\
40
+ \n\
33
41
  #ifdef HAS_POINT_CLOUD_SHOW_STYLE\n\
34
42
  if (v_pointCloudShow == 0.0)\n\
35
43
  {\n\
@@ -142,6 +142,8 @@ void main()
142
142
  gl_PointSize = vsOutput.pointSize;
143
143
  #elif defined(HAS_POINT_CLOUD_POINT_SIZE_STYLE) || defined(HAS_POINT_CLOUD_ATTENUATION)
144
144
  gl_PointSize = pointCloudPointSizeStylingStage(attributes, metadata);
145
+ #elif defined(HAS_POINT_DIAMETER)
146
+ gl_PointSize = u_pointDiameter;
145
147
  #else
146
148
  gl_PointSize = 1.0;
147
149
  #endif
@@ -143,6 +143,8 @@ void main()\n\
143
143
  gl_PointSize = vsOutput.pointSize;\n\
144
144
  #elif defined(HAS_POINT_CLOUD_POINT_SIZE_STYLE) || defined(HAS_POINT_CLOUD_ATTENUATION)\n\
145
145
  gl_PointSize = pointCloudPointSizeStylingStage(attributes, metadata);\n\
146
+ #elif defined(HAS_POINT_DIAMETER)\n\
147
+ gl_PointSize = u_pointDiameter;\n\
146
148
  #else\n\
147
149
  gl_PointSize = 1.0;\n\
148
150
  #endif\n\
@@ -135,7 +135,7 @@ RayShapeIntersection nextIntersection(inout Intersections ix) {
135
135
  surfaceIntersection = ix.intersections[i];
136
136
  int intersectionType = int(length(surfaceIntersection.xyz) - 0.5);
137
137
  bool currShapeIsPositive = intersectionType < 2;
138
- bool enter = intMod(intersectionType, 2) == 0;
138
+ bool enter = intersectionType % 2 == 0;
139
139
 
140
140
  ix.surroundCount += enter ? +1 : -1;
141
141
  ix.surroundIsPositive = currShapeIsPositive ? enter : ix.surroundIsPositive;
@@ -136,7 +136,7 @@ RayShapeIntersection nextIntersection(inout Intersections ix) {\n\
136
136
  surfaceIntersection = ix.intersections[i];\n\
137
137
  int intersectionType = int(length(surfaceIntersection.xyz) - 0.5);\n\
138
138
  bool currShapeIsPositive = intersectionType < 2;\n\
139
- bool enter = intMod(intersectionType, 2) == 0;\n\
139
+ bool enter = intersectionType % 2 == 0;\n\
140
140
  \n\
141
141
  ix.surroundCount += enter ? +1 : -1;\n\
142
142
  ix.surroundIsPositive = currShapeIsPositive ? enter : ix.surroundIsPositive;\n\
@@ -1,104 +1,36 @@
1
- // See Octree.glsl for the definitions of SampleData and intMod
1
+ // See Octree.glsl for the definitions of SampleData
2
2
 
3
3
  /* Megatexture defines (set in Scene/VoxelRenderResources.js)
4
4
  #define SAMPLE_COUNT ###
5
- #define NEAREST_SAMPLING
6
5
  #define PADDING
7
6
  */
8
7
 
9
- uniform ivec2 u_megatextureSliceDimensions; // number of slices per tile, in two dimensions
10
- uniform ivec2 u_megatextureTileDimensions; // number of tiles per megatexture, in two dimensions
11
- uniform vec2 u_megatextureVoxelSizeUv;
12
- uniform vec2 u_megatextureSliceSizeUv;
13
- uniform vec2 u_megatextureTileSizeUv;
8
+ uniform ivec3 u_megatextureTileCounts; // number of tiles in the megatexture, along each axis
14
9
 
15
- // Integer min, max, clamp: For WebGL1 only
16
- int intMin(int a, int b) {
17
- return a <= b ? a : b;
18
- }
19
- int intMax(int a, int b) {
20
- return a >= b ? a : b;
21
- }
22
- int intClamp(int v, int minVal, int maxVal) {
23
- return intMin(intMax(v, minVal), maxVal);
24
- }
25
-
26
- vec2 index1DTo2DTexcoord(int index, ivec2 dimensions, vec2 uvScale)
10
+ vec3 index1DTo3DTexCoord(int index)
27
11
  {
28
- int indexX = intMod(index, dimensions.x);
29
- int indexY = index / dimensions.x;
30
- return vec2(indexX, indexY) * uvScale;
12
+ int tilesPerZ = u_megatextureTileCounts.x * u_megatextureTileCounts.y;
13
+ int iz = index / tilesPerZ;
14
+ int remainder = index - iz * tilesPerZ;
15
+ int iy = remainder / u_megatextureTileCounts.x;
16
+ int ix = remainder - iy * u_megatextureTileCounts.x;
17
+ return vec3(ix, iy, iz) / vec3(u_megatextureTileCounts);
31
18
  }
32
19
 
33
- /*
34
- How is 3D data stored in a 2D megatexture?
35
-
36
- In this example there is only one loaded tile and it has 2x2x2 voxels (8 voxels total).
37
- The data is sliced by Z. The data at Z = 0 is placed in texels (0,0), (0,1), (1,0), (1,1) and
38
- the data at Z = 1 is placed in texels (2,0), (2,1), (3,0), (3,1).
39
- Note that there could be empty space in the megatexture because it's a power of two.
40
-
41
- 0 1 2 3
42
- +---+---+---+---+
43
- | | | | | 3
44
- +---+---+---+---+
45
- | | | | | 2
46
- +-------+-------+
47
- |010|110|011|111| 1
48
- |--- ---|--- ---|
49
- |000|100|001|101| 0
50
- +-------+-------+
51
-
52
- When doing linear interpolation the megatexture needs to be sampled twice: once for
53
- the Z slice above the voxel coordinate and once for the slice below. The two slices
54
- are interpolated with fract(coord.z - 0.5). For example, a Z coordinate of 1.0 is
55
- halfway between two Z slices so the interpolation factor is 0.5. Below is a side view
56
- of the 3D voxel grid with voxel coordinates on the left side.
57
-
58
- 2 +---+
59
- |001|
60
- 1 +-z-+
61
- |000|
62
- 0 +---+
63
-
64
- When doing nearest neighbor the megatexture only needs to be sampled once at the closest Z slice.
65
- */
66
-
67
20
  Properties getPropertiesFromMegatexture(in SampleData sampleData) {
68
21
  int tileIndex = sampleData.megatextureIndex;
69
22
 
70
23
  vec3 voxelCoord = sampleData.inputCoordinate;
71
- #if defined(NEAREST_SAMPLING)
72
- // Round to the center of the nearest voxel
73
- voxelCoord = floor(voxelCoord) + vec3(0.5);
74
- #endif
75
24
 
76
- // Tile location
77
- vec2 tileUvOffset = index1DTo2DTexcoord(tileIndex, u_megatextureTileDimensions, u_megatextureTileSizeUv);
78
-
79
- // Slice location
80
- float slice = voxelCoord.z - 0.5;
81
- int sliceIndex = int(floor(slice));
82
- int sliceIndex0 = intClamp(sliceIndex, 0, u_inputDimensions.z - 1);
83
- vec2 sliceUvOffset0 = index1DTo2DTexcoord(sliceIndex0, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);
25
+ // UV coordinate of the lower corner of the tile in the megatexture
26
+ vec3 tileUvOffset = index1DTo3DTexCoord(tileIndex);
84
27
 
85
28
  // Voxel location
86
- vec2 voxelUvOffset = clamp(voxelCoord.xy, vec2(0.5), vec2(u_inputDimensions.xy) - vec2(0.5)) * u_megatextureVoxelSizeUv;
87
-
88
- // Final location in the megatexture
89
- vec2 uv0 = tileUvOffset + sliceUvOffset0 + voxelUvOffset;
29
+ vec3 tileDimensions = vec3(u_inputDimensions);
30
+ vec3 clampedVoxelCoord = clamp(voxelCoord, vec3(0.5), tileDimensions - vec3(0.5));
31
+ vec3 voxelUv = clampedVoxelCoord / tileDimensions / vec3(u_megatextureTileCounts);
90
32
 
91
- #if defined(NEAREST_SAMPLING)
92
- return getPropertiesFromMegatextureAtUv(uv0);
93
- #else
94
- float sliceLerp = fract(slice);
95
- int sliceIndex1 = intMin(sliceIndex + 1, u_inputDimensions.z - 1);
96
- vec2 sliceUvOffset1 = index1DTo2DTexcoord(sliceIndex1, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);
97
- vec2 uv1 = tileUvOffset + sliceUvOffset1 + voxelUvOffset;
98
- Properties properties0 = getPropertiesFromMegatextureAtUv(uv0);
99
- Properties properties1 = getPropertiesFromMegatextureAtUv(uv1);
100
- return mixProperties(properties0, properties1, sliceLerp);
101
- #endif
33
+ return getPropertiesFromMegatextureAtUv(tileUvOffset + voxelUv);
102
34
  }
103
35
 
104
36
  // Convert an array of sample datas to a final weighted properties.