@cesium/engine 23.0.1 → 24.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-G6MJ3ZW3.js → chunk-2N4KDHS3.js} +10 -10
- package/Build/Workers/{chunk-C6HHBKT5.js → chunk-44EMEGKW.js} +5 -5
- package/Build/Workers/{chunk-TNXOPEIG.js → chunk-4TIG36AW.js} +12 -12
- package/Build/Workers/{chunk-PQTSXJBJ.js → chunk-5A2SW66E.js} +16 -16
- package/Build/Workers/{chunk-TXYQNXNW.js → chunk-5GXYJQ2K.js} +3 -3
- package/Build/Workers/{chunk-O67UP5YO.js → chunk-63SIWPLS.js} +13 -13
- package/Build/Workers/{chunk-CVAAIRNP.js → chunk-6MPGQEHA.js} +2 -2
- package/Build/Workers/{chunk-LHFC4R7Z.js → chunk-6RMS4S72.js} +6 -6
- package/Build/Workers/{chunk-77DJBHMI.js → chunk-6WLHJFD3.js} +7 -7
- package/Build/Workers/{chunk-HXEPZWJN.js → chunk-72VYSVEW.js} +9 -9
- package/Build/Workers/{chunk-VPWYHFQA.js → chunk-7MDYBRYJ.js} +4 -4
- package/Build/Workers/{chunk-XPMXRJDD.js → chunk-7O5XJTVE.js} +5 -5
- package/Build/Workers/{chunk-UEWYSOFD.js → chunk-7QRFIKWQ.js} +2 -2
- package/Build/Workers/{chunk-3UQ2YMPP.js → chunk-7TYLCBGK.js} +8 -8
- package/Build/Workers/{chunk-GLCPE2BJ.js → chunk-7X322WP2.js} +13 -13
- package/Build/Workers/{chunk-2OBWHTIC.js → chunk-A47HVBC5.js} +7 -7
- package/Build/Workers/{chunk-CID5SY7L.js → chunk-AF3MU2RL.js} +5 -5
- package/Build/Workers/{chunk-BTP3634E.js → chunk-AJLTU6PF.js} +1 -1
- package/Build/Workers/{chunk-YSJRB2UZ.js → chunk-AMIHNSST.js} +2 -2
- package/Build/Workers/{chunk-QPXGGVHC.js → chunk-B6SCUUFP.js} +10 -10
- package/Build/Workers/{chunk-QNABVTTP.js → chunk-BJD6QGXZ.js} +12 -12
- package/Build/Workers/{chunk-RZX6LOG6.js → chunk-C6P4IG5P.js} +6 -6
- package/Build/Workers/{chunk-4JJQRZYL.js → chunk-D4EJ2NXG.js} +17 -17
- package/Build/Workers/{chunk-K7UTK4OM.js → chunk-DHKPFLSJ.js} +1 -1
- package/Build/Workers/{chunk-S53HSRT6.js → chunk-DVB56LG7.js} +6 -6
- package/Build/Workers/{chunk-PBECJOWF.js → chunk-EDXL4W76.js} +2 -2
- package/Build/Workers/{chunk-ALTCIHRH.js → chunk-EV3VGO6Y.js} +17 -17
- package/Build/Workers/{chunk-UOQB7XQI.js → chunk-GOQBUCXH.js} +10 -10
- package/Build/Workers/{chunk-TMCTZ5E3.js → chunk-GQUNK2XC.js} +14 -14
- package/Build/Workers/{chunk-PAFMAR7A.js → chunk-HKUES6UG.js} +12 -12
- package/Build/Workers/{chunk-6U5QMZU3.js → chunk-HRHRYFHS.js} +9 -9
- package/Build/Workers/{chunk-PUO7BYDY.js → chunk-HXJMS2ZI.js} +1 -1
- package/Build/Workers/{chunk-FXSRA5UG.js → chunk-ILMFADZA.js} +4 -4
- package/Build/Workers/{chunk-U4SWB6TI.js → chunk-ISY4EZCA.js} +4 -4
- package/Build/Workers/{chunk-PGZ3B6CB.js → chunk-J6AW5YHS.js} +14 -14
- package/Build/Workers/{chunk-VX774SWE.js → chunk-JCI63T3K.js} +6 -6
- package/Build/Workers/{chunk-54O3AGOA.js → chunk-KLPGTXS3.js} +6 -6
- package/Build/Workers/{chunk-CNLXMOPM.js → chunk-LIB2H534.js} +10 -10
- package/Build/Workers/{chunk-H3TVRJLY.js → chunk-LXMCPFFS.js} +4 -4
- package/Build/Workers/{chunk-DNMASBMH.js → chunk-MKM27KGV.js} +2 -2
- package/Build/Workers/{chunk-66OWUDO7.js → chunk-N65BAKSH.js} +8 -8
- package/Build/Workers/{chunk-ZEMJQKHD.js → chunk-NKT5K3K3.js} +11 -11
- package/Build/Workers/{chunk-EIC3VAOZ.js → chunk-NPF7SSHZ.js} +7 -7
- package/Build/Workers/{chunk-YDR5LX5Z.js → chunk-PVV64VFW.js} +1 -1
- package/Build/Workers/{chunk-FKU77FNM.js → chunk-Q3C6VQH6.js} +4 -4
- package/Build/Workers/{chunk-CYOPNGPX.js → chunk-RQNJD3O4.js} +12 -12
- package/Build/Workers/{chunk-IJ3SUMK3.js → chunk-UIGVOKKI.js} +1 -1
- package/Build/Workers/{chunk-TFPG3ZKW.js → chunk-UQU4RXLT.js} +27 -19
- package/Build/Workers/{chunk-N6HRZLS6.js → chunk-VLDEUTOP.js} +2 -2
- package/Build/Workers/{chunk-MNSNOONX.js → chunk-VMVOUQ5J.js} +7 -7
- package/Build/Workers/{chunk-OZYB3AOR.js → chunk-XJRBB253.js} +11 -11
- package/Build/Workers/{chunk-B2VA6IEL.js → chunk-XY6HMDGI.js} +5 -5
- package/Build/Workers/{chunk-2M7DKGLW.js → chunk-Y7HNNPNK.js} +10 -10
- package/Build/Workers/{chunk-CJ7ZDY77.js → chunk-YAOZMOFL.js} +5 -5
- package/Build/Workers/{chunk-FCJQO4NC.js → chunk-YJZGW74L.js} +8 -8
- package/Build/Workers/{chunk-JUKGMJX7.js → chunk-YQFTYQMZ.js} +1 -1
- package/Build/Workers/{chunk-HNDE73JK.js → chunk-ZBZRTRJB.js} +10 -10
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +25 -25
- package/Build/Workers/createWallOutlineGeometry.js +24 -24
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +12 -12
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/BoundingSphere.js +1 -1
- package/Source/Core/Cartesian2.js +7 -5
- package/Source/Core/Cartesian3.js +8 -6
- package/Source/Core/Cartesian4.js +8 -6
- package/Source/Core/Color.js +5 -3
- package/Source/Core/DeveloperError.js +2 -1
- package/Source/Core/ITwinPlatform.js +1 -0
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/S2Cell.js +2 -2
- package/Source/Core/TerrainMesh.js +10 -1
- package/Source/Core/TerrainPicker.js +1 -0
- package/Source/Core/WallGeometry.js +1 -1
- package/Source/Core/WallOutlineGeometry.js +1 -1
- package/Source/Core/assert.js +27 -0
- package/Source/Core/globalTypes.js +4 -0
- package/Source/DataSources/CzmlDataSource.js +9 -0
- package/Source/DataSources/PathGraphics.js +13 -0
- package/Source/DataSources/PathVisualizer.js +330 -18
- package/Source/DataSources/StaticGeometryColorBatch.js +7 -2
- package/Source/DataSources/StaticGeometryPerMaterialBatch.js +7 -2
- package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +3 -1
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +3 -1
- package/Source/Renderer/Context.js +1 -1
- package/Source/Renderer/RenderState.js +2 -2
- package/Source/Renderer/VertexArray.js +80 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/BillboardCollection.js +65 -364
- package/Source/Scene/BufferPoint.js +148 -0
- package/Source/Scene/BufferPointCollection.js +135 -0
- package/Source/Scene/BufferPointMaterial.js +95 -0
- package/Source/Scene/BufferPolygon.js +516 -0
- package/Source/Scene/BufferPolygonCollection.js +368 -0
- package/Source/Scene/BufferPolygonMaterial.js +41 -0
- package/Source/Scene/BufferPolyline.js +185 -0
- package/Source/Scene/BufferPolylineCollection.js +136 -0
- package/Source/Scene/BufferPolylineMaterial.js +93 -0
- package/Source/Scene/BufferPrimitive.js +347 -0
- package/Source/Scene/BufferPrimitiveCollection.js +702 -0
- package/Source/Scene/BufferPrimitiveMaterial.js +140 -0
- package/Source/Scene/Cesium3DTileContent.js +5 -1
- package/Source/Scene/Cesium3DTileContentFactory.js +9 -0
- package/Source/Scene/Cesium3DTileStyle.js +22 -0
- package/Source/Scene/Cesium3DTileset.js +1 -0
- package/Source/Scene/ClippingPolygonCollection.js +270 -101
- package/Source/Scene/CubeMapPanorama.js +4 -4
- package/Source/Scene/GaussianSplat3DTileContent.js +40 -46
- package/Source/Scene/GaussianSplatPrimitive.js +413 -70
- package/Source/Scene/GetFeatureInfoFormat.js +3 -3
- package/Source/Scene/GltfLoader.js +215 -34
- package/Source/Scene/GltfSpzLoader.js +109 -0
- package/Source/Scene/ITwinData.js +1 -0
- package/Source/Scene/Label.js +32 -0
- package/Source/Scene/LabelCollection.js +14 -13
- package/Source/Scene/Material.js +2 -0
- package/Source/Scene/Megatexture.js +1 -0
- package/Source/Scene/MetadataClassProperty.js +24 -10
- package/Source/Scene/MetadataComponentType.js +115 -23
- package/Source/Scene/Model/CustomShaderPipelineStage.js +3 -1
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +761 -263
- package/Source/Scene/Model/MaterialPipelineStage.js +147 -0
- package/Source/Scene/Model/MetadataPipelineStage.js +3 -3
- package/Source/Scene/Model/ModelDrawCommand.js +6 -0
- package/Source/Scene/Model/ModelReader.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +3 -1
- package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +330 -0
- package/Source/Scene/ModelComponents.js +1632 -1542
- package/Source/Scene/PickedMetadataInfo.js +1 -0
- package/Source/Scene/ScreenSpaceCameraController.js +13 -0
- package/Source/Scene/SkyBox.js +17 -8
- package/Source/Scene/TileBoundingRegion.js +1 -1
- package/Source/Scene/TileBoundingS2Cell.js +1 -1
- package/Source/Scene/TileBoundingSphere.js +1 -1
- package/Source/Scene/TweenCollection.js +7 -0
- package/Source/Scene/VectorGltf3DTileContent.js +382 -0
- package/Source/Scene/VertexAttributeSemantic.js +14 -0
- package/Source/Scene/WebMapServiceImageryProvider.js +2 -2
- package/Source/Scene/WebMapTileServiceImageryProvider.js +366 -131
- package/Source/Scene/parseStructuralMetadata.js +97 -37
- package/Source/Scene/renderBufferPointCollection.js +334 -0
- package/Source/Scene/renderBufferPolygonCollection.js +386 -0
- package/Source/Scene/renderBufferPolylineCollection.js +529 -0
- package/Source/Shaders/BillboardCollectionFS.glsl +2 -77
- package/Source/Shaders/BillboardCollectionFS.js +2 -77
- package/Source/Shaders/BillboardCollectionVS.glsl +2 -60
- package/Source/Shaders/BillboardCollectionVS.js +2 -60
- package/Source/Shaders/BufferPointMaterialFS.glsl +27 -0
- package/Source/Shaders/BufferPointMaterialFS.js +29 -0
- package/Source/Shaders/BufferPointMaterialVS.glsl +48 -0
- package/Source/Shaders/BufferPointMaterialVS.js +50 -0
- package/Source/Shaders/BufferPolygonMaterialFS.glsl +13 -0
- package/Source/Shaders/BufferPolygonMaterialFS.js +15 -0
- package/Source/Shaders/BufferPolygonMaterialVS.glsl +30 -0
- package/Source/Shaders/BufferPolygonMaterialVS.js +32 -0
- package/Source/Shaders/BufferPolylineMaterialFS.glsl +13 -0
- package/Source/Shaders/BufferPolylineMaterialFS.js +15 -0
- package/Source/Shaders/BufferPolylineMaterialVS.glsl +49 -0
- package/Source/Shaders/BufferPolylineMaterialVS.js +51 -0
- package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +34 -48
- package/Source/Shaders/Model/EdgeVisibilityStageFS.js +34 -49
- package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +98 -0
- package/Source/Shaders/Model/EdgeVisibilityStageVS.js +100 -0
- package/Source/Shaders/Model/ModelFS.glsl +15 -0
- package/Source/Shaders/Model/ModelFS.js +15 -0
- package/Source/Shaders/Model/ModelVS.glsl +8 -0
- package/Source/Shaders/Model/ModelVS.js +8 -0
- package/Source/Shaders/PolygonSignedDistanceFS.glsl +64 -33
- package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
- package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +9 -2
- package/Source/Shaders/PrimitiveGaussianSplatVS.js +9 -2
- package/Source/Shaders/Voxels/VoxelFS.glsl +1 -1
- package/Source/Shaders/Voxels/VoxelFS.js +1 -1
- package/Source/Workers/decodeDraco.js +3 -0
- package/Source/Workers/decodeI3S.js +5 -2
- package/index.d.ts +1007 -111
- package/index.js +394 -369
- package/package.json +2 -2
|
@@ -149,9 +149,9 @@ function createTextureForPropertyTable(
|
|
|
149
149
|
|
|
150
150
|
const numFeatures = propertyTable.count;
|
|
151
151
|
|
|
152
|
-
let
|
|
152
|
+
let gpuCompatiblePropertyInfo;
|
|
153
153
|
try {
|
|
154
|
-
|
|
154
|
+
gpuCompatiblePropertyInfo = collectGpuCompatiblePropertyInfo(
|
|
155
155
|
properties,
|
|
156
156
|
bufferViews,
|
|
157
157
|
classDefinition,
|
|
@@ -164,7 +164,7 @@ function createTextureForPropertyTable(
|
|
|
164
164
|
return undefined;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
const numGpuCompatibleProperties =
|
|
167
|
+
const numGpuCompatibleProperties = gpuCompatiblePropertyInfo.length;
|
|
168
168
|
|
|
169
169
|
if (numGpuCompatibleProperties === 0) {
|
|
170
170
|
return undefined;
|
|
@@ -183,7 +183,7 @@ function createTextureForPropertyTable(
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
const packedBufferView = packPropertyTablePropertiesIntoRGBA8(
|
|
186
|
-
|
|
186
|
+
gpuCompatiblePropertyInfo,
|
|
187
187
|
numFeatures,
|
|
188
188
|
);
|
|
189
189
|
|
|
@@ -209,13 +209,13 @@ function createTextureForPropertyTable(
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
function
|
|
212
|
+
function collectGpuCompatiblePropertyInfo(
|
|
213
213
|
properties,
|
|
214
214
|
bufferViews,
|
|
215
215
|
classDefinition,
|
|
216
216
|
numFeatures,
|
|
217
217
|
) {
|
|
218
|
-
const
|
|
218
|
+
const propertyInfos = [];
|
|
219
219
|
const classProperties = classDefinition.properties;
|
|
220
220
|
|
|
221
221
|
// It's possible for a primitive in a tileset to only use a subset of the class properties defined in the schema.
|
|
@@ -234,7 +234,7 @@ function collectGpuCompatiblePropertyBufferViews(
|
|
|
234
234
|
: createNoDataBufferView(classProperty, numFeatures);
|
|
235
235
|
|
|
236
236
|
const bufferViewLength = bufferView.length;
|
|
237
|
-
const bytesPerElement = classProperty.
|
|
237
|
+
const bytesPerElement = classProperty.cpuBytesPerElement();
|
|
238
238
|
const numBufferElements = bufferViewLength / bytesPerElement;
|
|
239
239
|
if (numBufferElements !== numFeatures) {
|
|
240
240
|
throw new RuntimeError(
|
|
@@ -242,13 +242,13 @@ function collectGpuCompatiblePropertyBufferViews(
|
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
propertyInfos.push({
|
|
246
246
|
view: bufferView,
|
|
247
|
-
|
|
247
|
+
classProperty: classProperty,
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
return
|
|
251
|
+
return propertyInfos;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
@@ -287,18 +287,25 @@ function createNoDataBufferView(classProperty, numFeatures) {
|
|
|
287
287
|
noData = [noData];
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
const bytesPerElement = classProperty.
|
|
290
|
+
const bytesPerElement = classProperty.cpuBytesPerElement();
|
|
291
|
+
const bytesPerComponent = MetadataComponentType.getSizeInBytes(
|
|
292
|
+
classProperty.valueType,
|
|
293
|
+
);
|
|
291
294
|
const buffer = new ArrayBuffer(bytesPerElement * numFeatures);
|
|
292
295
|
const view = new DataView(buffer);
|
|
293
|
-
const
|
|
296
|
+
const accessors = MetadataComponentType.getDataViewAccessors(
|
|
294
297
|
view,
|
|
295
|
-
classProperty.
|
|
298
|
+
classProperty.valueType,
|
|
296
299
|
);
|
|
297
300
|
|
|
298
301
|
for (let i = 0; i < numFeatures; i++) {
|
|
299
302
|
for (let j = 0; j < metadataArrayLength; j++) {
|
|
300
303
|
for (let k = 0; k < metadataComponentCount; k++) {
|
|
301
|
-
|
|
304
|
+
const componentIdx = j * metadataComponentCount + k;
|
|
305
|
+
accessors.set(
|
|
306
|
+
bytesPerElement * i + componentIdx * bytesPerComponent,
|
|
307
|
+
noData[j][k],
|
|
308
|
+
);
|
|
302
309
|
}
|
|
303
310
|
}
|
|
304
311
|
}
|
|
@@ -308,39 +315,92 @@ function createNoDataBufferView(classProperty, numFeatures) {
|
|
|
308
315
|
|
|
309
316
|
// Make one big buffer view to load into the texture
|
|
310
317
|
// Since each texel is always 4 bytes (RGBA8 format), elements less than 4 bytes need to be padded (respecting little-endian order).
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
) {
|
|
315
|
-
const numGpuCompatibleProperties = bufferViewsForThisTable.length;
|
|
318
|
+
// Exception: single-component 64-bit types can be downcast to 32-bit for GPU compatibility (with potential loss of precision / range).
|
|
319
|
+
function packPropertyTablePropertiesIntoRGBA8(propertyInfos, numFeatures) {
|
|
320
|
+
const numGpuCompatibleProperties = propertyInfos.length;
|
|
316
321
|
const packedBufferView = new Uint8Array(
|
|
317
322
|
numGpuCompatibleProperties * numFeatures * NUM_CHANNELS,
|
|
318
323
|
);
|
|
324
|
+
const packedDataView = new DataView(
|
|
325
|
+
packedBufferView.buffer,
|
|
326
|
+
packedBufferView.byteOffset,
|
|
327
|
+
packedBufferView.byteLength,
|
|
328
|
+
);
|
|
319
329
|
|
|
320
|
-
for (
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
330
|
+
for (
|
|
331
|
+
let propertyIndex = 0;
|
|
332
|
+
propertyIndex < numGpuCompatibleProperties;
|
|
333
|
+
propertyIndex++
|
|
334
|
+
) {
|
|
335
|
+
const propertyInfo = propertyInfos[propertyIndex];
|
|
336
|
+
const classProperty = propertyInfo.classProperty;
|
|
337
|
+
const rowOffset = propertyIndex * numFeatures * NUM_CHANNELS;
|
|
338
|
+
const sourceType = classProperty.valueType;
|
|
339
|
+
const packedType = MetadataComponentType.gpuComponentType(sourceType);
|
|
340
|
+
|
|
341
|
+
// E.g. When the source component type is INT64, we first downcast each element to INT32 before packing into the GPU buffer.
|
|
342
|
+
if (sourceType !== packedType) {
|
|
343
|
+
downcastAndPackProperty(propertyInfo, packedDataView, rowOffset);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
324
346
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const destOffset = offset + j * NUM_CHANNELS;
|
|
347
|
+
packProperty(propertyInfo, packedBufferView, rowOffset);
|
|
348
|
+
}
|
|
328
349
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
destOffset,
|
|
332
|
-
);
|
|
350
|
+
return packedBufferView;
|
|
351
|
+
}
|
|
333
352
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
353
|
+
function packProperty(propertyInfo, packedBufferView, rowOffset) {
|
|
354
|
+
const bufferView = propertyInfo.view;
|
|
355
|
+
const bytesPerElement = propertyInfo.classProperty.cpuBytesPerElement();
|
|
356
|
+
const numElements = bufferView.length / bytesPerElement;
|
|
357
|
+
|
|
358
|
+
for (let elementIndex = 0; elementIndex < numElements; elementIndex++) {
|
|
359
|
+
const sourceOffset = elementIndex * bytesPerElement;
|
|
360
|
+
const destinationOffset = rowOffset + elementIndex * NUM_CHANNELS;
|
|
339
361
|
|
|
340
|
-
|
|
362
|
+
packedBufferView.set(
|
|
363
|
+
bufferView.subarray(sourceOffset, sourceOffset + bytesPerElement),
|
|
364
|
+
destinationOffset,
|
|
365
|
+
);
|
|
341
366
|
}
|
|
367
|
+
}
|
|
342
368
|
|
|
343
|
-
|
|
369
|
+
// This is the slow path - rather than doing a straight copy, we need to interpret and downcast each element before packing it into the GPU buffer.
|
|
370
|
+
// Note: this function does not handle properties with multiple components per element (or arrays). While not complete, this is OK because
|
|
371
|
+
// multi-component properties with 64-bit types - even when downcast to 32 bits - cannot fit into a single RGBA8 texel.
|
|
372
|
+
function downcastAndPackProperty(propertyInfo, packedDataView, rowOffset) {
|
|
373
|
+
const classProperty = propertyInfo.classProperty;
|
|
374
|
+
const bufferView = propertyInfo.view;
|
|
375
|
+
const sourceType = classProperty.valueType;
|
|
376
|
+
const packedType = MetadataComponentType.gpuComponentType(sourceType);
|
|
377
|
+
|
|
378
|
+
const bytesPerElement = classProperty.cpuBytesPerElement();
|
|
379
|
+
const numElements = bufferView.length / bytesPerElement;
|
|
380
|
+
|
|
381
|
+
const sourceDataView = new DataView(
|
|
382
|
+
bufferView.buffer,
|
|
383
|
+
bufferView.byteOffset,
|
|
384
|
+
bufferView.byteLength,
|
|
385
|
+
);
|
|
386
|
+
const sourceAccessors = MetadataComponentType.getDataViewAccessors(
|
|
387
|
+
sourceDataView,
|
|
388
|
+
sourceType,
|
|
389
|
+
);
|
|
390
|
+
const packedAccessors = MetadataComponentType.getDataViewAccessors(
|
|
391
|
+
packedDataView,
|
|
392
|
+
packedType,
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
const downcastFunction = MetadataComponentType.downcastFunction(sourceType);
|
|
396
|
+
|
|
397
|
+
for (let elementIndex = 0; elementIndex < numElements; elementIndex++) {
|
|
398
|
+
const sourceElementOffset = elementIndex * bytesPerElement;
|
|
399
|
+
const destinationElementOffset = rowOffset + elementIndex * NUM_CHANNELS;
|
|
400
|
+
|
|
401
|
+
const value = sourceAccessors.get(sourceElementOffset);
|
|
402
|
+
packedAccessors.set(destinationElementOffset, downcastFunction(value));
|
|
403
|
+
}
|
|
344
404
|
}
|
|
345
405
|
|
|
346
406
|
export default parseStructuralMetadata;
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import defined from "../Core/defined.js";
|
|
4
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
5
|
+
import Color from "../Core/Color.js";
|
|
6
|
+
import BufferPoint from "./BufferPoint.js";
|
|
7
|
+
import Buffer from "../Renderer/Buffer.js";
|
|
8
|
+
import BufferUsage from "../Renderer/BufferUsage.js";
|
|
9
|
+
import VertexArray from "../Renderer/VertexArray.js";
|
|
10
|
+
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
11
|
+
import RenderState from "../Renderer/RenderState.js";
|
|
12
|
+
import BlendingState from "./BlendingState.js";
|
|
13
|
+
import ShaderSource from "../Renderer/ShaderSource.js";
|
|
14
|
+
import ShaderProgram from "../Renderer/ShaderProgram.js";
|
|
15
|
+
import DrawCommand from "../Renderer/DrawCommand.js";
|
|
16
|
+
import Pass from "../Renderer/Pass.js";
|
|
17
|
+
import PrimitiveType from "../Core/PrimitiveType.js";
|
|
18
|
+
import BufferPointMaterialVS from "../Shaders/BufferPointMaterialVS.js";
|
|
19
|
+
import BufferPointMaterialFS from "../Shaders/BufferPointMaterialFS.js";
|
|
20
|
+
import EncodedCartesian3 from "../Core/EncodedCartesian3.js";
|
|
21
|
+
import AttributeCompression from "../Core/AttributeCompression.js";
|
|
22
|
+
import Matrix4 from "../Core/Matrix4.js";
|
|
23
|
+
import BoundingSphere from "../Core/BoundingSphere.js";
|
|
24
|
+
import BufferPointMaterial from "./BufferPointMaterial.js";
|
|
25
|
+
|
|
26
|
+
/** @import FrameState from "./FrameState.js"; */
|
|
27
|
+
/** @import BufferPointCollection from "./BufferPointCollection.js"; */
|
|
28
|
+
/** @import {Destroyable, TypedArray} from "../Core/globalTypes.js"; */
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* TODO(PR#13211): Need 'keyof' syntax to avoid duplicating attribute names.
|
|
32
|
+
* @typedef {'positionHigh' | 'positionLow' | 'pickColor' | 'showSizeAndColor' | 'outlineWidthAndOutlineColor'} BufferPointAttribute
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @type {Record<BufferPointAttribute, number>}
|
|
38
|
+
* @ignore
|
|
39
|
+
*/
|
|
40
|
+
const BufferPointAttributeLocations = {
|
|
41
|
+
positionHigh: 0,
|
|
42
|
+
positionLow: 1,
|
|
43
|
+
pickColor: 2,
|
|
44
|
+
showSizeAndColor: 3,
|
|
45
|
+
outlineWidthAndOutlineColor: 4,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {object} BufferPointRenderContext
|
|
50
|
+
* @property {VertexArray} [vertexArray]
|
|
51
|
+
* @property {Record<BufferPointAttribute, TypedArray>} [attributeArrays]
|
|
52
|
+
* @property {RenderState} [renderState]
|
|
53
|
+
* @property {ShaderProgram} [shaderProgram]
|
|
54
|
+
* @property {DrawCommand} [command]
|
|
55
|
+
* @property {Destroyable[]} [pickIds] Unordered list of collection PickIds.
|
|
56
|
+
* @property {Function} destroy
|
|
57
|
+
* @ignore
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
// Scratch variables.
|
|
61
|
+
const point = new BufferPoint();
|
|
62
|
+
const material = new BufferPointMaterial();
|
|
63
|
+
const pickColor = new Color();
|
|
64
|
+
const cartesian = new Cartesian3();
|
|
65
|
+
const encodedCartesian = new EncodedCartesian3();
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {BufferPointCollection} collection
|
|
69
|
+
* @param {FrameState} frameState
|
|
70
|
+
* @param {BufferPointRenderContext} [renderContext]
|
|
71
|
+
* @returns {BufferPointRenderContext}
|
|
72
|
+
* @ignore
|
|
73
|
+
*/
|
|
74
|
+
function renderBufferPointCollection(collection, frameState, renderContext) {
|
|
75
|
+
const context = frameState.context;
|
|
76
|
+
renderContext = renderContext || { destroy: destroyRenderContext };
|
|
77
|
+
|
|
78
|
+
if (!defined(renderContext.attributeArrays)) {
|
|
79
|
+
const featureCountMax = collection.primitiveCountMax;
|
|
80
|
+
|
|
81
|
+
renderContext.attributeArrays = {
|
|
82
|
+
positionHigh: new Float32Array(featureCountMax * 3),
|
|
83
|
+
positionLow: new Float32Array(featureCountMax * 3),
|
|
84
|
+
pickColor: new Uint8Array(featureCountMax * 4),
|
|
85
|
+
showSizeAndColor: new Float32Array(featureCountMax * 3),
|
|
86
|
+
outlineWidthAndOutlineColor: new Float32Array(featureCountMax * 2),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!defined(renderContext.pickIds)) {
|
|
91
|
+
renderContext.pickIds = [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (collection._dirtyCount > 0) {
|
|
95
|
+
const { attributeArrays, pickIds } = renderContext;
|
|
96
|
+
|
|
97
|
+
const positionHighArray = attributeArrays.positionHigh;
|
|
98
|
+
const positionLowArray = attributeArrays.positionLow;
|
|
99
|
+
const pickColorArray = attributeArrays.pickColor;
|
|
100
|
+
const showSizeAndColorArray = attributeArrays.showSizeAndColor;
|
|
101
|
+
const outlineWidthAndOutlineColorArray =
|
|
102
|
+
attributeArrays.outlineWidthAndOutlineColor;
|
|
103
|
+
|
|
104
|
+
const { _dirtyOffset, _dirtyCount } = collection;
|
|
105
|
+
|
|
106
|
+
for (let i = _dirtyOffset, il = _dirtyOffset + _dirtyCount; i < il; i++) {
|
|
107
|
+
collection.get(i, point);
|
|
108
|
+
|
|
109
|
+
if (!point._dirty) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (collection._allowPicking && point._pickId === 0) {
|
|
114
|
+
const pickId = context.createPickId({
|
|
115
|
+
collection,
|
|
116
|
+
index: i,
|
|
117
|
+
get primitive() {
|
|
118
|
+
// Cannot reuse primitives; scene.drillPick() appends to a list.
|
|
119
|
+
return collection.get(this.index, new BufferPoint());
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
point._pickId = pickId.key;
|
|
123
|
+
pickIds.push(pickId);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
point.getPosition(cartesian);
|
|
127
|
+
EncodedCartesian3.fromCartesian(cartesian, encodedCartesian);
|
|
128
|
+
point.getMaterial(material);
|
|
129
|
+
Color.fromRgba(point._pickId, pickColor);
|
|
130
|
+
|
|
131
|
+
positionHighArray[i * 3] = encodedCartesian.high.x;
|
|
132
|
+
positionHighArray[i * 3 + 1] = encodedCartesian.high.y;
|
|
133
|
+
positionHighArray[i * 3 + 2] = encodedCartesian.high.z;
|
|
134
|
+
|
|
135
|
+
positionLowArray[i * 3] = encodedCartesian.low.x;
|
|
136
|
+
positionLowArray[i * 3 + 1] = encodedCartesian.low.y;
|
|
137
|
+
positionLowArray[i * 3 + 2] = encodedCartesian.low.z;
|
|
138
|
+
|
|
139
|
+
pickColorArray[i * 4] = Color.floatToByte(pickColor.red);
|
|
140
|
+
pickColorArray[i * 4 + 1] = Color.floatToByte(pickColor.green);
|
|
141
|
+
pickColorArray[i * 4 + 2] = Color.floatToByte(pickColor.blue);
|
|
142
|
+
pickColorArray[i * 4 + 3] = Color.floatToByte(pickColor.alpha);
|
|
143
|
+
|
|
144
|
+
showSizeAndColorArray[i * 3] = point.show ? 1 : 0;
|
|
145
|
+
showSizeAndColorArray[i * 3 + 1] = material.size;
|
|
146
|
+
showSizeAndColorArray[i * 3 + 2] = AttributeCompression.encodeRGB8(
|
|
147
|
+
material.color,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
outlineWidthAndOutlineColorArray[i * 2] = material.outlineWidth;
|
|
151
|
+
outlineWidthAndOutlineColorArray[i * 2 + 1] =
|
|
152
|
+
AttributeCompression.encodeRGB8(material.outlineColor);
|
|
153
|
+
|
|
154
|
+
point._dirty = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!defined(renderContext.vertexArray)) {
|
|
159
|
+
const { attributeArrays } = renderContext;
|
|
160
|
+
|
|
161
|
+
renderContext.vertexArray = new VertexArray({
|
|
162
|
+
context,
|
|
163
|
+
attributes: [
|
|
164
|
+
{
|
|
165
|
+
index: BufferPointAttributeLocations.positionHigh,
|
|
166
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
167
|
+
componentsPerAttribute: 3,
|
|
168
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
169
|
+
typedArray: attributeArrays.positionHigh,
|
|
170
|
+
context,
|
|
171
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
172
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
index: BufferPointAttributeLocations.positionLow,
|
|
177
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
178
|
+
componentsPerAttribute: 3,
|
|
179
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
180
|
+
typedArray: attributeArrays.positionLow,
|
|
181
|
+
context,
|
|
182
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
183
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
index: BufferPointAttributeLocations.pickColor,
|
|
188
|
+
componentDatatype: ComponentDatatype.UNSIGNED_BYTE,
|
|
189
|
+
componentsPerAttribute: 4,
|
|
190
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
191
|
+
typedArray: attributeArrays.pickColor,
|
|
192
|
+
context,
|
|
193
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
194
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
195
|
+
}),
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
index: BufferPointAttributeLocations.showSizeAndColor,
|
|
199
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
200
|
+
componentsPerAttribute: 3,
|
|
201
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
202
|
+
typedArray: attributeArrays.showSizeAndColor,
|
|
203
|
+
context,
|
|
204
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
205
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
206
|
+
}),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
index: BufferPointAttributeLocations.outlineWidthAndOutlineColor,
|
|
210
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
211
|
+
componentsPerAttribute: 2,
|
|
212
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
213
|
+
typedArray: attributeArrays.outlineWidthAndOutlineColor,
|
|
214
|
+
context,
|
|
215
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
216
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
217
|
+
}),
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
});
|
|
221
|
+
} else if (collection._dirtyCount > 0) {
|
|
222
|
+
for (const key in BufferPointAttributeLocations) {
|
|
223
|
+
if (Object.hasOwn(BufferPointAttributeLocations, key)) {
|
|
224
|
+
const attribute = /** @type {BufferPointAttribute} */ (key);
|
|
225
|
+
renderContext.vertexArray.copyAttributeFromRange(
|
|
226
|
+
BufferPointAttributeLocations[attribute],
|
|
227
|
+
renderContext.attributeArrays[attribute],
|
|
228
|
+
collection._dirtyOffset,
|
|
229
|
+
collection._dirtyCount,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (!defined(renderContext.renderState)) {
|
|
236
|
+
renderContext.renderState = RenderState.fromCache({
|
|
237
|
+
blending: BlendingState.ALPHA_BLEND,
|
|
238
|
+
depthTest: { enabled: true },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (!defined(renderContext.shaderProgram)) {
|
|
243
|
+
renderContext.shaderProgram = ShaderProgram.fromCache({
|
|
244
|
+
context,
|
|
245
|
+
vertexShaderSource: new ShaderSource({
|
|
246
|
+
sources: [BufferPointMaterialVS],
|
|
247
|
+
}),
|
|
248
|
+
fragmentShaderSource: new ShaderSource({
|
|
249
|
+
sources: [BufferPointMaterialFS],
|
|
250
|
+
}),
|
|
251
|
+
attributeLocations: BufferPointAttributeLocations,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (
|
|
256
|
+
!defined(renderContext.command) ||
|
|
257
|
+
isCommandDirty(collection, renderContext.command)
|
|
258
|
+
) {
|
|
259
|
+
renderContext.command = new DrawCommand({
|
|
260
|
+
vertexArray: renderContext.vertexArray,
|
|
261
|
+
renderState: renderContext.renderState,
|
|
262
|
+
shaderProgram: renderContext.shaderProgram,
|
|
263
|
+
primitiveType: PrimitiveType.POINTS,
|
|
264
|
+
pass: Pass.OPAQUE,
|
|
265
|
+
pickId: "v_pickColor",
|
|
266
|
+
owner: collection,
|
|
267
|
+
count: collection.primitiveCount,
|
|
268
|
+
modelMatrix: collection.modelMatrix,
|
|
269
|
+
boundingVolume: collection.boundingVolumeWC,
|
|
270
|
+
debugShowBoundingVolume: collection.debugShowBoundingVolume,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
frameState.commandList.push(renderContext.command);
|
|
275
|
+
|
|
276
|
+
collection._dirtyCount = 0;
|
|
277
|
+
collection._dirtyOffset = 0;
|
|
278
|
+
|
|
279
|
+
return renderContext;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Returns true if DrawCommand is out of date for the given collection.
|
|
284
|
+
* @param {BufferPointCollection} collection
|
|
285
|
+
* @param {DrawCommand} command
|
|
286
|
+
* @ignore
|
|
287
|
+
*/
|
|
288
|
+
function isCommandDirty(collection, command) {
|
|
289
|
+
const isModelMatrixEqual = Matrix4.equals(
|
|
290
|
+
collection.modelMatrix,
|
|
291
|
+
command._modelMatrix,
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const isBoundingVolumeEqual = BoundingSphere.equals(
|
|
295
|
+
collection.boundingVolumeWC,
|
|
296
|
+
command._boundingVolume,
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
collection.primitiveCount !== command._count ||
|
|
301
|
+
collection.debugShowBoundingVolume !== command.debugShowBoundingVolume ||
|
|
302
|
+
!isModelMatrixEqual ||
|
|
303
|
+
!isBoundingVolumeEqual
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Destroys render context resources. Deleting properties from the context
|
|
309
|
+
* object isn't necessary, as collection.destroy() will discard the object.
|
|
310
|
+
* @ignore
|
|
311
|
+
*/
|
|
312
|
+
function destroyRenderContext() {
|
|
313
|
+
const context = /** @type {BufferPointRenderContext} */ (this);
|
|
314
|
+
|
|
315
|
+
if (defined(context.vertexArray)) {
|
|
316
|
+
context.vertexArray.destroy();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (defined(context.shaderProgram)) {
|
|
320
|
+
context.shaderProgram.destroy();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (defined(context.renderState)) {
|
|
324
|
+
RenderState.removeFromCache(context.renderState);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (defined(context.pickIds)) {
|
|
328
|
+
for (const pickId of context.pickIds) {
|
|
329
|
+
pickId.destroy();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export default renderBufferPointCollection;
|