@cesium/engine 21.0.1-ion.0 → 22.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.
- package/Build/Workers/{chunk-LSNF6CIP.js → chunk-2D3GLFZD.js} +12 -12
- package/Build/Workers/chunk-34YXP222.js +352 -0
- package/Build/Workers/{chunk-OLH67Z2S.js → chunk-3GL53OCU.js} +17 -18
- package/Build/Workers/{chunk-WIPOMPA5.js → chunk-5B7VZQZY.js} +6 -6
- package/Build/Workers/{chunk-NWJRIJQG.js → chunk-5T5SY63I.js} +2 -2
- package/Build/Workers/{chunk-DTYIUWZU.js → chunk-5ZF53EY6.js} +4 -4
- package/Build/Workers/{chunk-UTTKH2UG.js → chunk-6HBKE43B.js} +7 -7
- package/Build/Workers/{chunk-ZTGZMKAB.js → chunk-726NINF5.js} +16 -16
- package/Build/Workers/{chunk-L73TRTIG.js → chunk-75HAJIDT.js} +1 -1
- package/Build/Workers/{chunk-G5RX7BPJ.js → chunk-7KAXDKRU.js} +10 -10
- package/Build/Workers/chunk-7XEJGXX2.js +2759 -0
- package/Build/Workers/{chunk-ZOVMWDPW.js → chunk-A4DPJIWS.js} +18 -10
- package/Build/Workers/{chunk-UTL4WVC3.js → chunk-A6JAFSZT.js} +5 -5
- package/Build/Workers/{chunk-E6T4LSM6.js → chunk-AARZSH4V.js} +5 -5
- package/Build/Workers/{chunk-EEDSGIH7.js → chunk-AOM3FHBN.js} +6 -6
- package/Build/Workers/{chunk-WJV24LAS.js → chunk-BJSNGGBM.js} +4 -4
- package/Build/Workers/{chunk-VIDWZGD6.js → chunk-ECHAJNQJ.js} +12 -12
- package/Build/Workers/{chunk-MIFUV36K.js → chunk-EJO3NKMS.js} +1 -1
- package/Build/Workers/{chunk-ADADBRLI.js → chunk-EZ7NJXQN.js} +4 -4
- package/Build/Workers/{chunk-MJWRSKJV.js → chunk-FA3SCJDX.js} +2 -2
- package/Build/Workers/{chunk-XFS2ORSO.js → chunk-GYRDA3XK.js} +14 -14
- package/Build/Workers/{chunk-3XTJC4CV.js → chunk-H7B7FU2U.js} +7 -7
- package/Build/Workers/{chunk-HDBIC7IL.js → chunk-IGX772ZQ.js} +1 -1
- package/Build/Workers/{chunk-EHMAKCWQ.js → chunk-JDJAPBZP.js} +1 -1
- package/Build/Workers/{chunk-LK7H6V2E.js → chunk-JZFU2LEM.js} +4 -4
- package/Build/Workers/{chunk-3K4DRV7Y.js → chunk-KGLDJRSO.js} +9 -9
- package/Build/Workers/{chunk-LEFV6H2V.js → chunk-KUB64XW6.js} +11 -11
- package/Build/Workers/{chunk-26ZRRKTU.js → chunk-L7U26FFD.js} +16 -16
- package/Build/Workers/{chunk-T7WXNKIA.js → chunk-LEFQBK6H.js} +11 -11
- package/Build/Workers/{chunk-75UG66GR.js → chunk-LWJXCI3F.js} +5 -5
- package/Build/Workers/{chunk-ESPNIYL5.js → chunk-M7HRE4QR.js} +8 -8
- package/Build/Workers/{chunk-SGEAS4NZ.js → chunk-MXHRZHDF.js} +6 -6
- package/Build/Workers/{chunk-YFZMB6FZ.js → chunk-N52ZRKUE.js} +6 -6
- package/Build/Workers/{chunk-AQ4A5CMC.js → chunk-NE5JTQJP.js} +7 -7
- package/Build/Workers/{chunk-G74UMFQ4.js → chunk-NGKF5NTR.js} +5 -5
- package/Build/Workers/{chunk-TXK2FF6N.js → chunk-NHZNMTIR.js} +5 -5
- package/Build/Workers/{chunk-2PX2ULSM.js → chunk-OE22564R.js} +3 -3
- package/Build/Workers/{chunk-AGT6W3JS.js → chunk-OUBBMEWX.js} +6 -6
- package/Build/Workers/{chunk-JESBYOH5.js → chunk-P2H75UV5.js} +67 -33
- package/Build/Workers/{chunk-B56XVJRS.js → chunk-QCMRUVVF.js} +12 -12
- package/Build/Workers/{chunk-SDFGZML6.js → chunk-QSMIHPUM.js} +2 -2
- package/Build/Workers/{chunk-SF2XXYOB.js → chunk-RCCYW6E7.js} +12 -12
- package/Build/Workers/{chunk-EZJXK2UP.js → chunk-RQRODXVN.js} +4 -4
- package/Build/Workers/{chunk-WMG6UOCJ.js → chunk-SZN34LQ5.js} +10 -10
- package/Build/Workers/{chunk-XYBFMHXA.js → chunk-U4XMLGSR.js} +7 -7
- package/Build/Workers/{chunk-KGL66RWW.js → chunk-U7CX3HHE.js} +8 -8
- package/Build/Workers/{chunk-MFPT34BC.js → chunk-VCVA7BMD.js} +4 -4
- package/Build/Workers/{chunk-H3G7OYZY.js → chunk-VVZ667H6.js} +2 -2
- package/Build/Workers/{chunk-PQW63B2T.js → chunk-W4PIP5PG.js} +2 -2
- package/Build/Workers/{chunk-XPTKQIVN.js → chunk-XPVZWY4A.js} +8 -8
- package/Build/Workers/{chunk-OWCFUM4Z.js → chunk-XQ347YWU.js} +13 -13
- package/Build/Workers/{chunk-MBIUW42A.js → chunk-XZO6F23E.js} +1 -1
- package/Build/Workers/{chunk-6KX3IUUT.js → chunk-YLILBDWK.js} +2 -2
- package/Build/Workers/{chunk-RFZAUDYZ.js → chunk-YLXWC7OW.js} +4 -4
- package/Build/Workers/combineGeometry.js +21 -21
- package/Build/Workers/createBoxGeometry.js +15 -15
- package/Build/Workers/createBoxOutlineGeometry.js +13 -13
- package/Build/Workers/createCircleGeometry.js +23 -23
- package/Build/Workers/createCircleOutlineGeometry.js +16 -16
- package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createCorridorGeometry.js +26 -26
- package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
- package/Build/Workers/createCylinderGeometry.js +17 -17
- package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
- package/Build/Workers/createEllipseGeometry.js +23 -23
- package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipsoidGeometry.js +16 -16
- package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
- package/Build/Workers/createFrustumGeometry.js +15 -15
- package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
- package/Build/Workers/createGeometry.js +24 -22
- package/Build/Workers/createGroundPolylineGeometry.js +19 -19
- package/Build/Workers/createPlaneGeometry.js +13 -13
- package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
- package/Build/Workers/createPolygonGeometry.js +29 -29
- package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
- package/Build/Workers/createPolylineGeometry.js +22 -22
- package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
- package/Build/Workers/createRectangleGeometry.js +24 -24
- package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
- package/Build/Workers/createSimplePolylineGeometry.js +20 -20
- package/Build/Workers/createSphereGeometry.js +16 -16
- package/Build/Workers/createSphereOutlineGeometry.js +15 -15
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
- package/Build/Workers/createVectorTileGeometries.js +21 -21
- package/Build/Workers/createVectorTilePoints.js +11 -11
- package/Build/Workers/createVectorTilePolygons.js +19 -19
- package/Build/Workers/createVectorTilePolylines.js +12 -12
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +88 -0
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +21 -21
- package/Build/Workers/createVerticesFromHeightmap.js +21 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -277
- package/Build/Workers/createWallGeometry.js +21 -21
- package/Build/Workers/createWallOutlineGeometry.js +20 -20
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +92 -0
- package/Source/Core/ArcGISTiledElevationTerrainProvider.js +2 -2
- package/Source/Core/Cesium3DTilesTerrainData.js +930 -0
- package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +1866 -0
- package/Source/Core/Cesium3DTilesTerrainProvider.js +1052 -0
- package/Source/Core/CesiumTerrainProvider.js +2 -2
- package/Source/Core/Color.js +23 -6
- package/Source/Core/EllipsoidalOccluder.js +2 -2
- package/Source/Core/FeatureDetection.js +0 -2
- package/Source/Core/GoogleEarthEnterpriseMetadata.js +1 -1
- package/Source/Core/GoogleEarthEnterpriseTerrainData.js +1 -1
- package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
- package/Source/Core/HeightmapTerrainData.js +10 -22
- package/Source/Core/HilbertOrder.js +0 -6
- package/Source/Core/ITwinPlatform.js +6 -6
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonResource.js +35 -27
- package/Source/Core/PixelFormat.js +2 -2
- package/Source/Core/QuantizedMeshTerrainData.js +23 -57
- package/Source/Core/Resource.js +15 -11
- package/Source/Core/S2Cell.js +6 -18
- package/Source/Core/TaskProcessor.js +1 -1
- package/Source/Core/TerrainData.js +2 -1
- package/Source/Core/TerrainEncoding.js +215 -38
- package/Source/Core/TerrainMesh.js +8 -8
- package/Source/Core/TerrainProvider.js +151 -0
- package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
- package/Source/Core/binarySearch.js +1 -1
- package/Source/Core/createWorldBathymetryAsync.js +2 -2
- package/Source/Core/createWorldTerrainAsync.js +3 -3
- package/Source/Core/loadImageFromTypedArray.js +9 -3
- package/Source/Core/mergeSort.js +1 -1
- package/Source/DataSources/PropertyArray.js +2 -2
- package/Source/Renderer/AutomaticUniforms.js +61 -0
- package/Source/Renderer/Context.js +13 -7
- package/Source/Renderer/Pass.js +10 -9
- package/Source/Renderer/UniformState.js +12 -0
- package/Source/Renderer/VertexArray.js +1 -1
- package/Source/Scene/ArcGisMapServerImageryProvider.js +1 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Azure2DImageryProvider.js +7 -5
- package/Source/Scene/BatchTable.js +2 -2
- package/Source/Scene/BillboardCollection.js +25 -21
- package/Source/Scene/BingMapsImageryProvider.js +1 -1
- package/Source/Scene/BoundingVolumeSemantics.js +54 -62
- package/Source/Scene/Cesium3DTile.js +3 -3
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +1 -1
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/EdgeFramebuffer.js +245 -0
- package/Source/Scene/FrameState.js +12 -0
- package/Source/Scene/GaussianSplat3DTileContent.js +12 -16
- package/Source/Scene/GaussianSplatPrimitive.js +12 -8
- package/Source/Scene/GaussianSplatSorter.js +2 -2
- package/Source/Scene/Globe.js +1 -1
- package/Source/Scene/GlobeSurfaceTile.js +10 -4
- package/Source/Scene/GltfBufferViewLoader.js +18 -0
- package/Source/Scene/GltfLoader.js +46 -8
- package/Source/Scene/Google2DImageryProvider.js +39 -27
- package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
- package/Source/Scene/I3SDataProvider.js +1 -1
- package/Source/Scene/I3SDecoder.js +3 -3
- package/Source/Scene/ITwinData.js +4 -4
- package/Source/Scene/ImageryLayer.js +1 -1
- package/Source/Scene/Implicit3DTileContent.js +18 -7
- package/Source/Scene/ImplicitSubtree.js +3 -3
- package/Source/Scene/ImplicitTileset.js +2 -2
- package/Source/Scene/IonImageryProvider.js +15 -84
- package/Source/Scene/IonImageryProviderFactory.js +194 -0
- package/Source/Scene/LabelCollection.js +54 -36
- package/Source/Scene/MetadataComponentType.js +5 -5
- package/Source/Scene/MetadataTableProperty.js +3 -9
- package/Source/Scene/Model/EdgeDetectionPipelineStage.js +42 -0
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +800 -0
- package/Source/Scene/Model/MetadataPipelineStage.js +7 -7
- package/Source/Scene/Model/ModelDrawCommand.js +69 -0
- package/Source/Scene/Model/ModelImagery.js +4 -0
- package/Source/Scene/Model/ModelRuntimeNode.js +2 -2
- package/Source/Scene/Model/ModelRuntimePrimitive.js +13 -2
- package/Source/Scene/Model/ModelSceneGraph.js +15 -3
- package/Source/Scene/Model/ModelUtility.js +0 -1
- package/Source/Scene/Model/NodeRenderResources.js +1 -1
- package/Source/Scene/Model/PrimitiveRenderResources.js +1 -1
- package/Source/Scene/OIT.js +11 -1
- package/Source/Scene/PickFramebuffer.js +13 -17
- package/Source/Scene/Picking.js +104 -80
- package/Source/Scene/QuadtreePrimitive.js +34 -26
- package/Source/Scene/QuadtreeTile.js +66 -46
- package/Source/Scene/ResourceLoaderState.js +1 -1
- package/Source/Scene/Scene.js +124 -12
- package/Source/Scene/ScreenSpaceCameraController.js +1 -1
- package/Source/Scene/SensorVolumePortionToDisplay.js +6 -6
- package/Source/Scene/SingleTileImageryProvider.js +3 -3
- package/Source/Scene/Terrain.js +5 -5
- package/Source/Scene/TileMapServiceImageryProvider.js +2 -2
- package/Source/Scene/UrlTemplateImageryProvider.js +1 -1
- package/Source/Scene/View.js +3 -0
- package/Source/Scene/VoxelPrimitive.js +196 -189
- package/Source/Scene/VoxelShape.js +2 -0
- package/Source/Scene/createWorldImageryAsync.js +1 -1
- package/Source/Shaders/BillboardCollectionFS.glsl +102 -62
- package/Source/Shaders/BillboardCollectionFS.js +102 -63
- package/Source/Shaders/BillboardCollectionVS.glsl +44 -37
- package/Source/Shaders/BillboardCollectionVS.js +45 -38
- package/Source/Shaders/Builtin/Constants/passCesium3DTile.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.glsl +10 -0
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
- package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +1 -1
- package/Source/Shaders/Builtin/Constants/passOpaque.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
- package/Source/Shaders/Builtin/Constants/passTranslucent.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
- package/Source/Shaders/Builtin/Constants/passVoxels.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
- package/Source/Shaders/GlobeVS.glsl +1 -1
- package/Source/Shaders/GlobeVS.js +1 -1
- package/Source/Shaders/Model/EdgeDetectionStageFS.glsl +58 -0
- package/Source/Shaders/Model/EdgeDetectionStageFS.js +60 -0
- package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +83 -0
- package/Source/Shaders/Model/EdgeVisibilityStageFS.js +85 -0
- package/Source/Shaders/Model/ModelFS.glsl +5 -0
- package/Source/Shaders/Model/ModelFS.js +5 -0
- package/Source/Shaders/Model/PrimitiveOutlineStageFS.glsl +0 -1
- package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
- package/Source/Shaders/ShadowVolumeAppearanceFS.glsl +7 -15
- package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
- package/Source/Workers/createVerticesFromCesium3DTilesTerrain.js +46 -0
- package/Source/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +55 -0
- package/index.d.ts +281 -27
- package/index.js +176 -166
- package/package.json +2 -1
package/Source/Core/S2Cell.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable new-cap */
|
|
2
1
|
import Cartesian3 from "./Cartesian3.js";
|
|
3
2
|
import Cartographic from "./Cartographic.js";
|
|
4
3
|
import Check from "./Check.js";
|
|
@@ -209,15 +208,12 @@ S2Cell.isValidId = function (cellId) {
|
|
|
209
208
|
}
|
|
210
209
|
|
|
211
210
|
// Check if face bits indicate a valid value, in range [0-5].
|
|
212
|
-
// eslint-disable-next-line
|
|
213
211
|
if (cellId >> BigInt(S2_POSITION_BITS) > 5) {
|
|
214
212
|
return false;
|
|
215
213
|
}
|
|
216
214
|
|
|
217
215
|
// Check trailing 1 bit is in one of the even bit positions allowed for the 30 levels, using a bitmask.
|
|
218
|
-
// eslint-disable-next-line no-undef
|
|
219
216
|
const lowestSetBit = cellId & (~cellId + BigInt(1));
|
|
220
|
-
// eslint-disable-next-line
|
|
221
217
|
if (!(lowestSetBit & BigInt("0x1555555555555555"))) {
|
|
222
218
|
return false;
|
|
223
219
|
}
|
|
@@ -296,14 +292,12 @@ S2Cell.getLevel = function (cellId) {
|
|
|
296
292
|
//>>includeEnd('debug');
|
|
297
293
|
|
|
298
294
|
let lsbPosition = 0;
|
|
299
|
-
// eslint-disable-next-line
|
|
300
295
|
while (cellId !== BigInt(0)) {
|
|
301
|
-
// eslint-disable-next-line
|
|
302
296
|
if (cellId & BigInt(1)) {
|
|
303
297
|
break;
|
|
304
298
|
}
|
|
305
299
|
lsbPosition++;
|
|
306
|
-
cellId = cellId >> BigInt(1);
|
|
300
|
+
cellId = cellId >> BigInt(1);
|
|
307
301
|
}
|
|
308
302
|
|
|
309
303
|
// We use (>> 1) because there are 2 bits per level.
|
|
@@ -329,10 +323,8 @@ S2Cell.prototype.getChild = function (index) {
|
|
|
329
323
|
//>>includeEnd('debug');
|
|
330
324
|
|
|
331
325
|
// Shift sentinel bit 2 positions to the right.
|
|
332
|
-
// eslint-disable-next-line no-undef
|
|
333
326
|
const newLsb = lsb(this._cellId) >> BigInt(2);
|
|
334
327
|
// Insert child index before the sentinel bit.
|
|
335
|
-
// eslint-disable-next-line no-undef
|
|
336
328
|
const childCellId = this._cellId + BigInt(2 * index + 1 - 4) * newLsb;
|
|
337
329
|
return new S2Cell(childCellId);
|
|
338
330
|
};
|
|
@@ -350,10 +342,8 @@ S2Cell.prototype.getParent = function () {
|
|
|
350
342
|
}
|
|
351
343
|
//>>includeEnd('debug');
|
|
352
344
|
// Shift the sentinel bit 2 positions to the left.
|
|
353
|
-
// eslint-disable-next-line no-undef
|
|
354
345
|
const newLsb = lsb(this._cellId) << BigInt(2);
|
|
355
346
|
// Erase the left over bits to the right of the sentinel bit.
|
|
356
|
-
// eslint-disable-next-line no-undef
|
|
357
347
|
return new S2Cell((this._cellId & (~newLsb + BigInt(1))) | newLsb);
|
|
358
348
|
};
|
|
359
349
|
|
|
@@ -455,7 +445,6 @@ S2Cell.fromFacePositionLevel = function (face, position, level) {
|
|
|
455
445
|
).join("0");
|
|
456
446
|
const positionSuffixPadding = Array(S2_POSITION_BITS - 2 * level).join("0");
|
|
457
447
|
|
|
458
|
-
// eslint-disable-next-line no-undef
|
|
459
448
|
const cellId = BigInt(
|
|
460
449
|
`0b${faceBitString}${positionPrefixPadding}${positionBitString}1${
|
|
461
450
|
// Adding the sentinel bit that always follows the position bits.
|
|
@@ -500,7 +489,7 @@ function convertCellIdToFaceSiTi(cellId, level) {
|
|
|
500
489
|
// that represent the parent cell center.
|
|
501
490
|
const isLeaf = level === 30;
|
|
502
491
|
const shouldCorrect =
|
|
503
|
-
!isLeaf && (BigInt(i) ^ (cellId >> BigInt(2))) & BigInt(1);
|
|
492
|
+
!isLeaf && (BigInt(i) ^ (cellId >> BigInt(2))) & BigInt(1);
|
|
504
493
|
const correction = isLeaf ? 1 : shouldCorrect ? 2 : 0;
|
|
505
494
|
const si = (i << 1) + correction;
|
|
506
495
|
const ti = (j << 1) + correction;
|
|
@@ -515,7 +504,6 @@ function convertCellIdToFaceIJ(cellId) {
|
|
|
515
504
|
generateLookupTable();
|
|
516
505
|
}
|
|
517
506
|
|
|
518
|
-
// eslint-disable-next-line no-undef
|
|
519
507
|
const face = Number(cellId >> BigInt(S2_POSITION_BITS));
|
|
520
508
|
let bits = face & S2_SWAP_MASK;
|
|
521
509
|
const lookupMask = (1 << S2_LOOKUP_BITS) - 1;
|
|
@@ -529,7 +517,7 @@ function convertCellIdToFaceIJ(cellId) {
|
|
|
529
517
|
const extractMask = (1 << (2 * numberOfBits)) - 1;
|
|
530
518
|
bits +=
|
|
531
519
|
Number(
|
|
532
|
-
(cellId >> BigInt(k * 2 * S2_LOOKUP_BITS + 1)) & BigInt(extractMask),
|
|
520
|
+
(cellId >> BigInt(k * 2 * S2_LOOKUP_BITS + 1)) & BigInt(extractMask),
|
|
533
521
|
) << 2;
|
|
534
522
|
|
|
535
523
|
bits = S2_LOOKUP_IJ[bits];
|
|
@@ -715,7 +703,7 @@ function generateLookupTable() {
|
|
|
715
703
|
* @private
|
|
716
704
|
*/
|
|
717
705
|
function lsb(cellId) {
|
|
718
|
-
return cellId & (~cellId + BigInt(1));
|
|
706
|
+
return cellId & (~cellId + BigInt(1));
|
|
719
707
|
}
|
|
720
708
|
|
|
721
709
|
/**
|
|
@@ -723,7 +711,7 @@ function lsb(cellId) {
|
|
|
723
711
|
* @private
|
|
724
712
|
*/
|
|
725
713
|
function lsbForLevel(level) {
|
|
726
|
-
return BigInt(1) << BigInt(2 * (S2_MAX_LEVEL - level));
|
|
714
|
+
return BigInt(1) << BigInt(2 * (S2_MAX_LEVEL - level));
|
|
727
715
|
}
|
|
728
716
|
|
|
729
717
|
// Lookup table for getting trailing zero bits.
|
|
@@ -740,7 +728,7 @@ const Mod67BitPosition = [
|
|
|
740
728
|
* @private
|
|
741
729
|
*/
|
|
742
730
|
function countTrailingZeroBits(x) {
|
|
743
|
-
return Mod67BitPosition[(-x & x) % BigInt(67)];
|
|
731
|
+
return Mod67BitPosition[(-x & x) % BigInt(67)];
|
|
744
732
|
}
|
|
745
733
|
|
|
746
734
|
export default S2Cell;
|
|
@@ -267,7 +267,7 @@ async function scheduleTask(processor, parameters, transferableObjects) {
|
|
|
267
267
|
* finished.
|
|
268
268
|
*
|
|
269
269
|
* @param {object} parameters Any input data that will be posted to the worker.
|
|
270
|
-
* @param {
|
|
270
|
+
* @param {object[]} [transferableObjects] An array of objects contained in parameters that should be
|
|
271
271
|
* transferred to the worker instead of copied.
|
|
272
272
|
* @returns {Promise<object>|undefined} Either a promise that will resolve to the result when available, or undefined
|
|
273
273
|
* if there are too many active tasks,
|
|
@@ -10,6 +10,7 @@ import DeveloperError from "./DeveloperError.js";
|
|
|
10
10
|
* @see HeightmapTerrainData
|
|
11
11
|
* @see QuantizedMeshTerrainData
|
|
12
12
|
* @see GoogleEarthEnterpriseTerrainData
|
|
13
|
+
* @see Cesium3DTilesTerrainData
|
|
13
14
|
*/
|
|
14
15
|
function TerrainData() {
|
|
15
16
|
DeveloperError.throwInstantiationError();
|
|
@@ -29,7 +30,7 @@ Object.defineProperties(TerrainData.prototype, {
|
|
|
29
30
|
* Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land.
|
|
30
31
|
* Values in between 0 and 255 are allowed as well to smoothly blend between land and water.
|
|
31
32
|
* @memberof TerrainData.prototype
|
|
32
|
-
* @type {Uint8Array|HTMLImageElement|HTMLCanvasElement|undefined}
|
|
33
|
+
* @type {Uint8Array|HTMLImageElement|HTMLCanvasElement|ImageBitmap|undefined}
|
|
33
34
|
*/
|
|
34
35
|
waterMask: {
|
|
35
36
|
get: DeveloperError.throwInstantiationError,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AttributeCompression from "./AttributeCompression.js";
|
|
2
2
|
import Cartesian2 from "./Cartesian2.js";
|
|
3
3
|
import Cartesian3 from "./Cartesian3.js";
|
|
4
|
+
import Check from "./Check.js";
|
|
4
5
|
import ComponentDatatype from "./ComponentDatatype.js";
|
|
5
6
|
import defined from "./defined.js";
|
|
6
7
|
import CesiumMath from "./Math.js";
|
|
@@ -24,11 +25,11 @@ const SHIFT_LEFT_12 = Math.pow(2.0, 12.0);
|
|
|
24
25
|
* @constructor
|
|
25
26
|
*
|
|
26
27
|
* @param {Cartesian3} center The center point of the vertices.
|
|
27
|
-
* @param {AxisAlignedBoundingBox} axisAlignedBoundingBox The bounds of the tile in the east-north-up coordinates at the tiles center.
|
|
28
|
-
* @param {number} minimumHeight The minimum height.
|
|
29
|
-
* @param {number} maximumHeight The maximum height.
|
|
30
|
-
* @param {Matrix4} fromENU The east-north-up to fixed frame matrix at the center of the terrain mesh.
|
|
31
|
-
* @param {boolean} hasVertexNormals If the mesh has vertex normals.
|
|
28
|
+
* @param {AxisAlignedBoundingBox} [axisAlignedBoundingBox] The bounds of the tile in the east-north-up coordinates at the tiles center.
|
|
29
|
+
* @param {number} [minimumHeight] The minimum height.
|
|
30
|
+
* @param {number} [maximumHeight] The maximum height.
|
|
31
|
+
* @param {Matrix4} [fromENU] The east-north-up to fixed frame matrix at the center of the terrain mesh.
|
|
32
|
+
* @param {boolean} [hasVertexNormals=false] If the mesh has vertex normals.
|
|
32
33
|
* @param {boolean} [hasWebMercatorT=false] true if the terrain data includes a Web Mercator texture coordinate; otherwise, false.
|
|
33
34
|
* @param {boolean} [hasGeodeticSurfaceNormals=false] true if the terrain data includes geodetic surface normals; otherwise, false.
|
|
34
35
|
* @param {number} [exaggeration=1.0] A scalar used to exaggerate terrain.
|
|
@@ -75,32 +76,36 @@ function TerrainEncoding(
|
|
|
75
76
|
quantization = TerrainQuantization.NONE;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Matrix4.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
// Scale and bias from [0,1] to [ENU min, ENU max]
|
|
80
|
+
// Also compute the inverse of the scale and bias
|
|
81
|
+
let st = Matrix4.fromScale(dimensions, matrix4Scratch);
|
|
82
|
+
st = Matrix4.setTranslation(st, minimum, st);
|
|
83
|
+
|
|
84
|
+
let invSt = Matrix4.fromScale(
|
|
85
|
+
Cartesian3.fromElements(
|
|
86
|
+
1.0 / dimensions.x,
|
|
87
|
+
1.0 / dimensions.y,
|
|
88
|
+
1.0 / dimensions.z,
|
|
89
|
+
cartesian3Scratch,
|
|
90
|
+
),
|
|
91
|
+
matrix4Scratch2,
|
|
92
|
+
);
|
|
93
|
+
invSt = Matrix4.multiplyByTranslation(
|
|
94
|
+
invSt,
|
|
95
|
+
Cartesian3.negate(minimum, cartesian3Scratch),
|
|
96
|
+
invSt,
|
|
85
97
|
);
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Matrix4.multiply(
|
|
92
|
-
|
|
93
|
-
matrix = Matrix4.clone(fromENU);
|
|
94
|
-
Matrix4.setTranslation(matrix, Cartesian3.ZERO, matrix);
|
|
95
|
-
|
|
96
|
-
fromENU = Matrix4.clone(fromENU, new Matrix4());
|
|
99
|
+
matrix = Matrix4.clone(fromENU, new Matrix4());
|
|
100
|
+
let rtcOffset = Matrix4.getTranslation(fromENU, cartesian3Scratch);
|
|
101
|
+
rtcOffset = Cartesian3.subtract(rtcOffset, center, cartesian3Scratch);
|
|
102
|
+
matrix = Matrix4.setTranslation(matrix, rtcOffset, matrix);
|
|
103
|
+
matrix = Matrix4.multiply(matrix, st, matrix);
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const st = Matrix4.multiply(translationMatrix, scaleMatrix, matrix4Scratch);
|
|
105
|
+
toENU = Matrix4.inverseTransformation(fromENU, new Matrix4());
|
|
106
|
+
toENU = Matrix4.multiply(invSt, toENU, toENU);
|
|
101
107
|
|
|
102
|
-
Matrix4.multiply(fromENU, st,
|
|
103
|
-
Matrix4.multiply(matrix, st, matrix);
|
|
108
|
+
fromENU = Matrix4.multiply(fromENU, st, new Matrix4());
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
/**
|
|
@@ -111,13 +116,13 @@ function TerrainEncoding(
|
|
|
111
116
|
|
|
112
117
|
/**
|
|
113
118
|
* The minimum height of the tile including the skirts.
|
|
114
|
-
* @type {number}
|
|
119
|
+
* @type {number|undefined}
|
|
115
120
|
*/
|
|
116
121
|
this.minimumHeight = minimumHeight;
|
|
117
122
|
|
|
118
123
|
/**
|
|
119
124
|
* The maximum height of the tile.
|
|
120
|
-
* @type {number}
|
|
125
|
+
* @type {number|undefined}
|
|
121
126
|
*/
|
|
122
127
|
this.maximumHeight = maximumHeight;
|
|
123
128
|
|
|
@@ -130,19 +135,19 @@ function TerrainEncoding(
|
|
|
130
135
|
/**
|
|
131
136
|
* A matrix that takes a vertex from the tile, transforms it to east-north-up at the center and scales
|
|
132
137
|
* it so each component is in the [0, 1] range.
|
|
133
|
-
* @type {Matrix4}
|
|
138
|
+
* @type {Matrix4|undefined}
|
|
134
139
|
*/
|
|
135
140
|
this.toScaledENU = toENU;
|
|
136
141
|
|
|
137
142
|
/**
|
|
138
143
|
* A matrix that restores a vertex transformed with toScaledENU back to the earth fixed reference frame
|
|
139
|
-
* @type {Matrix4}
|
|
144
|
+
* @type {Matrix4|undefined}
|
|
140
145
|
*/
|
|
141
146
|
this.fromScaledENU = fromENU;
|
|
142
147
|
|
|
143
148
|
/**
|
|
144
149
|
* The matrix used to decompress the terrain vertices in the shader for RTE rendering.
|
|
145
|
-
* @type {Matrix4}
|
|
150
|
+
* @type {Matrix4|undefined}
|
|
146
151
|
*/
|
|
147
152
|
this.matrix = matrix;
|
|
148
153
|
|
|
@@ -150,7 +155,7 @@ function TerrainEncoding(
|
|
|
150
155
|
* The terrain mesh contains normals.
|
|
151
156
|
* @type {boolean}
|
|
152
157
|
*/
|
|
153
|
-
this.hasVertexNormals = hasVertexNormals;
|
|
158
|
+
this.hasVertexNormals = hasVertexNormals ?? false;
|
|
154
159
|
|
|
155
160
|
/**
|
|
156
161
|
* The terrain mesh contains a vertical texture coordinate following the Web Mercator projection.
|
|
@@ -188,6 +193,20 @@ function TerrainEncoding(
|
|
|
188
193
|
this._calculateStrideAndOffsets();
|
|
189
194
|
}
|
|
190
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Encode information about the terrain at a given position into the vertex buffer.
|
|
198
|
+
* Position, texture coordinates, height, and (optionally) normal, projection information,
|
|
199
|
+
* and geodetic surface normal are all packed into the same buffer.
|
|
200
|
+
*
|
|
201
|
+
* @param {Float32Array} vertexBuffer The buffer to write to.
|
|
202
|
+
* @param {number} bufferIndex The index into the buffer to start writing at.
|
|
203
|
+
* @param {Cartesian3} position The position of the vertex.
|
|
204
|
+
* @param {Cartesian2} uv The texture coordinates of the vertex.
|
|
205
|
+
* @param {number} height The height of the vertex.
|
|
206
|
+
* @param {Cartesian2} [normalToPack] The normal vector of the vertex.
|
|
207
|
+
* @param {number} [webMercatorT] The Web Mercator texture coordinate of the vertex.
|
|
208
|
+
* @param {Cartesian3} [geodeticSurfaceNormal] The geodetic surface normal of the vertex.
|
|
209
|
+
*/
|
|
191
210
|
TerrainEncoding.prototype.encode = function (
|
|
192
211
|
vertexBuffer,
|
|
193
212
|
bufferIndex,
|
|
@@ -198,6 +217,14 @@ TerrainEncoding.prototype.encode = function (
|
|
|
198
217
|
webMercatorT,
|
|
199
218
|
geodeticSurfaceNormal,
|
|
200
219
|
) {
|
|
220
|
+
//>>includeStart('debug', pragmas.debug);
|
|
221
|
+
Check.typeOf.object("vertexBuffer", vertexBuffer);
|
|
222
|
+
Check.typeOf.number("bufferIndex", bufferIndex);
|
|
223
|
+
Check.typeOf.object("position", position);
|
|
224
|
+
Check.typeOf.object("uv", uv);
|
|
225
|
+
Check.typeOf.number("height", height);
|
|
226
|
+
//>>includeEnd('debug');
|
|
227
|
+
|
|
201
228
|
const u = uv.x;
|
|
202
229
|
const v = uv.y;
|
|
203
230
|
|
|
@@ -238,11 +265,9 @@ TerrainEncoding.prototype.encode = function (
|
|
|
238
265
|
vertexBuffer[bufferIndex++] = compressed3;
|
|
239
266
|
}
|
|
240
267
|
} else {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
vertexBuffer[bufferIndex++] =
|
|
244
|
-
vertexBuffer[bufferIndex++] = cartesian3Scratch.y;
|
|
245
|
-
vertexBuffer[bufferIndex++] = cartesian3Scratch.z;
|
|
268
|
+
vertexBuffer[bufferIndex++] = position.x - this.center.x;
|
|
269
|
+
vertexBuffer[bufferIndex++] = position.y - this.center.y;
|
|
270
|
+
vertexBuffer[bufferIndex++] = position.z - this.center.z;
|
|
246
271
|
vertexBuffer[bufferIndex++] = height;
|
|
247
272
|
vertexBuffer[bufferIndex++] = u;
|
|
248
273
|
vertexBuffer[bufferIndex++] = v;
|
|
@@ -269,11 +294,25 @@ TerrainEncoding.prototype.encode = function (
|
|
|
269
294
|
const scratchPosition = new Cartesian3();
|
|
270
295
|
const scratchGeodeticSurfaceNormal = new Cartesian3();
|
|
271
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Add geodetic surface normals to a terrain vertex buffer.
|
|
299
|
+
* The new buffer will be larger than the old buffer.
|
|
300
|
+
*
|
|
301
|
+
* @param {Float32Array} oldBuffer The buffer without geodetic surface normals.
|
|
302
|
+
* @param {Float32Array} newBuffer The buffer with geodetic surface normals.
|
|
303
|
+
* @param {Ellipsoid} ellipsoid The ellipsoid to use to compute the geodetic surface normals.
|
|
304
|
+
*/
|
|
272
305
|
TerrainEncoding.prototype.addGeodeticSurfaceNormals = function (
|
|
273
306
|
oldBuffer,
|
|
274
307
|
newBuffer,
|
|
275
308
|
ellipsoid,
|
|
276
309
|
) {
|
|
310
|
+
//>>includeStart('debug', pragmas.debug);
|
|
311
|
+
Check.typeOf.object("oldBuffer", oldBuffer);
|
|
312
|
+
Check.typeOf.object("newBuffer", newBuffer);
|
|
313
|
+
Check.typeOf.object("ellipsoid", ellipsoid);
|
|
314
|
+
//>>includeEnd('debug');
|
|
315
|
+
|
|
277
316
|
if (this.hasGeodeticSurfaceNormals) {
|
|
278
317
|
return;
|
|
279
318
|
}
|
|
@@ -303,10 +342,21 @@ TerrainEncoding.prototype.addGeodeticSurfaceNormals = function (
|
|
|
303
342
|
}
|
|
304
343
|
};
|
|
305
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Remove geodetic surface normals from a terrain vertex buffer.
|
|
347
|
+
*
|
|
348
|
+
* @param {Float32Array} oldBuffer The buffer with geodetic surface normals.
|
|
349
|
+
* @param {Float32Array} newBuffer The buffer without geodetic surface normals.
|
|
350
|
+
*/
|
|
306
351
|
TerrainEncoding.prototype.removeGeodeticSurfaceNormals = function (
|
|
307
352
|
oldBuffer,
|
|
308
353
|
newBuffer,
|
|
309
354
|
) {
|
|
355
|
+
//>>includeStart('debug', pragmas.debug);
|
|
356
|
+
Check.typeOf.object("oldBuffer", oldBuffer);
|
|
357
|
+
Check.typeOf.object("newBuffer", newBuffer);
|
|
358
|
+
//>>includeEnd('debug');
|
|
359
|
+
|
|
310
360
|
if (!this.hasGeodeticSurfaceNormals) {
|
|
311
361
|
return;
|
|
312
362
|
}
|
|
@@ -326,7 +376,20 @@ TerrainEncoding.prototype.removeGeodeticSurfaceNormals = function (
|
|
|
326
376
|
}
|
|
327
377
|
};
|
|
328
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Decode a position from the vertex buffer.
|
|
381
|
+
*
|
|
382
|
+
* @param {Float32Array} buffer The buffer to decode from.
|
|
383
|
+
* @param {number} index The index of the vertex to decode.
|
|
384
|
+
* @param {Cartesian3} [result] The object to store the result in.
|
|
385
|
+
* @returns {Cartesian3} The decoded position.
|
|
386
|
+
*/
|
|
329
387
|
TerrainEncoding.prototype.decodePosition = function (buffer, index, result) {
|
|
388
|
+
//>>includeStart('debug', pragmas.debug);
|
|
389
|
+
Check.typeOf.object("buffer", buffer);
|
|
390
|
+
Check.typeOf.number("index", index);
|
|
391
|
+
//>>includeEnd('debug');
|
|
392
|
+
|
|
330
393
|
if (!defined(result)) {
|
|
331
394
|
result = new Cartesian3();
|
|
332
395
|
}
|
|
@@ -356,6 +419,14 @@ TerrainEncoding.prototype.decodePosition = function (buffer, index, result) {
|
|
|
356
419
|
return Cartesian3.add(result, this.center, result);
|
|
357
420
|
};
|
|
358
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Decode a position from the vertex buffer and apply vertical exaggeration.
|
|
424
|
+
*
|
|
425
|
+
* @param {Float32Array} buffer
|
|
426
|
+
* @param {number} index
|
|
427
|
+
* @param {Cartesian3} [result]
|
|
428
|
+
* @returns {Cartesian3} The exaggerated position.
|
|
429
|
+
*/
|
|
359
430
|
TerrainEncoding.prototype.getExaggeratedPosition = function (
|
|
360
431
|
buffer,
|
|
361
432
|
index,
|
|
@@ -389,11 +460,24 @@ TerrainEncoding.prototype.getExaggeratedPosition = function (
|
|
|
389
460
|
return result;
|
|
390
461
|
};
|
|
391
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Decode texture coordinates from the vertex buffer.
|
|
465
|
+
*
|
|
466
|
+
* @param {Float32Array} buffer The buffer to decode from.
|
|
467
|
+
* @param {number} index The index of the vertex to decode.
|
|
468
|
+
* @param {Cartesian2} [result] The object to store the result in.
|
|
469
|
+
* @returns {Cartesian2} The decoded texture coordinates.
|
|
470
|
+
*/
|
|
392
471
|
TerrainEncoding.prototype.decodeTextureCoordinates = function (
|
|
393
472
|
buffer,
|
|
394
473
|
index,
|
|
395
474
|
result,
|
|
396
475
|
) {
|
|
476
|
+
//>>includeStart('debug', pragmas.debug);
|
|
477
|
+
Check.typeOf.object("buffer", buffer);
|
|
478
|
+
Check.typeOf.number("index", index);
|
|
479
|
+
//>>includeEnd('debug');
|
|
480
|
+
|
|
397
481
|
if (!defined(result)) {
|
|
398
482
|
result = new Cartesian2();
|
|
399
483
|
}
|
|
@@ -410,7 +494,19 @@ TerrainEncoding.prototype.decodeTextureCoordinates = function (
|
|
|
410
494
|
return Cartesian2.fromElements(buffer[index + 4], buffer[index + 5], result);
|
|
411
495
|
};
|
|
412
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Decode a height from the vertex buffer.
|
|
499
|
+
*
|
|
500
|
+
* @param {Float32Array} buffer The buffer to decode from.
|
|
501
|
+
* @param {number} index The index of the vertex to decode.
|
|
502
|
+
* @returns {number} The decoded height.
|
|
503
|
+
*/
|
|
413
504
|
TerrainEncoding.prototype.decodeHeight = function (buffer, index) {
|
|
505
|
+
//>>includeStart('debug', pragmas.debug);
|
|
506
|
+
Check.typeOf.object("buffer", buffer);
|
|
507
|
+
Check.typeOf.number("index", index);
|
|
508
|
+
//>>includeEnd('debug');
|
|
509
|
+
|
|
414
510
|
index *= this.stride;
|
|
415
511
|
|
|
416
512
|
if (this.quantization === TerrainQuantization.BITS12) {
|
|
@@ -426,7 +522,19 @@ TerrainEncoding.prototype.decodeHeight = function (buffer, index) {
|
|
|
426
522
|
return buffer[index + 3];
|
|
427
523
|
};
|
|
428
524
|
|
|
525
|
+
/**
|
|
526
|
+
* Decode a web mercator T coordinate from the vertex buffer.
|
|
527
|
+
*
|
|
528
|
+
* @param {Float32Array} buffer The buffer to decode from.
|
|
529
|
+
* @param {number} index The index of the vertex to decode.
|
|
530
|
+
* @returns {number} The decoded web mercator T coordinate.
|
|
531
|
+
*/
|
|
429
532
|
TerrainEncoding.prototype.decodeWebMercatorT = function (buffer, index) {
|
|
533
|
+
//>>includeStart('debug', pragmas.debug);
|
|
534
|
+
Check.typeOf.object("buffer", buffer);
|
|
535
|
+
Check.typeOf.number("index", index);
|
|
536
|
+
//>>includeEnd('debug');
|
|
537
|
+
|
|
430
538
|
index *= this.stride;
|
|
431
539
|
|
|
432
540
|
if (this.quantization === TerrainQuantization.BITS12) {
|
|
@@ -439,11 +547,24 @@ TerrainEncoding.prototype.decodeWebMercatorT = function (buffer, index) {
|
|
|
439
547
|
return buffer[index + 6];
|
|
440
548
|
};
|
|
441
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Decode an oct-encoded normal from the vertex buffer.
|
|
552
|
+
*
|
|
553
|
+
* @param {Float32Array} buffer The buffer to decode from.
|
|
554
|
+
* @param {number} index The index of the vertex to decode.
|
|
555
|
+
* @param {Cartesian2} [result] The object to store the result in.
|
|
556
|
+
* @returns {Cartesian2} The decoded oct-encoded normal.
|
|
557
|
+
*/
|
|
442
558
|
TerrainEncoding.prototype.getOctEncodedNormal = function (
|
|
443
559
|
buffer,
|
|
444
560
|
index,
|
|
445
561
|
result,
|
|
446
562
|
) {
|
|
563
|
+
//>>includeStart('debug', pragmas.debug);
|
|
564
|
+
Check.typeOf.object("buffer", buffer);
|
|
565
|
+
Check.typeOf.number("index", index);
|
|
566
|
+
//>>includeEnd('debug');
|
|
567
|
+
|
|
447
568
|
index = index * this.stride + this._offsetVertexNormal;
|
|
448
569
|
|
|
449
570
|
const temp = buffer[index] / 256.0;
|
|
@@ -453,11 +574,42 @@ TerrainEncoding.prototype.getOctEncodedNormal = function (
|
|
|
453
574
|
return Cartesian2.fromElements(x, y, result);
|
|
454
575
|
};
|
|
455
576
|
|
|
577
|
+
/**
|
|
578
|
+
* @param {Float32Array} buffer
|
|
579
|
+
* @param {number} index
|
|
580
|
+
* @param {Cartesian3} result
|
|
581
|
+
* @returns {Cartesian3}
|
|
582
|
+
*/
|
|
583
|
+
TerrainEncoding.prototype.decodeNormal = function (buffer, index, result) {
|
|
584
|
+
//>>includeStart('debug', pragmas.debug);
|
|
585
|
+
Check.typeOf.object("buffer", buffer);
|
|
586
|
+
Check.typeOf.number("index", index);
|
|
587
|
+
Check.typeOf.object("result", result);
|
|
588
|
+
//>>includeEnd('debug');
|
|
589
|
+
|
|
590
|
+
const bufferIndex = (index = index * this.stride + this._offsetVertexNormal);
|
|
591
|
+
return AttributeCompression.octDecodeFloat(buffer[bufferIndex], result);
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Decode a geodetic surface normal from the vertex buffer.
|
|
596
|
+
*
|
|
597
|
+
* @param {Float32Array} buffer The buffer to decode from.
|
|
598
|
+
* @param {number} index The index of the vertex to decode.
|
|
599
|
+
* @param {Cartesian3} result The object to store the result in.
|
|
600
|
+
* @returns {Cartesian3} The decoded geodetic surface normal.
|
|
601
|
+
*/
|
|
456
602
|
TerrainEncoding.prototype.decodeGeodeticSurfaceNormal = function (
|
|
457
603
|
buffer,
|
|
458
604
|
index,
|
|
459
605
|
result,
|
|
460
606
|
) {
|
|
607
|
+
//>>includeStart('debug', pragmas.debug);
|
|
608
|
+
Check.typeOf.object("buffer", buffer);
|
|
609
|
+
Check.typeOf.number("index", index);
|
|
610
|
+
Check.typeOf.object("result", result);
|
|
611
|
+
//>>includeEnd('debug');
|
|
612
|
+
|
|
461
613
|
index = index * this.stride + this._offsetGeodeticSurfaceNormal;
|
|
462
614
|
|
|
463
615
|
result.x = buffer[index];
|
|
@@ -466,6 +618,9 @@ TerrainEncoding.prototype.decodeGeodeticSurfaceNormal = function (
|
|
|
466
618
|
return result;
|
|
467
619
|
};
|
|
468
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Calculate the stride and offsets for sampling the vertex buffer.
|
|
623
|
+
*/
|
|
469
624
|
TerrainEncoding.prototype._calculateStrideAndOffsets = function () {
|
|
470
625
|
let vertexStride = 0;
|
|
471
626
|
|
|
@@ -502,7 +657,17 @@ const attributesIndicesBits12 = {
|
|
|
502
657
|
geodeticSurfaceNormal: 2,
|
|
503
658
|
};
|
|
504
659
|
|
|
660
|
+
/**
|
|
661
|
+
* Get descriptors of the attributes stored in the vertex buffer.
|
|
662
|
+
*
|
|
663
|
+
* @param {Float32Array} buffer The vertex buffer.
|
|
664
|
+
* @returns {object[]} The attributes.
|
|
665
|
+
*/
|
|
505
666
|
TerrainEncoding.prototype.getAttributes = function (buffer) {
|
|
667
|
+
//>>includeStart('debug', pragmas.debug);
|
|
668
|
+
Check.typeOf.object("buffer", buffer);
|
|
669
|
+
//>>includeEnd('debug');
|
|
670
|
+
|
|
506
671
|
const datatype = ComponentDatatype.FLOAT;
|
|
507
672
|
const sizeInBytes = ComponentDatatype.getSizeInBytes(datatype);
|
|
508
673
|
const strideInBytes = this.stride * sizeInBytes;
|
|
@@ -560,6 +725,11 @@ TerrainEncoding.prototype.getAttributes = function (buffer) {
|
|
|
560
725
|
return attributes;
|
|
561
726
|
};
|
|
562
727
|
|
|
728
|
+
/**
|
|
729
|
+
* Get indices pointing to the attribute locations in the vertex buffer.
|
|
730
|
+
*
|
|
731
|
+
* @returns {object} The attribute indices.
|
|
732
|
+
*/
|
|
563
733
|
TerrainEncoding.prototype.getAttributeLocations = function () {
|
|
564
734
|
if (this.quantization === TerrainQuantization.NONE) {
|
|
565
735
|
return attributesIndicesNone;
|
|
@@ -567,6 +737,13 @@ TerrainEncoding.prototype.getAttributeLocations = function () {
|
|
|
567
737
|
return attributesIndicesBits12;
|
|
568
738
|
};
|
|
569
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Clones a TerrainEncoding object.
|
|
742
|
+
*
|
|
743
|
+
* @param {TerrainEncoding} [encoding] The encoding to clone.
|
|
744
|
+
* @param {TerrainEncoding} [result] The object to store the cloned encoding.
|
|
745
|
+
* @returns {TerrainEncoding|undefined} The cloned encoding.
|
|
746
|
+
*/
|
|
570
747
|
TerrainEncoding.clone = function (encoding, result) {
|
|
571
748
|
if (!defined(encoding)) {
|
|
572
749
|
return undefined;
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
* @param {number} [vertexStride=6] The number of components in each vertex.
|
|
23
23
|
* @param {OrientedBoundingBox} [orientedBoundingBox] A bounding box that completely contains the tile.
|
|
24
24
|
* @param {TerrainEncoding} encoding Information used to decode the mesh.
|
|
25
|
-
* @param {number[]} westIndicesSouthToNorth The indices of the vertices on the Western edge of the tile, ordered from South to North (clockwise).
|
|
26
|
-
* @param {number[]} southIndicesEastToWest The indices of the vertices on the Southern edge of the tile, ordered from East to West (clockwise).
|
|
27
|
-
* @param {number[]} eastIndicesNorthToSouth The indices of the vertices on the Eastern edge of the tile, ordered from North to South (clockwise).
|
|
28
|
-
* @param {number[]} northIndicesWestToEast The indices of the vertices on the Northern edge of the tile, ordered from West to East (clockwise).
|
|
25
|
+
* @param {number[]|Uint8Array|Uint16Array|Uint32Array} westIndicesSouthToNorth The indices of the vertices on the Western edge of the tile, ordered from South to North (clockwise).
|
|
26
|
+
* @param {number[]|Uint8Array|Uint16Array|Uint32Array} southIndicesEastToWest The indices of the vertices on the Southern edge of the tile, ordered from East to West (clockwise).
|
|
27
|
+
* @param {number[]|Uint8Array|Uint16Array|Uint32Array} eastIndicesNorthToSouth The indices of the vertices on the Eastern edge of the tile, ordered from North to South (clockwise).
|
|
28
|
+
* @param {number[]|Uint8Array|Uint16Array|Uint32Array} northIndicesWestToEast The indices of the vertices on the Northern edge of the tile, ordered from West to East (clockwise).
|
|
29
29
|
*
|
|
30
30
|
* @private
|
|
31
31
|
*/
|
|
@@ -129,25 +129,25 @@ function TerrainMesh(
|
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* The indices of the vertices on the Western edge of the tile, ordered from South to North (clockwise).
|
|
132
|
-
* @type {number[]}
|
|
132
|
+
* @type {number[]|Uint8Array|Uint16Array|Uint32Array}
|
|
133
133
|
*/
|
|
134
134
|
this.westIndicesSouthToNorth = westIndicesSouthToNorth;
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* The indices of the vertices on the Southern edge of the tile, ordered from East to West (clockwise).
|
|
138
|
-
* @type {number[]}
|
|
138
|
+
* @type {number[]|Uint8Array|Uint16Array|Uint32Array}
|
|
139
139
|
*/
|
|
140
140
|
this.southIndicesEastToWest = southIndicesEastToWest;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* The indices of the vertices on the Eastern edge of the tile, ordered from North to South (clockwise).
|
|
144
|
-
* @type {number[]}
|
|
144
|
+
* @type {number[]|Uint8Array|Uint16Array|Uint32Array}
|
|
145
145
|
*/
|
|
146
146
|
this.eastIndicesNorthToSouth = eastIndicesNorthToSouth;
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* The indices of the vertices on the Northern edge of the tile, ordered from West to East (clockwise).
|
|
150
|
-
* @type {number[]}
|
|
150
|
+
* @type {number[]|Uint8Array|Uint16Array|Uint32Array}
|
|
151
151
|
*/
|
|
152
152
|
this.northIndicesWestToEast = northIndicesWestToEast;
|
|
153
153
|
}
|