@cesium/engine 14.0.0 → 15.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-EWDGNOJE.js → chunk-25TOENEE.js} +7 -7
- package/Build/Workers/{chunk-OMXHEJTK.js → chunk-2AVIUB5H.js} +2 -2
- package/Build/Workers/{chunk-LJBJM6VI.js → chunk-3JZGPJMZ.js} +6 -6
- package/Build/Workers/{chunk-DT5NFR5C.js → chunk-3LHBH4TC.js} +7 -7
- package/Build/Workers/{chunk-3QLSKXKF.js → chunk-3LZF23RY.js} +6 -6
- package/Build/Workers/{chunk-ED6GLQTK.js → chunk-5S2B46UQ.js} +1 -1
- package/Build/Workers/{chunk-B4GSRXE3.js → chunk-67ONR44K.js} +6 -6
- package/Build/Workers/{chunk-LOZ4NKY3.js → chunk-6EDBC234.js} +11 -11
- package/Build/Workers/{chunk-7ZB2RVIQ.js → chunk-6EV4VOET.js} +10 -10
- package/Build/Workers/{chunk-KHWLAQVA.js → chunk-7ITUZTFH.js} +1 -1
- package/Build/Workers/{chunk-JHBPC4LK.js → chunk-ARVZCY6X.js} +7 -7
- package/Build/Workers/{chunk-FFBJDW4A.js → chunk-B2UQN3DH.js} +6 -6
- package/Build/Workers/{chunk-VCNOFQYH.js → chunk-B2Y4ZS6X.js} +9 -9
- package/Build/Workers/{chunk-Q4ZVWJXX.js → chunk-BD2TPFGC.js} +5 -5
- package/Build/Workers/{chunk-K4AH3TDT.js → chunk-CHX2K5AC.js} +10 -10
- package/Build/Workers/{chunk-3LYROPON.js → chunk-CJGVEABL.js} +13 -13
- package/Build/Workers/{chunk-KSYBJA4M.js → chunk-DYJHEP3B.js} +5 -5
- package/Build/Workers/{chunk-CI2HEJFC.js → chunk-E3H7AVMK.js} +13 -13
- package/Build/Workers/{chunk-F4CUH4MR.js → chunk-EZNAJPP5.js} +4 -4
- package/Build/Workers/{chunk-YJX7X577.js → chunk-F7ZI463G.js} +15 -15
- package/Build/Workers/{chunk-HEZHXDYB.js → chunk-FMZ5CX6V.js} +1 -1
- package/Build/Workers/{chunk-G3BVMPWG.js → chunk-FRAWHNSR.js} +2 -2
- package/Build/Workers/{chunk-J7IH4EYI.js → chunk-GGV2XJHE.js} +7 -7
- package/Build/Workers/{chunk-5KWRW7YL.js → chunk-GK4QU6QI.js} +2 -2
- package/Build/Workers/{chunk-77XPS7ZA.js → chunk-HYPB7FAV.js} +10 -10
- package/Build/Workers/{chunk-MVM4JV5U.js → chunk-I4HO2ED2.js} +9 -9
- package/Build/Workers/{chunk-FX4R4MTH.js → chunk-IGINOLDX.js} +6 -6
- package/Build/Workers/{chunk-PWF4EY5P.js → chunk-ISQSYLZY.js} +4 -4
- package/Build/Workers/{chunk-7UHKH6M3.js → chunk-JZAMRL5I.js} +6 -6
- package/Build/Workers/{chunk-HUFQVUMY.js → chunk-K5G2WELR.js} +7 -7
- package/Build/Workers/{chunk-5S5OOA6U.js → chunk-L5SO4Y5V.js} +1 -1
- package/Build/Workers/{chunk-LNSWJ43X.js → chunk-LCMJQVIF.js} +11 -11
- package/Build/Workers/{chunk-WVNLSTOF.js → chunk-MWJW37I7.js} +2 -2
- package/Build/Workers/{chunk-ZGFIT57T.js → chunk-NAGMYRDW.js} +27 -20
- package/Build/Workers/{chunk-SDIDRZDG.js → chunk-OYO6TKMU.js} +7 -7
- package/Build/Workers/{chunk-HKHQ3EDR.js → chunk-PUTA3AE2.js} +4 -4
- package/Build/Workers/{chunk-JPDKYBLF.js → chunk-Q5BHMNKU.js} +13 -13
- package/Build/Workers/{chunk-XK4OP6VA.js → chunk-QTEX3Y4V.js} +17 -17
- package/Build/Workers/{chunk-TVL3F7IU.js → chunk-QZKN2RXM.js} +1 -1
- package/Build/Workers/{chunk-Z3QWTHI7.js → chunk-RO2Z3LCR.js} +14 -14
- package/Build/Workers/{chunk-N2XAJBC6.js → chunk-RRN6LRDX.js} +12 -12
- package/Build/Workers/{chunk-FYGLNDKG.js → chunk-SLIA3GQP.js} +7 -7
- package/Build/Workers/{chunk-7EO56M5R.js → chunk-TFCOEX3W.js} +2 -2
- package/Build/Workers/{chunk-KM6MITPF.js → chunk-TU6ZXHVU.js} +5 -5
- package/Build/Workers/{chunk-LS3KVHYY.js → chunk-VJ2PDF64.js} +6 -6
- package/Build/Workers/{chunk-D7ZBZPHV.js → chunk-VMVPONIV.js} +5 -5
- package/Build/Workers/{chunk-3PIZQT3I.js → chunk-WPXU45PH.js} +4 -4
- package/Build/Workers/{chunk-WEHZP4SE.js → chunk-XDHM4G3P.js} +7 -7
- package/Build/Workers/{chunk-TY4DKOWR.js → chunk-XED3RXKO.js} +2 -2
- package/Build/Workers/{chunk-ZMNLEL6W.js → chunk-YNYCGTQH.js} +5 -5
- package/Build/Workers/{chunk-4CHMVQTQ.js → chunk-Z4SI54EB.js} +4 -4
- package/Build/Workers/{chunk-3JBEPBPL.js → chunk-ZVDLC3T4.js} +13 -13
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +20 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +50 -43
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/EllipsoidRhumbLine.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometryLibrary.js +26 -4
- package/Source/Core/TexturePacker.js +166 -0
- package/Source/DataSources/BillboardVisualizer.js +3 -3
- package/Source/DataSources/EntityCluster.js +44 -19
- package/Source/Renderer/Context.js +0 -4
- package/Source/Renderer/Texture.js +6 -5
- package/Source/Renderer/TextureAtlas.js +802 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +86 -141
- package/Source/Scene/BillboardCollection.js +132 -202
- package/Source/Scene/BillboardLoadState.js +44 -0
- package/Source/Scene/BillboardTexture.js +348 -0
- package/Source/Scene/Camera.js +2 -2
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +380 -126
- package/Source/Scene/Cesium3DTilesetStatistics.js +0 -1
- package/Source/Scene/Expression.js +1 -0
- package/Source/Scene/GltfLoader.js +5 -7
- package/Source/Scene/ImplicitSubtree.js +2 -0
- package/Source/Scene/KeyframeNode.js +16 -2
- package/Source/Scene/LabelCollection.js +212 -182
- package/Source/Scene/Megatexture.js +145 -81
- package/Source/Scene/Model/CustomShader.js +0 -2
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +5 -1
- package/Source/Scene/Scene.js +39 -15
- package/Source/Scene/ScreenSpaceCameraController.js +0 -8
- package/Source/Scene/SpatialNode.js +4 -11
- package/Source/Scene/Vector3DTilePoints.js +2 -5
- package/Source/Scene/VoxelBoxShape.js +12 -5
- package/Source/Scene/VoxelCell.js +6 -5
- package/Source/Scene/VoxelContent.js +171 -107
- package/Source/Scene/VoxelCylinderShape.js +65 -58
- package/Source/Scene/VoxelEllipsoidShape.js +15 -5
- package/Source/Scene/VoxelMetadataOrder.js +12 -0
- package/Source/Scene/VoxelPrimitive.js +122 -54
- package/Source/Scene/VoxelProvider.js +34 -29
- package/Source/Scene/VoxelRenderResources.js +30 -7
- package/Source/Scene/VoxelShape.js +10 -3
- package/Source/Scene/VoxelTraversal.js +264 -180
- package/Source/Scene/processVoxelProperties.js +3 -0
- package/Source/Shaders/GlobeFS.glsl +10 -1
- package/Source/Shaders/GlobeFS.js +10 -1
- package/Source/Shaders/Voxels/Megatexture.glsl +4 -16
- package/Source/Shaders/Voxels/Megatexture.js +4 -16
- package/Source/Shaders/Voxels/Octree.glsl +44 -7
- package/Source/Shaders/Voxels/Octree.js +44 -7
- package/Source/Shaders/Voxels/VoxelFS.glsl +9 -15
- package/Source/Shaders/Voxels/VoxelFS.js +9 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +15 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.js +15 -15
- package/index.d.ts +176 -79
- package/index.js +413 -409
- package/package.json +2 -2
- package/Source/Scene/TextureAtlas.js +0 -558
|
@@ -21,11 +21,11 @@ import TextureWrap from "../Renderer/TextureWrap.js";
|
|
|
21
21
|
* @alias Megatexture
|
|
22
22
|
* @constructor
|
|
23
23
|
*
|
|
24
|
-
* @param {Context} context
|
|
25
|
-
* @param {Cartesian3} dimensions
|
|
26
|
-
* @param {number} channelCount
|
|
27
|
-
* @param {MetadataComponentType} componentType
|
|
28
|
-
* @param {number} [
|
|
24
|
+
* @param {Context} context The context in which to create GPU resources.
|
|
25
|
+
* @param {Cartesian3} dimensions The number of voxels in each dimension of the tile.
|
|
26
|
+
* @param {number} channelCount The number of channels in the metadata.
|
|
27
|
+
* @param {MetadataComponentType} componentType The component type of the metadata.
|
|
28
|
+
* @param {number} [availableTextureMemoryBytes=134217728] An upper limit on the texture memory size in bytes.
|
|
29
29
|
*
|
|
30
30
|
* @private
|
|
31
31
|
*/
|
|
@@ -34,59 +34,35 @@ function Megatexture(
|
|
|
34
34
|
dimensions,
|
|
35
35
|
channelCount,
|
|
36
36
|
componentType,
|
|
37
|
-
|
|
37
|
+
availableTextureMemoryBytes,
|
|
38
38
|
) {
|
|
39
|
+
const maximumTextureMemoryByteLength = 512 * 1024 * 1024;
|
|
40
|
+
availableTextureMemoryBytes = Math.min(
|
|
41
|
+
defaultValue(availableTextureMemoryBytes, 128 * 1024 * 1024),
|
|
42
|
+
maximumTextureMemoryByteLength,
|
|
43
|
+
);
|
|
44
|
+
|
|
39
45
|
// TODO there are a lot of texture packing rules, see https://github.com/CesiumGS/cesium/issues/9572
|
|
40
46
|
// Unsigned short textures not allowed in webgl 1, so treat as float
|
|
41
47
|
if (componentType === MetadataComponentType.UNSIGNED_SHORT) {
|
|
42
48
|
componentType = MetadataComponentType.FLOAT32;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
const supportsFloatingPointTexture = context.floatingPointTexture;
|
|
46
51
|
if (
|
|
47
52
|
componentType === MetadataComponentType.FLOAT32 &&
|
|
48
|
-
!
|
|
53
|
+
!context.floatingPointTexture
|
|
49
54
|
) {
|
|
50
55
|
throw new RuntimeError("Floating point texture not supported");
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
componentType === MetadataComponentType.FLOAT32 ||
|
|
57
|
-
componentType === MetadataComponentType.FLOAT64
|
|
58
|
-
) {
|
|
59
|
-
pixelType = PixelDatatype.FLOAT;
|
|
60
|
-
} else if (componentType === MetadataComponentType.UINT8) {
|
|
61
|
-
pixelType = PixelDatatype.UNSIGNED_BYTE;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let pixelFormat;
|
|
65
|
-
if (channelCount === 1) {
|
|
66
|
-
pixelFormat = context.webgl2 ? PixelFormat.RED : PixelFormat.LUMINANCE;
|
|
67
|
-
} else if (channelCount === 2) {
|
|
68
|
-
pixelFormat = context.webgl2 ? PixelFormat.RG : PixelFormat.LUMINANCE_ALPHA;
|
|
69
|
-
} else if (channelCount === 3) {
|
|
70
|
-
pixelFormat = PixelFormat.RGB;
|
|
71
|
-
} else if (channelCount === 4) {
|
|
72
|
-
pixelFormat = PixelFormat.RGBA;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const maximumTextureMemoryByteLength = 512 * 1024 * 1024;
|
|
76
|
-
const defaultTextureMemoryByteLength = 128 * 1024 * 1024;
|
|
77
|
-
textureMemoryByteLength = Math.min(
|
|
78
|
-
defaultValue(textureMemoryByteLength, defaultTextureMemoryByteLength),
|
|
79
|
-
maximumTextureMemoryByteLength,
|
|
80
|
-
);
|
|
81
|
-
const maximumTextureDimensionContext = ContextLimits.maximumTextureSize;
|
|
58
|
+
const pixelDataType = getPixelDataType(componentType);
|
|
59
|
+
const pixelFormat = getPixelFormat(channelCount, context.webgl2);
|
|
82
60
|
const componentTypeByteLength =
|
|
83
61
|
MetadataComponentType.getSizeInBytes(componentType);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
maximumTextureDimensionContext,
|
|
89
|
-
CesiumMath.previousPowerOfTwo(Math.floor(Math.sqrt(texelCount))),
|
|
62
|
+
const textureDimension = getTextureDimension(
|
|
63
|
+
availableTextureMemoryBytes,
|
|
64
|
+
channelCount,
|
|
65
|
+
componentTypeByteLength,
|
|
90
66
|
);
|
|
91
67
|
|
|
92
68
|
const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.x));
|
|
@@ -116,6 +92,13 @@ function Megatexture(
|
|
|
116
92
|
*/
|
|
117
93
|
this.componentType = componentType;
|
|
118
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @type {number}
|
|
97
|
+
* @readonly
|
|
98
|
+
*/
|
|
99
|
+
this.textureMemoryByteLength =
|
|
100
|
+
componentTypeByteLength * channelCount * textureDimension ** 2;
|
|
101
|
+
|
|
119
102
|
/**
|
|
120
103
|
* @type {Cartesian3}
|
|
121
104
|
* @readonly
|
|
@@ -190,7 +173,7 @@ function Megatexture(
|
|
|
190
173
|
this.texture = new Texture({
|
|
191
174
|
context: context,
|
|
192
175
|
pixelFormat: pixelFormat,
|
|
193
|
-
pixelDatatype:
|
|
176
|
+
pixelDatatype: pixelDataType,
|
|
194
177
|
flipY: false,
|
|
195
178
|
width: textureDimension,
|
|
196
179
|
height: textureDimension,
|
|
@@ -249,6 +232,73 @@ function Megatexture(
|
|
|
249
232
|
this.occupiedCount = 0;
|
|
250
233
|
}
|
|
251
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Get the pixel data type to use in a megatexture.
|
|
237
|
+
* TODO support more
|
|
238
|
+
*
|
|
239
|
+
* @param {MetadataComponentType} componentType The component type of the metadata.
|
|
240
|
+
* @returns {PixelDatatype} The pixel datatype to use for a megatexture.
|
|
241
|
+
*
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
function getPixelDataType(componentType) {
|
|
245
|
+
if (
|
|
246
|
+
componentType === MetadataComponentType.FLOAT32 ||
|
|
247
|
+
componentType === MetadataComponentType.FLOAT64
|
|
248
|
+
) {
|
|
249
|
+
return PixelDatatype.FLOAT;
|
|
250
|
+
} else if (componentType === MetadataComponentType.UINT8) {
|
|
251
|
+
return PixelDatatype.UNSIGNED_BYTE;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get the pixel format to use for a megatexture.
|
|
257
|
+
*
|
|
258
|
+
* @param {number} channelCount The number of channels in the metadata. Must be 1 to 4.
|
|
259
|
+
* @param {boolean} webgl2 true if the context is using webgl2
|
|
260
|
+
* @returns {PixelFormat} The pixel format to use for a megatexture.
|
|
261
|
+
*
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
264
|
+
function getPixelFormat(channelCount, webgl2) {
|
|
265
|
+
if (channelCount === 1) {
|
|
266
|
+
return webgl2 ? PixelFormat.RED : PixelFormat.LUMINANCE;
|
|
267
|
+
} else if (channelCount === 2) {
|
|
268
|
+
return webgl2 ? PixelFormat.RG : PixelFormat.LUMINANCE_ALPHA;
|
|
269
|
+
} else if (channelCount === 3) {
|
|
270
|
+
return PixelFormat.RGB;
|
|
271
|
+
} else if (channelCount === 4) {
|
|
272
|
+
return PixelFormat.RGBA;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Compute the largest size of a square texture that will fit in the available memory.
|
|
278
|
+
*
|
|
279
|
+
* @param {number} availableTextureMemoryBytes An upper limit on the texture memory size.
|
|
280
|
+
* @param {number} channelCount The number of metadata channels per texel.
|
|
281
|
+
* @param {number} componentByteLength The byte length of each component of the metadata.
|
|
282
|
+
* @returns {number} The dimension of the square texture to use for the megatexture.
|
|
283
|
+
*
|
|
284
|
+
* @private
|
|
285
|
+
*/
|
|
286
|
+
function getTextureDimension(
|
|
287
|
+
availableTextureMemoryBytes,
|
|
288
|
+
channelCount,
|
|
289
|
+
componentByteLength,
|
|
290
|
+
) {
|
|
291
|
+
// Compute how many texels will fit in the available memory
|
|
292
|
+
const texelCount = Math.floor(
|
|
293
|
+
availableTextureMemoryBytes / (channelCount * componentByteLength),
|
|
294
|
+
);
|
|
295
|
+
// Return the largest power of two texture size that will fit in memory
|
|
296
|
+
return Math.min(
|
|
297
|
+
ContextLimits.maximumTextureSize,
|
|
298
|
+
CesiumMath.previousPowerOfTwo(Math.floor(Math.sqrt(texelCount))),
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
252
302
|
/**
|
|
253
303
|
* @alias MegatextureNode
|
|
254
304
|
* @constructor
|
|
@@ -275,8 +325,9 @@ function MegatextureNode(index) {
|
|
|
275
325
|
}
|
|
276
326
|
|
|
277
327
|
/**
|
|
278
|
-
*
|
|
279
|
-
* @
|
|
328
|
+
* Add an array of tile metadata to the megatexture.
|
|
329
|
+
* @param {Array} data The data to be added.
|
|
330
|
+
* @returns {number} The index of the tile's location in the megatexture.
|
|
280
331
|
*/
|
|
281
332
|
Megatexture.prototype.add = function (data) {
|
|
282
333
|
if (this.isFull()) {
|
|
@@ -339,10 +390,10 @@ Megatexture.prototype.isFull = function () {
|
|
|
339
390
|
};
|
|
340
391
|
|
|
341
392
|
/**
|
|
342
|
-
* @param {number} tileCount
|
|
343
|
-
* @param {Cartesian3} dimensions
|
|
344
|
-
* @param {number} channelCount number of channels in the metadata.
|
|
345
|
-
* @param {MetadataComponentType} componentType
|
|
393
|
+
* @param {number} tileCount The total number of tiles in the tileset.
|
|
394
|
+
* @param {Cartesian3} dimensions The number of voxels in each dimension of the tile.
|
|
395
|
+
* @param {number} channelCount The number of channels in the metadata.
|
|
396
|
+
* @param {MetadataComponentType} componentType The type of one channel of the metadata.
|
|
346
397
|
* @returns {number}
|
|
347
398
|
*/
|
|
348
399
|
Megatexture.getApproximateTextureMemoryByteLength = function (
|
|
@@ -390,55 +441,52 @@ Megatexture.getApproximateTextureMemoryByteLength = function (
|
|
|
390
441
|
};
|
|
391
442
|
|
|
392
443
|
/**
|
|
393
|
-
*
|
|
394
|
-
* @param {
|
|
444
|
+
* Write an array of tile metadata to the megatexture.
|
|
445
|
+
* @param {number} index The index of the tile's location in the megatexture.
|
|
446
|
+
* @param {Float32Array|Uint16Array|Uint8Array} data The data to be written.
|
|
395
447
|
*/
|
|
396
448
|
Megatexture.prototype.writeDataToTexture = function (index, data) {
|
|
397
449
|
// Unsigned short textures not allowed in webgl 1, so treat as float
|
|
398
450
|
const tileData =
|
|
399
451
|
data.constructor === Uint16Array ? new Float32Array(data) : data;
|
|
400
452
|
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
453
|
+
const {
|
|
454
|
+
tileVoxelDataTemp,
|
|
455
|
+
voxelCountPerTile,
|
|
456
|
+
sliceCountPerRegion,
|
|
457
|
+
voxelCountPerRegion,
|
|
458
|
+
channelCount,
|
|
459
|
+
regionCountPerMegatexture,
|
|
460
|
+
} = this;
|
|
461
|
+
|
|
462
|
+
for (let z = 0; z < voxelCountPerTile.z; z++) {
|
|
463
|
+
const sliceVoxelOffsetX = (z % sliceCountPerRegion.x) * voxelCountPerTile.x;
|
|
410
464
|
const sliceVoxelOffsetY =
|
|
411
|
-
Math.floor(z /
|
|
412
|
-
for (let y = 0; y <
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const writeIndex =
|
|
419
|
-
(sliceVoxelOffsetY + y) * voxelDimensionsPerRegion.x +
|
|
420
|
-
(sliceVoxelOffsetX + x);
|
|
465
|
+
Math.floor(z / sliceCountPerRegion.x) * voxelCountPerTile.y;
|
|
466
|
+
for (let y = 0; y < voxelCountPerTile.y; y++) {
|
|
467
|
+
const readOffset = getReadOffset(voxelCountPerTile, y, z);
|
|
468
|
+
const writeOffset =
|
|
469
|
+
(sliceVoxelOffsetY + y) * voxelCountPerRegion.x + sliceVoxelOffsetX;
|
|
470
|
+
for (let x = 0; x < voxelCountPerTile.x; x++) {
|
|
471
|
+
const readIndex = readOffset + x;
|
|
472
|
+
const writeIndex = writeOffset + x;
|
|
421
473
|
for (let c = 0; c < channelCount; c++) {
|
|
422
|
-
|
|
474
|
+
tileVoxelDataTemp[writeIndex * channelCount + c] =
|
|
423
475
|
tileData[readIndex * channelCount + c];
|
|
424
476
|
}
|
|
425
477
|
}
|
|
426
478
|
}
|
|
427
479
|
}
|
|
428
480
|
|
|
429
|
-
const regionDimensionsPerMegatexture = this.regionCountPerMegatexture;
|
|
430
|
-
const voxelWidth = voxelDimensionsPerRegion.x;
|
|
431
|
-
const voxelHeight = voxelDimensionsPerRegion.y;
|
|
432
481
|
const voxelOffsetX =
|
|
433
|
-
(index %
|
|
482
|
+
(index % regionCountPerMegatexture.x) * voxelCountPerRegion.x;
|
|
434
483
|
const voxelOffsetY =
|
|
435
|
-
Math.floor(index /
|
|
436
|
-
voxelDimensionsPerRegion.y;
|
|
484
|
+
Math.floor(index / regionCountPerMegatexture.x) * voxelCountPerRegion.y;
|
|
437
485
|
|
|
438
486
|
const source = {
|
|
439
|
-
arrayBufferView:
|
|
440
|
-
width:
|
|
441
|
-
height:
|
|
487
|
+
arrayBufferView: tileVoxelDataTemp,
|
|
488
|
+
width: voxelCountPerRegion.x,
|
|
489
|
+
height: voxelCountPerRegion.y,
|
|
442
490
|
};
|
|
443
491
|
|
|
444
492
|
const copyOptions = {
|
|
@@ -450,6 +498,22 @@ Megatexture.prototype.writeDataToTexture = function (index, data) {
|
|
|
450
498
|
this.texture.copyFrom(copyOptions);
|
|
451
499
|
};
|
|
452
500
|
|
|
501
|
+
/**
|
|
502
|
+
* Get the offset into the data array for a given row of contiguous voxel data.
|
|
503
|
+
*
|
|
504
|
+
* @param {Cartesian3} dimensions The number of voxels in each dimension of the tile.
|
|
505
|
+
* @param {number} y The y index of the voxel row
|
|
506
|
+
* @param {number} z The z index of the voxel row
|
|
507
|
+
* @returns {number} The offset into the data array
|
|
508
|
+
* @private
|
|
509
|
+
*/
|
|
510
|
+
function getReadOffset(dimensions, y, z) {
|
|
511
|
+
const voxelsPerInputSlice = dimensions.y * dimensions.x;
|
|
512
|
+
const sliceIndex = z;
|
|
513
|
+
const rowIndex = y;
|
|
514
|
+
return sliceIndex * voxelsPerInputSlice + rowIndex * dimensions.x;
|
|
515
|
+
}
|
|
516
|
+
|
|
453
517
|
/**
|
|
454
518
|
* Returns true if this object was destroyed; otherwise, false.
|
|
455
519
|
* <br /><br />
|
|
@@ -443,7 +443,6 @@ CustomShader.prototype.update = function (frameState) {
|
|
|
443
443
|
* @returns {boolean} True if this object was destroyed; otherwise, false.
|
|
444
444
|
*
|
|
445
445
|
* @see CustomShader#destroy
|
|
446
|
-
* @private
|
|
447
446
|
*/
|
|
448
447
|
CustomShader.prototype.isDestroyed = function () {
|
|
449
448
|
return false;
|
|
@@ -463,7 +462,6 @@ CustomShader.prototype.isDestroyed = function () {
|
|
|
463
462
|
* customShader = customShader && customShader.destroy();
|
|
464
463
|
*
|
|
465
464
|
* @see CustomShader#isDestroyed
|
|
466
|
-
* @private
|
|
467
465
|
*/
|
|
468
466
|
CustomShader.prototype.destroy = function () {
|
|
469
467
|
this._textureManager = this._textureManager && this._textureManager.destroy();
|
|
@@ -120,9 +120,9 @@ import pickModel from "./pickModel.js";
|
|
|
120
120
|
* @alias Model
|
|
121
121
|
* @internalConstructor
|
|
122
122
|
*
|
|
123
|
+
* @privateParam {object} options Object with the following properties:
|
|
123
124
|
* @privateParam {ResourceLoader} options.loader The loader used to load resources for this model.
|
|
124
125
|
* @privateParam {ModelType} options.type Type of this model, to distinguish individual glTF files from 3D Tiles internally.
|
|
125
|
-
* @privateParam {object} options Object with the following properties:
|
|
126
126
|
* @privateParam {Resource} options.resource The Resource to the 3D model.
|
|
127
127
|
* @privateParam {boolean} [options.show=true] Whether or not to render the model.
|
|
128
128
|
* @privateParam {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates.
|
|
@@ -346,15 +346,18 @@ ModelUtility.supportedExtensions = {
|
|
|
346
346
|
CESIUM_primitive_outline: true,
|
|
347
347
|
CESIUM_RTC: true,
|
|
348
348
|
EXT_feature_metadata: true,
|
|
349
|
+
EXT_implicit_cylinder_region: true,
|
|
350
|
+
EXT_implicit_ellipsoid_region: true,
|
|
349
351
|
EXT_instance_features: true,
|
|
350
352
|
EXT_mesh_features: true,
|
|
351
353
|
EXT_mesh_gpu_instancing: true,
|
|
352
354
|
EXT_meshopt_compression: true,
|
|
355
|
+
EXT_primitive_voxels: true,
|
|
353
356
|
EXT_structural_metadata: true,
|
|
354
357
|
EXT_texture_webp: true,
|
|
355
358
|
KHR_blend: true,
|
|
356
359
|
KHR_draco_mesh_compression: true,
|
|
357
|
-
|
|
360
|
+
KHR_implicit_shapes: true,
|
|
358
361
|
KHR_materials_common: true,
|
|
359
362
|
KHR_materials_pbrSpecularGlossiness: true,
|
|
360
363
|
KHR_materials_specular: true,
|
|
@@ -362,6 +365,7 @@ ModelUtility.supportedExtensions = {
|
|
|
362
365
|
KHR_materials_clearcoat: true,
|
|
363
366
|
KHR_materials_unlit: true,
|
|
364
367
|
KHR_mesh_quantization: true,
|
|
368
|
+
KHR_techniques_webgl: true,
|
|
365
369
|
KHR_texture_basisu: true,
|
|
366
370
|
KHR_texture_transform: true,
|
|
367
371
|
WEB3D_quantized_attributes: true,
|
package/Source/Scene/Scene.js
CHANGED
|
@@ -3805,6 +3805,38 @@ function getGlobeHeight(scene) {
|
|
|
3805
3805
|
return scene.getHeight(cartographic);
|
|
3806
3806
|
}
|
|
3807
3807
|
|
|
3808
|
+
function getMaxPrimitiveHeight(primitive, cartographic, scene) {
|
|
3809
|
+
let maxHeight = Number.NEGATIVE_INFINITY;
|
|
3810
|
+
|
|
3811
|
+
if (primitive instanceof PrimitiveCollection) {
|
|
3812
|
+
// If it's a PrimitiveCollection, iterate through its children
|
|
3813
|
+
const length = primitive.length;
|
|
3814
|
+
for (let i = 0; i < length; ++i) {
|
|
3815
|
+
const subPrimitive = primitive.get(i);
|
|
3816
|
+
const subHeight = getMaxPrimitiveHeight(
|
|
3817
|
+
subPrimitive,
|
|
3818
|
+
cartographic,
|
|
3819
|
+
scene,
|
|
3820
|
+
);
|
|
3821
|
+
if (defined(subHeight) && subHeight > maxHeight) {
|
|
3822
|
+
maxHeight = subHeight;
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
} else if (
|
|
3826
|
+
primitive.isCesium3DTileset &&
|
|
3827
|
+
primitive.show &&
|
|
3828
|
+
primitive.enableCollision
|
|
3829
|
+
) {
|
|
3830
|
+
// If it's an individual primitive, check its height
|
|
3831
|
+
const result = primitive.getHeight(cartographic, scene);
|
|
3832
|
+
if (defined(result) && result > maxHeight) {
|
|
3833
|
+
return result;
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
return maxHeight;
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3808
3840
|
/**
|
|
3809
3841
|
* Gets the height of the loaded surface at the cartographic position.
|
|
3810
3842
|
* @param {Cartographic} cartographic The cartographic position.
|
|
@@ -3831,21 +3863,13 @@ Scene.prototype.getHeight = function (cartographic, heightReference) {
|
|
|
3831
3863
|
let maxHeight = Number.NEGATIVE_INFINITY;
|
|
3832
3864
|
|
|
3833
3865
|
if (!ignore3dTiles) {
|
|
3834
|
-
const
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
) {
|
|
3842
|
-
continue;
|
|
3843
|
-
}
|
|
3844
|
-
|
|
3845
|
-
const result = primitive.getHeight(cartographic, this);
|
|
3846
|
-
if (defined(result) && result > maxHeight) {
|
|
3847
|
-
maxHeight = result;
|
|
3848
|
-
}
|
|
3866
|
+
const maxPrimitiveHeight = getMaxPrimitiveHeight(
|
|
3867
|
+
this.primitives,
|
|
3868
|
+
cartographic,
|
|
3869
|
+
this,
|
|
3870
|
+
);
|
|
3871
|
+
if (defined(maxPrimitiveHeight) && maxPrimitiveHeight > maxHeight) {
|
|
3872
|
+
maxHeight = maxPrimitiveHeight;
|
|
3849
3873
|
}
|
|
3850
3874
|
}
|
|
3851
3875
|
|
|
@@ -623,14 +623,6 @@ function handleZoom(
|
|
|
623
623
|
orientation.pitch = camera.pitch;
|
|
624
624
|
orientation.roll = camera.roll;
|
|
625
625
|
|
|
626
|
-
if (camera.frustum instanceof OrthographicFrustum) {
|
|
627
|
-
if (Math.abs(distance) > 0.0) {
|
|
628
|
-
camera.zoomIn(distance);
|
|
629
|
-
camera._adjustOrthographicFrustum(true);
|
|
630
|
-
}
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
626
|
const sameStartPosition = defaultValue(
|
|
635
627
|
movement.inertiaEnabled,
|
|
636
628
|
Cartesian2.equals(startPosition, object._zoomMouseStart),
|
|
@@ -320,12 +320,7 @@ SpatialNode.prototype.destroyKeyframeNode = function (
|
|
|
320
320
|
this.renderableKeyframeNodes.splice(renderableKeyframeNodeIndex, 1);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
keyframeNode.
|
|
324
|
-
keyframeNode.state = KeyframeNode.LoadState.UNLOADED;
|
|
325
|
-
keyframeNode.metadata = {};
|
|
326
|
-
keyframeNode.megatextureIndex = -1;
|
|
327
|
-
keyframeNode.priority = -Number.MAX_VALUE;
|
|
328
|
-
keyframeNode.highPriorityFrameNumber = -1;
|
|
323
|
+
keyframeNode.unload();
|
|
329
324
|
};
|
|
330
325
|
|
|
331
326
|
/**
|
|
@@ -337,20 +332,18 @@ SpatialNode.prototype.addKeyframeNodeToMegatextures = function (
|
|
|
337
332
|
megatextures,
|
|
338
333
|
) {
|
|
339
334
|
if (
|
|
340
|
-
keyframeNode.state !== KeyframeNode.LoadState.RECEIVED ||
|
|
341
335
|
keyframeNode.megatextureIndex !== -1 ||
|
|
342
|
-
keyframeNode.metadata.length !== megatextures.length
|
|
336
|
+
keyframeNode.content.metadata.length !== megatextures.length
|
|
343
337
|
) {
|
|
344
338
|
throw new DeveloperError("Keyframe node cannot be added to megatexture");
|
|
345
339
|
}
|
|
346
340
|
|
|
341
|
+
const { metadata } = keyframeNode.content;
|
|
347
342
|
for (let i = 0; i < megatextures.length; i++) {
|
|
348
343
|
const megatexture = megatextures[i];
|
|
349
|
-
keyframeNode.megatextureIndex = megatexture.add(
|
|
344
|
+
keyframeNode.megatextureIndex = megatexture.add(metadata[i]);
|
|
350
345
|
}
|
|
351
346
|
|
|
352
|
-
keyframeNode.state = KeyframeNode.LoadState.LOADED;
|
|
353
|
-
|
|
354
347
|
const renderableKeyframeNodes = this.renderableKeyframeNodes;
|
|
355
348
|
let renderableKeyframeNodeIndex = findKeyframeIndex(
|
|
356
349
|
keyframeNode.keyframe,
|
|
@@ -101,9 +101,8 @@ Object.defineProperties(Vector3DTilePoints.prototype, {
|
|
|
101
101
|
*/
|
|
102
102
|
texturesByteLength: {
|
|
103
103
|
get: function () {
|
|
104
|
-
const billboardSize =
|
|
105
|
-
|
|
106
|
-
const labelSize = this._labelCollection._textureAtlas.texture.sizeInBytes;
|
|
104
|
+
const billboardSize = this._billboardCollection.sizeInBytes;
|
|
105
|
+
const labelSize = this._labelCollection.sizeInBytes;
|
|
107
106
|
return billboardSize + labelSize;
|
|
108
107
|
},
|
|
109
108
|
},
|
|
@@ -496,8 +495,6 @@ Vector3DTilePoints.prototype.update = function (frameState) {
|
|
|
496
495
|
this._error = undefined;
|
|
497
496
|
throw error;
|
|
498
497
|
}
|
|
499
|
-
|
|
500
|
-
return;
|
|
501
498
|
}
|
|
502
499
|
|
|
503
500
|
this._polylineCollection.update(frameState);
|
|
@@ -24,6 +24,7 @@ function VoxelBoxShape() {
|
|
|
24
24
|
/**
|
|
25
25
|
* An oriented bounding box containing the bounded shape.
|
|
26
26
|
* The update function must be called before accessing this value.
|
|
27
|
+
* @private
|
|
27
28
|
* @type {OrientedBoundingBox}
|
|
28
29
|
* @readonly
|
|
29
30
|
*/
|
|
@@ -32,6 +33,7 @@ function VoxelBoxShape() {
|
|
|
32
33
|
/**
|
|
33
34
|
* A bounding sphere containing the bounded shape.
|
|
34
35
|
* The update function must be called before accessing this value.
|
|
36
|
+
* @private
|
|
35
37
|
* @type {BoundingSphere}
|
|
36
38
|
* @readonly
|
|
37
39
|
*/
|
|
@@ -40,6 +42,7 @@ function VoxelBoxShape() {
|
|
|
40
42
|
/**
|
|
41
43
|
* A transformation matrix containing the bounded shape.
|
|
42
44
|
* The update function must be called before accessing this value.
|
|
45
|
+
* @private
|
|
43
46
|
* @type {Matrix4}
|
|
44
47
|
* @readonly
|
|
45
48
|
*/
|
|
@@ -48,6 +51,7 @@ function VoxelBoxShape() {
|
|
|
48
51
|
/**
|
|
49
52
|
* A transformation matrix containing the shape, ignoring the bounds.
|
|
50
53
|
* The update function must be called before accessing this value.
|
|
54
|
+
* @private
|
|
51
55
|
* @type {Matrix4}
|
|
52
56
|
* @readonly
|
|
53
57
|
*/
|
|
@@ -72,6 +76,7 @@ function VoxelBoxShape() {
|
|
|
72
76
|
);
|
|
73
77
|
|
|
74
78
|
/**
|
|
79
|
+
* @private
|
|
75
80
|
* @type {Object<string, any>}
|
|
76
81
|
* @readonly
|
|
77
82
|
*/
|
|
@@ -83,6 +88,7 @@ function VoxelBoxShape() {
|
|
|
83
88
|
};
|
|
84
89
|
|
|
85
90
|
/**
|
|
91
|
+
* @private
|
|
86
92
|
* @type {Object<string, any>}
|
|
87
93
|
* @readonly
|
|
88
94
|
*/
|
|
@@ -93,6 +99,7 @@ function VoxelBoxShape() {
|
|
|
93
99
|
|
|
94
100
|
/**
|
|
95
101
|
* The maximum number of intersections against the shape for any ray direction.
|
|
102
|
+
* @private
|
|
96
103
|
* @type {number}
|
|
97
104
|
* @readonly
|
|
98
105
|
*/
|
|
@@ -115,7 +122,7 @@ const transformLocalToUv = Matrix4.fromRotationTranslation(
|
|
|
115
122
|
|
|
116
123
|
/**
|
|
117
124
|
* Update the shape's state.
|
|
118
|
-
*
|
|
125
|
+
* @private
|
|
119
126
|
* @param {Matrix4} modelMatrix The model matrix.
|
|
120
127
|
* @param {Cartesian3} minBounds The minimum bounds.
|
|
121
128
|
* @param {Cartesian3} maxBounds The maximum bounds.
|
|
@@ -302,7 +309,7 @@ const scratchTileMaxBounds = new Cartesian3();
|
|
|
302
309
|
/**
|
|
303
310
|
* Computes an oriented bounding box for a specified tile.
|
|
304
311
|
* The update function must be called before calling this function.
|
|
305
|
-
*
|
|
312
|
+
* @private
|
|
306
313
|
* @param {number} tileLevel The tile's level.
|
|
307
314
|
* @param {number} tileX The tile's x coordinate.
|
|
308
315
|
* @param {number} tileY The tile's y coordinate.
|
|
@@ -356,7 +363,7 @@ const sampleSizeScratch = new Cartesian3();
|
|
|
356
363
|
/**
|
|
357
364
|
* Computes an oriented bounding box for a specified sample within a specified tile.
|
|
358
365
|
* The update function must be called before calling this function.
|
|
359
|
-
*
|
|
366
|
+
* @private
|
|
360
367
|
* @param {SpatialNode} spatialNode The spatial node containing the sample
|
|
361
368
|
* @param {Cartesian3} tileDimensions The size of the tile in number of samples, before padding
|
|
362
369
|
* @param {Cartesian3} tileUv The sample coordinate within the tile
|
|
@@ -429,7 +436,7 @@ VoxelBoxShape.prototype.computeOrientedBoundingBoxForSample = function (
|
|
|
429
436
|
|
|
430
437
|
/**
|
|
431
438
|
* Defines the minimum bounds of the shape. Corresponds to minimum X, Y, Z.
|
|
432
|
-
*
|
|
439
|
+
* @private
|
|
433
440
|
* @type {Cartesian3}
|
|
434
441
|
* @constant
|
|
435
442
|
* @readonly
|
|
@@ -440,7 +447,7 @@ VoxelBoxShape.DefaultMinBounds = Object.freeze(
|
|
|
440
447
|
|
|
441
448
|
/**
|
|
442
449
|
* Defines the maximum bounds of the shape. Corresponds to maximum X, Y, Z.
|
|
443
|
-
*
|
|
450
|
+
* @private
|
|
444
451
|
* @type {Cartesian3}
|
|
445
452
|
* @constant
|
|
446
453
|
* @readonly
|
|
@@ -71,8 +71,8 @@ VoxelCell.fromKeyframeNode = function (
|
|
|
71
71
|
//>>includeEnd('debug');
|
|
72
72
|
|
|
73
73
|
const voxelCell = new VoxelCell(primitive, tileIndex, sampleIndex);
|
|
74
|
-
const { spatialNode,
|
|
75
|
-
voxelCell._metadata = getMetadataForSample(primitive,
|
|
74
|
+
const { spatialNode, content } = keyframeNode;
|
|
75
|
+
voxelCell._metadata = getMetadataForSample(primitive, content, sampleIndex);
|
|
76
76
|
voxelCell._orientedBoundingBox = getOrientedBoundingBox(
|
|
77
77
|
primitive,
|
|
78
78
|
spatialNode,
|
|
@@ -85,15 +85,16 @@ VoxelCell.fromKeyframeNode = function (
|
|
|
85
85
|
/**
|
|
86
86
|
* @private
|
|
87
87
|
* @param {VoxelPrimitive} primitive
|
|
88
|
-
* @param {
|
|
88
|
+
* @param {VoxelContent} content
|
|
89
89
|
* @param {number} sampleIndex
|
|
90
90
|
* @returns {object}
|
|
91
91
|
*/
|
|
92
|
-
function getMetadataForSample(primitive,
|
|
93
|
-
if (!defined(metadata)) {
|
|
92
|
+
function getMetadataForSample(primitive, content, sampleIndex) {
|
|
93
|
+
if (!defined(content) || !defined(content.metadata)) {
|
|
94
94
|
return undefined;
|
|
95
95
|
}
|
|
96
96
|
const { names, types } = primitive.provider;
|
|
97
|
+
const { metadata } = content;
|
|
97
98
|
const metadataMap = {};
|
|
98
99
|
for (let i = 0; i < names.length; i++) {
|
|
99
100
|
const name = names[i];
|