@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
|
@@ -10,7 +10,9 @@ import Matrix2 from "../Core/Matrix2.js";
|
|
|
10
10
|
import Matrix3 from "../Core/Matrix3.js";
|
|
11
11
|
import Matrix4 from "../Core/Matrix4.js";
|
|
12
12
|
import MetadataType from "./MetadataType.js";
|
|
13
|
-
import MetadataComponentType
|
|
13
|
+
import MetadataComponentType, {
|
|
14
|
+
ScalarCategories,
|
|
15
|
+
} from "./MetadataComponentType.js";
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* A metadata property, as part of a {@link MetadataClass}.
|
|
@@ -31,8 +33,8 @@ import MetadataComponentType from "./MetadataComponentType.js";
|
|
|
31
33
|
* @param {number|number[]|number[][]} [options.max] A number or an array of numbers storing the maximum allowable value of this property. Only defined when type is a numeric type.
|
|
32
34
|
* @param {number|number[]|number[][]} [options.offset] The offset to be added to property values as part of the value transform.
|
|
33
35
|
* @param {number|number[]|number[][]} [options.scale] The scale to be multiplied to property values as part of the value transform.
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
+
* @param {number|string|Array} [options.noData] The no-data sentinel value that represents null values.
|
|
37
|
+
* @param {number|string|Array} [options.default] A default value to use when an entity's property value is not defined.
|
|
36
38
|
* @param {boolean} [options.required=false] Whether the property is required.
|
|
37
39
|
* @param {string} [options.name] The name of the property.
|
|
38
40
|
* @param {string} [options.description] The description of the property.
|
|
@@ -59,8 +61,8 @@ function MetadataClassProperty(options) {
|
|
|
59
61
|
|
|
60
62
|
const normalized =
|
|
61
63
|
defined(componentType) &&
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
+
(options.normalized ?? false) &&
|
|
65
|
+
MetadataComponentType.isIntegerType(componentType);
|
|
64
66
|
|
|
65
67
|
// Basic information about this property
|
|
66
68
|
this._id = id;
|
|
@@ -369,7 +371,7 @@ Object.defineProperties(MetadataClassProperty.prototype, {
|
|
|
369
371
|
* The no-data sentinel value that represents null values
|
|
370
372
|
*
|
|
371
373
|
* @memberof MetadataClassProperty.prototype
|
|
372
|
-
* @type {
|
|
374
|
+
* @type {number|string|Array}
|
|
373
375
|
* @readonly
|
|
374
376
|
*/
|
|
375
377
|
noData: {
|
|
@@ -382,7 +384,7 @@ Object.defineProperties(MetadataClassProperty.prototype, {
|
|
|
382
384
|
* A default value to use when an entity's property value is not defined.
|
|
383
385
|
*
|
|
384
386
|
* @memberof MetadataClassProperty.prototype
|
|
385
|
-
* @type {
|
|
387
|
+
* @type {number|string|Array}
|
|
386
388
|
* @readonly
|
|
387
389
|
*/
|
|
388
390
|
default: {
|
|
@@ -1188,4 +1190,207 @@ MetadataClassProperty.valueTransformInPlace = function (
|
|
|
1188
1190
|
return values;
|
|
1189
1191
|
};
|
|
1190
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* Determines the byte size of a single property element.
|
|
1195
|
+
* For example, if the metadata type is VEC3 and the component type is FLOAT32, this would return 12 bytes.
|
|
1196
|
+
*
|
|
1197
|
+
* @returns {number} The byte size of a single property element.
|
|
1198
|
+
*
|
|
1199
|
+
* @private
|
|
1200
|
+
*/
|
|
1201
|
+
MetadataClassProperty.prototype.bytesPerElement = function () {
|
|
1202
|
+
const type = this.type;
|
|
1203
|
+
const valueType = this.valueType;
|
|
1204
|
+
const componentCount = MetadataType.getComponentCount(type);
|
|
1205
|
+
const arrayLength = this.isArray ? this.arrayLength : 1;
|
|
1206
|
+
const bytesPerComponent = MetadataComponentType.getSizeInBytes(valueType);
|
|
1207
|
+
return componentCount * arrayLength * bytesPerComponent;
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Determines whether this property can be stored in a texture, given the property's datatype and the number of
|
|
1212
|
+
* texture channels dedicated property value.
|
|
1213
|
+
*
|
|
1214
|
+
* @param {Number} channelsLength The number of texture channels to pack each property value into
|
|
1215
|
+
* @returns {boolean} true if the property can be stored in a texture with the given number of channels, false otherwise
|
|
1216
|
+
*
|
|
1217
|
+
* @private
|
|
1218
|
+
*/
|
|
1219
|
+
MetadataClassProperty.prototype.isGpuCompatible = function (channelsLength) {
|
|
1220
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1221
|
+
if (!defined(channelsLength) || channelsLength <= 0) {
|
|
1222
|
+
throw new DeveloperError("channelsLength must be a positive number.");
|
|
1223
|
+
}
|
|
1224
|
+
//>>includeEnd('debug');
|
|
1225
|
+
|
|
1226
|
+
const type = this.type;
|
|
1227
|
+
|
|
1228
|
+
if (this.isVariableLengthArray) {
|
|
1229
|
+
return false;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
if (type === MetadataType.STRING) {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// For the time being, boolean properties are not considered GPU compatible, because they are
|
|
1237
|
+
// packed as bitstreams and the texture-unpacking logic does not currently support this.
|
|
1238
|
+
if (type === MetadataType.BOOLEAN) {
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
// For all other properties, make sure the components fit in the sampled channels.
|
|
1243
|
+
// (Note that it's possible to treat 64-bit types as two 32-bit components, but for now that's not supported)
|
|
1244
|
+
const elementSizeInBytes = this.bytesPerElement();
|
|
1245
|
+
if (elementSizeInBytes > channelsLength) {
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
return true;
|
|
1250
|
+
};
|
|
1251
|
+
|
|
1252
|
+
const floatTypesByComponentCount = [undefined, "float", "vec2", "vec3", "vec4"];
|
|
1253
|
+
|
|
1254
|
+
const integerTypesByComponentCount = [
|
|
1255
|
+
undefined,
|
|
1256
|
+
"int",
|
|
1257
|
+
"ivec2",
|
|
1258
|
+
"ivec3",
|
|
1259
|
+
"ivec4",
|
|
1260
|
+
];
|
|
1261
|
+
|
|
1262
|
+
const unsignedIntegerTypesByComponentCount = [
|
|
1263
|
+
undefined,
|
|
1264
|
+
"uint",
|
|
1265
|
+
"uvec2",
|
|
1266
|
+
"uvec3",
|
|
1267
|
+
"uvec4",
|
|
1268
|
+
];
|
|
1269
|
+
|
|
1270
|
+
// Map from scalar component type to the GLSL function used to reinterpret from uint bits to the scalar type
|
|
1271
|
+
const uintBitsToScalarType = {
|
|
1272
|
+
[ScalarCategories.FLOAT]: "uintBitsToFloat",
|
|
1273
|
+
[ScalarCategories.INTEGER]: "int",
|
|
1274
|
+
[ScalarCategories.UNSIGNED_INTEGER]: "",
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
MetadataClassProperty.prototype.getGlslTypeWebGL1 = function () {
|
|
1278
|
+
let componentCount = MetadataType.getComponentCount(this.type);
|
|
1279
|
+
if (this.isArray) {
|
|
1280
|
+
// fixed-sized arrays of length 2-4 UINT8s are represented as vectors as the
|
|
1281
|
+
// shader since those are more useful in GLSL.
|
|
1282
|
+
componentCount = this.arrayLength;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// Normalized UINT8 properties are float types in the shader
|
|
1286
|
+
if (this.normalized) {
|
|
1287
|
+
return floatTypesByComponentCount[componentCount];
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
// other UINT8-based properties are represented as integer types.
|
|
1291
|
+
return integerTypesByComponentCount[componentCount];
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
MetadataClassProperty.prototype.getGlslType = function () {
|
|
1295
|
+
const valueType = this.valueType;
|
|
1296
|
+
|
|
1297
|
+
let componentCount = MetadataType.getComponentCount(this.type);
|
|
1298
|
+
const arrayLength = this.isArray ? this.arrayLength : 1;
|
|
1299
|
+
componentCount *= arrayLength;
|
|
1300
|
+
|
|
1301
|
+
// Normalized fields are integers represented as float types ([0, 1] or [-1, 1] depending if signed)
|
|
1302
|
+
if (!MetadataComponentType.isIntegerType(valueType) || this.normalized) {
|
|
1303
|
+
return floatTypesByComponentCount[componentCount];
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
if (MetadataComponentType.isUnsignedIntegerType(valueType)) {
|
|
1307
|
+
return unsignedIntegerTypesByComponentCount[componentCount];
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
return integerTypesByComponentCount[componentCount];
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
MetadataClassProperty.prototype.unpackTextureInShader = function (
|
|
1314
|
+
sampledTextureExpression,
|
|
1315
|
+
channelsString,
|
|
1316
|
+
metadataVariableName,
|
|
1317
|
+
shaderLines,
|
|
1318
|
+
) {
|
|
1319
|
+
const glslType = this.getGlslType();
|
|
1320
|
+
const valueType = this.valueType;
|
|
1321
|
+
const numChannels = channelsString.length;
|
|
1322
|
+
const type = this.type;
|
|
1323
|
+
|
|
1324
|
+
// Calculate total number of components
|
|
1325
|
+
// (e.g. a length-2 fixed-sized array of VEC2 has 4 components - isGpuCompatible checks this fits in the channels)
|
|
1326
|
+
const componentCount =
|
|
1327
|
+
MetadataType.getComponentCount(type) *
|
|
1328
|
+
(this.isArray ? this.arrayLength : 1);
|
|
1329
|
+
const channelsPerComponent = Math.floor(numChannels / componentCount);
|
|
1330
|
+
|
|
1331
|
+
const rawChannelsName = `${metadataVariableName}_rawChannels`;
|
|
1332
|
+
const rawBitsName = `${metadataVariableName}_rawBits`;
|
|
1333
|
+
const unpackedValueName = `${metadataVariableName}_unpackedValue`;
|
|
1334
|
+
|
|
1335
|
+
const declareUnpackedValueLine = `${glslType} ${unpackedValueName};`;
|
|
1336
|
+
const declareRawBitsLine = `uint ${rawBitsName};`;
|
|
1337
|
+
shaderLines.push(declareUnpackedValueLine);
|
|
1338
|
+
shaderLines.push(declareRawBitsLine);
|
|
1339
|
+
|
|
1340
|
+
// Sample all (specified) channels of the texture
|
|
1341
|
+
const assignRawValuesLine = `${floatTypesByComponentCount[numChannels]} ${rawChannelsName} = ${sampledTextureExpression};`;
|
|
1342
|
+
shaderLines.push(assignRawValuesLine);
|
|
1343
|
+
|
|
1344
|
+
const castFunction =
|
|
1345
|
+
uintBitsToScalarType[MetadataComponentType.category(valueType)];
|
|
1346
|
+
const hasMultipleComponents = componentCount > 1;
|
|
1347
|
+
|
|
1348
|
+
// Unpack each component of the output property from the raw channel values
|
|
1349
|
+
// E.g. if the output type is a vec2, and 4 channels are given, unpack x from `rg` and y from `ba`
|
|
1350
|
+
for (let i = 0; i < componentCount; i++) {
|
|
1351
|
+
const channelSlice = "rgba".slice(
|
|
1352
|
+
i * channelsPerComponent,
|
|
1353
|
+
(i + 1) * channelsPerComponent,
|
|
1354
|
+
);
|
|
1355
|
+
const subChannels = numChannels > 1 ? `.${channelSlice}` : "";
|
|
1356
|
+
const assignRawBitsLine = `${rawBitsName} = czm_unpackTexture(${rawChannelsName}${subChannels});`;
|
|
1357
|
+
|
|
1358
|
+
let indexExpression = "";
|
|
1359
|
+
if (hasMultipleComponents) {
|
|
1360
|
+
indexExpression = `[${i}]`;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
let normalize = "";
|
|
1364
|
+
let toFloatIfNormalize = "";
|
|
1365
|
+
if (this.normalized) {
|
|
1366
|
+
const maxValue = MetadataComponentType.getMaximum(valueType);
|
|
1367
|
+
normalize = ` * ${1.0 / Number(maxValue)}`;
|
|
1368
|
+
toFloatIfNormalize = "float";
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const assignUnpackedValueLine = `${unpackedValueName}${indexExpression} = ${toFloatIfNormalize}(${castFunction}(${rawBitsName}))${normalize};`;
|
|
1372
|
+
|
|
1373
|
+
shaderLines.push(assignRawBitsLine);
|
|
1374
|
+
shaderLines.push(assignUnpackedValueLine);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
return unpackedValueName;
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
// In WebGL 1, we limit property texture support to UINT8 properties.
|
|
1381
|
+
MetadataClassProperty.prototype.unpackTextureInShaderWebGL1 = function (
|
|
1382
|
+
sampledTextureExpression,
|
|
1383
|
+
) {
|
|
1384
|
+
// no unpacking needed if for normalized types
|
|
1385
|
+
if (this.normalized) {
|
|
1386
|
+
return sampledTextureExpression;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// integer types are read from the texture as normalized float values.
|
|
1390
|
+
// these need to be rescaled to [0, 255] and cast to the appropriate integer
|
|
1391
|
+
// type.
|
|
1392
|
+
const glslType = this.getGlslTypeWebGL1();
|
|
1393
|
+
return `${glslType}(255.0 * ${sampledTextureExpression})`;
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1191
1396
|
export default MetadataClassProperty;
|
|
@@ -3,6 +3,7 @@ import Check from "../Core/Check.js";
|
|
|
3
3
|
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
4
4
|
import DeveloperError from "../Core/DeveloperError.js";
|
|
5
5
|
import FeatureDetection from "../Core/FeatureDetection.js";
|
|
6
|
+
import defined from "../Core/defined.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* An enum of metadata component types.
|
|
@@ -54,18 +55,14 @@ const MetadataComponentType = {
|
|
|
54
55
|
*/
|
|
55
56
|
UINT32: "UINT32",
|
|
56
57
|
/**
|
|
57
|
-
* A 64-bit signed integer.
|
|
58
|
-
*
|
|
59
|
-
* @see FeatureDetection.supportsBigInt
|
|
58
|
+
* A 64-bit signed integer.
|
|
60
59
|
*
|
|
61
60
|
* @type {string}
|
|
62
61
|
* @constant
|
|
63
62
|
*/
|
|
64
63
|
INT64: "INT64",
|
|
65
64
|
/**
|
|
66
|
-
* A 64-bit signed integer.
|
|
67
|
-
*
|
|
68
|
-
* @see FeatureDetection.supportsBigInt
|
|
65
|
+
* A 64-bit signed integer.
|
|
69
66
|
*
|
|
70
67
|
* @type {string}
|
|
71
68
|
* @constant
|
|
@@ -87,11 +84,89 @@ const MetadataComponentType = {
|
|
|
87
84
|
FLOAT64: "FLOAT64",
|
|
88
85
|
};
|
|
89
86
|
|
|
87
|
+
export const ScalarCategories = {
|
|
88
|
+
INTEGER: "int",
|
|
89
|
+
UNSIGNED_INTEGER: "uint",
|
|
90
|
+
FLOAT: "float",
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
MetadataComponentType.typeInfo = {
|
|
94
|
+
INT8: {
|
|
95
|
+
vectorCompatible: true,
|
|
96
|
+
size: 1,
|
|
97
|
+
maximumValue: 127,
|
|
98
|
+
minimumValue: -128,
|
|
99
|
+
category: ScalarCategories.INTEGER,
|
|
100
|
+
},
|
|
101
|
+
UINT8: {
|
|
102
|
+
vectorCompatible: true,
|
|
103
|
+
size: 1,
|
|
104
|
+
maximumValue: 255,
|
|
105
|
+
minimumValue: 0,
|
|
106
|
+
category: ScalarCategories.UNSIGNED_INTEGER,
|
|
107
|
+
},
|
|
108
|
+
INT16: {
|
|
109
|
+
vectorCompatible: true,
|
|
110
|
+
size: 2,
|
|
111
|
+
maximumValue: 32767,
|
|
112
|
+
minimumValue: -32768,
|
|
113
|
+
category: ScalarCategories.INTEGER,
|
|
114
|
+
},
|
|
115
|
+
UINT16: {
|
|
116
|
+
vectorCompatible: true,
|
|
117
|
+
size: 2,
|
|
118
|
+
maximumValue: 65535,
|
|
119
|
+
minimumValue: 0,
|
|
120
|
+
category: ScalarCategories.UNSIGNED_INTEGER,
|
|
121
|
+
},
|
|
122
|
+
INT32: {
|
|
123
|
+
vectorCompatible: true,
|
|
124
|
+
size: 4,
|
|
125
|
+
maximumValue: 2147483647,
|
|
126
|
+
minimumValue: -2147483648,
|
|
127
|
+
category: ScalarCategories.INTEGER,
|
|
128
|
+
},
|
|
129
|
+
UINT32: {
|
|
130
|
+
vectorCompatible: true,
|
|
131
|
+
size: 4,
|
|
132
|
+
maximumValue: 4294967295,
|
|
133
|
+
minimumValue: 0,
|
|
134
|
+
category: ScalarCategories.UNSIGNED_INTEGER,
|
|
135
|
+
},
|
|
136
|
+
INT64: {
|
|
137
|
+
vectorCompatible: false,
|
|
138
|
+
size: 8,
|
|
139
|
+
maximumValue: BigInt("9223372036854775807"),
|
|
140
|
+
minimumValue: BigInt("-9223372036854775808"),
|
|
141
|
+
category: ScalarCategories.INTEGER,
|
|
142
|
+
},
|
|
143
|
+
UINT64: {
|
|
144
|
+
vectorCompatible: false,
|
|
145
|
+
size: 8,
|
|
146
|
+
maximumValue: BigInt("18446744073709551615"),
|
|
147
|
+
minimumValue: BigInt(0),
|
|
148
|
+
category: ScalarCategories.UNSIGNED_INTEGER,
|
|
149
|
+
},
|
|
150
|
+
FLOAT32: {
|
|
151
|
+
vectorCompatible: true,
|
|
152
|
+
size: 4,
|
|
153
|
+
maximumValue: 340282346638528859811704183484516925440.0,
|
|
154
|
+
minimumValue: -340282346638528859811704183484516925440.0,
|
|
155
|
+
category: ScalarCategories.FLOAT,
|
|
156
|
+
},
|
|
157
|
+
FLOAT64: {
|
|
158
|
+
vectorCompatible: true,
|
|
159
|
+
size: 8,
|
|
160
|
+
maximumValue: Number.MAX_VALUE,
|
|
161
|
+
minimumValue: -Number.MAX_VALUE,
|
|
162
|
+
category: ScalarCategories.FLOAT,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
90
166
|
/**
|
|
91
167
|
* Gets the minimum value for the numeric type.
|
|
92
168
|
* <p>
|
|
93
|
-
* Returns a BigInt for the INT64 and UINT64 types
|
|
94
|
-
* Otherwise an approximate number is returned.
|
|
169
|
+
* Returns a BigInt for the INT64 and UINT64 types.
|
|
95
170
|
* </p>
|
|
96
171
|
*
|
|
97
172
|
* @param {MetadataComponentType} type The type.
|
|
@@ -100,46 +175,21 @@ const MetadataComponentType = {
|
|
|
100
175
|
* @private
|
|
101
176
|
*/
|
|
102
177
|
MetadataComponentType.getMinimum = function (type) {
|
|
178
|
+
const typeInfo = MetadataComponentType.typeInfo[type];
|
|
179
|
+
|
|
103
180
|
//>>includeStart('debug', pragmas.debug);
|
|
104
|
-
|
|
181
|
+
if (!defined(typeInfo)) {
|
|
182
|
+
throw new DeveloperError(`Invalid MetadataComponentType: ${type}`);
|
|
183
|
+
}
|
|
105
184
|
//>>includeEnd('debug');
|
|
106
185
|
|
|
107
|
-
|
|
108
|
-
case MetadataComponentType.INT8:
|
|
109
|
-
return -128;
|
|
110
|
-
case MetadataComponentType.UINT8:
|
|
111
|
-
return 0;
|
|
112
|
-
case MetadataComponentType.INT16:
|
|
113
|
-
return -32768;
|
|
114
|
-
case MetadataComponentType.UINT16:
|
|
115
|
-
return 0;
|
|
116
|
-
case MetadataComponentType.INT32:
|
|
117
|
-
return -2147483648;
|
|
118
|
-
case MetadataComponentType.UINT32:
|
|
119
|
-
return 0;
|
|
120
|
-
case MetadataComponentType.INT64:
|
|
121
|
-
if (FeatureDetection.supportsBigInt()) {
|
|
122
|
-
return BigInt("-9223372036854775808");
|
|
123
|
-
}
|
|
124
|
-
return -Math.pow(2, 63);
|
|
125
|
-
case MetadataComponentType.UINT64:
|
|
126
|
-
if (FeatureDetection.supportsBigInt()) {
|
|
127
|
-
return BigInt(0);
|
|
128
|
-
}
|
|
129
|
-
return 0;
|
|
130
|
-
case MetadataComponentType.FLOAT32:
|
|
131
|
-
// Maximum 32-bit floating point number. This value will be converted to the nearest 64-bit Number
|
|
132
|
-
return -340282346638528859811704183484516925440.0;
|
|
133
|
-
case MetadataComponentType.FLOAT64:
|
|
134
|
-
return -Number.MAX_VALUE;
|
|
135
|
-
}
|
|
186
|
+
return typeInfo.minimumValue;
|
|
136
187
|
};
|
|
137
188
|
|
|
138
189
|
/**
|
|
139
190
|
* Gets the maximum value for the numeric type.
|
|
140
191
|
* <p>
|
|
141
|
-
* Returns a BigInt for the INT64 and UINT64 types
|
|
142
|
-
* Otherwise an approximate number is returned.
|
|
192
|
+
* Returns a BigInt for the INT64 and UINT64 types.
|
|
143
193
|
* </p>
|
|
144
194
|
*
|
|
145
195
|
* @param {MetadataComponentType} type The type.
|
|
@@ -148,41 +198,15 @@ MetadataComponentType.getMinimum = function (type) {
|
|
|
148
198
|
* @private
|
|
149
199
|
*/
|
|
150
200
|
MetadataComponentType.getMaximum = function (type) {
|
|
201
|
+
const typeInfo = MetadataComponentType.typeInfo[type];
|
|
202
|
+
|
|
151
203
|
//>>includeStart('debug', pragmas.debug);
|
|
152
|
-
|
|
204
|
+
if (!defined(typeInfo)) {
|
|
205
|
+
throw new DeveloperError(`Invalid MetadataComponentType: ${type}`);
|
|
206
|
+
}
|
|
153
207
|
//>>includeEnd('debug');
|
|
154
208
|
|
|
155
|
-
|
|
156
|
-
case MetadataComponentType.INT8:
|
|
157
|
-
return 127;
|
|
158
|
-
case MetadataComponentType.UINT8:
|
|
159
|
-
return 255;
|
|
160
|
-
case MetadataComponentType.INT16:
|
|
161
|
-
return 32767;
|
|
162
|
-
case MetadataComponentType.UINT16:
|
|
163
|
-
return 65535;
|
|
164
|
-
case MetadataComponentType.INT32:
|
|
165
|
-
return 2147483647;
|
|
166
|
-
case MetadataComponentType.UINT32:
|
|
167
|
-
return 4294967295;
|
|
168
|
-
case MetadataComponentType.INT64:
|
|
169
|
-
if (FeatureDetection.supportsBigInt()) {
|
|
170
|
-
// Need to initialize with a string otherwise the value will be 9223372036854775808
|
|
171
|
-
return BigInt("9223372036854775807");
|
|
172
|
-
}
|
|
173
|
-
return Math.pow(2, 63) - 1;
|
|
174
|
-
case MetadataComponentType.UINT64:
|
|
175
|
-
if (FeatureDetection.supportsBigInt()) {
|
|
176
|
-
// Need to initialize with a string otherwise the value will be 18446744073709551616
|
|
177
|
-
return BigInt("18446744073709551615");
|
|
178
|
-
}
|
|
179
|
-
return Math.pow(2, 64) - 1;
|
|
180
|
-
case MetadataComponentType.FLOAT32:
|
|
181
|
-
// Maximum 32-bit floating point number
|
|
182
|
-
return 340282346638528859811704183484516925440.0;
|
|
183
|
-
case MetadataComponentType.FLOAT64:
|
|
184
|
-
return Number.MAX_VALUE;
|
|
185
|
-
}
|
|
209
|
+
return typeInfo.maximumValue;
|
|
186
210
|
};
|
|
187
211
|
|
|
188
212
|
/**
|
|
@@ -194,23 +218,14 @@ MetadataComponentType.getMaximum = function (type) {
|
|
|
194
218
|
* @private
|
|
195
219
|
*/
|
|
196
220
|
MetadataComponentType.isIntegerType = function (type) {
|
|
221
|
+
const typeInfo = MetadataComponentType.typeInfo[type];
|
|
197
222
|
//>>includeStart('debug', pragmas.debug);
|
|
198
|
-
|
|
223
|
+
if (!defined(typeInfo)) {
|
|
224
|
+
throw new DeveloperError(`Invalid MetadataComponentType: ${type}`);
|
|
225
|
+
}
|
|
199
226
|
//>>includeEnd('debug');
|
|
200
227
|
|
|
201
|
-
|
|
202
|
-
case MetadataComponentType.INT8:
|
|
203
|
-
case MetadataComponentType.UINT8:
|
|
204
|
-
case MetadataComponentType.INT16:
|
|
205
|
-
case MetadataComponentType.UINT16:
|
|
206
|
-
case MetadataComponentType.INT32:
|
|
207
|
-
case MetadataComponentType.UINT32:
|
|
208
|
-
case MetadataComponentType.INT64:
|
|
209
|
-
case MetadataComponentType.UINT64:
|
|
210
|
-
return true;
|
|
211
|
-
default:
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
228
|
+
return typeInfo.category !== ScalarCategories.FLOAT;
|
|
214
229
|
};
|
|
215
230
|
|
|
216
231
|
/**
|
|
@@ -222,19 +237,14 @@ MetadataComponentType.isIntegerType = function (type) {
|
|
|
222
237
|
* @private
|
|
223
238
|
*/
|
|
224
239
|
MetadataComponentType.isUnsignedIntegerType = function (type) {
|
|
240
|
+
const typeInfo = MetadataComponentType.typeInfo[type];
|
|
225
241
|
//>>includeStart('debug', pragmas.debug);
|
|
226
|
-
|
|
242
|
+
if (!defined(typeInfo)) {
|
|
243
|
+
throw new DeveloperError(`Invalid MetadataComponentType: ${type}`);
|
|
244
|
+
}
|
|
227
245
|
//>>includeEnd('debug');
|
|
228
246
|
|
|
229
|
-
|
|
230
|
-
case MetadataComponentType.UINT8:
|
|
231
|
-
case MetadataComponentType.UINT16:
|
|
232
|
-
case MetadataComponentType.UINT32:
|
|
233
|
-
case MetadataComponentType.UINT64:
|
|
234
|
-
return true;
|
|
235
|
-
default:
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
247
|
+
return typeInfo.category === ScalarCategories.UNSIGNED_INTEGER;
|
|
238
248
|
};
|
|
239
249
|
|
|
240
250
|
/**
|
|
@@ -246,23 +256,31 @@ MetadataComponentType.isUnsignedIntegerType = function (type) {
|
|
|
246
256
|
* @private
|
|
247
257
|
*/
|
|
248
258
|
MetadataComponentType.isVectorCompatible = function (type) {
|
|
259
|
+
const typeInfo = MetadataComponentType.typeInfo[type];
|
|
260
|
+
|
|
249
261
|
//>>includeStart('debug', pragmas.debug);
|
|
250
|
-
|
|
262
|
+
if (!defined(typeInfo)) {
|
|
263
|
+
throw new DeveloperError(`Invalid MetadataComponentType: ${type}`);
|
|
264
|
+
}
|
|
251
265
|
//>>includeEnd('debug');
|
|
252
266
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
267
|
+
return typeInfo.vectorCompatible;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Gets the category of the numeric type (signed integer, unsigned integer, or float).
|
|
272
|
+
* @param {MetadataComponentType} type The type.
|
|
273
|
+
* @returns {ScalarCategories} The category.
|
|
274
|
+
*/
|
|
275
|
+
MetadataComponentType.category = function (type) {
|
|
276
|
+
const typeInfo = MetadataComponentType.typeInfo[type];
|
|
277
|
+
//>>includeStart('debug', pragmas.debug);
|
|
278
|
+
if (!defined(typeInfo)) {
|
|
279
|
+
throw new DeveloperError(`Invalid MetadataComponentType: ${type}`);
|
|
265
280
|
}
|
|
281
|
+
//>>includeEnd('debug');
|
|
282
|
+
|
|
283
|
+
return typeInfo.category;
|
|
266
284
|
};
|
|
267
285
|
|
|
268
286
|
/**
|
|
@@ -380,24 +398,7 @@ MetadataComponentType.getSizeInBytes = function (type) {
|
|
|
380
398
|
Check.typeOf.string("type", type);
|
|
381
399
|
//>>includeEnd('debug');
|
|
382
400
|
|
|
383
|
-
|
|
384
|
-
case MetadataComponentType.INT8:
|
|
385
|
-
case MetadataComponentType.UINT8:
|
|
386
|
-
return 1;
|
|
387
|
-
case MetadataComponentType.INT16:
|
|
388
|
-
case MetadataComponentType.UINT16:
|
|
389
|
-
return 2;
|
|
390
|
-
case MetadataComponentType.INT32:
|
|
391
|
-
case MetadataComponentType.UINT32:
|
|
392
|
-
return 4;
|
|
393
|
-
case MetadataComponentType.INT64:
|
|
394
|
-
case MetadataComponentType.UINT64:
|
|
395
|
-
return 8;
|
|
396
|
-
case MetadataComponentType.FLOAT32:
|
|
397
|
-
return 4;
|
|
398
|
-
case MetadataComponentType.FLOAT64:
|
|
399
|
-
return 8;
|
|
400
|
-
}
|
|
401
|
+
return MetadataComponentType.typeInfo[type].size;
|
|
401
402
|
};
|
|
402
403
|
|
|
403
404
|
/**
|
|
@@ -466,4 +467,38 @@ MetadataComponentType.toComponentDatatype = function (type) {
|
|
|
466
467
|
}
|
|
467
468
|
};
|
|
468
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Gets a function for setting values of the given component type on a DataView.
|
|
472
|
+
*
|
|
473
|
+
* @param {DataView} view The DataView.
|
|
474
|
+
* @param {MetadataComponentType} componentType The component type.
|
|
475
|
+
* @returns {Function} The setter function.
|
|
476
|
+
*
|
|
477
|
+
* @private
|
|
478
|
+
*/
|
|
479
|
+
MetadataComponentType.getDataViewSetter = function (view, componentType) {
|
|
480
|
+
const setters = {
|
|
481
|
+
[MetadataComponentType.UINT8]: view.setUint8.bind(view),
|
|
482
|
+
[MetadataComponentType.INT8]: view.setInt8.bind(view),
|
|
483
|
+
[MetadataComponentType.UINT16]: (offset, value) =>
|
|
484
|
+
view.setUint16(offset, value, true /* little-endian */),
|
|
485
|
+
[MetadataComponentType.INT16]: (offset, value) =>
|
|
486
|
+
view.setInt16(offset, value, true),
|
|
487
|
+
[MetadataComponentType.UINT32]: (offset, value) =>
|
|
488
|
+
view.setUint32(offset, value, true),
|
|
489
|
+
[MetadataComponentType.INT32]: (offset, value) =>
|
|
490
|
+
view.setInt32(offset, value, true),
|
|
491
|
+
[MetadataComponentType.FLOAT32]: (offset, value) =>
|
|
492
|
+
view.setFloat32(offset, value, true),
|
|
493
|
+
[MetadataComponentType.FLOAT64]: (offset, value) =>
|
|
494
|
+
view.setFloat64(offset, value, true),
|
|
495
|
+
[MetadataComponentType.UINT64]: (offset, value) =>
|
|
496
|
+
view.setBigUint64(offset, BigInt(value), true),
|
|
497
|
+
[MetadataComponentType.INT64]: (offset, value) =>
|
|
498
|
+
view.setBigInt64(offset, BigInt(value), true),
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
return setters[componentType];
|
|
502
|
+
};
|
|
503
|
+
|
|
469
504
|
export default Object.freeze(MetadataComponentType);
|