@loaders.gl/gltf 4.0.0-beta.1 → 4.0.0-beta.3
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/dist/{dist.min.js → dist.dev.js} +3448 -3448
- package/dist/{esm/glb-loader.js → glb-loader.js} +2 -2
- package/dist/glb-loader.js.map +1 -0
- package/dist/{esm/glb-writer.js → glb-writer.js} +2 -2
- package/dist/glb-writer.js.map +1 -0
- package/dist/{esm/gltf-loader.js → gltf-loader.js} +2 -2
- package/dist/gltf-loader.js.map +1 -0
- package/dist/{esm/gltf-writer.js → gltf-writer.js} +2 -2
- package/dist/gltf-writer.js.map +1 -0
- package/dist/index.cjs +3558 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/lib → lib}/api/gltf-extensions.js +11 -11
- package/dist/lib/api/gltf-extensions.js.map +1 -0
- package/dist/lib/api/gltf-scenegraph.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/api/gltf-scenegraph.js +9 -17
- package/dist/lib/api/gltf-scenegraph.js.map +1 -0
- package/dist/{esm/lib → lib}/api/normalize-gltf-v1.js +7 -8
- package/dist/lib/api/normalize-gltf-v1.js.map +1 -0
- package/dist/{esm/lib → lib}/api/post-process-gltf.js +19 -20
- package/dist/lib/api/post-process-gltf.js.map +1 -0
- package/dist/lib/encoders/encode-glb.js.map +1 -0
- package/dist/{esm/lib → lib}/encoders/encode-gltf.js +1 -1
- package/dist/lib/encoders/encode-gltf.js.map +1 -0
- package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/extensions/EXT_mesh_features.js +7 -5
- package/dist/lib/extensions/EXT_mesh_features.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/EXT_meshopt_compression.js +2 -2
- package/dist/lib/extensions/EXT_meshopt_compression.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/EXT_structural_metadata.js +7 -7
- package/dist/lib/extensions/EXT_structural_metadata.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/EXT_texture_webp.js +2 -2
- package/dist/lib/extensions/EXT_texture_webp.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/KHR_binary_gltf.js +1 -1
- package/dist/lib/extensions/KHR_binary_gltf.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/KHR_draco_mesh_compression.js +2 -2
- package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/KHR_texture_basisu.js +1 -1
- package/dist/lib/extensions/KHR_texture_basisu.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/KHR_texture_transform.js +6 -6
- package/dist/lib/extensions/KHR_texture_transform.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/deprecated/EXT_feature_metadata.js +3 -3
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/deprecated/KHR_lights_punctual.js +2 -2
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/deprecated/KHR_materials_unlit.js +1 -1
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/{esm/lib → lib}/extensions/deprecated/KHR_techniques_webgl.js +1 -1
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts +1 -1
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/extensions/utils/3d-tiles-utils.js +6 -9
- package/dist/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
- package/dist/lib/gltf-utils/get-typed-array.d.ts +10 -0
- package/dist/lib/gltf-utils/get-typed-array.d.ts.map +1 -1
- package/dist/lib/gltf-utils/get-typed-array.js +51 -0
- package/dist/lib/gltf-utils/get-typed-array.js.map +1 -0
- package/dist/{esm/lib → lib}/gltf-utils/gltf-attribute-utils.js +1 -1
- package/dist/lib/gltf-utils/gltf-attribute-utils.js.map +1 -0
- package/dist/lib/gltf-utils/gltf-constants.js.map +1 -0
- package/dist/lib/gltf-utils/gltf-utils.d.ts +2 -2
- package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/gltf-utils/gltf-utils.js +7 -32
- package/dist/lib/gltf-utils/gltf-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/gltf-utils/resolve-url.js +1 -1
- package/dist/lib/gltf-utils/resolve-url.js.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-glb.js +6 -2
- package/dist/lib/parsers/parse-glb.js.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-gltf.js +7 -7
- package/dist/lib/parsers/parse-gltf.js.map +1 -0
- package/dist/lib/types/glb-types.js.map +1 -0
- package/dist/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +3 -1
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
- package/dist/lib/types/gltf-json-schema.d.ts +7 -0
- package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-json-schema.js.map +1 -0
- package/dist/lib/types/gltf-postprocessed-schema.js.map +1 -0
- package/dist/lib/types/gltf-types.d.ts +1 -1
- package/dist/lib/types/gltf-types.d.ts.map +1 -1
- package/dist/lib/types/gltf-types.js.map +1 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/lib/utils/version.js +2 -0
- package/dist/lib/utils/version.js.map +1 -0
- package/dist/{esm/meshopt → meshopt}/meshopt-decoder.js +1 -1
- package/dist/meshopt/meshopt-decoder.js.map +1 -0
- package/dist/{esm/webp → webp}/webp.js +1 -1
- package/dist/webp/webp.js.map +1 -0
- package/package.json +19 -11
- package/src/lib/api/gltf-scenegraph.ts +5 -17
- package/src/lib/extensions/EXT_mesh_features.ts +4 -2
- package/src/lib/extensions/utils/3d-tiles-utils.ts +17 -17
- package/src/lib/gltf-utils/get-typed-array.ts +53 -14
- package/src/lib/gltf-utils/gltf-utils.ts +3 -39
- package/src/lib/types/gltf-ext-mesh-features-schema.ts +3 -1
- package/src/lib/types/gltf-json-schema.ts +7 -0
- package/src/lib/types/gltf-types.ts +1 -1
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/glb-loader.js +0 -54
- package/dist/es5/glb-loader.js.map +0 -1
- package/dist/es5/glb-writer.js +0 -34
- package/dist/es5/glb-writer.js.map +0 -1
- package/dist/es5/gltf-loader.js +0 -81
- package/dist/es5/gltf-loader.js.map +0 -1
- package/dist/es5/gltf-writer.js +0 -35
- package/dist/es5/gltf-writer.js.map +0 -1
- package/dist/es5/index.js +0 -88
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/api/gltf-extensions.js +0 -111
- package/dist/es5/lib/api/gltf-extensions.js.map +0 -1
- package/dist/es5/lib/api/gltf-scenegraph.js +0 -598
- package/dist/es5/lib/api/gltf-scenegraph.js.map +0 -1
- package/dist/es5/lib/api/normalize-gltf-v1.js +0 -331
- package/dist/es5/lib/api/normalize-gltf-v1.js.map +0 -1
- package/dist/es5/lib/api/post-process-gltf.js +0 -470
- package/dist/es5/lib/api/post-process-gltf.js.map +0 -1
- package/dist/es5/lib/encoders/encode-glb.js +0 -61
- package/dist/es5/lib/encoders/encode-glb.js.map +0 -1
- package/dist/es5/lib/encoders/encode-gltf.js +0 -20
- package/dist/es5/lib/encoders/encode-gltf.js.map +0 -1
- package/dist/es5/lib/extensions/EXT_mesh_features.js +0 -99
- package/dist/es5/lib/extensions/EXT_mesh_features.js.map +0 -1
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js +0 -94
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +0 -1
- package/dist/es5/lib/extensions/EXT_structural_metadata.js +0 -375
- package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +0 -1
- package/dist/es5/lib/extensions/EXT_texture_webp.js +0 -43
- package/dist/es5/lib/extensions/EXT_texture_webp.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_binary_gltf.js +0 -39
- package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +0 -246
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_texture_basisu.js +0 -36
- package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_texture_transform.js +0 -231
- package/dist/es5/lib/extensions/KHR_texture_transform.js.map +0 -1
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +0 -260
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +0 -1
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js +0 -99
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js +0 -76
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js +0 -113
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
- package/dist/es5/lib/extensions/utils/3d-tiles-utils.js +0 -254
- package/dist/es5/lib/extensions/utils/3d-tiles-utils.js.map +0 -1
- package/dist/es5/lib/gltf-utils/get-typed-array.js +0 -23
- package/dist/es5/lib/gltf-utils/get-typed-array.js.map +0 -1
- package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js +0 -68
- package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
- package/dist/es5/lib/gltf-utils/gltf-constants.js +0 -48
- package/dist/es5/lib/gltf-utils/gltf-constants.js.map +0 -1
- package/dist/es5/lib/gltf-utils/gltf-utils.js +0 -115
- package/dist/es5/lib/gltf-utils/gltf-utils.js.map +0 -1
- package/dist/es5/lib/gltf-utils/resolve-url.js +0 -18
- package/dist/es5/lib/gltf-utils/resolve-url.js.map +0 -1
- package/dist/es5/lib/parsers/parse-glb.js +0 -120
- package/dist/es5/lib/parsers/parse-glb.js.map +0 -1
- package/dist/es5/lib/parsers/parse-gltf.js +0 -283
- package/dist/es5/lib/parsers/parse-gltf.js.map +0 -1
- package/dist/es5/lib/types/glb-types.js +0 -2
- package/dist/es5/lib/types/glb-types.js.map +0 -1
- package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js +0 -2
- package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js.map +0 -1
- package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js +0 -2
- package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js.map +0 -1
- package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js +0 -2
- package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js.map +0 -1
- package/dist/es5/lib/types/gltf-json-schema.js +0 -2
- package/dist/es5/lib/types/gltf-json-schema.js.map +0 -1
- package/dist/es5/lib/types/gltf-postprocessed-schema.js +0 -2
- package/dist/es5/lib/types/gltf-postprocessed-schema.js.map +0 -1
- package/dist/es5/lib/types/gltf-types.js +0 -2
- package/dist/es5/lib/types/gltf-types.js.map +0 -1
- package/dist/es5/lib/utils/assert.js +0 -12
- package/dist/es5/lib/utils/assert.js.map +0 -1
- package/dist/es5/lib/utils/version.js +0 -9
- package/dist/es5/lib/utils/version.js.map +0 -1
- package/dist/es5/meshopt/meshopt-decoder.js +0 -215
- package/dist/es5/meshopt/meshopt-decoder.js.map +0 -1
- package/dist/es5/webp/webp.js +0 -83
- package/dist/es5/webp/webp.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/glb-loader.js.map +0 -1
- package/dist/esm/glb-writer.js.map +0 -1
- package/dist/esm/gltf-loader.js.map +0 -1
- package/dist/esm/gltf-writer.js.map +0 -1
- package/dist/esm/index.js +0 -13
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/api/gltf-extensions.js.map +0 -1
- package/dist/esm/lib/api/gltf-scenegraph.js.map +0 -1
- package/dist/esm/lib/api/normalize-gltf-v1.js.map +0 -1
- package/dist/esm/lib/api/post-process-gltf.js.map +0 -1
- package/dist/esm/lib/encoders/encode-glb.js.map +0 -1
- package/dist/esm/lib/encoders/encode-gltf.js.map +0 -1
- package/dist/esm/lib/extensions/EXT_mesh_features.js.map +0 -1
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +0 -1
- package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +0 -1
- package/dist/esm/lib/extensions/EXT_texture_webp.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_texture_basisu.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_texture_transform.js.map +0 -1
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +0 -1
- package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
- package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
- package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
- package/dist/esm/lib/extensions/utils/3d-tiles-utils.js.map +0 -1
- package/dist/esm/lib/gltf-utils/get-typed-array.js +0 -16
- package/dist/esm/lib/gltf-utils/get-typed-array.js.map +0 -1
- package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
- package/dist/esm/lib/gltf-utils/gltf-constants.js.map +0 -1
- package/dist/esm/lib/gltf-utils/gltf-utils.js.map +0 -1
- package/dist/esm/lib/gltf-utils/resolve-url.js.map +0 -1
- package/dist/esm/lib/parsers/parse-glb.js.map +0 -1
- package/dist/esm/lib/parsers/parse-gltf.js.map +0 -1
- package/dist/esm/lib/types/glb-types.js.map +0 -1
- package/dist/esm/lib/types/gltf-ext-feature-metadata-schema.js.map +0 -1
- package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js.map +0 -1
- package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js.map +0 -1
- package/dist/esm/lib/types/gltf-json-schema.js.map +0 -1
- package/dist/esm/lib/types/gltf-postprocessed-schema.js.map +0 -1
- package/dist/esm/lib/types/gltf-types.js.map +0 -1
- package/dist/esm/lib/utils/assert.js.map +0 -1
- package/dist/esm/lib/utils/version.js +0 -2
- package/dist/esm/lib/utils/version.js.map +0 -1
- package/dist/esm/meshopt/meshopt-decoder.js.map +0 -1
- package/dist/esm/meshopt/meshopt-encoder.ts.disabled +0 -409
- package/dist/esm/webp/webp.js.map +0 -1
- package/src/bundle.ts +0 -4
- /package/dist/{esm/lib → lib}/encoders/encode-glb.js +0 -0
- /package/dist/{esm/lib → lib}/gltf-utils/gltf-constants.js +0 -0
- /package/dist/{esm/lib → lib}/types/glb-types.js +0 -0
- /package/dist/{esm/lib → lib}/types/gltf-ext-feature-metadata-schema.js +0 -0
- /package/dist/{esm/lib → lib}/types/gltf-ext-mesh-features-schema.js +0 -0
- /package/dist/{esm/lib → lib}/types/gltf-ext-structural-metadata-schema.js +0 -0
- /package/dist/{esm/lib → lib}/types/gltf-json-schema.js +0 -0
- /package/dist/{esm/lib → lib}/types/gltf-postprocessed-schema.js +0 -0
- /package/dist/{esm/lib → lib}/types/gltf-types.js +0 -0
- /package/dist/{esm/lib → lib}/utils/assert.js +0 -0
- /package/dist/{es5/meshopt → meshopt}/meshopt-encoder.ts.disabled +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/extensions/utils/3d-tiles-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;G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,UAAU,EAAE,aAAa,EACzB,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,GACjB,aAAa,EAAE,CAOjB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,UAAU,EAC3B,YAAY,EAAE,UAAU,GAAG,IAAI,EAC/B,aAAa,EAAE,UAAU,GAAG,IAAI,GAC/B,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CA0BvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getComponentTypeFromArray
|
|
1
|
+
import { getComponentTypeFromArray } from "../../gltf-utils/gltf-utils.js";
|
|
2
2
|
import { getImageData } from '@loaders.gl/images';
|
|
3
3
|
import { emod } from '@loaders.gl/math';
|
|
4
4
|
const ATTRIBUTE_TYPE_TO_COMPONENTS = {
|
|
@@ -69,13 +69,10 @@ export function convertRawBufferToMetadataArray(data, attributeType, componentTy
|
|
|
69
69
|
}
|
|
70
70
|
export function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
|
|
71
71
|
var _json$textures, _json$textures$textur;
|
|
72
|
-
const
|
|
73
|
-
const texCoordAccessorKey = "TEXCOORD_".concat(textureInfo.texCoord || 0);
|
|
72
|
+
const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
|
|
74
73
|
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
75
|
-
const textureCoordinates =
|
|
76
|
-
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
74
|
+
const textureCoordinates = scenegraph.getTypedArrayForAccessor(texCoordAccessorIndex);
|
|
75
|
+
const json = scenegraph.gltf.json;
|
|
79
76
|
const textureIndex = textureInfo.index;
|
|
80
77
|
const imageIndex = (_json$textures = json.textures) === null || _json$textures === void 0 ? void 0 : (_json$textures$textur = _json$textures[textureIndex]) === null || _json$textures$textur === void 0 ? void 0 : _json$textures$textur.source;
|
|
81
78
|
if (typeof imageIndex !== 'undefined') {
|
|
@@ -91,7 +88,7 @@ export function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
|
|
|
91
88
|
return textureData;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
|
-
return
|
|
91
|
+
return [];
|
|
95
92
|
}
|
|
96
93
|
export function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) {
|
|
97
94
|
if (!(propertyData !== null && propertyData !== void 0 && propertyData.length)) {
|
|
@@ -150,7 +147,7 @@ function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, i
|
|
|
150
147
|
const imageOffset = offset + map.offset;
|
|
151
148
|
const imageData = getImageData(parsedImage);
|
|
152
149
|
if (imageData.data.length <= imageOffset) {
|
|
153
|
-
throw new Error(
|
|
150
|
+
throw new Error(`${imageData.data.length} <= ${imageOffset}`);
|
|
154
151
|
}
|
|
155
152
|
const imageValue = imageData.data[imageOffset];
|
|
156
153
|
value |= imageValue << map.shift;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-tiles-utils.js","names":["getComponentTypeFromArray","getImageData","emod","ATTRIBUTE_TYPE_TO_COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","BOOLEAN","STRING","ENUM","ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY","INT8","Int8Array","UINT8","Uint8Array","INT16","Int16Array","UINT16","Uint16Array","INT32","Int32Array","UINT32","Uint32Array","INT64","BigInt64Array","UINT64","BigUint64Array","FLOAT32","Float32Array","FLOAT64","Float64Array","ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE","getArrayElementByteSize","attributeType","componentType","getOffsetsForProperty","scenegraph","bufferViewIndex","offsetType","numberOfElements","arrayOffsetsBytes","getTypedArrayForBufferView","arrayOffsets","convertRawBufferToMetadataArray","data","elementCount","arguments","length","undefined","numberOfComponents","ArrayType","size","byteLength","buffer","offset","byteOffset","bufferArray","slice","getPrimitiveTextureData","textureInfo","primitive","_json$textures","_json$textures$textur","texCoordAccessorKey","texCoord","texCoordAccessorIndex","attributes","textureCoordinates","getTypedArrayForAccessor","json","gltf","textureIndex","index","imageIndex","textures","source","_json$images","_json$images$imageInd","_scenegraph$gltf$imag","mimeType","images","parsedImage","width","textureData","value","getImageValueByCoordinates","channels","push","primitivePropertyDataToAttributes","attributeName","propertyData","featureTable","featureIndices","texelData","findIndex","item","typedArray","bufferIndex","buffers","arrayBuffer","addBufferView","accessorIndex","addAccessor","count","CHANNELS_MAP","r","shift","g","b","a","u","v","components","indexOf","coordinatesToOffset","c","map","Object","values","imageOffset","imageData","Error","imageValue","componentsCount","w","iX","indX","Math","round","h","height","iY","indY","parseVariableLengthArrayNumeric","valuesData","valuesDataBytesLength","valueSize","attributeValueArray","arrayOffset","arrayByteSize","typedArrayOffset","parseFixedLengthArrayNumeric","arrayCount","elementOffset","getPropertyDataString","valuesDataBytes","stringOffsets","stringsArray","textDecoder","TextDecoder","stringOffset","stringByteSize","stringData","subarray","stringAttribute","decode"],"sources":["../../../../src/lib/extensions/utils/3d-tiles-utils.ts"],"sourcesContent":["/**\n * loaders.gl, MIT license\n *\n * Shared code for 3DTiles extensions:\n * * EXT_feature_metadata\n * * EXT_mesh_features\n * * EXT_structural_metadata\n */\n\nimport type {GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../../types/gltf-json-schema';\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {ImageType} from '@loaders.gl/images';\n\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\nimport {getComponentTypeFromArray} from '../../gltf-utils/gltf-utils';\nimport {getImageData} from '@loaders.gl/images';\nimport {emod} from '@loaders.gl/math';\n\nexport type NumericComponentType =\n | 'INT8'\n | 'UINT8'\n | 'INT16'\n | 'UINT16'\n | 'INT32'\n | 'UINT32'\n | 'INT64'\n | 'UINT64'\n | 'FLOAT32'\n | 'FLOAT64';\n\nconst ATTRIBUTE_TYPE_TO_COMPONENTS = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16,\n BOOLEAN: 1,\n STRING: 1,\n ENUM: 1\n};\n\nconst ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {\n INT8: Int8Array,\n UINT8: Uint8Array,\n INT16: Int16Array,\n UINT16: Uint16Array,\n INT32: Int32Array,\n UINT32: Uint32Array,\n INT64: BigInt64Array,\n UINT64: BigUint64Array,\n FLOAT32: Float32Array,\n FLOAT64: Float64Array\n};\n\nconst ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {\n INT8: 1,\n UINT8: 1,\n INT16: 2,\n UINT16: 2,\n INT32: 4,\n UINT32: 4,\n INT64: 8,\n UINT64: 8,\n FLOAT32: 4,\n FLOAT64: 8\n};\n\nexport function getArrayElementByteSize(attributeType, componentType): number {\n return (\n ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[componentType] *\n ATTRIBUTE_TYPE_TO_COMPONENTS[attributeType]\n );\n}\n\n/**\n * Gets offset array from `arrayOffsets` or `stringOffsets`.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param bufferViewIndex - Buffer view index\n * @param offsetType - The type of values in `arrayOffsets` or `stringOffsets`.\n * @param numberOfElements - The number of elements in each property array.\n * @returns Array of values offsets. The number of offsets in the array is equal to `numberOfElements` plus one.\n */\nexport function getOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n bufferViewIndex: number,\n offsetType: 'UINT8' | 'UINT16' | 'UINT32' | 'UINT64' | string,\n numberOfElements: number\n): TypedArray | null {\n if (\n offsetType !== 'UINT8' &&\n offsetType !== 'UINT16' &&\n offsetType !== 'UINT32' &&\n offsetType !== 'UINT64'\n ) {\n return null;\n }\n const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);\n const arrayOffsets = convertRawBufferToMetadataArray(\n arrayOffsetsBytes,\n 'SCALAR', // offsets consist of ONE component\n offsetType,\n numberOfElements + 1 // The number of offsets is equal to the property table `count` plus one.\n );\n\n // We don't support BigInt offsets at the moment. It requires additional logic and potential issues in Safari\n if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {\n return null;\n }\n return arrayOffsets;\n}\n\n/**\n * Converts raw bytes that are in the buffer to an array of the type defined by the schema.\n * @param data - Raw bytes in the buffer.\n * @param attributeType - SCALAR, VECN, MATN.\n * @param componentType - Type of the component in elements, e.g. 'UINT8' or 'FLOAT32'.\n * @param elementCount - Number of elements in the array. Default value is 1.\n * @returns Data array\n */\nexport function convertRawBufferToMetadataArray(\n data: Uint8Array,\n attributeType: string,\n componentType: NumericComponentType,\n elementCount: number = 1\n): BigTypedArray {\n const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS[attributeType];\n const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[componentType];\n const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[componentType];\n const length = elementCount * numberOfComponents;\n const byteLength = length * size;\n let buffer = data.buffer;\n let offset = data.byteOffset;\n if (offset % size !== 0) {\n const bufferArray = new Uint8Array(buffer);\n buffer = bufferArray.slice(offset, offset + byteLength).buffer;\n offset = 0;\n }\n return new ArrayType(buffer, offset, length);\n}\n\n/**\n * Processes data encoded in the texture associated with the primitive.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param textureInfo - Reference to the texture where extension data are stored.\n * @param primitive - Primitive object in the mesh.\n * @returns Array of data taken. Null if data can't be taken from the texture.\n */\nexport function getPrimitiveTextureData(\n scenegraph: GLTFScenegraph,\n textureInfo: GLTFTextureInfoMetadata,\n primitive: GLTFMeshPrimitive\n): number[] {\n /*\n texture.index is an index for the \"textures\" array.\n The texture object referenced by this index looks like this:\n {\n \"sampler\": 0,\n \"source\": 0\n }\n \"sampler\" is an index for the \"samplers\" array\n \"source\" is an index for the \"images\" array that contains data stored in rgba channels of the image.\n\n texture.texCoord is a number-suffix (like 1) for an attribute like \"TEXCOORD_1\" in meshes.primitives\n The value of \"TEXCOORD_1\" is an accessor that is used to get coordinates.\n These coordinates are being used to get data from the image.\n \n Default for texture.texCoord is 0\n @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/specification/2.0/schema/textureInfo.schema.json\n */\n const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;\n const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];\n const textureCoordinates: TypedArray = scenegraph.getTypedArrayForAccessor(texCoordAccessorIndex);\n\n const json = scenegraph.gltf.json;\n const textureIndex: number = textureInfo.index;\n const imageIndex = json.textures?.[textureIndex]?.source;\n if (typeof imageIndex !== 'undefined') {\n const mimeType = json.images?.[imageIndex]?.mimeType;\n const parsedImage = scenegraph.gltf.images?.[imageIndex];\n // Checking for width is to prevent handling Un-processed images (e.g. [analyze] stage, where loadImages option is set to false)\n if (parsedImage && typeof parsedImage.width !== 'undefined') {\n const textureData: number[] = [];\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const value = getImageValueByCoordinates(\n parsedImage,\n mimeType,\n textureCoordinates,\n index,\n textureInfo.channels\n );\n textureData.push(value);\n }\n return textureData;\n }\n }\n return [];\n}\n\n/**\n * Puts property data to attributes.\n * It creates corresponding buffer, bufferView and accessor\n * so the data can be accessed like regular data stored in buffers.\n * @param scenegraph - Scenegraph object.\n * @param attributeName - Name of the attribute.\n * @param propertyData - Property data to store.\n * @param featureTable - Array where unique data from the property data are being stored.\n * @param primitive - Primitive object.\n */\nexport function primitivePropertyDataToAttributes(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n propertyData: number[],\n featureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n // No reason to create an empty buffer if there is no property data to store.\n if (!propertyData?.length) {\n return;\n }\n /*\n featureTable will contain unique values, e.g.\n propertyData = [24, 35, 28, 24]\n featureTable = [24, 35, 28]\n featureIndices will contain indices that refer featureTextureTable, e.g.\n featureIndices = [0, 1, 2, 0]\n */\n const featureIndices: number[] = [];\n for (const texelData of propertyData) {\n let index = featureTable.findIndex((item) => item === texelData);\n if (index === -1) {\n index = featureTable.push(texelData) - 1;\n }\n featureIndices.push(index);\n }\n const typedArray = new Uint32Array(featureIndices);\n const bufferIndex =\n scenegraph.gltf.buffers.push({\n arrayBuffer: typedArray.buffer,\n byteOffset: typedArray.byteOffset,\n byteLength: typedArray.byteLength\n }) - 1;\n const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);\n const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {\n size: 1,\n componentType: getComponentTypeFromArray(typedArray),\n count: typedArray.length\n });\n primitive.attributes[attributeName] = accessorIndex;\n}\n\n/**\n * Gets the value from the texture by coordinates provided.\n * @param parsedImage - Image where the data are stored.\n * @param mimeType - MIME type.\n * @param textureCoordinates - uv coordinates to access data in the image.\n * @param index - Index of uv coordinates in the array textureCoordinates.\n * @param channels - Image channels where data are stored.\n * Channels of an RGBA texture are numbered 0..3 respectively.\n * For Ext_mesh_features and EXT_strucural_metadata the channels default is [0]\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features/schema/featureIdTexture.schema.json\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTexture.property.schema.json\n * @returns Value taken from the image.\n */\nfunction getImageValueByCoordinates(\n parsedImage: ImageType,\n mimeType: string | undefined,\n textureCoordinates: TypedArray,\n index: number,\n channels: number[] | string = [0]\n) {\n const CHANNELS_MAP = {\n r: {offset: 0, shift: 0},\n g: {offset: 1, shift: 8},\n b: {offset: 2, shift: 16},\n a: {offset: 3, shift: 24}\n };\n\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n let components = 1;\n if (mimeType && (mimeType.indexOf('image/jpeg') !== -1 || mimeType.indexOf('image/png') !== -1))\n components = 4;\n const offset = coordinatesToOffset(u, v, parsedImage, components);\n let value: number = 0;\n for (const c of channels) {\n /*\n According to the EXT_feature_metadata extension specification:\n Channels are labeled by rgba and are swizzled with a string of 1-4 characters.\n According to the EXT_mesh_features extension specification:\n The channels array contains non-negative integer values corresponding to channels of the source texture that the feature ID consists of.\n Channels of an RGBA texture are numbered 0–3 respectively.\n Function getImageValueByCoordinates is used to process both extensions. \n So, there should be possible to get the element of CHANNELS_MAP by either index (0, 1, 2, 3) or key (r, g, b, a).\n */\n const map = typeof c === 'number' ? Object.values(CHANNELS_MAP)[c] : CHANNELS_MAP[c];\n const imageOffset = offset + map.offset;\n const imageData = getImageData(parsedImage);\n if (imageData.data.length <= imageOffset) {\n throw new Error(`${imageData.data.length} <= ${imageOffset}`);\n }\n const imageValue = imageData.data[imageOffset];\n value |= imageValue << map.shift;\n }\n return value;\n}\n\n/**\n * Retrieves the offset in the image where the data are stored.\n * @param u - u-coordinate.\n * @param v - v-coordinate.\n * @param parsedImage - Image where the data are stored.\n * @param componentsCount - Number of components the data consists of.\n * @returns Offset in the image where the data are stored.\n */\nfunction coordinatesToOffset(\n u: number,\n v: number,\n parsedImage: any,\n componentsCount: number = 1\n): number {\n const w = parsedImage.width;\n const iX = emod(u) * (w - 1);\n const indX = Math.round(iX);\n\n const h = parsedImage.height;\n const iY = emod(v) * (h - 1);\n const indY = Math.round(iY);\n const components = parsedImage.components ? parsedImage.components : componentsCount;\n // components is a number of channels in the image\n const offset = (indY * w + indX) * components;\n return offset;\n}\n\n/**\n * Parses variable-length array data.\n * In this case every value of the property in the table will be an array\n * of arbitrary length.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - Number of rows in the property table.\n * @param arrayOffsets - Offsets of nested arrays in the flat values array.\n * @param valuesDataBytesLength - Data byte length.\n * @param valueSize - Value size in bytes.\n * @returns Array of typed arrays.\n */\nexport function parseVariableLengthArrayNumeric(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayOffsets: TypedArray,\n valuesDataBytesLength: number,\n valueSize: number\n): BigTypedArray[] {\n const attributeValueArray: BigTypedArray[] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset > valuesDataBytesLength) {\n break;\n }\n const typedArrayOffset = arrayOffset / valueSize;\n const elementCount = arrayByteSize / valueSize;\n attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed-length array data.\n * In this case every value of the property in the table will be an array\n * of constant length equal to `arrayCount`.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - Number of rows in the property table.\n * @param arrayCount - Nested arrays length.\n * @returns Array of typed arrays.\n */\nexport function parseFixedLengthArrayNumeric(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number\n): BigTypedArray[] {\n const attributeValueArray: BigTypedArray[] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = index * arrayCount;\n attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));\n }\n return attributeValueArray;\n}\n\n/**\n * Decodes properties of string type from binary source.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param stringOffsets - Index of the buffer view containing offsets for strings. It should be available for string type.\n * @returns String property values\n */\nexport function getPropertyDataString(\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null,\n stringOffsets: TypedArray | null\n): string[] | string[][] {\n if (arrayOffsets) {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error('Not implemented - arrayOffsets for strings is specified');\n }\n\n if (stringOffsets) {\n const stringsArray: string[] = [];\n const textDecoder = new TextDecoder('utf8');\n\n let stringOffset = 0;\n for (let index = 0; index < numberOfElements; index++) {\n const stringByteSize = stringOffsets[index + 1] - stringOffsets[index];\n\n if (stringByteSize + stringOffset <= valuesDataBytes.length) {\n const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset);\n const stringAttribute = textDecoder.decode(stringData);\n\n stringsArray.push(stringAttribute);\n stringOffset += stringByteSize;\n }\n }\n\n return stringsArray;\n }\n return [];\n}\n"],"mappings":"SAcQA,yBAAyB;AACjC,SAAQC,YAAY,QAAO,oBAAoB;AAC/C,SAAQC,IAAI,QAAO,kBAAkB;AAcrC,MAAMC,4BAA4B,GAAG;EACnCC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;EACVC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE;AACR,CAAC;AAED,MAAMC,iCAAiC,GAAG;EACxCC,IAAI,EAAEC,SAAS;EACfC,KAAK,EAAEC,UAAU;EACjBC,KAAK,EAAEC,UAAU;EACjBC,MAAM,EAAEC,WAAW;EACnBC,KAAK,EAAEC,UAAU;EACjBC,MAAM,EAAEC,WAAW;EACnBC,KAAK,EAAEC,aAAa;EACpBC,MAAM,EAAEC,cAAc;EACtBC,OAAO,EAAEC,YAAY;EACrBC,OAAO,EAAEC;AACX,CAAC;AAED,MAAMC,qCAAqC,GAAG;EAC5CpB,IAAI,EAAE,CAAC;EACPE,KAAK,EAAE,CAAC;EACRE,KAAK,EAAE,CAAC;EACRE,MAAM,EAAE,CAAC;EACTE,KAAK,EAAE,CAAC;EACRE,MAAM,EAAE,CAAC;EACTE,KAAK,EAAE,CAAC;EACRE,MAAM,EAAE,CAAC;EACTE,OAAO,EAAE,CAAC;EACVE,OAAO,EAAE;AACX,CAAC;AAED,OAAO,SAASG,uBAAuBA,CAACC,aAAa,EAAEC,aAAa,EAAU;EAC5E,OACEH,qCAAqC,CAACG,aAAa,CAAC,GACpDnC,4BAA4B,CAACkC,aAAa,CAAC;AAE/C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,UAAU,CAAC7E,KAAK,CAACsF,aAAa,EAAEA,aAAa,GAAGD,UAAU,CAAC,CAAC;EACvF;EACA,OAAOL,mBAAmB;AAC5B;AAUA,OAAO,SAASO,qBAAqBA,CACnCzG,gBAAwB,EACxB0G,eAA2B,EAC3BvG,YAA+B,EAC/BwG,aAAgC,EACT;EACvB,IAAIxG,YAAY,EAAE;IAEhB,MAAM,IAAI+E,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EAEA,IAAIyB,aAAa,EAAE;IACjB,MAAMC,YAAsB,GAAG,EAAE;IACjC,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,MAAM,CAAC;IAE3C,IAAIC,YAAY,GAAG,CAAC;IACpB,KAAK,IAAI9E,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGjC,gBAAgB,EAAEiC,KAAK,EAAE,EAAE;MACrD,MAAM+E,cAAc,GAAGL,aAAa,CAAC1E,KAAK,GAAG,CAAC,CAAC,GAAG0E,aAAa,CAAC1E,KAAK,CAAC;MAEtE,IAAI+E,cAAc,GAAGD,YAAY,IAAIL,eAAe,CAAClG,MAAM,EAAE;QAC3D,MAAMyG,UAAU,GAAGP,eAAe,CAACQ,QAAQ,CAACH,YAAY,EAAEC,cAAc,GAAGD,YAAY,CAAC;QACxF,MAAMI,eAAe,GAAGN,WAAW,CAACO,MAAM,CAACH,UAAU,CAAC;QAEtDL,YAAY,CAAC5D,IAAI,CAACmE,eAAe,CAAC;QAClCJ,YAAY,IAAIC,cAAc;MAChC;IACF;IAEA,OAAOJ,YAAY;EACrB;EACA,OAAO,EAAE;AACX"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import type { TypedArray } from '@loaders.gl/schema';
|
|
2
|
+
import type { GLTF, GLTFExternalBuffer, GLTFAccessor } from '../types/gltf-types';
|
|
1
3
|
export declare function getTypedArrayForBufferView(json: any, buffers: any, bufferViewIndex: any): Uint8Array;
|
|
2
4
|
export declare function getTypedArrayForImageData(json: any, buffers: any, imageIndex: any): Uint8Array;
|
|
5
|
+
/**
|
|
6
|
+
* Gets data pointed by the accessor.
|
|
7
|
+
* @param json - json part of gltf content of a GLTF tile.
|
|
8
|
+
* @param buffers - Array containing buffers of data.
|
|
9
|
+
* @param accessor - accepts accessor index or accessor object.
|
|
10
|
+
* @returns {TypedArray} Typed array with type matching the type of data poited by the accessor.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTypedArrayForAccessor(json: GLTF, buffers: GLTFExternalBuffer[], accessor: GLTFAccessor | number): TypedArray;
|
|
3
13
|
//# sourceMappingURL=get-typed-array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-typed-array.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/get-typed-array.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-typed-array.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/get-typed-array.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAC,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAKhF,wBAAgB,0BAA0B,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,EAAE,eAAe,KAAA,cAWxE;AAID,wBAAgB,yBAAyB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,EAAE,UAAU,KAAA,cAIlE;AAED;;;;;;GAMG;AAEH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,kBAAkB,EAAE,EAC7B,QAAQ,EAAE,YAAY,GAAG,MAAM,GAC9B,UAAU,CAsCZ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assert } from "../utils/assert.js";
|
|
2
|
+
import { getAccessorArrayTypeAndLength } from "./gltf-utils.js";
|
|
3
|
+
export function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
|
|
4
|
+
const bufferView = json.bufferViews[bufferViewIndex];
|
|
5
|
+
assert(bufferView);
|
|
6
|
+
const bufferIndex = bufferView.buffer;
|
|
7
|
+
const binChunk = buffers[bufferIndex];
|
|
8
|
+
assert(binChunk);
|
|
9
|
+
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
10
|
+
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
11
|
+
}
|
|
12
|
+
export function getTypedArrayForImageData(json, buffers, imageIndex) {
|
|
13
|
+
const image = json.images[imageIndex];
|
|
14
|
+
const bufferViewIndex = json.bufferViews[image.bufferView];
|
|
15
|
+
return getTypedArrayForBufferView(json, buffers, bufferViewIndex);
|
|
16
|
+
}
|
|
17
|
+
export function getTypedArrayForAccessor(json, buffers, accessor) {
|
|
18
|
+
var _json$accessors, _json$bufferViews;
|
|
19
|
+
const gltfAccessor = typeof accessor === 'number' ? (_json$accessors = json.accessors) === null || _json$accessors === void 0 ? void 0 : _json$accessors[accessor] : accessor;
|
|
20
|
+
if (!gltfAccessor) {
|
|
21
|
+
throw new Error(`No gltf accessor ${accessor}`);
|
|
22
|
+
}
|
|
23
|
+
const bufferView = (_json$bufferViews = json.bufferViews) === null || _json$bufferViews === void 0 ? void 0 : _json$bufferViews[gltfAccessor.bufferView || 0];
|
|
24
|
+
if (!bufferView) {
|
|
25
|
+
throw new Error(`No gltf buffer view for accessor ${bufferView}`);
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
arrayBuffer,
|
|
29
|
+
byteOffset: bufferByteOffset
|
|
30
|
+
} = buffers[bufferView.buffer];
|
|
31
|
+
const byteOffset = (bufferByteOffset || 0) + (gltfAccessor.byteOffset || 0) + (bufferView.byteOffset || 0);
|
|
32
|
+
const {
|
|
33
|
+
ArrayType,
|
|
34
|
+
length,
|
|
35
|
+
componentByteSize,
|
|
36
|
+
numberOfComponentsInElement
|
|
37
|
+
} = getAccessorArrayTypeAndLength(gltfAccessor, bufferView);
|
|
38
|
+
const elementByteSize = componentByteSize * numberOfComponentsInElement;
|
|
39
|
+
const elementAddressScale = bufferView.byteStride || elementByteSize;
|
|
40
|
+
if (typeof bufferView.byteStride === 'undefined' || bufferView.byteStride === elementByteSize) {
|
|
41
|
+
const result = new ArrayType(arrayBuffer, byteOffset, length);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
const result = new ArrayType(length);
|
|
45
|
+
for (let i = 0; i < gltfAccessor.count; i++) {
|
|
46
|
+
const values = new ArrayType(arrayBuffer, byteOffset + i * elementAddressScale, numberOfComponentsInElement);
|
|
47
|
+
result.set(values, i * numberOfComponentsInElement);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=get-typed-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-typed-array.js","names":["assert","getAccessorArrayTypeAndLength","getTypedArrayForBufferView","json","buffers","bufferViewIndex","bufferView","bufferViews","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","byteLength","getTypedArrayForImageData","imageIndex","image","images","getTypedArrayForAccessor","accessor","_json$accessors","_json$bufferViews","gltfAccessor","accessors","Error","bufferByteOffset","ArrayType","length","componentByteSize","numberOfComponentsInElement","elementByteSize","elementAddressScale","byteStride","result","i","count","values","set"],"sources":["../../../src/lib/gltf-utils/get-typed-array.ts"],"sourcesContent":["// TODO - GLTFScenegraph should use these\nimport {assert} from '../utils/assert';\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFExternalBuffer, GLTFAccessor} from '../types/gltf-types';\nimport {getAccessorArrayTypeAndLength} from './gltf-utils';\n\n// accepts buffer view index or buffer view object\n// returns a `Uint8Array`\nexport function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {\n const bufferView = json.bufferViews[bufferViewIndex];\n assert(bufferView);\n\n // Get hold of the arrayBuffer\n const bufferIndex = bufferView.buffer;\n const binChunk = buffers[bufferIndex];\n assert(binChunk);\n\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n}\n\n// accepts accessor index or accessor object\n// returns a `Uint8Array`\nexport function getTypedArrayForImageData(json, buffers, imageIndex) {\n const image = json.images[imageIndex];\n const bufferViewIndex = json.bufferViews[image.bufferView];\n return getTypedArrayForBufferView(json, buffers, bufferViewIndex);\n}\n\n/**\n * Gets data pointed by the accessor.\n * @param json - json part of gltf content of a GLTF tile.\n * @param buffers - Array containing buffers of data.\n * @param accessor - accepts accessor index or accessor object.\n * @returns {TypedArray} Typed array with type matching the type of data poited by the accessor.\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayForAccessor(\n json: GLTF,\n buffers: GLTFExternalBuffer[],\n accessor: GLTFAccessor | number\n): TypedArray {\n const gltfAccessor = typeof accessor === 'number' ? json.accessors?.[accessor] : accessor;\n if (!gltfAccessor) {\n throw new Error(`No gltf accessor ${accessor}`);\n }\n const bufferView = json.bufferViews?.[gltfAccessor.bufferView || 0];\n if (!bufferView) {\n throw new Error(`No gltf buffer view for accessor ${bufferView}`);\n }\n // Get `arrayBuffer` the `bufferView` looks at\n const {arrayBuffer, byteOffset: bufferByteOffset} = buffers[bufferView.buffer];\n // Resulting byteOffset is sum of the buffer, accessor and bufferView byte offsets\n const byteOffset =\n (bufferByteOffset || 0) + (gltfAccessor.byteOffset || 0) + (bufferView.byteOffset || 0);\n // Deduce TypedArray type and its length from `accessor` and `bufferView` data\n const {ArrayType, length, componentByteSize, numberOfComponentsInElement} =\n getAccessorArrayTypeAndLength(gltfAccessor, bufferView);\n // 'length' is a whole number of components of all elements in the buffer pointed by the accessor\n // Multiplier to calculate the address of the element in the arrayBuffer\n const elementByteSize = componentByteSize * numberOfComponentsInElement;\n const elementAddressScale = bufferView.byteStride || elementByteSize;\n // Creare an array of component's type where all components (not just elements) will reside\n if (typeof bufferView.byteStride === 'undefined' || bufferView.byteStride === elementByteSize) {\n // No iterleaving\n const result: TypedArray = new ArrayType(arrayBuffer, byteOffset, length);\n return result;\n }\n // Iterleaving\n const result: TypedArray = new ArrayType(length);\n for (let i = 0; i < gltfAccessor.count; i++) {\n const values = new ArrayType(\n arrayBuffer,\n byteOffset + i * elementAddressScale,\n numberOfComponentsInElement\n );\n result.set(values, i * numberOfComponentsInElement);\n }\n return result;\n}\n"],"mappings":"SACQA,MAAM;AAAA,SAGNC,6BAA6B;AAIrC,OAAO,SAASC,0BAA0BA,CAACC,IAAI,EAAEC,OAAO,EAAEC,eAAe,EAAE;EACzE,MAAMC,UAAU,GAAGH,IAAI,CAACI,WAAW,CAACF,eAAe,CAAC;EACpDL,MAAM,CAACM,UAAU,CAAC;EAGlB,MAAME,WAAW,GAAGF,UAAU,CAACG,MAAM;EACrC,MAAMC,QAAQ,GAAGN,OAAO,CAACI,WAAW,CAAC;EACrCR,MAAM,CAACU,QAAQ,CAAC;EAEhB,MAAMC,UAAU,GAAG,CAACL,UAAU,CAACK,UAAU,IAAI,CAAC,IAAID,QAAQ,CAACC,UAAU;EACrE,OAAO,IAAIC,UAAU,CAACF,QAAQ,CAACG,WAAW,EAAEF,UAAU,EAAEL,UAAU,CAACQ,UAAU,CAAC;AAChF;AAIA,OAAO,SAASC,yBAAyBA,CAACZ,IAAI,EAAEC,OAAO,EAAEY,UAAU,EAAE;EACnE,MAAMC,KAAK,GAAGd,IAAI,CAACe,MAAM,CAACF,UAAU,CAAC;EACrC,MAAMX,eAAe,GAAGF,IAAI,CAACI,WAAW,CAACU,KAAK,CAACX,UAAU,CAAC;EAC1D,OAAOJ,0BAA0B,CAACC,IAAI,EAAEC,OAAO,EAAEC,eAAe,CAAC;AACnE;AAUA,OAAO,SAASc,wBAAwBA,CACtChB,IAAU,EACVC,OAA6B,EAC7BgB,QAA+B,EACnB;EAAA,IAAAC,eAAA,EAAAC,iBAAA;EACZ,MAAMC,YAAY,GAAG,OAAOH,QAAQ,KAAK,QAAQ,IAAAC,eAAA,GAAGlB,IA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KAAK,EAAED,CAAC,EAAE,EAAE;IAC3C,MAAME,MAAM,GAAG,IAAIV,SAAS,CAC1Bd,WAAW,EACXF,UAAU,GAAGwB,CAAC,GAAGH,mBAAmB,EACpCF,2BACF,CAAC;IACDI,MAAM,CAACI,GAAG,CAACD,MAAM,EAAEF,CAAC,GAAGL,2BAA2B,CAAC;EACrD;EACA,OAAOI,MAAM;AACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAccessorTypeFromSize, getComponentTypeFromArray } from
|
|
1
|
+
import { getAccessorTypeFromSize, getComponentTypeFromArray } from "./gltf-utils.js";
|
|
2
2
|
export function getGLTFAccessors(attributes) {
|
|
3
3
|
const accessors = {};
|
|
4
4
|
for (const name in attributes) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-attribute-utils.js","names":["getAccessorTypeFromSize","getComponentTypeFromArray","getGLTFAccessors","attributes","accessors","name","attribute","glTFAccessor","getGLTFAccessor","buffer","size","count","getAccessorData","value","byteOffset","type","componentType","ArrayBuffer","isView","toTypedArray","Float32Array","length","array","ArrayType","convertTypedArrays","arguments","undefined","Array","isArray"],"sources":["../../../src/lib/gltf-utils/gltf-attribute-utils.ts"],"sourcesContent":["// import type {TypedArray} from '../types/loader-utils';\nimport type {GLTFAccessor} from '../types/gltf-json-schema';\n// TODO - remove\nimport {getAccessorTypeFromSize, getComponentTypeFromArray} from './gltf-utils';\n\n// Returns a fresh attributes object with glTF-standardized attributes names\n// Attributes that cannot be identified will not be included\n// Removes `indices` if present, as it should be stored separately from the attributes\nexport function getGLTFAccessors(attributes): {[key: string]: GLTFAccessor} {\n const accessors = {};\n for (const name in attributes) {\n const attribute = attributes[name];\n if (name !== 'indices') {\n const glTFAccessor = getGLTFAccessor(attribute);\n accessors[name] = glTFAccessor;\n }\n }\n return accessors;\n}\n\n// Fix up a single accessor.\n// Input: typed array or a partial accessor object\n// Return: accessor object\nexport function getGLTFAccessor(attribute) {\n const {buffer, size, count} = getAccessorData(attribute);\n\n const glTFAccessor: GLTFAccessor = {\n // glTF Accessor values\n // TODO: Instead of a bufferView index we could have an actual buffer (typed array)\n // bufferView: null,\n // TODO: Deprecate `value` in favor of bufferView?\n // @ts-ignore\n value: buffer,\n size, // Decoded `type` (e.g. SCALAR)\n\n byteOffset: 0,\n count,\n type: getAccessorTypeFromSize(size),\n componentType: getComponentTypeFromArray(buffer)\n };\n\n return glTFAccessor;\n}\n\n// export function getGLTFAttribute(data, gltfAttributeName): GLTFAccessor {\n// return data.attributes[data.glTFAttributeMap[gltfAttributeName]];\n// }\n\nfunction getAccessorData(attribute) {\n let buffer = attribute;\n let size = 1;\n let count = 0;\n\n if (attribute && attribute.value) {\n buffer = attribute.value;\n size = attribute.size || 1;\n }\n\n if (buffer) {\n if (!ArrayBuffer.isView(buffer)) {\n buffer = toTypedArray(buffer, Float32Array);\n }\n count = buffer.length / size;\n }\n\n return {buffer, size, count};\n}\n\n// Convert non-typed arrays to arrays of specified format\nfunction toTypedArray(array, ArrayType, convertTypedArrays = false) {\n if (!array) {\n return null;\n }\n if (Array.isArray(array)) {\n return new ArrayType(array);\n }\n if (convertTypedArrays && !(array instanceof ArrayType)) {\n return new ArrayType(array);\n }\n return array;\n}\n"],"mappings":"SAGQA,uBAAuB,EAAEC,yBAAyB;AAK1D,OAAO,SAASC,gBAAgBA,CAACC,UAAU,EAAiC;EAC1E,MAAMC,SAAS,GAAG,CAAC,CAAC;EACpB,KAAK,MAAMC,IAAI,IAAIF,UAAU,EAAE;IAC7B,MAAMG,SAAS,GAAGH,UAAU,CAACE,IAAI,CAAC;IAClC,IAAIA,IAAI,KAAK,SAAS,EAAE;MACtB,MAAME,YAAY,GAAGC,eAAe,CAACF,SAAS,CAAC;MAC/CF,SAAS,CAACC,IAAI,CAAC,GAAGE,YAAY;IAChC;EACF;EACA,OAAOH,SAAS;AAClB;AAKA,OAAO,SAASI,eAAeA,CAACF,SAAS,EAAE;EACzC,MAAM;IAACG,MAAM;IAA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AIA,SAAS,CAACD,KAAK,CAAC;EAC7B;EACA,OAAOA,KAAK;AACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-constants.js","names":["COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","BYTES","getBytesFromComponentType","componentType","getSizeFromAccessorType","type","getGLEnumFromSamplerParameter","parameter","GL_TEXTURE_MAG_FILTER","GL_TEXTURE_MIN_FILTER","GL_TEXTURE_WRAP_S","GL_TEXTURE_WRAP_T","PARAMETER_MAP","magFilter","minFilter","wrapS","wrapT"],"sources":["../../../src/lib/gltf-utils/gltf-constants.ts"],"sourcesContent":["export const COMPONENTS = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16\n};\n\nexport const BYTES = {\n 5120: 1, // BYTE\n 5121: 1, // UNSIGNED_BYTE\n 5122: 2, // SHORT\n 5123: 2, // UNSIGNED_SHORT\n 5125: 4, // UNSIGNED_INT\n 5126: 4 // FLOAT\n};\n\n// ENUM LOOKUP\n\nexport function getBytesFromComponentType(componentType) {\n return BYTES[componentType];\n}\n\nexport function getSizeFromAccessorType(type) {\n return COMPONENTS[type];\n}\n\nexport function getGLEnumFromSamplerParameter(parameter) {\n const GL_TEXTURE_MAG_FILTER = 0x2800;\n const GL_TEXTURE_MIN_FILTER = 0x2801;\n const GL_TEXTURE_WRAP_S = 0x2802;\n const GL_TEXTURE_WRAP_T = 0x2803;\n\n const PARAMETER_MAP = {\n magFilter: GL_TEXTURE_MAG_FILTER,\n minFilter: GL_TEXTURE_MIN_FILTER,\n wrapS: GL_TEXTURE_WRAP_S,\n wrapT: GL_TEXTURE_WRAP_T\n };\n\n return PARAMETER_MAP[parameter];\n}\n"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;EACxBC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,KAAK,GAAG;EACnB,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE;AACR,CAAC;AAID,OAAO,SAASC,yBAAyBA,CAACC,aAAa,EAAE;EACvD,OAAOF,KAAK,CAACE,aAAa,CAAC;AAC7B;AAEA,OAAO,SAASC,uBAAuBA,CAACC,IAAI,EAAE;EAC5C,OAAOZ,UAAU,CAACY,IAAI,CAAC;AACzB;AAEA,OAAO,SAASC,6BAA6BA,CAACC,SAAS,EAAE;EACvD,MAAMC,qBAAqB,GAAG,MAAM;EACpC,MAAMC,qBAAqB,GAAG,MAAM;EACpC,MAAMC,iBAAiB,GAAG,MAAM;EAChC,MAAMC,iBAAiB,GAAG,MAAM;EAEhC,MAAMC,aAAa,GAAG;IACpBC,SAAS,EAAEL,qBAAqB;IAChCM,SAAS,EAAEL,qBAAqB;IAChCM,KAAK,EAAEL,iBAAiB;IACxBM,KAAK,EAAEL;EACT,CAAC;EAED,OAAOC,aAAa,CAACL,SAAS,CAAC;AACjC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { GLTFWithBuffers } from '../types/gltf-types';
|
|
2
1
|
import type { GLTFPostprocessed } from '../types/gltf-postprocessed-schema';
|
|
3
2
|
export declare function getAccessorTypeFromSize(size: any): string;
|
|
4
3
|
export declare function getComponentTypeFromArray(typedArray: any): number;
|
|
@@ -6,8 +5,9 @@ export declare function getAccessorArrayTypeAndLength(accessor: any, bufferView:
|
|
|
6
5
|
ArrayType: any;
|
|
7
6
|
length: number;
|
|
8
7
|
byteLength: number;
|
|
8
|
+
componentByteSize: any;
|
|
9
|
+
numberOfComponentsInElement: any;
|
|
9
10
|
};
|
|
10
|
-
export declare function getFloat32ArrayForAccessor(gltfData: GLTFWithBuffers, texCoordAccessor: number): Float32Array | null;
|
|
11
11
|
/**
|
|
12
12
|
* Calculate the GPU memory used by a GLTF tile, for both buffer and texture memory
|
|
13
13
|
* @param gltf - the gltf content of a GLTF tile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/gltf-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"gltf-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/gltf-utils/gltf-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,oCAAoC,CAAC;AA8D1E,wBAAgB,uBAAuB,CAAC,IAAI,KAAA,UAG3C;AAED,wBAAgB,yBAAyB,CAAC,UAAU,KAAA,UAMnD;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,KAAA,EAAE,UAAU,KAAA;;;;;;EAUjE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAiBlE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assert } from
|
|
2
|
-
import { BYTES, COMPONENTS } from
|
|
1
|
+
import { assert } from "../utils/assert.js";
|
|
2
|
+
import { BYTES, COMPONENTS } from "../gltf-utils/gltf-constants.js";
|
|
3
3
|
const MIPMAP_FACTOR = 1.33;
|
|
4
4
|
const TYPES = ['SCALAR', 'VEC2', 'VEC3', 'VEC4'];
|
|
5
5
|
const ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [[Int8Array, 5120], [Uint8Array, 5121], [Int16Array, 5122], [Uint16Array, 5123], [Uint32Array, 5125], [Float32Array, 5126], [Float64Array, 5130]];
|
|
@@ -47,41 +47,16 @@ export function getAccessorArrayTypeAndLength(accessor, bufferView) {
|
|
|
47
47
|
const length = accessor.count * components;
|
|
48
48
|
const byteLength = accessor.count * components * bytesPerComponent;
|
|
49
49
|
assert(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
50
|
+
const componentByteSize = BYTES[accessor.componentType];
|
|
51
|
+
const numberOfComponentsInElement = COMPONENTS[accessor.type];
|
|
50
52
|
return {
|
|
51
53
|
ArrayType,
|
|
52
54
|
length,
|
|
53
|
-
byteLength
|
|
55
|
+
byteLength,
|
|
56
|
+
componentByteSize,
|
|
57
|
+
numberOfComponentsInElement
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
|
-
export function getFloat32ArrayForAccessor(gltfData, texCoordAccessor) {
|
|
57
|
-
var _gltfData$json$access;
|
|
58
|
-
const accessor = (_gltfData$json$access = gltfData.json.accessors) === null || _gltfData$json$access === void 0 ? void 0 : _gltfData$json$access[texCoordAccessor];
|
|
59
|
-
if (accessor && typeof accessor.bufferView !== 'undefined') {
|
|
60
|
-
var _gltfData$json$buffer;
|
|
61
|
-
const bufferView = (_gltfData$json$buffer = gltfData.json.bufferViews) === null || _gltfData$json$buffer === void 0 ? void 0 : _gltfData$json$buffer[accessor.bufferView];
|
|
62
|
-
if (bufferView) {
|
|
63
|
-
const {
|
|
64
|
-
arrayBuffer,
|
|
65
|
-
byteOffset: bufferByteOffset
|
|
66
|
-
} = gltfData.buffers[bufferView.buffer];
|
|
67
|
-
const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
|
|
68
|
-
const {
|
|
69
|
-
ArrayType,
|
|
70
|
-
length
|
|
71
|
-
} = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
72
|
-
const bytes = BYTES[accessor.componentType];
|
|
73
|
-
const components = COMPONENTS[accessor.type];
|
|
74
|
-
const elementAddressScale = bufferView.byteStride || bytes * components;
|
|
75
|
-
const result = new Float32Array(length);
|
|
76
|
-
for (let i = 0; i < accessor.count; i++) {
|
|
77
|
-
const uv = new ArrayType(arrayBuffer, byteOffset + i * elementAddressScale, 2);
|
|
78
|
-
result.set(uv, i * components);
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
60
|
export function getMemoryUsageGLTF(gltf) {
|
|
86
61
|
let {
|
|
87
62
|
images,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-utils.js","names":["assert","BYTES","COMPONENTS","MIPMAP_FACTOR","TYPES","ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT","Int8Array","Uint8Array","Int16Array","Uint16Array","Uint32Array","Float32Array","Float64Array","ARRAY_TO_COMPONENT_TYPE","Map","ATTRIBUTE_TYPE_TO_COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE","ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY","getAccessorTypeFromSize","size","type","getComponentTypeFromArray","typedArray","componentType","get","constructor","Error","getAccessorArrayTypeAndLength","accessor","bufferView","ArrayType","components","bytesPerComponent","length","count","byteLength","componentByteSize","numberOfComponentsInElement","getMemoryUsageGLTF","gltf","images","bufferViews","imageBufferViews","map","i","filter","view","includes","bufferMemory","reduce","acc","pixelCount","image","width","height","Math","ceil"],"sources":["../../../src/lib/gltf-utils/gltf-utils.ts"],"sourcesContent":["import {assert} from '../utils/assert';\n\nimport type {GLTFPostprocessed} from '../types/gltf-postprocessed-schema';\nimport {BYTES, COMPONENTS} from '../gltf-utils/gltf-constants';\n\n/**\n * Memory needed to store texture and all mipmap levels 1 + 1/4 + 1/16 + 1/64 + ...\n * Minimum 1.33, but due to GPU layout may be 1.5\n */\nconst MIPMAP_FACTOR = 1.33;\n\nconst TYPES = ['SCALAR', 'VEC2', 'VEC3', 'VEC4'];\n\ntype TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nconst ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT: [TypedArrayConstructor, number][] = [\n [Int8Array, 5120],\n [Uint8Array, 5121],\n [Int16Array, 5122],\n [Uint16Array, 5123],\n [Uint32Array, 5125],\n [Float32Array, 5126],\n [Float64Array, 5130]\n];\nconst ARRAY_TO_COMPONENT_TYPE = new Map<TypedArrayConstructor, number>(\n ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT\n);\n\nconst ATTRIBUTE_TYPE_TO_COMPONENTS = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16\n};\n\nconst ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {\n 5120: 1,\n 5121: 1,\n 5122: 2,\n 5123: 2,\n 5125: 4,\n 5126: 4\n};\n\nconst ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {\n 5120: Int8Array,\n 5121: Uint8Array,\n 5122: Int16Array,\n 5123: Uint16Array,\n 5125: Uint32Array,\n 5126: Float32Array\n};\n\nexport function getAccessorTypeFromSize(size) {\n const type = TYPES[size - 1];\n return type || TYPES[0];\n}\n\nexport function getComponentTypeFromArray(typedArray) {\n const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);\n if (!componentType) {\n throw new Error('Illegal typed array');\n }\n return componentType;\n}\n\nexport function getAccessorArrayTypeAndLength(accessor, bufferView) {\n const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];\n const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];\n const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];\n const length = accessor.count * components;\n const byteLength = accessor.count * components * bytesPerComponent;\n assert(byteLength >= 0 && byteLength <= bufferView.byteLength);\n const componentByteSize = BYTES[accessor.componentType];\n const numberOfComponentsInElement = COMPONENTS[accessor.type];\n return {ArrayType, length, byteLength, componentByteSize, numberOfComponentsInElement};\n}\n\n/**\n * Calculate the GPU memory used by a GLTF tile, for both buffer and texture memory\n * @param gltf - the gltf content of a GLTF tile\n * @returns - total memory usage in bytes\n */\nexport function getMemoryUsageGLTF(gltf: GLTFPostprocessed): number {\n let {images, bufferViews} = gltf;\n images = images || [];\n bufferViews = bufferViews || [];\n const imageBufferViews = images.map((i) => i.bufferView);\n bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view as any));\n\n const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);\n\n // Assume each pixel of the texture is 4 channel with mimmaps (which add 33%)\n // TODO correctly handle compressed textures\n const pixelCount = images.reduce((acc, image) => {\n // @ts-ignore\n const {width, height} = (image as any).image;\n return acc + width * height;\n }, 0);\n return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);\n}\n"],"mappings":"SAAQA,MAAM;AAAA,SAGNC,KAAK,EAAEC,UAAU;AAMzB,MAAMC,aAAa,GAAG,IAAI;AAE1B,MAAMC,KAAK,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;AAYhD,MAAMC,mCAAsE,GAAG,CAC7E,CAACC,SAAS,EAAE,IAAI,CAAC,EACjB,CAACC,UAAU,EAAE,IAAI,CAAC,EAClB,CAACC,UAAU,EAAE,IAAI,CAAC,EAClB,CAACC,WAAW,EAAE,IAAI,CAAC,EACnB,CAACC,WAAW,EAAE,IAAI,CAAC,EACnB,CAACC,YAAY,EAAE,IAAI,CAAC,EACpB,CAACC,YAAY,EAAE,IAAI,CAAC,CACrB;AACD,MAAMC,uBAAuB,GAAG,IAAIC,GAAG,CACrCT,mCACF,CAAC;AAED,MAAMU,4BAA4B,GAAG;EACnCC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CAAC;EACPC,IAAI,EAAE,CA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Uri || options.uri;
|
|
7
7
|
if (!baseUrl) {
|
|
8
|
-
throw new Error(
|
|
8
|
+
throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
|
|
9
9
|
}
|
|
10
10
|
return baseUrl.substr(0, baseUrl.lastIndexOf('/') + 1) + url;
|
|
11
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-url.js","names":["resolveUrl","url","options","absolute","startsWith","baseUrl","baseUri","uri","Error","substr","lastIndexOf"],"sources":["../../../src/lib/gltf-utils/resolve-url.ts"],"sourcesContent":["// Resolves a relative url against a baseUrl\n// If url is absolute, return it unchanged\nexport function resolveUrl(url, options) {\n // TODO: Use better logic to handle all protocols plus not delay on data\n const absolute = url.startsWith('data:') || url.startsWith('http:') || url.startsWith('https:');\n if (absolute) {\n return url;\n }\n const baseUrl = options.baseUri || options.uri;\n if (!baseUrl) {\n throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);\n }\n return baseUrl.substr(0, baseUrl.lastIndexOf('/') + 1) + url;\n}\n"],"mappings":"AAEA,OAAO,SAASA,UAAUA,CAACC,GAAG,EAAEC,OAAO,EAAE;EAEvC,MAAMC,QAAQ,GAAGF,GAAG,CAACG,UAAU,CAAC,OAAO,CAAC,IAAIH,GAAG,CAACG,UAAU,CAAC,OAAO,CAAC,IAAIH,GAAG,CAACG,UAAU,CAAC,QAAQ,CAAC;EAC/F,IAAID,QAAQ,EAAE;IACZ,OAAOF,GAAG;EACZ;EACA,MAAMI,OAAO,GAAGH,OAAO,CAACI,OAAO,IAAIJ,OAAO,CAACK,GAAG;EAC9C,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIG,KAAK,CAAE,sDAAqDP,GAAI,EAAC,CAAC;EAC9E;EACA,OAAOI,OAAO,CAACI,MAAM,CAAC,CAAC,EAAEJ,OAAO,CAACK,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGT,GAAG;AAC9D"}
|
|
@@ -10,7 +10,11 @@ const GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
|
|
|
10
10
|
const GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
|
|
11
11
|
function getMagicString(dataView) {
|
|
12
12
|
let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
13
|
-
return
|
|
13
|
+
return `\
|
|
14
|
+
${String.fromCharCode(dataView.getUint8(byteOffset + 0))}\
|
|
15
|
+
${String.fromCharCode(dataView.getUint8(byteOffset + 1))}\
|
|
16
|
+
${String.fromCharCode(dataView.getUint8(byteOffset + 2))}\
|
|
17
|
+
${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
|
|
14
18
|
}
|
|
15
19
|
export function isGLB(arrayBuffer) {
|
|
16
20
|
let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -47,7 +51,7 @@ export function parseGLBSync(glb, arrayBuffer) {
|
|
|
47
51
|
case 2:
|
|
48
52
|
return parseGLBV2(glb, dataView, byteOffset, options = {});
|
|
49
53
|
default:
|
|
50
|
-
throw new Error(
|
|
54
|
+
throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
function parseGLBV1(glb, dataView, byteOffset) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-glb.js","names":["padToNBytes","assert","LITTLE_ENDIAN","MAGIC_glTF","GLB_FILE_HEADER_SIZE","GLB_CHUNK_HEADER_SIZE","GLB_CHUNK_TYPE_JSON","GLB_CHUNK_TYPE_BIN","GLB_V1_CONTENT_FORMAT_JSON","GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED","GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED","getMagicString","dataView","byteOffset","arguments","length","undefined","String","fromCharCode","getUint8","isGLB","arrayBuffer","options","DataView","magic","magic1","getUint32","parseGLBSync","glb","type","version","byteLength","Object","assign","header","hasBinChunk","json","binChunks","parseGLBV1","parseGLBV2","Error","contentLength","contentFormat","parseJSONChunk","parseBINChunk","parseGLBChunksSync","chunkLength","chunkFormat","strict","jsonChunk","Uint8Array","buffer","textDecoder","TextDecoder","jsonText","decode","JSON","parse","push"],"sources":["../../../src/lib/parsers/parse-glb.ts"],"sourcesContent":["/* eslint-disable camelcase, max-statements */\n// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#glb-file-format-specification\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF\nimport type {GLB} from '../types/glb-types';\nimport {padToNBytes, assert} from '@loaders.gl/loader-utils';\n\n/** Options for parsing a GLB */\nexport type ParseGLBOptions = {\n /** @deprecated This option was used by XVIZ protocol to define a non-standard magic number */\n magic?: number;\n /** @deprecated This option was used by XVIZ protocol to embed non-standard chunks */\n strict?: boolean;\n};\n\n/** Binary GLTF is little endian. */\nconst LITTLE_ENDIAN = true;\n\n/** 'glTF' in Big-Endian ASCII */\nconst MAGIC_glTF = 0x676c5446;\nconst GLB_FILE_HEADER_SIZE = 12;\nconst GLB_CHUNK_HEADER_SIZE = 8;\nconst GLB_CHUNK_TYPE_JSON = 0x4e4f534a;\nconst GLB_CHUNK_TYPE_BIN = 0x004e4942;\nconst GLB_V1_CONTENT_FORMAT_JSON = 0x0;\n\n/** @deprecated - Backward compatibility for old xviz files */\nconst GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;\n/** @deprecated - Backward compatibility for old xviz files */\nconst GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;\n\nfunction getMagicString(dataView, byteOffset = 0) {\n return `\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 0))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 1))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 2))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;\n}\n\n/** Check if the contents of an array buffer contains GLB byte markers */\nexport function isGLB(\n arrayBuffer: ArrayBuffer,\n byteOffset: number = 0,\n options: ParseGLBOptions = {}\n): boolean {\n const dataView = new DataView(arrayBuffer);\n // Check that GLB Header starts with the magic number\n const {magic = MAGIC_glTF} = options;\n const magic1 = dataView.getUint32(byteOffset, false);\n return magic1 === magic || magic1 === MAGIC_glTF;\n}\n\n/**\n * Synchronously parse a GLB\n * @param glb - Target, Output is stored there\n * @param arrayBuffer - Input data\n * @param byteOffset - Offset into arrayBuffer to start parsing from (for \"embedded\" GLBs, e.g. in 3D tiles)\n * @param options\n * @returns\n */\nexport function parseGLBSync(\n glb: GLB,\n arrayBuffer: ArrayBuffer,\n byteOffset: number = 0,\n options: ParseGLBOptions = {}\n) {\n // Check that GLB Header starts with the magic number\n const dataView = new DataView(arrayBuffer);\n\n // Compare format with GLBLoader documentation\n const type = getMagicString(dataView, byteOffset + 0);\n const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN); // Version 2 of binary glTF container format\n const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN); // Total byte length of binary file\n\n Object.assign(glb, {\n // Put less important stuff in a header, to avoid clutter\n header: {\n byteOffset, // Byte offset into the initial arrayBuffer\n byteLength,\n hasBinChunk: false\n },\n\n type,\n version,\n\n json: {},\n binChunks: []\n } as GLB);\n\n byteOffset += GLB_FILE_HEADER_SIZE;\n\n switch (glb.version) {\n case 1:\n return parseGLBV1(glb, dataView, byteOffset);\n case 2:\n return parseGLBV2(glb, dataView, byteOffset, (options = {}));\n default:\n throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);\n }\n}\n\n/**\n * Parse a V1 GLB\n * @param glb - target, output is stored in this object\n * @param dataView - Input, memory to be parsed\n * @param byteOffset - Offset of first byte of GLB data in the data view\n * @returns Number of bytes parsed (there could be additional non-GLB data after the GLB)\n */\nfunction parseGLBV1(glb: GLB, dataView: DataView, byteOffset: number): number {\n // Sanity: ensure file is big enough to hold at least the headers\n assert(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);\n\n // Explanation of GLB structure:\n // https://cloud.githubusercontent.com/assets/3479527/22600725/36b87122-ea55-11e6-9d40-6fd42819fcab.png\n const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN); // Byte length of chunk\n const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN); // Chunk format as uint32\n byteOffset += GLB_CHUNK_HEADER_SIZE;\n\n // GLB v1 only supports a single chunk type\n assert(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);\n\n parseJSONChunk(glb, dataView, byteOffset, contentLength);\n // No need to call the function padToBytes() from parseJSONChunk()\n byteOffset += contentLength;\n byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);\n\n return byteOffset;\n}\n\n/**\n * Parse a V2 GLB\n * @param glb - target, output is stored in this object\n * @param dataView - Input, memory to be parsed\n * @param byteOffset - Offset of first byte of GLB data in the data view\n * @returns Number of bytes parsed (there could be additional non-GLB data after the GLB)\n */\nfunction parseGLBV2(\n glb: GLB,\n dataView: DataView,\n byteOffset: number,\n options: ParseGLBOptions\n): number {\n // Sanity: ensure file is big enough to hold at least the first chunk header\n assert(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);\n\n parseGLBChunksSync(glb, dataView, byteOffset, options);\n\n return byteOffset + glb.header.byteLength;\n}\n\n/** Iterate over GLB chunks and parse them */\nfunction parseGLBChunksSync(\n glb: GLB,\n dataView: DataView,\n byteOffset: number,\n options: ParseGLBOptions\n) {\n // Per spec we must iterate over chunks, ignoring all except JSON and BIN\n // Iterate as long as there is space left for another chunk header\n while (byteOffset + 8 <= glb.header.byteLength) {\n const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN); // Byte length of chunk\n const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN); // Chunk format as uint32\n byteOffset += GLB_CHUNK_HEADER_SIZE;\n\n // Per spec we must iterate over chunks, ignoring all except JSON and BIN\n switch (chunkFormat) {\n case GLB_CHUNK_TYPE_JSON:\n parseJSONChunk(glb, dataView, byteOffset, chunkLength);\n break;\n case GLB_CHUNK_TYPE_BIN:\n parseBINChunk(glb, dataView, byteOffset, chunkLength);\n break;\n\n // Backward compatibility for very old xviz files\n case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:\n if (!options.strict) {\n parseJSONChunk(glb, dataView, byteOffset, chunkLength);\n }\n break;\n case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:\n if (!options.strict) {\n parseBINChunk(glb, dataView, byteOffset, chunkLength);\n }\n break;\n\n default:\n // Ignore, per spec\n // console.warn(`Unknown GLB chunk type`); // eslint-disable-line\n break;\n }\n\n byteOffset += padToNBytes(chunkLength, 4);\n }\n\n return byteOffset;\n}\n\n/* Parse a GLB JSON chunk */\nfunction parseJSONChunk(glb: GLB, dataView: DataView, byteOffset: number, chunkLength: number) {\n // 1. Create a \"view\" of the binary encoded JSON data inside the GLB\n const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);\n\n // 2. Decode the JSON binary array into clear text\n const textDecoder = new TextDecoder('utf8');\n const jsonText = textDecoder.decode(jsonChunk);\n\n // 3. Parse the JSON text into a JavaScript data structure\n glb.json = JSON.parse(jsonText);\n\n return padToNBytes(chunkLength, 4);\n}\n\n/** Parse a GLB BIN chunk */\nfunction parseBINChunk(glb: GLB, dataView, byteOffset, chunkLength) {\n // Note: BIN chunk can be optional\n glb.header.hasBinChunk = true;\n glb.binChunks.push({\n byteOffset,\n byteLength: chunkLength,\n arrayBuffer: dataView.buffer\n // TODO - copy, or create typed array view?\n });\n\n return padToNBytes(chunkLength, 4);\n}\n"],"mappings":"AAIA,SAAQA,WAAW,EAAEC,MAAM,QAAO,0BAA0B;AAW5D,MAAMC,aAAa,GAAG,IAAI;AAG1B,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,oBAAoB,GAAG,EAAE;AAC/B,MAAMC,qBAAq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,EAAEiC,WAAW,EAAE;EAElElB,GAAG,CAACM,MAAM,CAACC,WAAW,GAAG,IAAI;EAC7BP,GAAG,CAACS,SAAS,CAACqB,IAAI,CAAC;IACjB7C,UAAU;IACVkB,UAAU,EAAEe,WAAW;IACvBzB,WAAW,EAAET,QAAQ,CAACuC;EAExB,CAAC,CAAC;EAEF,OAAOnD,WAAW,CAAC8C,WAAW,EAAE,CAAC,CAAC;AACpC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { parseJSON, sliceArrayBuffer, parseFromContext } from '@loaders.gl/loader-utils';
|
|
2
2
|
import { ImageLoader } from '@loaders.gl/images';
|
|
3
3
|
import { BasisLoader, selectSupportedBasisFormat } from '@loaders.gl/textures';
|
|
4
|
-
import { assert } from
|
|
5
|
-
import { isGLB, parseGLBSync } from
|
|
6
|
-
import { resolveUrl } from
|
|
7
|
-
import { getTypedArrayForBufferView } from
|
|
8
|
-
import { preprocessExtensions, decodeExtensions } from
|
|
9
|
-
import { normalizeGLTFV1 } from
|
|
4
|
+
import { assert } from "../utils/assert.js";
|
|
5
|
+
import { isGLB, parseGLBSync } from "./parse-glb.js";
|
|
6
|
+
import { resolveUrl } from "../gltf-utils/resolve-url.js";
|
|
7
|
+
import { getTypedArrayForBufferView } from "../gltf-utils/get-typed-array.js";
|
|
8
|
+
import { preprocessExtensions, decodeExtensions } from "../api/gltf-extensions.js";
|
|
9
|
+
import { normalizeGLTFV1 } from "../api/normalize-gltf-v1.js";
|
|
10
10
|
export function isGLTF(arrayBuffer, options) {
|
|
11
11
|
const byteOffset = 0;
|
|
12
12
|
return isGLB(arrayBuffer, byteOffset, options);
|
|
@@ -43,7 +43,7 @@ function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
|
43
43
|
} else if (data instanceof ArrayBuffer) {
|
|
44
44
|
const glb = {};
|
|
45
45
|
byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
|
|
46
|
-
assert(glb.type === 'glTF',
|
|
46
|
+
assert(glb.type === 'glTF', `Invalid GLB magic string ${glb.type}`);
|
|
47
47
|
gltf._glb = glb;
|
|
48
48
|
gltf.json = glb.json;
|
|
49
49
|
} else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-gltf.js","names":["parseJSON","sliceArrayBuffer","parseFromContext","ImageLoader","BasisLoader","selectSupportedBasisFormat","assert","isGLB","parseGLBSync","resolveUrl","getTypedArrayForBufferView","preprocessExtensions","decodeExtensions","normalizeGLTFV1","isGLTF","arrayBuffer","options","byteOffset","parseGLTF","gltf","arrayBufferOrString","_options$gltf","_options$gltf2","_options$gltf3","arguments","length","undefined","context","parseGLTFContainerSync","normalize","loadBuffers","json","buffers","loadImages","data","uri","baseUri","ArrayBuffer","textDecoder","TextDecoder","decode","glb","type","_glb","Array","fill","header","hasBinChunk","binChunks","byteLength","images","i","buffer","_context$fetch","_response$arrayBuffer","fetch","response","call","imageIndices","getReferencesImageIndices","promises","imageIndex","push","loadImage","Promise","all","Set","textures","texture","source","add","from","sort","image","index","hasOwnProperty","bufferView","Number","isFinite","array","parsedImage","mimeType","basis","format","compressed","mipmaps","width","height"],"sources":["../../../src/lib/parsers/parse-gltf.ts"],"sourcesContent":["/* eslint-disable camelcase, max-statements, no-restricted-globals */\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {GLB} from '../types/glb-types';\nimport type {ParseGLBOptions} from './parse-glb';\n\nimport type {ImageType, TextureLevel} from '@loaders.gl/schema';\nimport {parseJSON, sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {BasisLoader, selectSupportedBasisFormat} from '@loaders.gl/textures';\n\nimport {assert} from '../utils/assert';\nimport {isGLB, parseGLBSync} from './parse-glb';\nimport {resolveUrl} from '../gltf-utils/resolve-url';\nimport {getTypedArrayForBufferView} from '../gltf-utils/get-typed-array';\nimport {preprocessExtensions, decodeExtensions} from '../api/gltf-extensions';\nimport {normalizeGLTFV1} from '../api/normalize-gltf-v1';\n\n/** */\nexport type ParseGLTFOptions = ParseGLBOptions & {\n normalize?: boolean;\n loadImages?: boolean;\n loadBuffers?: boolean;\n decompressMeshes?: boolean;\n excludeExtensions?: string[];\n\n /** @deprecated not supported in v4. `postProcessGLTF()` must be called by the application */\n postProcess?: false;\n};\n\n/** Check if an array buffer appears to contain GLTF data */\nexport function isGLTF(arrayBuffer: ArrayBuffer, options?: ParseGLTFOptions): boolean {\n const byteOffset = 0;\n return isGLB(arrayBuffer, byteOffset, options);\n}\n\nexport async function parseGLTF(\n gltf: GLTFWithBuffers,\n arrayBufferOrString,\n byteOffset = 0,\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<GLTFWithBuffers> {\n parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);\n\n normalizeGLTFV1(gltf, {normalize: options?.gltf?.normalize});\n\n preprocessExtensions(gltf, options, context);\n\n // Load linked buffers asynchronously and decodes base64 buffers in parallel\n if (options?.gltf?.loadBuffers && gltf.json.buffers) {\n await loadBuffers(gltf, options, context);\n }\n\n // loadImages and decodeExtensions should not be running in parallel, because\n // decodeExtensions uses data from images taken during the loadImages call.\n if (options?.gltf?.loadImages) {\n await loadImages(gltf, options, context);\n }\n\n await decodeExtensions(gltf, options, context);\n\n return gltf;\n}\n\n/**\n *\n * @param gltf\n * @param data - can be ArrayBuffer (GLB), ArrayBuffer (Binary JSON), String (JSON), or Object (parsed JSON)\n * @param byteOffset\n * @param options\n */\nfunction parseGLTFContainerSync(gltf, data, byteOffset, options) {\n // Initialize gltf container\n if (options.uri) {\n gltf.baseUri = options.uri;\n }\n\n // If data is binary and starting with magic bytes, assume binary JSON text, convert to string\n if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(data);\n }\n\n if (typeof data === 'string') {\n // If string, try to parse as JSON\n gltf.json = parseJSON(data);\n } else if (data instanceof ArrayBuffer) {\n // If still ArrayBuffer, parse as GLB container\n const glb: GLB = {} as GLB;\n byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);\n\n assert(glb.type === 'glTF', `Invalid GLB magic string ${glb.type}`);\n\n gltf._glb = glb;\n gltf.json = glb.json;\n } else {\n assert(false, 'GLTF: must be ArrayBuffer or string');\n }\n\n // Populate buffers\n // Create an external buffers array to hold binary data\n const buffers = gltf.json.buffers || [];\n gltf.buffers = new Array(buffers.length).fill(null);\n\n // Populates JSON and some bin chunk info\n if (gltf._glb && gltf._glb.header.hasBinChunk) {\n const {binChunks} = gltf._glb;\n gltf.buffers[0] = {\n arrayBuffer: binChunks[0].arrayBuffer,\n byteOffset: binChunks[0].byteOffset,\n byteLength: binChunks[0].byteLength\n };\n\n // TODO - this modifies JSON and is a post processing thing\n // gltf.json.buffers[0].data = gltf.buffers[0].arrayBuffer;\n // gltf.json.buffers[0].byteOffset = gltf.buffers[0].byteOffset;\n }\n\n // Populate images\n const images = gltf.json.images || [];\n gltf.images = new Array(images.length).fill({});\n}\n\n/** Asynchronously fetch and parse buffers, store in buffers array outside of json\n * TODO - traverse gltf and determine which buffers are actually needed\n */\nasync function loadBuffers(gltf: GLTFWithBuffers, options, context: LoaderContext) {\n // TODO\n const buffers = gltf.json.buffers || [];\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = buffers[i];\n if (buffer.uri) {\n const {fetch} = context;\n assert(fetch);\n\n const uri = resolveUrl(buffer.uri, options);\n const response = await context?.fetch?.(uri);\n const arrayBuffer = await response?.arrayBuffer?.();\n\n gltf.buffers[i] = {\n arrayBuffer,\n byteOffset: 0,\n byteLength: arrayBuffer.byteLength\n };\n\n delete buffer.uri;\n } else if (gltf.buffers[i] === null) {\n gltf.buffers[i] = {\n arrayBuffer: new ArrayBuffer(buffer.byteLength),\n byteOffset: 0,\n byteLength: buffer.byteLength\n };\n }\n }\n}\n\n/**\n * Loads all images\n * TODO - traverse gltf and determine which images are actually needed\n * @param gltf\n * @param options\n * @param context\n * @returns\n */\nasync function loadImages(gltf: GLTFWithBuffers, options, context: LoaderContext) {\n const imageIndices = getReferencesImageIndices(gltf);\n\n const images = gltf.json.images || [];\n\n const promises: Promise<any>[] = [];\n for (const imageIndex of imageIndices) {\n promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));\n }\n\n return await Promise.all(promises);\n}\n\n/** Make sure we only load images that are actually referenced by textures */\nfunction getReferencesImageIndices(gltf: GLTFWithBuffers): number[] {\n const imageIndices = new Set<number>();\n\n const textures = gltf.json.textures || [];\n for (const texture of textures) {\n if (texture.source !== undefined) {\n imageIndices.add(texture.source);\n }\n }\n\n return Array.from(imageIndices).sort();\n}\n\n/** Asynchronously fetches and parses one image, store in images array outside of json */\nasync function loadImage(\n gltf: GLTFWithBuffers,\n image,\n index: number,\n options,\n context: LoaderContext\n) {\n let arrayBuffer;\n\n if (image.uri && !image.hasOwnProperty('bufferView')) {\n const uri = resolveUrl(image.uri, options);\n\n const {fetch} = context;\n const response = await fetch(uri);\n\n arrayBuffer = await response.arrayBuffer();\n image.bufferView = {\n data: arrayBuffer\n };\n }\n\n if (Number.isFinite(image.bufferView)) {\n const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);\n arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);\n }\n\n assert(arrayBuffer, 'glTF image has no data');\n\n // Call `parse`\n let parsedImage = (await parseFromContext(\n arrayBuffer,\n [ImageLoader, BasisLoader],\n {\n ...options,\n mimeType: image.mimeType,\n basis: options.basis || {format: selectSupportedBasisFormat()}\n },\n context\n )) as ImageType | TextureLevel[][];\n\n if (parsedImage && parsedImage[0]) {\n parsedImage = {\n compressed: true,\n // @ts-expect-error\n mipmaps: false,\n width: parsedImage[0].width,\n height: parsedImage[0].height,\n data: parsedImage[0]\n };\n }\n // TODO making sure ImageLoader is overridable by using array of loaders\n // const parsedImage = await parse(arrayBuffer, [ImageLoader]);\n\n // Store the loaded image\n gltf.images = gltf.images || [];\n // @ts-expect-error TODO - sort out image typing asap\n gltf.images[index] = parsedImage;\n}\n"],"mappings":"AAQA,SAAQA,SAAS,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAO,0BAA0B;AACtF,SAAQC,WAAW,QAAO,oBAAoB;AAC9C,SAAQC,WAAW,EAAEC,0BAA0B,QAAO,sBAAsB;AAAC,SAErEC,MAAM;AAAA,SACNC,KAAK,EAAEC,YAAY;AAAA,SACnBC,UAAU;AAAA,SACVC,0BAA0B;AAAA,SAC1BC,oBAAoB,EAAEC,gBAAgB;AAAA,SACtCC,eAAe;AAevB,OAAO,SAASC,MAAMA,CAACC,WAAwB,EAAEC,OAA0B,EAAW;EACpF,MAAMC,UAAU,GAAG,CAAC;EACpB,OAAOV,KAAK,CAACQ,WAAW,EAAEE,UAAU,EAAED,OAAO,CAAC;AAChD;AAEA,OAAO,eAAeE,SAASA,CAC7BC,IAAqB,EACrBC,mBAAmB,EAIO;EAAA,IAAAC,aAAA,EAAAC,cAAA,EAAAC,cAAA;EAAA,IAH1BN,UAAU,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IACdR,OAA0B,GAAAQ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAC1BC,OAAsB,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEtBE,sBAAsB,CAACT,IAAI,EAAEC,mBAAmB,EAAEH,UAAU,EAAED,OAAO,CAAC;EAEtEH,eAAe,CAACM,IAAI,EAAE;IAACU,SAAS,EAAEb,OAAO,aAAPA,OAAO,wBAAAK,aAAA,GAAPL,OAAO,CAAEG,IAAI,cAAAE,aAAA,uBAAbA,aAAA,CAAeQ;EAAS,CAAC,CAAC;EAE5DlB,oBAAoB,CAACQ,IAAI,EAAEH,OAAO,EAAEW,OAAO,CAAC;EAG5C,IA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AG;MACjB1C,IAAI,EAAEnB;IACR,CAAC;EACH;EAEA,IAAI8D,MAAM,CAACC,QAAQ,CAACL,KAAK,CAACG,UAAU,CAAC,EAAE;IACrC,MAAMG,KAAK,GAAGrE,0BAA0B,CAACS,IAAI,CAACY,IAAI,EAAEZ,IAAI,CAACa,OAAO,EAAEyC,KAAK,CAACG,UAAU,CAAC;IACnF7D,WAAW,GAAGd,gBAAgB,CAAC8E,KAAK,CAAC3B,MAAM,EAAE2B,KAAK,CAAC9D,UAAU,EAAE8D,KAAK,CAAC9B,UAAU,CAAC;EAClF;EAEA3C,MAAM,CAACS,WAAW,EAAE,wBAAwB,CAAC;EAG7C,IAAIiE,WAAW,GAAI,MAAM9E,gBAAgB,CACvCa,WAAW,EACX,CAACZ,WAAW,EAAEC,WAAW,CAAC,EAC1B;IACE,GAAGY,OAAO;IACViE,QAAQ,EAAER,KAAK,CAACQ,QAAQ;IACxBC,KAAK,EAAElE,OAAO,CAACkE,KAAK,IAAI;MAACC,MAAM,EAAE9E,0BAA0B,CAAC;IAAC;EAC/D,CAAC,EACDsB,OACF,CAAkC;EAElC,IAAIqD,WAAW,IAAIA,WAAW,CAAC,CAAC,CAAC,EAAE;IACjCA,WAAW,GAAG;MACZI,UAAU,EAAE,IAAI;MAEhBC,OAAO,EAAE,KAAK;MACdC,KAAK,EAAEN,WAAW,CAAC,CAAC,CAAC,CAACM,KAAK;MAC3BC,MAAM,EAAEP,WAAW,CAAC,CAAC,CAAC,CAACO,MAAM;MAC7BrD,IAAI,EAAE8C,WAAW,CAAC,CAAC;IACrB,CAAC;EACH;EAKA7D,IAAI,CAAC+B,MAAM,GAAG/B,IAAI,CAAC+B,MAAM,IAAI,EAAE;EAE/B/B,IAAI,CAAC+B,MAAM,CAACwB,KAAK,CAAC,GAAGM,WAAW;AAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glb-types.js","names":[],"sources":["../../../src/lib/types/glb-types.ts"],"sourcesContent":["export type GLBBinChunk = {\n byteOffset: number;\n byteLength: number;\n arrayBuffer: ArrayBuffer;\n};\n\nexport type GLB = {\n type: string;\n version: number; // Version 2 of binary glTF container format\n\n // Put less important stuff in a header, to avoid clutter\n header: {\n byteOffset: number; // Byte offset into the initial arrayBuffer\n byteLength: number;\n hasBinChunk: boolean;\n };\n\n // Per spec we must iterate over chunks, ignoring all except JSON and BIN\n json: Record<string, any>;\n binChunks: GLBBinChunk[];\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-ext-feature-metadata-schema.js","names":[],"sources":["../../../src/lib/types/gltf-ext-feature-metadata-schema.ts"],"sourcesContent":["import {GLTFTextureInfo} from './gltf-json-schema';\n\n/* eslint-disable camelcase */\n\n/**\n * EXT_feature_metadata extension types\n * This extension has glTF-level metadata and primitive-level feature indexing and segmentation metadata\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n *\n * glTF-level metadata\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#gltf-extension-1\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata/schema/glTF.EXT_feature_metadata.schema.json\n */\nexport type GLTF_EXT_feature_metadata_GLTF = {\n /** An object defining classes and enums. */\n schema?: GLTF_EXT_feature_metadata_Schema;\n /** A uri to an external schema file. */\n schemaUri?: string;\n /** An object containing statistics about features. */\n statistics?: GLTF_EXT_feature_metadata_Statistics;\n /** A dictionary, where each key is a feature table ID and each value is an object defining the feature table. */\n featureTables?: {\n [key: string]: GLTF_EXT_feature_metadata_FeatureTable;\n };\n /** A dictionary, where each key is a feature texture ID and each value is an object defining the feature texture. */\n featureTextures?: {\n [key: string]: GLTF_EXT_feature_metadata_FeatureTexture;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * An object defining classes and enums.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#schema\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/schema.schema.json\n */\nexport type GLTF_EXT_feature_metadata_Schema = {\n /** The name of the schema. */\n name?: string;\n /** The description of the schema. */\n description?: string;\n /** Application-specific version of the schema. */\n version?: string;\n /** A dictionary, where each key is a class ID and each value is an object defining the class. */\n classes?: {\n [key: string]: GLTF_EXT_feature_metadata_Class;\n };\n /** A dictionary, where each key is an enum ID and each value is an object defining the values for the enum. */\n enums?: {\n [key: string]: GLTF_EXT_feature_metadata_Enum;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * A class containing a set of properties.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#class\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/class.schema.json\n */\nexport type GLTF_EXT_feature_metadata_Class = {\n /** The name of the class, e.g. for display purposes. */\n name?: string;\n /** The description of the class. */\n description?: string;\n /** A dictionary, where each key is a property ID and each value is an object defining the property. */\n properties: {\n [key: string]: GLTF_EXT_feature_metadata_ClassProperty;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * A class property.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#class-property\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/class.property.schema.json\n */\nexport type GLTF_EXT_feature_metadata_ClassProperty = {\n /** The name of the property, e.g. for display purposes. */\n name?: string;\n /** The description of the property. */\n description?: string;\n /**\n * The property type. If ENUM is used, then enumType must also be specified.\n * If ARRAY is used, then componentType must also be specified.\n * ARRAY is a fixed-length array when componentCount is defined, and variable-length otherwise.\n */\n type:\n | 'INT8'\n | 'UINT8'\n | 'INT16'\n | 'UINT16'\n | 'INT32'\n | 'UINT32'\n | 'INT64'\n | 'UINT64'\n | 'FLOAT32'\n | 'FLOAT64'\n | 'BOOLEAN'\n | 'STRING'\n | 'ENUM'\n | 'ARRAY'\n | string;\n /**\n * An enum ID as declared in the enums dictionary.\n * This value must be specified when type or componentType is ENUM.\n */\n enumType?: string;\n /**\n * When type is ARRAY this indicates the type of each component of the array.\n * If ENUM is used, then enumType must also be specified.\n */\n componentType?:\n | 'INT8'\n | 'UINT8'\n | 'INT16'\n | 'UINT16'\n | 'INT32'\n | 'UINT32'\n | 'INT64'\n | 'UINT64'\n | 'FLOAT32'\n | 'FLOAT64'\n | 'BOOLEAN'\n | 'STRING'\n | 'ENUM'\n | string;\n /** The number of components per element for ARRAY elements. */\n componentCount?: number;\n /**\n * Specifies whether integer values are normalized.\n * This applies both when type is an integer type, or when type is ARRAY with a componentType that is an integer type.\n * For unsigned integer types, values are normalized between [0.0, 1.0].\n * For signed integer types, values are normalized between [-1.0, 1.0].\n * For all other types, this property is ignored.\n */\n normalized: boolean;\n /**\n * Maximum allowed values for property values.\n * Only applicable for numeric types and fixed-length arrays of numeric types.\n * For numeric types this is a single number.\n * For fixed-length arrays this is an array with componentCount number of elements.\n * The normalized property has no effect on these values: they always correspond to the integer values.\n */\n max?: number | number[];\n /**\n * Minimum allowed values for property values.\n * Only applicable for numeric types and fixed-length arrays of numeric types.\n * For numeric types this is a single number.\n * For fixed-length arrays this is an array with componentCount number of elements.\n * The normalized property has no effect on these values: they always correspond to the integer values.\n */\n min?: number | number[];\n /**\n * A default value to use when the property value is not defined.\n * If used, optional must be set to true.\n * The type of the default value must match the property definition: For BOOLEAN use true or false.\n * For STRING use a JSON string. For a numeric type use a JSON number.\n * For ENUM use the enum name, not the integer value.\n * For ARRAY use a JSON array containing values matching the componentType.\n */\n default?: boolean | number | string | number[];\n /** If true, this property is optional. */\n optional?: boolean; // default false;\n /**\n * An identifier that describes how this property should be interpreted.\n * The semantic cannot be used by other properties in the class.\n */\n semantic?: string;\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * An object defining the values of an enum.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#enum\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata/schema/enum.schema.json\n */\nexport type GLTF_EXT_feature_metadata_Enum = {\n /** The name of the enum, e.g. for display purposes. */\n name?: string;\n /** The description of the enum. */\n description?: string;\n /** The type of the integer enum value. */\n valueType?: 'INT8' | 'UINT8' | 'INT16' | 'UINT16' | 'INT32' | 'UINT32' | 'INT64' | 'UINT64'; // default: \"UINT16\"\n /** An array of enum values. Duplicate names or duplicate integer values are not allowed. */\n values: GLTF_EXT_feature_metadata_EnumValue[];\n extensions?: Record<string, unknown>;\n extras?: unknown;\n [key: string]: unknown;\n};\n\n/**\n * An enum value.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#enum-value\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata/schema/enum.value.schema.json\n */\nexport type GLTF_EXT_feature_metadata_EnumValue = {\n /** The name of the enum value. */\n name: string;\n /** The description of the enum value. */\n description?: string;\n /** The integer enum value. */\n value: number; // default: \"UINT16\"\n extensions?: Record<string, unknown>;\n extras?: unknown;\n [key: string]: unknown;\n};\n\n/**\n * A feature table defined by a class and property values stored in arrays.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#feature-table\n * JSON Schenma - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureTable.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureTable = {\n /** The class that property values conform to. The value must be a class ID declared in the classes dictionary. */\n class?: string;\n /** The number of features, as well as the number of elements in each property array. */\n count: number;\n /**\n * A dictionary, where each key corresponds to a property ID in the class properties dictionary\n * and each value is an object describing where property values are stored.\n * Optional properties may be excluded from this dictionary.\n */\n properties?: {\n [key: string]: GLTF_EXT_feature_metadata_FeatureTableProperty;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * An array of binary property values.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#feature-table-property\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureTable.property.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureTableProperty = {\n /**\n * The index of the buffer view containing property values.\n * The data type of property values is determined by the property definition:\n * When type is BOOLEAN values are packed into a bitfield.\n * When type is STRING values are stored as byte sequences and decoded as UTF-8 strings.\n * When type is a numeric type values are stored as the provided type.\n * When type is ENUM values are stored as the enum's valueType.\n * Each enum value in the buffer must match one of the allowed values in the enum definition.\n * When type is ARRAY elements are packed tightly together and the data type is based on the componentType following the same rules as above.\n * arrayOffsetBufferView is required for variable-size arrays\n * and stringOffsetBufferView is required for strings (for variable-length arrays of strings, both are required)\n * The buffer view byteOffset must be aligned to a multiple of 8 bytes.\n * If the buffer view's buffer is the GLB-stored BIN chunk the byte offset is measured relative to the beginning of the GLB.\n * Otherwise it is measured relative to the beginning of the buffer.\n */\n bufferView: number;\n\n /** The type of values in arrayOffsetBufferView and stringOffsetBufferView. */\n offsetType?: 'UINT8' | 'UINT16' | 'UINT32' | 'UINT64' | string; // default: \"UINT32\"\n /**\n * The index of the buffer view containing offsets for variable-length arrays.\n * The number of offsets is equal to the feature table count plus one.\n * The offsets represent the start positions of each array, with the last offset representing the position after the last array.\n * The array length is computed using the difference between the current offset and the subsequent offset.\n * If componentType is STRING the offsets index into the string offsets array (stored in stringOffsetBufferView),\n * otherwise they index into the property array (stored in bufferView).\n * The data type of these offsets is determined by offsetType.\n * The buffer view byteOffset must be aligned to a multiple of 8 bytes in the same manner as the main bufferView\n */\n arrayOffsetBufferView?: number;\n /**\n * The index of the buffer view containing offsets for strings.\n * The number of offsets is equal to the number of string components plus one.\n * The offsets represent the byte offsets of each string in the main bufferView,\n * with the last offset representing the byte offset after the last string.\n * The string byte length is computed using the difference between the current offset and the subsequent offset.\n * The data type of these offsets is determined by offsetType.\n * The buffer view byteOffset must be aligned to a multiple of 8 bytes in the same manner as the main bufferView.\n */\n stringOffsetBufferView?: number;\n extensions?: Record<string, unknown>;\n extras?: unknown;\n /** This is not part of the spec. GLTFLoader loads feature tables data into this property */\n data: unknown;\n};\n\n/**\n * Features whose property values are stored directly in texture channels. This is not to be confused with feature ID textures which store feature IDs for use with a feature table.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#feature-texture\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureTexture.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureTexture = {\n /** The class this feature texture conforms to. The value must be a class ID declared in the classes dictionary. */\n class: string;\n /**\n * A dictionary, where each key corresponds to a property ID in the class properties dictionary\n * and each value describes the texture channels containing property values.\n */\n properties: {\n [key: string]: GLTF_EXT_feature_metadata_TextureAccessor;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * A description of how to access property values from the color channels of a texture.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#texture-accessor\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/textureAccessor.schema.json\n */\nexport type GLTF_EXT_feature_metadata_TextureAccessor = {\n /** Texture channels containing property values. Channels are labeled by rgba and are swizzled with a string of 1-4 characters. */\n channels: string;\n /** The glTF texture and texture coordinates to use. */\n texture: GLTFTextureInfo;\n extensions?: Record<string, unknown>;\n extras?: unknown;\n /** This is not part of the spec. GLTFLoader loads feature tables data into this property */\n data: unknown;\n};\n\n/**\n * Statistics about features.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#statistics-1\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/statistics.schema.json\n */\nexport type GLTF_EXT_feature_metadata_Statistics = {\n /**\n * A dictionary, where each key is a class ID declared in the classes dictionary\n * and each value is an object containing statistics about features that conform to the class.\n */\n classes?: {\n [key: string]: GLTF_EXT_feature_metadata_StatisticsClass;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * Statistics about features that conform to the class.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#class-statistics\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/statistics.class.property.schema.json\n */\nexport type GLTF_EXT_feature_metadata_StatisticsClass = {\n /** The number of features that conform to the class. */\n count?: number;\n /**\n * A dictionary, where each key is a class ID declared in the classes dictionary\n * and each value is an object containing statistics about property values.\n */\n properties?: {\n [key: string]: GLTF_EXT_feature_metadata_StatisticsClassProperty;\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * min, max, mean, median, standardDeviation, variance, sum are\n * only applicable for numeric types and fixed-length arrays of numeric types.\n * For numeric types this is a single number.\n * For fixed-length arrays this is an array with componentCount number of elements.\n * The normalized property has no effect on these values.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#property-statistics\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/statistics.class.property.schema.json\n */\nexport type GLTF_EXT_feature_metadata_StatisticsClassProperty = {\n /** The minimum property value. */\n min?: number | number[];\n /** The maximum property value. */\n max?: number | number[];\n /** The arithmetic mean of the property values. */\n mean?: number | number[];\n /** The median of the property values. */\n median?: number | number[];\n /** The standard deviation of the property values. */\n standardDeviation?: number | number[];\n /** The variance of the property values. */\n variance?: number | number[];\n /** The sum of the property values. */\n sum?: number | number[];\n /**\n * A dictionary, where each key corresponds to an enum name and each value is the number of occurrences of that enum.\n * Only applicable when type or componentType is ENUM.\n * For fixed-length arrays, this is an array with componentCount number of elements.\n */\n occurrences: {\n [key: string]: number | number[];\n };\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * EXT_feature_metadata extension types\n * This extension has glTF-level metadata and primitive-level (feature indexing and segmentation) metadata\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n *\n * primitive-level metadata\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#primitive-extension\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/mesh.primitive.EXT_feature_metadata.schema.json\n */\nexport type GLTF_EXT_feature_metadata_Primitive = {\n /** Feature ids definition in attributes */\n featureIdAttributes?: GLTF_EXT_feature_metadata_FeatureIdAttribute[];\n /** Feature ids definition in textures */\n featureIdTextures?: GLTF_EXT_feature_metadata_FeatureIdTexture[];\n /** An array of IDs of feature textures from the root EXT_feature_metadata object. */\n featureTextures?: string[];\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * Attribute which described featureIds definition.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#feature-id-attribute\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureIdAttribute.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureIdAttribute = {\n /** Name of feature table */\n featureTable: string;\n /** Described how feature ids are defined */\n featureIds: GLTF_EXT_feature_metadata_FeatureIdAttributeFeatureIds;\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * Defining featureIds by attributes or implicitly.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#primitive-extensionfeatureidattributes\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureIdAttribute.featureIds.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureIdAttributeFeatureIds = {\n /** Name of attribute where featureIds are defined */\n attribute?: string;\n /** Sets a constant feature ID for each vertex. The default is 0. */\n constant?: number;\n /** Sets the rate at which feature IDs increment.\n * If divisor is zero then constant is used.\n * If divisor is greater than zero the feature ID increments once per divisor sets of vertices, starting at constant.\n * The default is 0\n */\n divisor?: number;\n};\n\n/**\n * An object describing a texture used for storing per-texel feature IDs.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#feature-id-texture\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureIdTexture.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureIdTexture = {\n /** The ID of the feature table in the model's root `EXT_feature_metadata.featureTables` dictionary. */\n featureTable: string;\n /** A description of the texture and channel to use for feature IDs. The `channels` property must have a single channel. Furthermore,\n * feature IDs must be whole numbers in the range `[0, count - 1]` (inclusive), where `count` is the total number of features\n * in the feature table. Texel values must be read as integers. Texture filtering should be disabled when fetching feature IDs.\n */\n featureIds: GLTF_EXT_feature_metadata_FeatureIdTextureAccessor;\n};\n\n/**\n * A description of how to access property values from the color channels of a texture.\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#featureidtexturefeatureids\n * JSON Schema - https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/textureAccessor.schema.json\n */\nexport type GLTF_EXT_feature_metadata_FeatureIdTextureAccessor = {\n /** gLTF textureInfo object - https://github.com/CesiumGS/glTF/blob/3d-tiles-next/specification/2.0/schema/textureInfo.schema.json */\n texture: GLTFTextureInfo;\n /** Must be a single channel (\"r\", \"g\", \"b\", or \"a\") */\n channels: 'r' | 'g' | 'b' | 'a';\n};\n"],"mappings":""}
|
|
@@ -31,7 +31,9 @@ export type GLTF_EXT_mesh_features_featureId = {
|
|
|
31
31
|
* (e.g. a value of `0` corresponds to `_FEATURE_ID_0`).
|
|
32
32
|
*/
|
|
33
33
|
attribute?: number;
|
|
34
|
-
/** A texture containing feature IDs.
|
|
34
|
+
/** A texture containing feature IDs.
|
|
35
|
+
* @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/featureIdTexture.schema.json
|
|
36
|
+
*/
|
|
35
37
|
texture?: GLTFTextureInfoMetadata;
|
|
36
38
|
/** The index of the property table containing per-feature property values. Only applicable when using the `EXT_structural_metadata` extension. */
|
|
37
39
|
propertyTable?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-ext-mesh-features-schema.d.ts","sourceRoot":"","sources":["../../../src/lib/types/gltf-ext-mesh-features-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAG3D;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,mCAAmC;IACnC,UAAU,EAAE,gCAAgC,EAAE,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mJAAmJ;IACnJ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB
|
|
1
|
+
{"version":3,"file":"gltf-ext-mesh-features-schema.d.ts","sourceRoot":"","sources":["../../../src/lib/types/gltf-ext-mesh-features-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAG3D;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,mCAAmC;IACnC,UAAU,EAAE,gCAAgC,EAAE,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mJAAmJ;IACnJ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,kJAAkJ;IAClJ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,4FAA4F;IAC5F,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-ext-mesh-features-schema.js","names":[],"sources":["../../../src/lib/types/gltf-ext-mesh-features-schema.ts"],"sourcesContent":["import {GLTFTextureInfoMetadata} from './gltf-json-schema';\n/* eslint-disable camelcase */\n\n/**\n * EXT_mesh_features extension types\n * This is a primitive-level extension.\n * An object describing feature IDs for a mesh primitive.\n * @see https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features\n * or https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/mesh.primitive.EXT_mesh_features.schema.json\n */\nexport type GLTF_EXT_mesh_features = {\n /** An array of feature ID sets. */\n featureIds: GLTF_EXT_mesh_features_featureId[];\n extensions?: Record<string, unknown>;\n extras?: unknown;\n};\n\n/**\n * Feature IDs stored in an attribute or texture.\n * @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/featureId.schema.json\n */\nexport type GLTF_EXT_mesh_features_featureId = {\n /** The number of unique features in the attribute or texture. */\n featureCount: number;\n /** A value that indicates that no feature is associated with this vertex or texel. */\n nullFeatureId?: number;\n /** A label assigned to this feature ID set. Labels must be alphanumeric identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. */\n label?: string;\n /**\n * An attribute containing feature IDs.\n * When `attribute` and `texture` are omitted the feature IDs are assigned to vertices by their index.\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features/schema/featureIdAttribute.schema.json\n * An integer value used to construct a string in the format `_FEATURE_ID_<set index>` which is a reference to a key in `mesh.primitives.attributes`\n * (e.g. a value of `0` corresponds to `_FEATURE_ID_0`).\n */\n attribute?: number;\n /** A texture containing feature IDs.\n * @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/featureIdTexture.schema.json\n */\n texture?: GLTFTextureInfoMetadata;\n /** The index of the property table containing per-feature property values. Only applicable when using the `EXT_structural_metadata` extension. */\n propertyTable?: number;\n extensions?: Record<string, unknown>;\n extras?: unknown;\n\n /** This is not part of the spec. GLTFLoader loads feature tables data into this property */\n data?: unknown;\n};\n"],"mappings":""}
|