@cesium/engine 22.3.0 → 23.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-EAAH543Q.js → chunk-2GL2EUEE.js} +11 -11
- package/Build/Workers/{chunk-EUDHHS7K.js → chunk-2WI4HGJU.js} +6 -6
- package/Build/Workers/{chunk-LWZHJWYK.js → chunk-36LBFITA.js} +665 -366
- package/Build/Workers/{chunk-7U5YNLF3.js → chunk-3B65YFXC.js} +1 -1
- package/Build/Workers/{chunk-D63Z7KKL.js → chunk-4LGFX2P5.js} +11 -11
- package/Build/Workers/{chunk-D6OKR3BQ.js → chunk-4UNQX2MP.js} +2 -2
- package/Build/Workers/{chunk-BO22JHBX.js → chunk-52K3GJKG.js} +3 -3
- package/Build/Workers/{chunk-XLIJV3YZ.js → chunk-56OHFSLH.js} +10 -10
- package/Build/Workers/{chunk-AWELU5C6.js → chunk-5A7YSAXT.js} +14 -14
- package/Build/Workers/{chunk-T5MJDW43.js → chunk-5JP5FG7U.js} +7 -7
- package/Build/Workers/{chunk-NVL7JXAQ.js → chunk-5R7SBUTW.js} +10 -10
- package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
- package/Build/Workers/{chunk-YHPBT4I5.js → chunk-6FVFM2KB.js} +5 -5
- package/Build/Workers/{chunk-WHLGBMBC.js → chunk-6SLGTBB2.js} +5 -5
- package/Build/Workers/{chunk-VIQIKMTZ.js → chunk-7KRN6JPQ.js} +14 -14
- package/Build/Workers/{chunk-TCOUGKXF.js → chunk-AA33B6PU.js} +4 -4
- package/Build/Workers/{chunk-S2KVL7OJ.js → chunk-AP6XWET5.js} +8 -8
- package/Build/Workers/{chunk-5PJB7ASO.js → chunk-APDKMX7W.js} +6 -6
- package/Build/Workers/{chunk-IXL46IYV.js → chunk-ARCFIOKA.js} +12 -12
- package/Build/Workers/{chunk-KIJR26N3.js → chunk-BNBD2YZK.js} +16 -16
- package/Build/Workers/{chunk-4R6FGUFP.js → chunk-DT5SJBKA.js} +29 -15
- package/Build/Workers/{chunk-FUDC3KOT.js → chunk-ESD4IEOU.js} +5 -5
- package/Build/Workers/{chunk-K2PLKJJG.js → chunk-FSDVXW7M.js} +5 -5
- package/Build/Workers/{chunk-4BBANFU6.js → chunk-G3YT7M7A.js} +1 -1
- package/Build/Workers/{chunk-K4PGSAR5.js → chunk-GN5NEUDT.js} +8 -8
- package/Build/Workers/{chunk-OOYICVOK.js → chunk-HYLEKKO5.js} +1 -1
- package/Build/Workers/{chunk-FDOLXORR.js → chunk-HYTFXWMY.js} +7 -7
- package/Build/Workers/{chunk-7SLNBIZS.js → chunk-IFA7VHHP.js} +560 -277
- package/Build/Workers/{chunk-N66PIK46.js → chunk-IYVDOB5V.js} +4 -4
- package/Build/Workers/{chunk-ZWWN2CQH.js → chunk-JUGY5AZN.js} +4 -4
- package/Build/Workers/{chunk-4O2ARYS7.js → chunk-KPYU6YZG.js} +1 -1
- package/Build/Workers/{chunk-TY5JXMVO.js → chunk-L7RDJ4V7.js} +1 -1
- package/Build/Workers/{chunk-L4OFWHNI.js → chunk-LDQWNMEC.js} +1 -1
- package/Build/Workers/{chunk-N6XBJBI7.js → chunk-MQJG522T.js} +6 -6
- package/Build/Workers/{chunk-FS42VX2H.js → chunk-MT5M7RLZ.js} +2 -2
- package/Build/Workers/{chunk-7ATKQRBM.js → chunk-N4AWE7TZ.js} +10 -10
- package/Build/Workers/{chunk-EOSX23OS.js → chunk-NAYRNPEP.js} +4 -4
- package/Build/Workers/{chunk-NO3LMU7T.js → chunk-NNHU33JK.js} +7 -7
- package/Build/Workers/{chunk-HWGP4GVC.js → chunk-NQCAZU7S.js} +13 -13
- package/Build/Workers/{chunk-6GBGEUWR.js → chunk-NUYLNQKV.js} +2 -2
- package/Build/Workers/{chunk-E4YDCSQK.js → chunk-OC6X22PG.js} +9 -9
- package/Build/Workers/{chunk-ZGGVEGTA.js → chunk-OHBM4YG4.js} +12 -12
- package/Build/Workers/{chunk-6WDMPXQ7.js → chunk-OMXN7YF4.js} +12 -12
- package/Build/Workers/{chunk-LK7GEFGB.js → chunk-OQ3EAJNW.js} +2 -2
- package/Build/Workers/{chunk-M5DVYXJJ.js → chunk-OQBPOKPZ.js} +6 -6
- package/Build/Workers/{chunk-WUWPKBOZ.js → chunk-PQVNT5CJ.js} +6 -6
- package/Build/Workers/{chunk-W5NV72VR.js → chunk-QA24Q62E.js} +17 -17
- package/Build/Workers/{chunk-PJLRXIMS.js → chunk-QQX7S5QT.js} +17 -17
- package/Build/Workers/{chunk-D2PEV362.js → chunk-QTOHIXGF.js} +10 -10
- package/Build/Workers/{chunk-MASEF4OV.js → chunk-R7M4XNPP.js} +8 -8
- package/Build/Workers/{chunk-2MLJ46ZZ.js → chunk-SGKTBHFQ.js} +13 -13
- package/Build/Workers/{chunk-EY5HOJFQ.js → chunk-SQTRWKO2.js} +5 -5
- package/Build/Workers/{chunk-AFGP5BXS.js → chunk-T43FXHNC.js} +7 -7
- package/Build/Workers/{chunk-IHFAFGR2.js → chunk-UEEGWJJP.js} +2 -2
- package/Build/Workers/{chunk-TMGLPEZW.js → chunk-WKXDCVBO.js} +4 -4
- package/Build/Workers/{chunk-VRAAQ3FS.js → chunk-Y5AJSEEN.js} +2 -2
- package/Build/Workers/{chunk-Y5MRBKQN.js → chunk-ZIW5FCIW.js} +18 -18
- 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 +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- 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/AttributeCompression.js +53 -6
- package/Source/Core/Cartesian2.js +689 -684
- package/Source/Core/Cartesian3.js +1044 -1043
- package/Source/Core/Cartesian4.js +816 -813
- package/Source/Core/GoogleMaps.js +23 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/OpenCageGeocoderService.js +2 -3
- package/Source/Core/globalTypes.js +16 -0
- package/Source/Renderer/ShaderDestination.js +54 -13
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +7 -4
- package/Source/Scene/BillboardCollection.js +64 -25
- package/Source/Scene/BufferLoader.js +65 -74
- package/Source/Scene/CubeMapPanorama.js +351 -0
- package/Source/Scene/DerivedCommand.js +8 -31
- package/Source/Scene/DracoLoader.js +79 -78
- package/Source/Scene/EquirectangularPanorama.js +264 -0
- package/Source/Scene/FrameState.js +7 -0
- package/Source/Scene/GaussianSplatPrimitive.js +906 -167
- package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
- package/Source/Scene/GltfBufferViewLoader.js +109 -118
- package/Source/Scene/GltfDracoLoader.js +167 -176
- package/Source/Scene/GltfImageLoader.js +91 -101
- package/Source/Scene/GltfIndexBufferLoader.js +228 -241
- package/Source/Scene/GltfJsonLoader.js +90 -99
- package/Source/Scene/GltfLoader.js +313 -324
- package/Source/Scene/GltfSpzLoader.js +127 -134
- package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
- package/Source/Scene/GltfTextureLoader.js +217 -231
- package/Source/Scene/GltfVertexBufferLoader.js +267 -276
- package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
- package/Source/Scene/Label.js +6 -4
- package/Source/Scene/LabelCollection.js +59 -1
- package/Source/Scene/MetadataClassProperty.js +212 -7
- package/Source/Scene/MetadataComponentType.js +162 -127
- package/Source/Scene/MetadataSchemaLoader.js +60 -67
- package/Source/Scene/MetadataTable.js +14 -0
- package/Source/Scene/MetadataTableProperty.js +14 -0
- package/Source/Scene/Model/B3dmLoader.js +216 -224
- package/Source/Scene/Model/CustomShader.js +6 -1
- package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
- package/Source/Scene/Model/GeoJsonLoader.js +53 -61
- package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
- package/Source/Scene/Model/I3dmLoader.js +232 -240
- package/Source/Scene/Model/MaterialPipelineStage.js +1 -1
- package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
- package/Source/Scene/Model/PntsLoader.js +78 -89
- package/Source/Scene/Panorama.js +53 -0
- package/Source/Scene/PanoramaProvider.js +43 -0
- package/Source/Scene/PointPrimitiveCollection.js +14 -22
- package/Source/Scene/PropertyTable.js +43 -0
- package/Source/Scene/PropertyTexture.js +1 -1
- package/Source/Scene/PropertyTextureProperty.js +0 -97
- package/Source/Scene/ResourceLoader.js +84 -92
- package/Source/Scene/Scene.js +12 -0
- package/Source/Scene/SkyBox.js +29 -164
- package/Source/Scene/StructuralMetadata.js +18 -3
- package/Source/Scene/parseStructuralMetadata.js +244 -0
- package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
- package/Source/Shaders/BillboardCollectionFS.js +67 -40
- package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
- package/Source/Shaders/BillboardCollectionVS.js +22 -31
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
- package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
- package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
- package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageFS.js +2 -1
- package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageVS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +2 -2
- package/Source/Shaders/Model/ModelFS.js +2 -2
- package/Source/Shaders/Model/ModelVS.glsl +2 -2
- package/Source/Shaders/Model/ModelVS.js +2 -2
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
- package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
- package/index.d.ts +564 -189
- package/index.js +127 -119
- package/package.json +1 -1
- package/Build/Workers/chunk-LYBNPUEI.js +0 -1443
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Matrix3 from "../../Core/Matrix3.js";
|
|
2
|
+
import PrimitiveType from "../../Core/PrimitiveType.js";
|
|
2
3
|
import defined from "../../Core/defined.js";
|
|
4
|
+
import oneTimeWarning from "../../Core/oneTimeWarning.js";
|
|
3
5
|
import ShaderDestination from "../../Renderer/ShaderDestination.js";
|
|
4
6
|
import MetadataStageFS from "../../Shaders/Model/MetadataStageFS.js";
|
|
5
7
|
import MetadataStageVS from "../../Shaders/Model/MetadataStageVS.js";
|
|
@@ -34,7 +36,7 @@ const MetadataPipelineStage = {
|
|
|
34
36
|
FUNCTION_ID_INITIALIZE_METADATA_VS: "initializeMetadataVS",
|
|
35
37
|
FUNCTION_ID_INITIALIZE_METADATA_FS: "initializeMetadataFS",
|
|
36
38
|
FUNCTION_SIGNATURE_INITIALIZE_METADATA:
|
|
37
|
-
"void initializeMetadata(out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes)",
|
|
39
|
+
"void initializeMetadata(FeatureIds featureIds, out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes)",
|
|
38
40
|
FUNCTION_ID_SET_METADATA_VARYINGS: "setMetadataVaryings",
|
|
39
41
|
FUNCTION_SIGNATURE_SET_METADATA_VARYINGS: "void setMetadataVaryings()",
|
|
40
42
|
|
|
@@ -85,6 +87,11 @@ MetadataPipelineStage.process = function (
|
|
|
85
87
|
const { shaderBuilder, model } = renderResources;
|
|
86
88
|
const { structuralMetadata = {}, content } = model;
|
|
87
89
|
const statistics = content?.tileset.metadataExtension?.statistics;
|
|
90
|
+
const webgl2 = frameState.context.webgl2;
|
|
91
|
+
const usedMetadataProperties = collectMetadataUsedByOtherStages(
|
|
92
|
+
model,
|
|
93
|
+
primitive,
|
|
94
|
+
);
|
|
88
95
|
|
|
89
96
|
const propertyAttributesInfo = getPropertyAttributesInfo(
|
|
90
97
|
structuralMetadata.propertyAttributes,
|
|
@@ -95,9 +102,18 @@ MetadataPipelineStage.process = function (
|
|
|
95
102
|
structuralMetadata.propertyTextures,
|
|
96
103
|
statistics,
|
|
97
104
|
);
|
|
105
|
+
const propertyTablesInfo = getPropertyTablesInfo(
|
|
106
|
+
structuralMetadata.propertyTables,
|
|
107
|
+
primitive,
|
|
108
|
+
renderResources,
|
|
109
|
+
statistics,
|
|
110
|
+
usedMetadataProperties,
|
|
111
|
+
);
|
|
98
112
|
|
|
99
113
|
// Declare <type>MetadataClass and <type>MetadataStatistics structs as needed
|
|
100
|
-
const allPropertyInfos = propertyAttributesInfo
|
|
114
|
+
const allPropertyInfos = propertyAttributesInfo
|
|
115
|
+
.concat(propertyTexturesInfo)
|
|
116
|
+
.concat(propertyTablesInfo);
|
|
101
117
|
declareMetadataTypeStructs(shaderBuilder, allPropertyInfos);
|
|
102
118
|
|
|
103
119
|
// Always declare the Metadata, MetadataClass, and MetadataStatistics structs
|
|
@@ -112,7 +128,11 @@ MetadataPipelineStage.process = function (
|
|
|
112
128
|
}
|
|
113
129
|
for (let i = 0; i < propertyTexturesInfo.length; i++) {
|
|
114
130
|
const info = propertyTexturesInfo[i];
|
|
115
|
-
processPropertyTextureProperty(renderResources, info);
|
|
131
|
+
processPropertyTextureProperty(renderResources, info, webgl2);
|
|
132
|
+
}
|
|
133
|
+
for (let i = 0; i < propertyTablesInfo.length; i++) {
|
|
134
|
+
const info = propertyTablesInfo[i];
|
|
135
|
+
processPropertyTableProperty(renderResources, info, webgl2);
|
|
116
136
|
}
|
|
117
137
|
};
|
|
118
138
|
|
|
@@ -122,6 +142,7 @@ MetadataPipelineStage.process = function (
|
|
|
122
142
|
* @param {PropertyAttribute[]} propertyAttributes The PropertyAttributes with properties to be described
|
|
123
143
|
* @param {ModelComponents.Primitive} primitive The primitive to be rendered
|
|
124
144
|
* @param {object} [statistics] Statistics about the properties (if the model is from a 3DTiles tileset)
|
|
145
|
+
* @param {object} usedMetadataProperties Metadata properties used in the primitive's shader by other stages
|
|
125
146
|
* @returns {object[]} An array of objects containing information about each PropertyAttributeProperty
|
|
126
147
|
* @private
|
|
127
148
|
*/
|
|
@@ -160,6 +181,7 @@ function getPropertyAttributeInfo(propertyAttribute, primitive, statistics) {
|
|
|
160
181
|
infoArray[i] = {
|
|
161
182
|
metadataVariable: sanitizeGlslIdentifier(propertyId),
|
|
162
183
|
property,
|
|
184
|
+
classProperty: property.classProperty,
|
|
163
185
|
type: property.classProperty.type,
|
|
164
186
|
glslType,
|
|
165
187
|
variableName,
|
|
@@ -202,7 +224,10 @@ function getPropertyTextureInfo(propertyTexture, statistics) {
|
|
|
202
224
|
const classStatistics = statistics?.classes[classId];
|
|
203
225
|
|
|
204
226
|
const propertiesArray = Object.entries(propertyTexture.properties).filter(
|
|
205
|
-
([id, property]) =>
|
|
227
|
+
([id, property]) => {
|
|
228
|
+
const numChannels = property.textureReader.channels.length;
|
|
229
|
+
return property.classProperty.isGpuCompatible(numChannels);
|
|
230
|
+
},
|
|
206
231
|
);
|
|
207
232
|
const infoArray = new Array(propertiesArray.length);
|
|
208
233
|
|
|
@@ -212,8 +237,9 @@ function getPropertyTextureInfo(propertyTexture, statistics) {
|
|
|
212
237
|
infoArray[i] = {
|
|
213
238
|
metadataVariable: sanitizeGlslIdentifier(propertyId),
|
|
214
239
|
property,
|
|
240
|
+
classProperty: property.classProperty,
|
|
215
241
|
type: property.classProperty.type,
|
|
216
|
-
glslType: property.getGlslType(),
|
|
242
|
+
glslType: property.classProperty.getGlslType(),
|
|
217
243
|
propertyStatistics: classStatistics?.properties[propertyId],
|
|
218
244
|
shaderDestination: ShaderDestination.FRAGMENT,
|
|
219
245
|
};
|
|
@@ -222,10 +248,177 @@ function getPropertyTextureInfo(propertyTexture, statistics) {
|
|
|
222
248
|
return infoArray;
|
|
223
249
|
}
|
|
224
250
|
|
|
251
|
+
const NUM_CHANNELS = 4; // use all channels for property table textures
|
|
252
|
+
|
|
253
|
+
function getPropertyTablesInfo(
|
|
254
|
+
propertyTables,
|
|
255
|
+
primitive,
|
|
256
|
+
renderResources,
|
|
257
|
+
statistics,
|
|
258
|
+
usedMetadataProperties,
|
|
259
|
+
) {
|
|
260
|
+
if (!defined(propertyTables)) {
|
|
261
|
+
return [];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Each feature ID set can reference a property table.
|
|
265
|
+
// For a given primitive, as we have here, the mapping is 1:1.
|
|
266
|
+
// (This isn't strictly enforced in the EXT_mesh_features schema, but would be considered ill-formed and ambiguous.
|
|
267
|
+
// There _is_ a way to specify which featureID set to use for picking and styling in the Cesium3DTileset API, which we may want to respect here in the future).
|
|
268
|
+
const tableToFeatureSetInfo = mapPropertyTablesToFeatureIdSets(
|
|
269
|
+
renderResources,
|
|
270
|
+
primitive,
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
return propertyTables
|
|
274
|
+
.filter(
|
|
275
|
+
(propertyTable) =>
|
|
276
|
+
defined(propertyTable.class) &&
|
|
277
|
+
tableToFeatureSetInfo.has(String(propertyTable.id)),
|
|
278
|
+
)
|
|
279
|
+
.flatMap((propertyTable) =>
|
|
280
|
+
getPropertyTableInfo(
|
|
281
|
+
propertyTable,
|
|
282
|
+
tableToFeatureSetInfo,
|
|
283
|
+
statistics,
|
|
284
|
+
usedMetadataProperties,
|
|
285
|
+
),
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function getPropertyTableInfo(
|
|
290
|
+
propertyTable,
|
|
291
|
+
tableToFeatureSetInfo,
|
|
292
|
+
statistics,
|
|
293
|
+
usedMetadataProperties,
|
|
294
|
+
) {
|
|
295
|
+
const { sanitizeGlslIdentifier } = ModelUtility;
|
|
296
|
+
|
|
297
|
+
const classDefinition = propertyTable.class;
|
|
298
|
+
const classStatistics = statistics?.classes[classDefinition.id];
|
|
299
|
+
const featureSetInfo =
|
|
300
|
+
tableToFeatureSetInfo.get(String(propertyTable.id)) ?? {};
|
|
301
|
+
|
|
302
|
+
// Depending on whether the featureIDs are a feature texture or feature attribute,
|
|
303
|
+
// the shader usage may be restricted to a given shader stage.
|
|
304
|
+
const shaderDestination =
|
|
305
|
+
featureSetInfo.shaderDestination ?? ShaderDestination.BOTH;
|
|
306
|
+
|
|
307
|
+
const properties = propertyTable.properties;
|
|
308
|
+
const classProperties = classDefinition.properties;
|
|
309
|
+
const infoArray = [];
|
|
310
|
+
|
|
311
|
+
// This is the per-table index of the property info, which is used to index into the property table texture
|
|
312
|
+
// during a texelFetch.
|
|
313
|
+
let propertyInfoIndex = 0;
|
|
314
|
+
|
|
315
|
+
// See note in {@link parseStructuralMetadata.collectGpuCompatiblePropertyBufferViews} about
|
|
316
|
+
// why we iterate over the class definition properties rather than the property table properties.
|
|
317
|
+
for (const [propertyId, classProperty] of Object.entries(classProperties)) {
|
|
318
|
+
if (!classProperty.isGpuCompatible(NUM_CHANNELS)) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// For performance reasons, since property tables can be quite large, only include properties that are used by other pipeline stages in the shader.
|
|
323
|
+
// Note: we could do this for property textures and attributes as well - but since users can call the `pickMetadata`
|
|
324
|
+
// API with an arbitrary metadata property, we'd need to rebuild every model's shaders each time such a call is made. Since property textures
|
|
325
|
+
// and attributes tend to be less numerous than property tables anyway, it's more important to optimize table usage in this way.
|
|
326
|
+
const property = properties[propertyId];
|
|
327
|
+
const propertyShaderDestination = ShaderDestination.intersection(
|
|
328
|
+
propertyDestination(propertyId, usedMetadataProperties),
|
|
329
|
+
shaderDestination,
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
if (propertyShaderDestination === ShaderDestination.NONE) {
|
|
333
|
+
// Still need to increment the index to stay aligned with the rows of the metadata texture.
|
|
334
|
+
// The texture includes metadata whether or not it's used in the shader.
|
|
335
|
+
propertyInfoIndex++;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
infoArray.push({
|
|
340
|
+
metadataVariable: sanitizeGlslIdentifier(propertyId),
|
|
341
|
+
property: property,
|
|
342
|
+
classProperty: classProperty,
|
|
343
|
+
type: classProperty.type,
|
|
344
|
+
glslType: classProperty.getGlslType(),
|
|
345
|
+
propertyStatistics: classStatistics?.properties[propertyId],
|
|
346
|
+
shaderDestination: propertyShaderDestination,
|
|
347
|
+
propertyTable: propertyTable,
|
|
348
|
+
featureIdVariableName: featureSetInfo.variableName,
|
|
349
|
+
propertyInfoIndex: propertyInfoIndex,
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
propertyInfoIndex++;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return infoArray;
|
|
356
|
+
}
|
|
357
|
+
|
|
225
358
|
/**
|
|
226
|
-
*
|
|
359
|
+
* Map property tables to feature ID sets for a given primitive. In general, the mapping is not 1:1, but
|
|
360
|
+
* within a given primitive it is safe to treat it as such.
|
|
361
|
+
*
|
|
362
|
+
* @param {PrimitiveRenderResources} renderResources
|
|
363
|
+
* @param {ModelComponents.Primitive} primitive
|
|
364
|
+
* @returns A map from property table ID to an object with the corresponding feature ID set information
|
|
365
|
+
* for the given primitive. (Contains the shader variable name and shader destination.)
|
|
366
|
+
*
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
function mapPropertyTablesToFeatureIdSets(renderResources, primitive) {
|
|
370
|
+
const propertyTableToFeatureSet = new Map();
|
|
371
|
+
|
|
372
|
+
function addMapEntry(featureIds, shaderDestination) {
|
|
373
|
+
const propertyTableId = featureIds?.propertyTableId;
|
|
374
|
+
if (!defined(propertyTableId)) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const key = String(propertyTableId);
|
|
379
|
+
const entry = {
|
|
380
|
+
// This is consistent with the variable name given in the feature ID pipeline stage.
|
|
381
|
+
// Aliases can also be used, but this will always be valid.
|
|
382
|
+
variableName: featureIds.positionalLabel,
|
|
383
|
+
shaderDestination: shaderDestination,
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const existingEntry = propertyTableToFeatureSet.get(key);
|
|
387
|
+
if (defined(existingEntry)) {
|
|
388
|
+
console.warn(
|
|
389
|
+
`Multiple feature ID sets reference the same property table ${propertyTableId} in primitive. Only one will be used.`,
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
propertyTableToFeatureSet.set(key, entry);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Collect feature IDs from two sources: the primitive, and instances
|
|
396
|
+
const primitiveFeatureIds = primitive?.featureIds ?? [];
|
|
397
|
+
for (let i = 0; i < primitiveFeatureIds.length; i++) {
|
|
398
|
+
const featureIds = primitiveFeatureIds[i];
|
|
399
|
+
// Textures feature sets are fragment-only
|
|
400
|
+
const isTexture = defined(featureIds?.textureReader);
|
|
401
|
+
addMapEntry(
|
|
402
|
+
featureIds,
|
|
403
|
+
isTexture ? ShaderDestination.FRAGMENT : ShaderDestination.BOTH,
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Instance feature IDs (if present)
|
|
408
|
+
const instances = renderResources.runtimeNode?.node?.instances;
|
|
409
|
+
const instanceFeatureIds = instances?.featureIds ?? [];
|
|
410
|
+
for (let i = 0; i < instanceFeatureIds.length; i++) {
|
|
411
|
+
const featureIds = instanceFeatureIds[i];
|
|
412
|
+
addMapEntry(featureIds, ShaderDestination.BOTH);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return propertyTableToFeatureSet;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Declare <type>MetadataClass structs in the shader for each PropertyAttributeProperty, PropertyTextureProperty, and MetadataTableProperty
|
|
227
420
|
* @param {ShaderBuilder} shaderBuilder The shader builder for the primitive
|
|
228
|
-
* @param {object[]} propertyInfos Information about the PropertyAttributeProperties and
|
|
421
|
+
* @param {object[]} propertyInfos Information about the PropertyAttributeProperties, PropertyTextureProperties, and PropertyTableProperties
|
|
229
422
|
* @private
|
|
230
423
|
*/
|
|
231
424
|
function declareMetadataTypeStructs(shaderBuilder, propertyInfos) {
|
|
@@ -409,10 +602,11 @@ function addPropertyAttributePropertyMetadata(renderResources, propertyInfo) {
|
|
|
409
602
|
* Update the shader for a single PropertyTextureProperty
|
|
410
603
|
* @param {PrimitiveRenderResources} renderResources The render resources for the primitive
|
|
411
604
|
* @param {object[]} propertyInfo Info about the PropertyTextureProperty
|
|
605
|
+
* @param {boolean} webgl2 True if the context is WebGL2
|
|
412
606
|
* @private
|
|
413
607
|
*/
|
|
414
|
-
function processPropertyTextureProperty(renderResources, propertyInfo) {
|
|
415
|
-
addPropertyTexturePropertyMetadata(renderResources, propertyInfo);
|
|
608
|
+
function processPropertyTextureProperty(renderResources, propertyInfo, webgl2) {
|
|
609
|
+
addPropertyTexturePropertyMetadata(renderResources, propertyInfo, webgl2);
|
|
416
610
|
addPropertyMetadataClass(renderResources.shaderBuilder, propertyInfo);
|
|
417
611
|
addPropertyMetadataStatistics(renderResources.shaderBuilder, propertyInfo);
|
|
418
612
|
}
|
|
@@ -422,15 +616,21 @@ function processPropertyTextureProperty(renderResources, propertyInfo) {
|
|
|
422
616
|
* initializeMetadata function, for a PropertyTextureProperty
|
|
423
617
|
* @param {PrimitiveRenderResources} renderResources The render resources for the primitive
|
|
424
618
|
* @param {object} propertyInfo Info about the PropertyTextureProperty
|
|
619
|
+
* @param {boolean} webgl2 True if the context is WebGL2
|
|
425
620
|
* @private
|
|
426
621
|
*/
|
|
427
|
-
function addPropertyTexturePropertyMetadata(
|
|
622
|
+
function addPropertyTexturePropertyMetadata(
|
|
623
|
+
renderResources,
|
|
624
|
+
propertyInfo,
|
|
625
|
+
webgl2,
|
|
626
|
+
) {
|
|
428
627
|
const { shaderBuilder, uniformMap } = renderResources;
|
|
429
628
|
const { metadataVariable, glslType, property } = propertyInfo;
|
|
430
629
|
|
|
431
630
|
const { texCoord, channels, index, texture, transform } =
|
|
432
631
|
property.textureReader;
|
|
433
632
|
const textureUniformName = `u_propertyTexture_${index}`;
|
|
633
|
+
const initializationLines = [];
|
|
434
634
|
|
|
435
635
|
// Property texture properties may share the same physical texture, so only
|
|
436
636
|
// add the texture uniform the first time we encounter it.
|
|
@@ -473,11 +673,18 @@ function addPropertyTexturePropertyMetadata(renderResources, propertyInfo) {
|
|
|
473
673
|
texCoordVariableExpression = `vec2(${transformUniformName} * vec3(${texCoordVariable}, 1.0))`;
|
|
474
674
|
}
|
|
475
675
|
const valueExpression = `texture(${textureUniformName}, ${texCoordVariableExpression}).${channels}`;
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
676
|
+
const classProperty = property.classProperty;
|
|
677
|
+
let unpackedValue;
|
|
678
|
+
if (webgl2) {
|
|
679
|
+
unpackedValue = classProperty.unpackTextureInShader(
|
|
680
|
+
valueExpression,
|
|
681
|
+
channels,
|
|
682
|
+
metadataVariable,
|
|
683
|
+
initializationLines,
|
|
684
|
+
);
|
|
685
|
+
} else {
|
|
686
|
+
unpackedValue = classProperty.unpackTextureInShaderWebGL1(valueExpression);
|
|
687
|
+
}
|
|
481
688
|
|
|
482
689
|
const transformedValue = addValueTransformUniforms({
|
|
483
690
|
valueExpression: unpackedValue,
|
|
@@ -488,23 +695,24 @@ function addPropertyTexturePropertyMetadata(renderResources, propertyInfo) {
|
|
|
488
695
|
property: property,
|
|
489
696
|
});
|
|
490
697
|
|
|
491
|
-
const
|
|
698
|
+
const finalAssignment = `metadata.${metadataVariable} = ${transformedValue};`;
|
|
699
|
+
initializationLines.push(finalAssignment);
|
|
492
700
|
shaderBuilder.addFunctionLines(
|
|
493
701
|
MetadataPipelineStage.FUNCTION_ID_INITIALIZE_METADATA_FS,
|
|
494
|
-
|
|
702
|
+
initializationLines,
|
|
495
703
|
);
|
|
496
704
|
}
|
|
497
705
|
|
|
498
706
|
/**
|
|
499
707
|
* Add fields to the MetadataClass struct, and metadataClass value expressions
|
|
500
|
-
* to the initializeMetadata function, for a PropertyAttributeProperty
|
|
501
|
-
* PropertyTextureProperty
|
|
708
|
+
* to the initializeMetadata function, for a PropertyAttributeProperty,
|
|
709
|
+
* PropertyTextureProperty, or MetadataTableProperty
|
|
502
710
|
* @param {ShaderBuilder} shaderBuilder The shader builder for the primitive
|
|
503
|
-
* @param {object} propertyInfo Info about the PropertyAttributeProperty or
|
|
711
|
+
* @param {object} propertyInfo Info about the PropertyAttributeProperty, PropertyTextureProperty, or MetadataTableProperty
|
|
504
712
|
* @private
|
|
505
713
|
*/
|
|
506
714
|
function addPropertyMetadataClass(shaderBuilder, propertyInfo) {
|
|
507
|
-
const
|
|
715
|
+
const classProperty = propertyInfo.classProperty;
|
|
508
716
|
const { metadataVariable, glslType, shaderDestination } = propertyInfo;
|
|
509
717
|
|
|
510
718
|
// Construct assignment statements to set values in the metadataClass struct
|
|
@@ -594,6 +802,113 @@ function addPropertyMetadataStatistics(shaderBuilder, propertyInfo) {
|
|
|
594
802
|
);
|
|
595
803
|
}
|
|
596
804
|
|
|
805
|
+
function processPropertyTableProperty(renderResources, propertyInfo, webgl2) {
|
|
806
|
+
addPropertyTablePropertyMetadata(renderResources, propertyInfo, webgl2);
|
|
807
|
+
addPropertyMetadataClass(renderResources.shaderBuilder, propertyInfo);
|
|
808
|
+
addPropertyMetadataStatistics(renderResources.shaderBuilder, propertyInfo);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function addPropertyTablePropertyMetadata(
|
|
812
|
+
renderResources,
|
|
813
|
+
propertyInfo,
|
|
814
|
+
webgl2,
|
|
815
|
+
) {
|
|
816
|
+
const { shaderBuilder, uniformMap } = renderResources;
|
|
817
|
+
const {
|
|
818
|
+
metadataVariable,
|
|
819
|
+
glslType,
|
|
820
|
+
property,
|
|
821
|
+
featureIdVariableName,
|
|
822
|
+
propertyTable,
|
|
823
|
+
propertyInfoIndex,
|
|
824
|
+
} = propertyInfo;
|
|
825
|
+
|
|
826
|
+
if (!webgl2) {
|
|
827
|
+
oneTimeWarning(
|
|
828
|
+
"PropertyTableCustomShader",
|
|
829
|
+
"Property table support for custom shaders requires WebGL2.",
|
|
830
|
+
);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
if (!defined(featureIdVariableName) || !defined(propertyTable.texture)) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// For property tables, all properties are packed into a single texture.
|
|
839
|
+
// Thus, the texture identifier is based on the table id.
|
|
840
|
+
const textureUniformName = `u_propertyTableTexture_${propertyTable.id}`;
|
|
841
|
+
const initializationLines = [];
|
|
842
|
+
|
|
843
|
+
if (!uniformMap.hasOwnProperty(textureUniformName)) {
|
|
844
|
+
// Note that, unlike property textures, property table textures are available in both
|
|
845
|
+
// the vertex and fragment shaders. While property textures rely on interpolated UV coords,
|
|
846
|
+
// property table textures generally apply to non-interpolated texel fetches based on (featureId, propertyId).
|
|
847
|
+
shaderBuilder.addUniform(
|
|
848
|
+
"sampler2D",
|
|
849
|
+
textureUniformName,
|
|
850
|
+
ShaderDestination.BOTH,
|
|
851
|
+
);
|
|
852
|
+
uniformMap[textureUniformName] = () => propertyTable.texture;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
const shaderDestination = propertyInfo.shaderDestination;
|
|
856
|
+
if (ShaderDestination.includesVertexShader(shaderDestination)) {
|
|
857
|
+
shaderBuilder.addStructField(
|
|
858
|
+
MetadataPipelineStage.STRUCT_ID_METADATA_VS,
|
|
859
|
+
glslType,
|
|
860
|
+
metadataVariable,
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (ShaderDestination.includesFragmentShader(shaderDestination)) {
|
|
865
|
+
shaderBuilder.addStructField(
|
|
866
|
+
MetadataPipelineStage.STRUCT_ID_METADATA_FS,
|
|
867
|
+
glslType,
|
|
868
|
+
metadataVariable,
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
const featureIdExpression = `featureIds.${featureIdVariableName}`;
|
|
873
|
+
const texCoordExpression = `ivec2(${featureIdExpression}, ${propertyInfoIndex})`;
|
|
874
|
+
const textureSampleExpression = `texelFetch(${textureUniformName}, ${texCoordExpression}, 0)`;
|
|
875
|
+
const classProperty = propertyInfo.classProperty;
|
|
876
|
+
|
|
877
|
+
const unpackedVariable = classProperty.unpackTextureInShader(
|
|
878
|
+
textureSampleExpression,
|
|
879
|
+
`rgba`,
|
|
880
|
+
metadataVariable,
|
|
881
|
+
initializationLines,
|
|
882
|
+
);
|
|
883
|
+
|
|
884
|
+
const transformedValue = addValueTransformUniforms({
|
|
885
|
+
valueExpression: unpackedVariable,
|
|
886
|
+
renderResources: renderResources,
|
|
887
|
+
glslType: glslType,
|
|
888
|
+
metadataVariable: metadataVariable,
|
|
889
|
+
shaderDestination: shaderDestination,
|
|
890
|
+
// If the property is on the schema but not used by this primitive, value transforms come from class schema property
|
|
891
|
+
property: property ?? classProperty,
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
const finalAssignment = `metadata.${metadataVariable} = ${transformedValue};`;
|
|
895
|
+
initializationLines.push(finalAssignment);
|
|
896
|
+
|
|
897
|
+
if (ShaderDestination.includesVertexShader(shaderDestination)) {
|
|
898
|
+
shaderBuilder.addFunctionLines(
|
|
899
|
+
MetadataPipelineStage.FUNCTION_ID_INITIALIZE_METADATA_VS,
|
|
900
|
+
initializationLines,
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if (ShaderDestination.includesFragmentShader(shaderDestination)) {
|
|
905
|
+
shaderBuilder.addFunctionLines(
|
|
906
|
+
MetadataPipelineStage.FUNCTION_ID_INITIALIZE_METADATA_FS,
|
|
907
|
+
initializationLines,
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
597
912
|
/**
|
|
598
913
|
* Construct GLSL assignment statements to set metadata spec values in a struct
|
|
599
914
|
* @param {object[]} fieldNames An object with the following properties:
|
|
@@ -609,6 +924,8 @@ function getStructAssignments(fieldNames, values, struct, type) {
|
|
|
609
924
|
function constructAssignment(field) {
|
|
610
925
|
const value = values[field.specName];
|
|
611
926
|
if (defined(value)) {
|
|
927
|
+
// Note: template literals will coerce arrays to strings, if needed (e.g. if the metadata type is a vecN or an array, or even an array of vecN)
|
|
928
|
+
// In any case, the resulting string ends up as a flattened, comma-separated list. For example: [[1,2], [3,4]] will end up as vec4(1,2,3,4), which is valid GLSL.
|
|
612
929
|
return `${struct}.${field.shaderName} = ${type}(${value});`;
|
|
613
930
|
}
|
|
614
931
|
}
|
|
@@ -627,7 +944,7 @@ function getStructAssignments(fieldNames, values, struct, type) {
|
|
|
627
944
|
* @param {string} options.glslType The GLSL type of the variable
|
|
628
945
|
* @param {ShaderDestination} options.shaderDestination Which shader(s) use this variable
|
|
629
946
|
* @param {PrimitiveRenderResources} options.renderResources The render resources for this primitive
|
|
630
|
-
* @param {(PropertyAttributeProperty|PropertyTextureProperty)} options.property The property from which the value is derived
|
|
947
|
+
* @param {(PropertyAttributeProperty|PropertyTextureProperty|MetadataTableProperty|MetadataClassProperty)} options.property The property from which the value is derived
|
|
631
948
|
* @returns {string} A wrapped GLSL value expression
|
|
632
949
|
* @private
|
|
633
950
|
*/
|
|
@@ -647,6 +964,8 @@ function addValueTransformUniforms(options) {
|
|
|
647
964
|
shaderBuilder.addUniform(glslType, offsetUniformName, shaderDestination);
|
|
648
965
|
shaderBuilder.addUniform(glslType, scaleUniformName, shaderDestination);
|
|
649
966
|
|
|
967
|
+
// Note: if property is an instance of MetadataClassProperty, offset and scale will be the default values set on the class definition.
|
|
968
|
+
// Otherwise, the spec allows them to be overridden per-property instance.
|
|
650
969
|
const { offset, scale } = property;
|
|
651
970
|
uniformMap[offsetUniformName] = () => offset;
|
|
652
971
|
uniformMap[scaleUniformName] = () => scale;
|
|
@@ -654,4 +973,101 @@ function addValueTransformUniforms(options) {
|
|
|
654
973
|
return `czm_valueTransform(${offsetUniformName}, ${scaleUniformName}, ${valueExpression})`;
|
|
655
974
|
}
|
|
656
975
|
|
|
976
|
+
function collectMetadataUsedByOtherStages(model, primitive) {
|
|
977
|
+
const usedInVertex = new Set();
|
|
978
|
+
const usedInFragment = new Set();
|
|
979
|
+
|
|
980
|
+
collectMetadataUsedInCustomShader(model, usedInVertex, usedInFragment);
|
|
981
|
+
collectMetadataUsedInPointCloudStyling(
|
|
982
|
+
model,
|
|
983
|
+
primitive,
|
|
984
|
+
usedInVertex,
|
|
985
|
+
usedInFragment,
|
|
986
|
+
);
|
|
987
|
+
|
|
988
|
+
return {
|
|
989
|
+
usedInVertex,
|
|
990
|
+
usedInFragment,
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function collectMetadataUsedInCustomShader(
|
|
995
|
+
model,
|
|
996
|
+
usedInVertex,
|
|
997
|
+
usedInFragment,
|
|
998
|
+
) {
|
|
999
|
+
const customShader = model.customShader;
|
|
1000
|
+
if (!defined(customShader)) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
const fragmentMetadataSet =
|
|
1005
|
+
customShader.usedVariablesFragment?.metadataSet ?? {};
|
|
1006
|
+
for (const propertyId in fragmentMetadataSet) {
|
|
1007
|
+
if (fragmentMetadataSet.hasOwnProperty(propertyId)) {
|
|
1008
|
+
usedInFragment.add(propertyId);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
const vertexMetadataSet = customShader.usedVariablesVertex?.metadataSet ?? {};
|
|
1013
|
+
for (const propertyId in vertexMetadataSet) {
|
|
1014
|
+
if (vertexMetadataSet.hasOwnProperty(propertyId)) {
|
|
1015
|
+
usedInVertex.add(propertyId);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function collectMetadataUsedInPointCloudStyling(
|
|
1021
|
+
model,
|
|
1022
|
+
primitive,
|
|
1023
|
+
usedInVertex,
|
|
1024
|
+
usedInFragment,
|
|
1025
|
+
) {
|
|
1026
|
+
const style = model.style;
|
|
1027
|
+
const hasPointCloudStyle =
|
|
1028
|
+
defined(style) && primitive.primitiveType === PrimitiveType.POINTS;
|
|
1029
|
+
if (!hasPointCloudStyle) {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
const colorVariables = style.color?.getVariables() ?? [];
|
|
1034
|
+
for (const propertyId of colorVariables) {
|
|
1035
|
+
usedInVertex.add(propertyId);
|
|
1036
|
+
usedInFragment.add(propertyId);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
const showVariables = style.show?.getVariables() ?? [];
|
|
1040
|
+
for (const propertyId of showVariables) {
|
|
1041
|
+
usedInVertex.add(propertyId);
|
|
1042
|
+
usedInFragment.add(propertyId);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// Only used in vertex shader
|
|
1046
|
+
const pointSizeVariables = style.pointSize?.getVariables() ?? [];
|
|
1047
|
+
for (const propertyId of pointSizeVariables) {
|
|
1048
|
+
usedInVertex.add(propertyId);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Determines the shader destination(s) for a given property based on its use in other pipeline stages.
|
|
1054
|
+
*
|
|
1055
|
+
* @param {object} propertyId The ID of the property to check
|
|
1056
|
+
* @param {object} usedMetadataProperties Metadata properties used in the primitive's shader by other stages
|
|
1057
|
+
* @returns {ShaderDestination} The shader destination(s) for the property
|
|
1058
|
+
* @private
|
|
1059
|
+
*/
|
|
1060
|
+
function propertyDestination(propertyId, usedMetadataProperties) {
|
|
1061
|
+
const fragmentDestination = usedMetadataProperties.usedInFragment.has(
|
|
1062
|
+
propertyId,
|
|
1063
|
+
)
|
|
1064
|
+
? ShaderDestination.FRAGMENT
|
|
1065
|
+
: ShaderDestination.NONE;
|
|
1066
|
+
const vertexDestination = usedMetadataProperties.usedInVertex.has(propertyId)
|
|
1067
|
+
? ShaderDestination.VERTEX
|
|
1068
|
+
: ShaderDestination.NONE;
|
|
1069
|
+
|
|
1070
|
+
return ShaderDestination.union(fragmentDestination, vertexDestination);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
657
1073
|
export default MetadataPipelineStage;
|