@loaders.gl/gltf 4.0.0-beta.2 → 4.0.0-beta.4
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} +3016 -3442
- 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-scenegraph.js","names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorArrayTypeAndLength","getAccessorTypeFromSize","getComponentTypeFromArray","makeDefaultGLTFJson","asset","version","generator","buffers","extensions","extensionsRequired","extensionsUsed","GLTFScenegraph","constructor","gltf","_defineProperty","json","images","sourceBuffers","byteLength","getApplicationData","key","data","getExtraData","extras","hasExtension","extensionName","isUsedExtension","getUsedExtensions","find","name","isRequiredExtension","getRequiredExtensions","getExtension","isExtension","getRequiredExtension","isRequired","getRemovedExtensions","extensionsRemoved","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","concat","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","getTypedArrayForAccessor","accessor","ArrayType","length","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","includes","push","addExtension","extensionData","arguments","undefined","addRequiredExtension","registerRequiredExtension","ext","removeExtension","_this$json$extensions","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","_this$json","_this$json$buffers","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"sources":["../../../../src/lib/api/gltf-scenegraph.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-json-schema';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {\n getAccessorArrayTypeAndLength,\n getAccessorTypeFromSize,\n getComponentTypeFromArray\n} from '../gltf-utils/gltf-utils';\n\ntype Extension = {[key: string]: any};\n\nfunction makeDefaultGLTFJson(): GLTF {\n return {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: [],\n extensions: {},\n extensionsRequired: [],\n extensionsUsed: []\n };\n}\n\n/**\n * Class for structured access to GLTF data\n */\nexport class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n // TODO - why is this not GLTFWithBuffers - what happens to images?\n constructor(gltf?: {json: GLTF; buffers?: any[]; images?: any[]}) {\n // Declare locally so\n\n this.gltf = {\n json: gltf?.json || makeDefaultGLTFJson(),\n buffers: gltf?.buffers || [],\n images: gltf?.images || []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): unknown {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: unknown} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n hasExtension(extensionName: string): boolean {\n const isUsedExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const isRequiredExtension = this.getRequiredExtensions().find((name) => name === extensionName);\n return typeof isUsedExtension === 'string' || typeof isRequiredExtension === 'string';\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? (extensions[extensionName] as T) : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getRemovedExtensions(): string[] {\n return (this.json.extensionsRemoved || []) as string[];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && (this.json[array] as {}[])[index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n accessor = this.getAccessor(accessor);\n // @ts-ignore\n const bufferView = this.getBufferView(accessor.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n // Create a new typed array as a view into the combined buffer\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // @ts-ignore\n const byteOffset = bufferView.byteOffset + accessor.byteOffset;\n return new ArrayType(arrayBuffer, byteOffset, length);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n (this.json.extras as Record<string, unknown>)[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: any, extensionName: string, data: object): void {\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: any, extensionName: string): void {\n const extensions = object?.extensions || {};\n\n if (extensions[extensionName]) {\n this.json.extensionsRemoved = this.json.extensionsRemoved || [];\n const extensionsRemoved = this.json.extensionsRemoved as string[];\n if (!extensionsRemoved.includes(extensionName)) {\n extensionsRemoved.push(extensionName);\n }\n }\n\n delete extensions[extensionName];\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensions?.[extensionName]) {\n this.json.extensionsRemoved = this.json.extensionsRemoved || [];\n const extensionsRemoved = this.json.extensionsRemoved as string[];\n if (!extensionsRemoved.includes(extensionName)) {\n extensionsRemoved.push(extensionName);\n }\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any, bufferIndex = 0, byteOffset = this.byteLength): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: bufferIndex,\n // Write offset from the start of the binary body\n byteOffset,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"mappings":";AAkBA,SAAQA,sBAAsB,QAAO,oBAAoB;AACzD,SAAQC,WAAW,EAAEC,WAAW,QAAO,0BAA0B;AACjE,SAAQC,MAAM,QAAO,iBAAiB;AACtC,SACEC,6BAA6B,EAC7BC,uBAAuB,EACvBC,yBAAyB,QACpB,0BAA0B;AAIjC,SAASC,mBAAmBA,CAAA,EAAS;EACnC,OAAO;IACLC,KAAK,EAAE;MACLC,OAAO,EAAE,KAAK;MACdC,SAAS,EAAE;IACb,CAAC;IACDC,OAAO,EAAE,EAAE;IACXC,UAAU,EAAE,CAAC,CAAC;IACdC,kBAAkB,EAAE,EAAE;IACtBC,cAAc,EAAE;EAClB,CAAC;AACH;AAKA,OAAO,MAAMC,cAAc,CAAC;EAO1BC,WAAWA,CAACC,IAAoD,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAGhE,IAAI,CAACD,IAAI,GAAG;MACVE,IAAI,EAAE,CAAAF,IAAI,aAAJA,IAA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AChC,GAAG,GAAG,EAAE;IACf,MAAMwC,UAAU,GAAGlH,MAAM,CAACmH,QAAQ,CAAC,CAAC,EAAE5C,IAAI,CAAC;IAC3C,KAAK,MAAMwC,KAAK,IAAIG,UAAU,EAAE;MAE9BR,MAAM,CAAC/B,GAAG,CAACzD,IAAI,CAAC6F,KAAK,CAAC;MAEtBL,MAAM,CAAChC,GAAG,CAACxD,IAAI,CAAC6F,KAAK,CAAC;IACxB;IAEA,KAAK,IAAIjI,KAAK,GAAGyF,IAAI,EAAEzF,KAAK,GAAGkB,MAAM,CAACQ,MAAM,EAAE1B,KAAK,IAAIyF,IAAI,EAAE;MAC3D,KAAK,IAAI6C,cAAc,GAAG,CAAC,EAAEA,cAAc,GAAG7C,IAAI,EAAE6C,cAAc,EAAE,EAAE;QAEpEV,MAAM,CAAC/B,GAAG,CAAC,CAAC,GAAGyC,cAAc,CAAC,GAAGnC,IAAI,CAACN,GAAG,CAEvC+B,MAAM,CAAC/B,GAAG,CAAC,CAAC,GAAGyC,cAAc,CAAC,EAC9BpH,MAAM,CAAClB,KAAK,GAAGsI,cAAc,CAC/B,CAAC;QAEDV,MAAM,CAAChC,GAAG,CAAC,CAAC,GAAG0C,cAAc,CAAC,GAAGnC,IAAI,CAACP,GAAG,CAEvCgC,MAAM,CAAChC,GAAG,CAAC,CAAC,GAAG0C,cAAc,CAAC,EAC9BpH,MAAM,CAAClB,KAAK,GAAGsI,cAAc,CAC/B,CAAC;MACH;IACF;IACA,OAAOV,MAAM;EACf;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-gltf-v1.js","names":["KHR_binary_glTF","GLTF_ARRAYS","accessors","animations","buffers","bufferViews","images","materials","meshes","nodes","samplers","scenes","skins","textures","GLTF_KEYS","accessor","buffer","bufferView","image","material","mesh","node","sampler","scene","skin","texture","GLTFV1Normalizer","constructor","_defineProperty","normalize","gltf","options","json","asset","version","undefined","console","warn","concat","Error","_addAsset","_convertTopLevelObjectsToArrays","preprocess","_convertObjectIdsToArrayIndices","_updateObjects","_updateMaterial","generator","arrayName","_convertTopLevelObjectToArray","mapName","objectMap","Array","isArray","id","object","index","length","push","idToIndexMap","_convertIdsToIndices","_convertIdToIndex","_convertTextureIds","_convertMeshIds","_convertNodeIds","_convertSceneIds","source","primitive","primitives","attributes","indices","attributeName","children","map","child","topLevelArrayName","key","Number","isFinite","type","_material$values","_material$values2","_material$values3","pbrMetallicRoughness","baseColorFactor","metallicFactor","roughnessFactor","textureId","values","tex","texture2d_0","diffuseTex","textureIndex","findIndex","baseColorTexture","normalizeGLTFV1","arguments"],"sources":["../../../../src/lib/api/normalize-gltf-v1.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport * as KHR_binary_glTF from '../extensions/KHR_binary_gltf';\n\n// Binary format changes (mainly implemented by GLBLoader)\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF\n\n// JSON format changes:\n// https://github.com/khronosgroup/gltf/issues/605\n\n// - [x] Top-level JSON objects are arrays now\n// - [ ] Removed indirection from animation: sampler now refers directly to accessors, #712\n// - [ ] material.parameter.value and technique.parameter.value must be an array, #690\n// - [ ] Node can have only one mesh #821\n// - [ ] Added reqs on JSON encoding\n// - [ ] Added reqs on binary data alignment #802 (comment)\n\n// Additions:\n// - [ ] Added accessor.normalized, #691, #706\n// - [ ] Added glExtensionsUsed property and 5125 (UNSIGNED_INT) accessor.componentType value, #619\n// - [ ] Added extensionsRequired property, #720, #721\n// - [ ] Added \"STEP\" as valid animation.sampler.interpolation value, #712\n\n// Removals:\n// - [x] Removed buffer.type, #786, #629\n// - [ ] Removed revision number from profile.version, #709\n// - [ ] Removed technique.functions.scissor and removed 3089 (SCISSOR_TEST) as a valid value for technique.states.enable, #681\n// - [ ] Techniques, programs, and shaders were moved out to KHR_technique_webgl extension.\n\n// Other edits:\n// - [x] asset is now required, #642\n// - [ ] buffer.byteLength and bufferView.byteLength are now required, #560.\n// - [ ] accessor.min and accessor.max are now required, #593, and clarified that the JSON value and binary data must be the same, #628.\n// - [ ] Clarified animation.sampler and animation.channel restrictions, #712\n// - [ ] skin.inverseBindMatrices is now optional, #461.\n// - [ ] Attribute parameters can't have a value defined in the technique or parameter, #563 (comment).\n// - [ ] Only TEXCOORD and COLOR attribute semantics can be written in the form [semantic]_[set_index], #563 (comment).\n// - [ ] TEXCOORD and COLOR attribute semantics must be written in the form [semantic]_[set_index], e.g., just TEXCOORD should be TEXCOORD_0, and just COLOR should be COLOR_0, #649\n// - [ ] camera.perspective.aspectRatio and camera.perspective.yfov must now be > 0, not >= 0, #563 (comment).\n// - [ ] Application-specific parameter semantics must start with an underscore, e.g., _TEMPERATURE and _SIMULATION_TIME, #563 (comment).\n// - [ ] Properties in technique.parameters must be defined in technique.uniforms or technique.attributes,\n\n// #563 (comment).\n// - [ ] technique.parameter.count can only be defined when the semantic is JOINTMATRIX or an application-specific semantic is used. It can never be defined for attribute parameters; only uniforms, d2f6945\n// - [ ] technique.parameter.semantic is required when the parameter is an attribute, 28e113d\n// - [ ] Mesh-only models are allowed, e.g., without materials, #642\n// - [ ] Skeleton hierarchies (nodes containing jointName) must be separated from non-skeleton hierarchies., #647\n// - [ ] technique.states.functions.blendColor and technique.states.functions.depthRange parameters now must match WebGL function min/max, #707\n\nconst GLTF_ARRAYS = {\n accessors: 'accessor',\n animations: 'animation',\n buffers: 'buffer',\n bufferViews: 'bufferView',\n images: 'image',\n materials: 'material',\n meshes: 'mesh',\n nodes: 'node',\n samplers: 'sampler',\n scenes: 'scene',\n skins: 'skin',\n textures: 'texture'\n};\n\nconst GLTF_KEYS = {\n accessor: 'accessors',\n animations: 'animation',\n buffer: 'buffers',\n bufferView: 'bufferViews',\n image: 'images',\n material: 'materials',\n mesh: 'meshes',\n node: 'nodes',\n sampler: 'samplers',\n scene: 'scenes',\n skin: 'skins',\n texture: 'textures'\n};\n\n/**\n * Converts (normalizes) glTF v1 to v2\n */\nclass GLTFV1Normalizer {\n idToIndexMap = {\n animations: {},\n accessors: {},\n buffers: {},\n bufferViews: {},\n images: {},\n materials: {},\n meshes: {},\n nodes: {},\n samplers: {},\n scenes: {},\n skins: {},\n textures: {}\n };\n\n json;\n\n // constructor() {}\n\n /**\n * Convert (normalize) glTF < 2.0 to glTF 2.0\n * @param gltf - object with json and binChunks\n * @param options\n * @param options normalize Whether to actually normalize\n */\n normalize(gltf, options) {\n this.json = gltf.json;\n const json = gltf.json;\n\n // Check version\n switch (json.asset && json.asset.version) {\n // We are converting to v2 format. Return if there is nothing to do\n case '2.0':\n return;\n\n // This class is written to convert 1.0\n case undefined:\n case '1.0':\n break;\n\n default:\n // eslint-disable-next-line no-undef, no-console\n console.warn(`glTF: Unknown version ${json.asset.version}`);\n return;\n }\n\n if (!options.normalize) {\n // We are still missing a few conversion tricks, remove once addressed\n throw new Error('glTF v1 is not supported.');\n }\n\n // eslint-disable-next-line no-undef, no-console\n console.warn('Converting glTF v1 to glTF v2 format. This is experimental and may fail.');\n\n this._addAsset(json);\n\n // In glTF2 top-level fields are Arrays not Object maps\n this._convertTopLevelObjectsToArrays(json);\n\n // Extract bufferView indices for images\n // (this extension needs to be invoked early in the normalization process)\n // TODO can this be handled by standard extension processing instead of called explicitly?\n KHR_binary_glTF.preprocess(gltf);\n\n // Convert object references from ids to indices\n this._convertObjectIdsToArrayIndices(json);\n\n this._updateObjects(json);\n\n this._updateMaterial(json);\n }\n\n // asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639\n _addAsset(json) {\n json.asset = json.asset || {};\n // We are normalizing to glTF v2, so change version to \"2.0\"\n json.asset.version = '2.0';\n json.asset.generator = json.asset.generator || 'Normalized to glTF 2.0 by loaders.gl';\n }\n\n _convertTopLevelObjectsToArrays(json) {\n // TODO check that all arrays are covered\n for (const arrayName in GLTF_ARRAYS) {\n this._convertTopLevelObjectToArray(json, arrayName);\n }\n }\n\n /** Convert one top level object to array */\n _convertTopLevelObjectToArray(json, mapName) {\n const objectMap = json[mapName];\n if (!objectMap || Array.isArray(objectMap)) {\n return;\n }\n\n // Rewrite the top-level field as an array\n json[mapName] = [];\n // Copy the map key into object.id\n for (const id in objectMap) {\n const object = objectMap[id];\n object.id = object.id || id; // Mutates the loaded object\n const index = json[mapName].length;\n json[mapName].push(object);\n this.idToIndexMap[mapName][id] = index;\n }\n }\n\n /** Go through all objects in all top-level arrays and replace ids with indices */\n _convertObjectIdsToArrayIndices(json) {\n for (const arrayName in GLTF_ARRAYS) {\n this._convertIdsToIndices(json, arrayName);\n }\n if ('scene' in json) {\n json.scene = this._convertIdToIndex(json.scene, 'scene');\n }\n\n // Convert any index references that are not using array names\n\n // texture.source (image)\n for (const texture of json.textures) {\n this._convertTextureIds(texture);\n }\n for (const mesh of json.meshes) {\n this._convertMeshIds(mesh);\n }\n for (const node of json.nodes) {\n this._convertNodeIds(node);\n }\n for (const node of json.scenes) {\n this._convertSceneIds(node);\n }\n }\n\n _convertTextureIds(texture) {\n if (texture.source) {\n texture.source = this._convertIdToIndex(texture.source, 'image');\n }\n }\n\n _convertMeshIds(mesh) {\n for (const primitive of mesh.primitives) {\n const {attributes, indices, material} = primitive;\n for (const attributeName in attributes) {\n attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], 'accessor');\n }\n if (indices) {\n primitive.indices = this._convertIdToIndex(indices, 'accessor');\n }\n if (material) {\n primitive.material = this._convertIdToIndex(material, 'material');\n }\n }\n }\n\n _convertNodeIds(node) {\n if (node.children) {\n node.children = node.children.map((child) => this._convertIdToIndex(child, 'node'));\n }\n if (node.meshes) {\n node.meshes = node.meshes.map((mesh) => this._convertIdToIndex(mesh, 'mesh'));\n }\n }\n\n _convertSceneIds(scene) {\n if (scene.nodes) {\n scene.nodes = scene.nodes.map((node) => this._convertIdToIndex(node, 'node'));\n }\n }\n\n /** Go through all objects in a top-level array and replace ids with indices */\n _convertIdsToIndices(json, topLevelArrayName) {\n if (!json[topLevelArrayName]) {\n console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`); // eslint-disable-line no-console, no-undef\n json[topLevelArrayName] = [];\n }\n for (const object of json[topLevelArrayName]) {\n for (const key in object) {\n const id = object[key];\n const index = this._convertIdToIndex(id, key);\n object[key] = index;\n }\n }\n }\n\n _convertIdToIndex(id, key) {\n const arrayName = GLTF_KEYS[key];\n if (arrayName in this.idToIndexMap) {\n const index = this.idToIndexMap[arrayName][id];\n if (!Number.isFinite(index)) {\n throw new Error(`gltf v1: failed to resolve ${key} with id ${id}`);\n }\n return index;\n }\n return id;\n }\n\n /**\n *\n * @param {*} json\n */\n _updateObjects(json) {\n for (const buffer of this.json.buffers) {\n // - [x] Removed buffer.type, #786, #629\n delete buffer.type;\n }\n }\n\n /**\n * Update material (set pbrMetallicRoughness)\n * @param {*} json\n */\n _updateMaterial(json) {\n for (const material of json.materials) {\n material.pbrMetallicRoughness = {\n baseColorFactor: [1, 1, 1, 1],\n metallicFactor: 1,\n roughnessFactor: 1\n };\n\n const textureId =\n material.values?.tex || material.values?.texture2d_0 || material.values?.diffuseTex;\n const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);\n if (textureIndex !== -1) {\n material.pbrMetallicRoughness.baseColorTexture = {index: textureIndex};\n }\n }\n }\n}\n\nexport function normalizeGLTFV1(gltf, options = {}) {\n return new GLTFV1Normalizer().normalize(gltf, options);\n}\n"],"mappings":";AACA,OAAO,KAAKA,eAAe,MAAM,+BAA+B;AA+ChE,MAAMC,WAAW,GAAG;EAClBC,SAAS,EAAE,UAAU;EACrBC,UAAU,EAAE,WAAW;EACvBC,OAAO,EAAE,QAAQ;EACjBC,WAAW,EAAE,YAAY;EACzBC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,UAAU;EACrBC,MAAM,EAAE,MAAM;EACdC,KAAK,EAAE,MAAM;EACbC,QAAQ,EAAE,SAAS;EACnBC,MAAM,EAAE,OAAO;EACfC,KAAK,EAAE,MAAM;EACbC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,SAAS,GAAG;EAChBC,QAAQ,EAAE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CAAC;MAED,MAAMC,SAAS,GACb,EAAAP,gBAAA,GAAA5D,QAAQ,CAACoE,MAAM,cAAAR,gBAAA,uBAAfA,gBAAA,CAAiBS,GAAG,OAAAR,iBAAA,GAAI7D,QAAQ,CAACoE,MAAM,cAAAP,iBAAA,uBAAfA,iBAAA,CAAiBS,WAAW,OAAAR,iBAAA,GAAI9D,QAAQ,CAACoE,MAAM,cAAAN,iBAAA,uBAAfA,iBAAA,CAAiBS,UAAU;MACrF,MAAMC,YAAY,GAAG3D,IAAI,CAACnB,QAAQ,CAAC+E,SAAS,CAAEnE,OAAO,IAAKA,OAAO,CAAC4B,EAAE,KAAKiC,SAAS,CAAC;MACnF,IAAIK,YAAY,KAAK,CAAC,CAAC,EAAE;QACvBxE,QAAQ,CAAC+D,oBAAoB,CAACW,gBAAgB,GAAG;UAACtC,KAAK,EAAEoC;QAAY,CAAC;MACxE;IACF;EACF;AACF;AAEA,OAAO,SAASG,eAAeA,CAAChE,IAAI,EAAgB;EAAA,IAAdC,OAAO,GAAAgE,SAAA,CAAAvC,MAAA,QAAAuC,SAAA,QAAA5D,SAAA,GAAA4D,SAAA,MAAG,CAAC,CAAC;EAChD,OAAO,IAAIrE,gBAAgB,CAAC,CAAC,CAACG,SAAS,CAACC,IAAI,EAAEC,OAAO,CAAC;AACxD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-process-gltf.js","names":["assert","getAccessorArrayTypeAndLength","COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","BYTES","GL_SAMPLER","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","REPEAT","LINEAR","NEAREST_MIPMAP_LINEAR","SAMPLER_PARAMETER_GLTF_TO_GL","magFilter","minFilter","wrapS","wrapT","DEFAULT_SAMPLER_PARAMETERS","makeDefaultSampler","id","parameters","getBytesFromComponentType","componentType","getSizeFromAccessorType","type","GLTFPostProcessor","constructor","_defineProperty","postProcess","gltf","options","arguments","length","undefined","json","buffers","images","baseUri","jsonUnprocessed","_resolveTree","bufferViews","map","bufView","i","_resolveBufferView","image","_resolveImage","samplers","sampler","_resolveSampler","textures","texture","_resolveTexture","accessors","accessor","_resolveAccessor","materials","material","_resolveMaterial","meshes","mesh","_resolveMesh","nodes","node","_resolveNode","_resolveNodeChildren","skins","skin","_resolveSkin","scenes","scene","_resolveScene","getScene","index","_get","getNode","getSkin","getMesh","getMaterial","getAccessor","getCamera","cameras","getTexture","getSampler","getImage","getBufferView","getBuffer","array","object","console","warn","concat","gltfNode","camera","reduce","accum","meshIndex","primitives","children","child","gltfSkin","inverseBindMatrices","gltfMesh","gltfPrimitive","primitive","attributes","indices","attribute","gltfMaterial","normalTexture","occlusionTexture","emissiveTexture","emissiveFactor","pbrMetallicRoughness","mr","baseColorTexture","metallicRoughnessTexture","gltfAccessor","bytesPerComponent","components","bytesPerElement","value","bufferView","sparse","buffer","ArrayType","byteLength","byteOffset","cutBuffer","arrayBuffer","slice","byteStride","_getValueFromInterleavedBuffer","count","result","Uint8Array","elementOffset","set","gltfTexture","source","gltfSampler","key","glEnum","_enumSamplerParameter","gltfImage","preloadedImage","gltfBufferView","bufferIndex","data","_resolveCamera","gltfCamera","perspective","orthographic","postProcessGLTF"],"sources":["../../../../src/lib/api/post-process-gltf.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {ParseGLTFOptions} from '../parsers/parse-gltf';\n\nimport type {\n GLTF,\n GLTFAccessor,\n GLTFBufferView,\n GLTFCamera,\n GLTFImage,\n GLTFMaterial,\n GLTFMesh,\n GLTFNode,\n GLTFSampler,\n GLTFScene,\n GLTFSkin,\n GLTFTexture\n} from '../types/gltf-json-schema';\n\nimport type {\n GLTFPostprocessed,\n GLTFAccessorPostprocessed,\n GLTFBufferPostprocessed,\n GLTFBufferViewPostprocessed,\n GLTFCameraPostprocessed,\n GLTFImagePostprocessed,\n GLTFMaterialPostprocessed,\n GLTFMeshPostprocessed,\n GLTFNodePostprocessed,\n GLTFSamplerPostprocessed,\n GLTFScenePostprocessed,\n GLTFSkinPostprocessed,\n GLTFTexturePostprocessed,\n GLTFMeshPrimitivePostprocessed\n} from '../types/gltf-postprocessed-schema';\n\nimport {assert} from '../utils/assert';\nimport {getAccessorArrayTypeAndLength} from '../gltf-utils/gltf-utils';\n\n// This is a post processor for loaded glTF files\n// The goal is to make the loaded data easier to use in WebGL applications\n//\n// Functions:\n// * Resolve indexed arrays structure of glTF into a linked tree.\n// * Translate stringified enum keys and values into WebGL constants.\n// * Load images (optional)\n\n// ENUM LOOKUP\n\nconst 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 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\nconst GL_SAMPLER = {\n // Sampler parameters\n TEXTURE_MAG_FILTER: 0x2800,\n TEXTURE_MIN_FILTER: 0x2801,\n TEXTURE_WRAP_S: 0x2802,\n TEXTURE_WRAP_T: 0x2803,\n\n // Sampler default values\n REPEAT: 0x2901,\n LINEAR: 0x2601,\n NEAREST_MIPMAP_LINEAR: 0x2702\n};\n\nconst SAMPLER_PARAMETER_GLTF_TO_GL = {\n magFilter: GL_SAMPLER.TEXTURE_MAG_FILTER,\n minFilter: GL_SAMPLER.TEXTURE_MIN_FILTER,\n wrapS: GL_SAMPLER.TEXTURE_WRAP_S,\n wrapT: GL_SAMPLER.TEXTURE_WRAP_T\n};\n\n// When undefined, a sampler with repeat wrapping and auto filtering should be used.\n// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\nconst DEFAULT_SAMPLER_PARAMETERS = {\n [GL_SAMPLER.TEXTURE_MAG_FILTER]: GL_SAMPLER.LINEAR,\n [GL_SAMPLER.TEXTURE_MIN_FILTER]: GL_SAMPLER.NEAREST_MIPMAP_LINEAR,\n [GL_SAMPLER.TEXTURE_WRAP_S]: GL_SAMPLER.REPEAT,\n [GL_SAMPLER.TEXTURE_WRAP_T]: GL_SAMPLER.REPEAT\n};\n\nfunction makeDefaultSampler(): GLTFSamplerPostprocessed {\n return {\n id: 'default-sampler',\n parameters: DEFAULT_SAMPLER_PARAMETERS\n };\n}\n\nfunction getBytesFromComponentType(componentType) {\n return BYTES[componentType];\n}\n\nfunction getSizeFromAccessorType(type) {\n return COMPONENTS[type];\n}\n\nclass GLTFPostProcessor {\n baseUri: string = '';\n // @ts-expect-error\n jsonUnprocessed: GLTF;\n // @ts-expect-error\n json: GLTFPostprocessed;\n buffers: {\n arrayBuffer: ArrayBuffer;\n byteOffset: number;\n byteLength: number;\n }[] = [];\n images: any[] = [];\n\n postProcess(gltf: GLTFWithBuffers, options = {}) {\n const {json, buffers = [], images = []} = gltf;\n // @ts-expect-error\n const {baseUri = ''} = gltf;\n assert(json);\n\n this.baseUri = baseUri;\n this.buffers = buffers;\n this.images = images;\n this.jsonUnprocessed = json;\n\n this.json = this._resolveTree(gltf.json, options);\n\n return this.json;\n }\n\n // Convert indexed glTF structure into tree structure\n // cross-link index resolution, enum lookup, convenience calculations\n // eslint-disable-next-line complexity, max-statements\n _resolveTree(gltf: GLTF, options = {}): GLTFPostprocessed {\n // @ts-expect-error\n const json: GLTFPostprocessed = {...gltf};\n this.json = json;\n\n if (gltf.bufferViews) {\n json.bufferViews = gltf.bufferViews.map((bufView, i) => this._resolveBufferView(bufView, i));\n }\n if (gltf.images) {\n json.images = gltf.images.map((image, i) => this._resolveImage(image, i));\n }\n if (gltf.samplers) {\n json.samplers = gltf.samplers.map((sampler, i) => this._resolveSampler(sampler, i));\n }\n if (gltf.textures) {\n json.textures = gltf.textures.map((texture, i) => this._resolveTexture(texture, i));\n }\n if (gltf.accessors) {\n json.accessors = gltf.accessors.map((accessor, i) => this._resolveAccessor(accessor, i));\n }\n if (gltf.materials) {\n json.materials = gltf.materials.map((material, i) => this._resolveMaterial(material, i));\n }\n if (gltf.meshes) {\n json.meshes = gltf.meshes.map((mesh, i) => this._resolveMesh(mesh, i));\n }\n if (gltf.nodes) {\n json.nodes = gltf.nodes.map((node, i) => this._resolveNode(node, i));\n json.nodes = json.nodes.map((node, i) => this._resolveNodeChildren(node));\n }\n if (gltf.skins) {\n json.skins = gltf.skins.map((skin, i) => this._resolveSkin(skin, i));\n }\n if (gltf.scenes) {\n json.scenes = gltf.scenes.map((scene, i) => this._resolveScene(scene, i));\n }\n if (typeof this.json.scene === 'number' && json.scenes) {\n json.scene = json.scenes[this.json.scene];\n }\n\n return json;\n }\n\n getScene(index: number): GLTFScenePostprocessed {\n return this._get(this.json.scenes, index);\n }\n\n getNode(index: number): GLTFNodePostprocessed {\n return this._get(this.json.nodes, index);\n }\n\n getSkin(index: number): GLTFSkinPostprocessed {\n return this._get(this.json.skins, index);\n }\n\n getMesh(index: number): GLTFMeshPostprocessed {\n return this._get(this.json.meshes, index);\n }\n\n getMaterial(index: number): GLTFMaterialPostprocessed {\n return this._get(this.json.materials, index);\n }\n\n getAccessor(index: number): GLTFAccessorPostprocessed {\n return this._get(this.json.accessors, index);\n }\n\n getCamera(index: number): GLTFCameraPostprocessed {\n return this._get(this.json.cameras, index);\n }\n\n getTexture(index: number): GLTFTexturePostprocessed {\n return this._get(this.json.textures, index);\n }\n\n getSampler(index: number): GLTFSamplerPostprocessed {\n return this._get(this.json.samplers, index);\n }\n\n getImage(index: number): GLTFImagePostprocessed {\n return this._get(this.json.images, index);\n }\n\n getBufferView(index: number): GLTFBufferViewPostprocessed {\n return this._get(this.json.bufferViews, index);\n }\n\n getBuffer(index: number): GLTFBufferPostprocessed {\n return this._get(this.json.buffers, index);\n }\n\n _get<T>(array: T[] | undefined, index: number): T {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = array && array[index];\n if (!object) {\n console.warn(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object as T;\n }\n\n // PARSING HELPERS\n\n _resolveScene(scene: GLTFScene, index: number): GLTFScenePostprocessed {\n return {\n ...scene,\n // @ts-ignore\n id: scene.id || `scene-${index}`,\n nodes: (scene.nodes || []).map((node) => this.getNode(node))\n };\n }\n\n _resolveNode(gltfNode: GLTFNode, index: number): GLTFNodePostprocessed {\n // @ts-expect-error\n const node: GLTFNodePostprocessed = {\n ...gltfNode,\n // @ts-expect-error id could already be present, glTF standard does not prevent it\n id: gltfNode?.id || `node-${index}`\n };\n if (gltfNode.mesh !== undefined) {\n node.mesh = this.getMesh(gltfNode.mesh);\n }\n if (gltfNode.camera !== undefined) {\n node.camera = this.getCamera(gltfNode.camera);\n }\n if (gltfNode.skin !== undefined) {\n node.skin = this.getSkin(gltfNode.skin);\n }\n\n // TODO deprecated - Delete in v4.0?\n // @ts-expect-error node.meshes does not seem to be part of the GLTF standard\n if (gltfNode.meshes !== undefined && gltfNode.meshes.length) {\n // @ts-expect-error\n node.mesh = gltfNode.meshes.reduce(\n (accum, meshIndex) => {\n const mesh = this.getMesh(meshIndex);\n accum.id = mesh.id;\n accum.primitives = accum.primitives.concat(mesh.primitives);\n return accum;\n },\n {primitives: []}\n );\n }\n\n return node;\n }\n\n _resolveNodeChildren(node: GLTFNodePostprocessed): GLTFNodePostprocessed {\n if (node.children) {\n // @ts-expect-error node.children are numbers at this stage\n node.children = node.children.map((child) => this.getNode(child));\n }\n return node;\n }\n\n _resolveSkin(gltfSkin: GLTFSkin, index: number): GLTFSkinPostprocessed {\n const inverseBindMatrices =\n typeof gltfSkin.inverseBindMatrices === 'number'\n ? this.getAccessor(gltfSkin.inverseBindMatrices)\n : undefined;\n\n return {\n ...gltfSkin,\n id: gltfSkin.id || `skin-${index}`,\n inverseBindMatrices\n };\n }\n\n _resolveMesh(gltfMesh: GLTFMesh, index: number): GLTFMeshPostprocessed {\n const mesh: GLTFMeshPostprocessed = {\n ...gltfMesh,\n id: gltfMesh.id || `mesh-${index}`,\n primitives: []\n };\n if (gltfMesh.primitives) {\n mesh.primitives = gltfMesh.primitives.map((gltfPrimitive) => {\n const primitive: GLTFMeshPrimitivePostprocessed = {\n ...gltfPrimitive,\n attributes: {},\n indices: undefined,\n material: undefined\n };\n const attributes = gltfPrimitive.attributes;\n for (const attribute in attributes) {\n primitive.attributes[attribute] = this.getAccessor(attributes[attribute]);\n }\n if (gltfPrimitive.indices !== undefined) {\n primitive.indices = this.getAccessor(gltfPrimitive.indices);\n }\n if (gltfPrimitive.material !== undefined) {\n primitive.material = this.getMaterial(gltfPrimitive.material);\n }\n return primitive;\n });\n }\n return mesh;\n }\n\n _resolveMaterial(gltfMaterial: GLTFMaterial, index: number): GLTFMaterialPostprocessed {\n // @ts-expect-error\n const material: GLTFMaterialPostprocessed = {\n ...gltfMaterial,\n // @ts-expect-error\n id: gltfMaterial.id || `material-${index}`\n };\n if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture};\n material.normalTexture.texture = this.getTexture(material.normalTexture.index);\n }\n if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture};\n material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index);\n }\n if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture};\n material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index);\n }\n if (!material.emissiveFactor) {\n material.emissiveFactor = material.emissiveTexture ? [1, 1, 1] : [0, 0, 0];\n }\n\n if (material.pbrMetallicRoughness) {\n material.pbrMetallicRoughness = {...material.pbrMetallicRoughness};\n const mr = material.pbrMetallicRoughness;\n if (mr.baseColorTexture) {\n mr.baseColorTexture = {...mr.baseColorTexture};\n mr.baseColorTexture.texture = this.getTexture(mr.baseColorTexture.index);\n }\n if (mr.metallicRoughnessTexture) {\n mr.metallicRoughnessTexture = {...mr.metallicRoughnessTexture};\n mr.metallicRoughnessTexture.texture = this.getTexture(mr.metallicRoughnessTexture.index);\n }\n }\n return material;\n }\n\n _resolveAccessor(gltfAccessor: GLTFAccessor, index: number): GLTFAccessorPostprocessed {\n // Look up enums\n const bytesPerComponent = getBytesFromComponentType(gltfAccessor.componentType);\n const components = getSizeFromAccessorType(gltfAccessor.type);\n const bytesPerElement = bytesPerComponent * components;\n\n const accessor: GLTFAccessorPostprocessed = {\n ...gltfAccessor,\n // @ts-expect-error\n id: gltfAccessor.id || `accessor-${index}`,\n bytesPerComponent,\n components,\n bytesPerElement,\n value: undefined!,\n bufferView: undefined!,\n sparse: undefined!\n };\n if (gltfAccessor.bufferView !== undefined) {\n // Draco encoded meshes don't have bufferView\n accessor.bufferView = this.getBufferView(gltfAccessor.bufferView);\n }\n\n // Create TypedArray for the accessor\n // Note: The canonical way to instantiate is to ignore this array and create\n // WebGLBuffer's using the bufferViews.\n if (accessor.bufferView) {\n const buffer = accessor.bufferView.buffer;\n const {ArrayType, byteLength} = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);\n const byteOffset =\n (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;\n let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);\n if (accessor.bufferView.byteStride) {\n cutBuffer = this._getValueFromInterleavedBuffer(\n buffer,\n byteOffset,\n accessor.bufferView.byteStride,\n accessor.bytesPerElement,\n accessor.count\n );\n }\n accessor.value = new ArrayType(cutBuffer);\n }\n\n return accessor;\n }\n\n /**\n * Take values of particular accessor from interleaved buffer\n * various parts of the buffer\n * @param buffer\n * @param byteOffset\n * @param byteStride\n * @param bytesPerElement\n * @param count\n * @returns\n */\n _getValueFromInterleavedBuffer(\n buffer,\n byteOffset: number,\n byteStride: number,\n bytesPerElement: number,\n count: number\n ): ArrayBufferLike {\n const result = new Uint8Array(count * bytesPerElement);\n for (let i = 0; i < count; i++) {\n const elementOffset = byteOffset + i * byteStride;\n result.set(\n new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)),\n i * bytesPerElement\n );\n }\n return result.buffer;\n }\n\n _resolveTexture(gltfTexture: GLTFTexture, index: number): GLTFTexturePostprocessed {\n return {\n ...gltfTexture,\n // @ts-expect-error id could already be present, glTF standard does not prevent it\n id: gltfTexture.id || `texture-${index}`,\n sampler:\n typeof gltfTexture.sampler === 'number'\n ? this.getSampler(gltfTexture.sampler)\n : makeDefaultSampler(),\n source: typeof gltfTexture.source === 'number' ? this.getImage(gltfTexture.source) : undefined\n };\n }\n\n _resolveSampler(gltfSampler: GLTFSampler, index: number): GLTFSamplerPostprocessed {\n const sampler: GLTFSamplerPostprocessed = {\n // @ts-expect-error id could already be present, glTF standard does not prevent it\n id: gltfSampler.id || `sampler-${index}`,\n ...gltfSampler,\n parameters: {}\n };\n // Map textual parameters to GL parameter values\n for (const key in sampler) {\n const glEnum = this._enumSamplerParameter(key);\n if (glEnum !== undefined) {\n sampler.parameters[glEnum] = sampler[key];\n }\n }\n return sampler;\n }\n\n _enumSamplerParameter(key: string): number {\n return SAMPLER_PARAMETER_GLTF_TO_GL[key];\n }\n\n _resolveImage(gltfImage: GLTFImage, index: number): GLTFImagePostprocessed {\n const image: GLTFImagePostprocessed = {\n ...gltfImage,\n // @ts-expect-error id could already be present, glTF standard does not prevent it\n id: gltfImage.id || `image-${index}`,\n image: null!,\n bufferView:\n gltfImage.bufferView !== undefined ? this.getBufferView(gltfImage.bufferView) : undefined\n };\n\n // Check if image has been preloaded by the GLTFLoader\n // If so, link it into the JSON and drop the URI\n const preloadedImage = this.images[index];\n if (preloadedImage) {\n image.image = preloadedImage;\n }\n\n return image;\n }\n\n _resolveBufferView(gltfBufferView: GLTFBufferView, index: number): GLTFBufferViewPostprocessed {\n const bufferIndex = gltfBufferView.buffer;\n const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;\n // Add offset of buffer, then offset of buffer view\n let byteOffset = this.buffers[bufferIndex].byteOffset || 0;\n if (gltfBufferView.byteOffset) {\n byteOffset += gltfBufferView.byteOffset;\n }\n\n const bufferView: GLTFBufferViewPostprocessed = {\n // // @ts-expect-error id could already be present, glTF standard does not prevent it\n id: `bufferView-${index}`,\n ...gltfBufferView,\n // ...this.buffers[bufferIndex],\n buffer: this.buffers[bufferIndex],\n data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)\n };\n\n return bufferView;\n }\n\n _resolveCamera(gltfCamera: GLTFCamera, index): GLTFCameraPostprocessed {\n const camera: GLTFCameraPostprocessed = {\n ...gltfCamera,\n // @ts-expect-error id could already be present, glTF standard does not prevent it\n id: gltfCamera.id || `camera-${index}`\n };\n\n // TODO - create 4x4 matrices\n if (camera.perspective) {\n // camera.matrix = createPerspectiveMatrix(camera.perspective);\n }\n if (camera.orthographic) {\n // camera.matrix = createOrthographicMatrix(camera.orthographic);\n }\n return camera;\n }\n}\n\nexport function postProcessGLTF(\n gltf: GLTFWithBuffers,\n options?: ParseGLTFOptions\n): GLTFPostprocessed {\n return new GLTFPostProcessor().postProcess(gltf, options);\n}\n"],"mappings":";AAqCA,SAAQA,MAAM,QAAO,iBAAiB;AACtC,SAAQC,6BAA6B,QAAO,0BAA0B;AAYtE,MAAMC,UAAU,GAAG;EACjBC,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,MAAMC,KAAK,GAAG;EACZ,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE,CAAC;EACP,IAAI,EAAE;AACR,CAAC;AAED,MAAMC,UAAU,GAAG;EAEjBC,kBAAkB,EAAE,MAAM;EAC1BC,kBAAkB,EAAE,MAAM;EAC1BC,cAAc,EAAE,MAAM;EACtBC,cAAc,EAAE,MAAM;EAGtBC,MAAM,EAAE,MAAM;EACdC,MAAM,EAA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c,CAACnB,UAAU,EAAE;MAC7BA,UAAU,IAAImB,cAAc,CAACnB,UAAU;IACzC;IAEA,MAAML,UAAuC,GAAG;MAE9CvG,EAAE,gBAAAwE,MAAA,CAAgBlB,KAAK,CAAE;MACzB,GAAGyE,cAAc;MAEjBtB,MAAM,EAAE,IAAI,CAACzF,OAAO,CAACgH,WAAW,CAAC;MACjCC,IAAI,EAAE,IAAIb,UAAU,CAACN,WAAW,EAAEF,UAAU,EAAEmB,cAAc,CAACpB,UAAU;IACzE,CAAC;IAED,OAAOJ,UAAU;EACnB;EAEA2B,cAAcA,CAACC,UAAsB,EAAE7E,KAAK,EAA2B;IACrE,MAAMoB,MAA+B,GAAG;MACtC,GAAGyD,UAAU;MAEbnI,EAAE,EAAEmI,UAAU,CAACnI,EAAE,cAAAwE,MAAA,CAAclB,KAAK;IACtC,CAAC;IAGD,IAAIoB,MAAM,CAAC0D,WAAW,EAAE,CAExB;IACA,IAAI1D,MAAM,CAAC2D,YAAY,EAAE,CAEzB;IACA,OAAO3D,MAAM;EACf;AACF;AAEA,OAAO,SAAS4D,eAAeA,CAC7B5H,IAAqB,EACrBC,OAA0B,EACP;EACnB,OAAO,IAAIL,iBAAiB,CAAC,CAAC,CAACG,WAAW,CAACC,IAAI,EAAEC,OAAO,CAAC;AAC3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode-glb.js","names":["copyPaddedStringToDataView","copyPaddedArrayBufferToDataView","MAGIC_glTF","MAGIC_JSON","MAGIC_BIN","LE","encodeGLBSync","glb","dataView","byteOffset","arguments","length","undefined","options","magic","version","json","binary","byteOffsetStart","setUint32","byteOffsetFileLength","byteOffsetJsonHeader","jsonString","JSON","stringify","jsonByteLength","byteOffsetBinHeader","binByteLength","fileByteLength"],"sources":["../../../../src/lib/encoders/encode-glb.ts"],"sourcesContent":["/* eslint-disable camelcase, max-statements */\nimport {\n copyPaddedStringToDataView,\n copyPaddedArrayBufferToDataView\n} from '@loaders.gl/loader-utils';\n// import type {GLB} from '../types/glb-types';\n\nconst MAGIC_glTF = 0x46546c67; // glTF in ASCII\nconst MAGIC_JSON = 0x4e4f534a; // JSON in ASCII\nconst MAGIC_BIN = 0x004e4942; // BIN\\0 in ASCII\n\nconst LE = true; // Binary GLTF is little endian.\n\nexport type GLBEncodeOptions = {};\n\n/**\n * Encode the full GLB buffer with header etc\n *\n * @param glb\n * @param dataView - if `null`, does not encode but just calculates length\n * @param byteOffset\n * @param options\n * @returns\n *\n * @see https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#glb-file-format-specification\n * @todo type GLB argument\n */\nexport function encodeGLBSync(\n glb,\n dataView: DataView | null,\n byteOffset = 0,\n options: GLBEncodeOptions = {}\n) {\n const {magic = MAGIC_glTF, version = 2, json = {}, binary} = glb;\n\n const byteOffsetStart = byteOffset;\n\n // Write GLB Header\n if (dataView) {\n dataView.setUint32(byteOffset + 0, magic, LE); // Magic number (the ASCII string 'glTF').\n dataView.setUint32(byteOffset + 4, version, LE); // Version 2 of binary glTF container format uint32\n dataView.setUint32(byteOffset + 8, 0, LE); // Total byte length of generated file (uint32), will be set last\n }\n const byteOffsetFileLength = byteOffset + 8;\n byteOffset += 12; // GLB_FILE_HEADER_SIZE\n\n // Write the JSON chunk header\n const byteOffsetJsonHeader = byteOffset;\n if (dataView) {\n dataView.setUint32(byteOffset + 0, 0, LE); // Byte length of json chunk (will be written later)\n dataView.setUint32(byteOffset + 4, MAGIC_JSON, LE); // Chunk type\n }\n byteOffset += 8; // GLB_CHUNK_HEADER_SIZE\n\n // Write the JSON chunk\n const jsonString = JSON.stringify(json);\n byteOffset = copyPaddedStringToDataView(dataView, byteOffset, jsonString, 4);\n\n // Now we know the JSON chunk length so we can write it.\n if (dataView) {\n const jsonByteLength = byteOffset - byteOffsetJsonHeader - 8; // GLB_CHUNK_HEADER_SIZE\n dataView.setUint32(byteOffsetJsonHeader + 0, jsonByteLength, LE); // Byte length of json chunk (uint32)\n }\n\n // Write the BIN chunk if present. The BIN chunk is optional.\n if (binary) {\n const byteOffsetBinHeader = byteOffset;\n\n // Write the BIN chunk header\n if (dataView) {\n dataView.setUint32(byteOffset + 0, 0, LE); // Byte length BIN (uint32)\n dataView.setUint32(byteOffset + 4, MAGIC_BIN, LE); // Chunk type\n }\n byteOffset += 8; // GLB_CHUNK_HEADER_SIZE\n\n byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, binary, 4);\n\n // Now we know the BIN chunk length so we can write it.\n if (dataView) {\n const binByteLength = byteOffset - byteOffsetBinHeader - 8; // GLB_CHUNK_HEADER_SIZE\n dataView.setUint32(byteOffsetBinHeader + 0, binByteLength, LE); // Byte length BIN (uint32)\n }\n }\n\n // Now we know the glb file length so we can write it.\n if (dataView) {\n const fileByteLength = byteOffset - byteOffsetStart;\n dataView.setUint32(byteOffsetFileLength, fileByteLength, LE); // Total byte length of generated file (uint32)\n }\n\n return byteOffset;\n}\n"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,+BAA+B,QAC1B,0BAA0B;AAGjC,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,SAAS,GAAG,UAAU;AAE5B,MAAMC,EAAE,GAAG,IAAI;AAgBf,OAAO,SAASC,aAAaA,CAC3BC,GAAG,EACHC,QAAyB,EAGzB;EAAA,IAFAC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IACdG,OAAyB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE9B,MAAM;IAACI,KAAK,GAAGZ,UAAU;IAAEa,OAAO,GAAG,CAAC;IAAEC,IAAI,GAAG,CAAC,CAAC;IAAEC;EAAM,CAAC,GAAGV,GAAG;EAEhE,MAAMW,eAAe,GAAGT,UAAU;EAGlC,IAAID,QAAQ,EAAE;IACZA,QAAQ,CAAC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,UAAU,EAAEQ,MAAM,EAAE,CAAC,CAAC;IAG7E,IAAIT,QAAQ,EAAE;MACZ,MAAMmB,aAAa,GAAGlB,UAAU,GAAGiB,mBAAmB,GAAG,CAAC;MAC1DlB,QAAQ,CAACW,SAAS,CAACO,mBAAmB,GAAG,CAAC,EAAEC,aAAa,EAAEtB,EAAE,CAAC;IAChE;EACF;EAGA,IAAIG,QAAQ,EAAE;IACZ,MAAMoB,cAAc,GAAGnB,UAAU,GAAGS,eAAe;IACnDV,QAAQ,CAACW,SAAS,CAACC,oBAAoB,EAAEQ,cAAc,EAAEvB,EAAE,CAAC;EAC9D;EAEA,OAAOI,UAAU;AACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode-gltf.js","names":["encodeGLBSync","encodeGLTFSync","gltf","arrayBuffer","byteOffset","options","convertBuffersToBase64","firstBuffer","arguments","length","undefined","buffers","Error"],"sources":["../../../../src/lib/encoders/encode-gltf.ts"],"sourcesContent":["import {encodeGLBSync} from './encode-glb';\n\nexport type GLTFEncodeOptions = Record<string, any>;\n\n/**\n * Encode the full glTF file as a binary GLB file\n * Returns an ArrayBuffer that represents the complete GLB image that can be saved to file\n *\n * @todo - Does not support encoding to non-GLB versions of glTF format. Other formats\n * - Encode as a textual JSON file with binary data in base64 data URLs.\n * - Encode as a JSON with all images (and buffers?) in separate binary files\n *\n * glb-file-format-specification\n * @see https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#\n *\n * @param gltf\n * @param arrayBuffer\n * @param byteOffset\n * @param options\n * @returns\n */\nexport function encodeGLTFSync(gltf, arrayBuffer, byteOffset, options) {\n convertBuffersToBase64(gltf);\n\n // TODO: Copy buffers to binary\n\n return encodeGLBSync(gltf, arrayBuffer, byteOffset, options);\n}\n\nfunction convertBuffersToBase64(gltf, {firstBuffer = 0} = {}) {\n if (gltf.buffers && gltf.buffers.length > firstBuffer) {\n throw new Error('encodeGLTF: multiple buffers not yet implemented');\n }\n}\n"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAc;AAqB1C,OAAO,SAASC,cAAcA,CAACC,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACrEC,sBAAsB,CAACJ,IAAI,CAAC;EAI5B,OAAOF,aAAa,CAACE,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,CAAC;AAC9D;AAEA,SAASC,sBAAsBA,CAACJ,IAAI,EAA0B;EAAA,IAAxB;IAACK,WAAW,GAAG;EAAC,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC1D,IAAIN,IAAI,CAACS,OAAO,IAAIT,IAAI,CAACS,OAAO,CAACF,MAAM,GAAGF,WAAW,EAAE;IACrD,MAAM,IAAIK,KAAK,CAAC,kDAAkD,CAAC;EACrE;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EXT_mesh_features.js","names":["GLTFScenegraph","getPrimitiveTextureData","EXT_MESH_FEATURES_NAME","name","decode","gltfData","options","scenegraph","decodeExtMeshFeatures","json","gltf","meshes","mesh","primitive","primitives","processMeshPrimitiveFeatures","_options$gltf","_primitive$extensions","loadBuffers","extension","extensions","featureIds","featureId","_options$gltf2","featureIdData","attribute","accessorKey","concat","accessorIndex","attributes","getTypedArrayForAccessor","texture","loadImages","data"],"sources":["../../../../src/lib/extensions/EXT_mesh_features.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_mesh_features\n// https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features\n/* eslint-disable camelcase */\nimport type {GLTF, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {\n GLTF_EXT_mesh_features,\n GLTF_EXT_mesh_features_featureId\n} from '../types/gltf-ext-mesh-features-schema';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getPrimitiveTextureData} from './utils/3d-tiles-utils';\n\nconst EXT_MESH_FEATURES_NAME = 'EXT_mesh_features';\nexport const name = EXT_MESH_FEATURES_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtMeshFeatures(scenegraph, options);\n}\n\n/**\n * Decodes feature metadata from extension.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFLoaderOptions} options - GLTFLoader options.\n */\nfunction decodeExtMeshFeatures(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n const json = scenegraph.gltf.json;\n if (!json.meshes) {\n return;\n }\n\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processMeshPrimitiveFeatures(scenegraph, primitive, options);\n }\n }\n}\n\n/**\n * Takes data from EXT_mesh_features and store it in 'data' property of featureIds.\n * If combined with EXT_structural_metadata, corresponding data are taken from the property tables of that extension.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFMeshPrimitive} primitive - Primitive that contains extensions.\n * @param {GLTFLoaderOptions} options - GLTFLoader options.\n */\nfunction processMeshPrimitiveFeatures(\n scenegraph: GLTFScenegraph,\n primitive: GLTFMeshPrimitive,\n options: GLTFLoaderOptions\n): void {\n // Processing of mesh primitive features requires buffers to be loaded.\n if (!options?.gltf?.loadBuffers) {\n return;\n }\n\n const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME] as GLTF_EXT_mesh_features;\n const featureIds: GLTF_EXT_mesh_features_featureId[] = extension?.featureIds;\n\n if (!featureIds) {\n return;\n }\n\n for (const featureId of featureIds) {\n let featureIdData: number[] | null = null;\n // Process \"Feature ID by Vertex\"\n if (typeof featureId.attribute !== 'undefined') {\n const accessorKey = `_FEATURE_ID_${featureId.attribute}`;\n const accessorIndex = primitive.attributes[accessorKey];\n featureIdData = scenegraph.getTypedArrayForAccessor(accessorIndex) as number[];\n }\n\n // Process \"Feature ID by Texture Coordinates\"\n else if (typeof featureId.texture !== 'undefined' && options?.gltf?.loadImages) {\n featureIdData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);\n }\n\n // Process \"Feature ID by Index\"\n else {\n /*\n When both featureId.attribute and featureId.texture are undefined,\n then the feature ID value for each vertex is given implicitly, via the index of the vertex.\n In this case, the featureCount must match the number of vertices of the mesh primitive.\n */\n // TODO: At the moment of writing we don't have a tileset with the data of that kind. Implement it later.\n }\n\n featureId.data = featureIdData;\n }\n}\n"],"mappings":"AAUA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SAAQC,uBAAuB,QAAO,wBAAwB;AAE9D,MAAMC,sBAAsB,GAAG,mBAAmB;AAClD,OAAO,MAAMC,IAAI,GAAGD,sBAAsB;AAE1C,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAIP,cAAc,CAACK,QAAQ,CAAC;EAC/CG,qBAAqB,CAACD,UAAU,EAAED,OAAO,CAAC;AAC5C;AAOA,SAASE,qBAAqBA,CAACD,UAA0B,EAAED,OAA0B,EAAQ;EAC3F,MAAMG,IAAI,GAAGF,UAAU,CAACG,IAAI,CAACD,IAAI;EACjC,IAAI,CAACA,IAAI,CAACE,MAAM,EAAE;IAChB;EACF;EAGA,KAAK,MAAMC,IAAI,IAAIH,IAAI,CAACE,MAAM,EAAE;IAC9B,KAAK,MAAME,SAAS,IAAID,IAAI,CAACE,UAAU,EAAE;MACvCC,4BAA4B,CAACR,UAAU,EAAEM,SAAS,EAAEP,OAAO,CAAC;IAC9D;EACF;AACF;AASA,SAASS,4BAA4BA,CACnCR,UAA0B,EAC1BM,SAA4B,EAC5BP,OAA0B,EACpB;EAAA,IAAAU,aAAA,EAAAC,qBAAA;EAEN,IAAI,EAACX,OAAO,aAAPA,OAAO,gBAAAU,aAAA,GAAPV,OAAO,CAAEI,IAAI,cAAAM,aAAA,eAAbA,aAAA,CAAeE,WAAW,GAAE;IAC/B;EACF;EAEA,MAAMC,SAAS,IAAAF,qBAAA,GAAGJ,SAAS,CAACO,UAAU,cAAAH,qBAAA,uBAApBA,qBAAA,CAAuBf,sBAAsB,CAA2B;EAC1F,MAAMmB,UAA8C,GAAGF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,UAAU;EAE5E,IAAI,CAACA,UAAU,EAAE;IACf;EACF;EAEA,KAAK,MAAMC,SAAS,IAAID,UAAU,EAAE;IAAA,IAAAE,cAAA;IAClC,IAAIC,aAA8B,GAAG,IAAI;IAEzC,IAAI,OAAOF,SAAS,CAACG,SAAS,KAAK,WAAW,EAAE;MAC9C,MAAMC,WAAW,kBAAAC,MAAA,CAAkBL,SAAS,CAACG,SAAS,CAAE;MACxD,MAAMG,aAAa,GAAGf,SAAS,CAACgB,UAAU,CAACH,WAAW,CAAC;MACvDF,aAAa,GAAGjB,UAAU,CAACuB,wBAAwB,CAACF,aAAa,CAAa;IAChF,CAAC,MAGI,IAAI,OAAON,SAAS,CAACS,OAAO,KAAK,WAAW,IAAIzB,OAAO,aAAPA,OAAO,gBAAAiB,cAAA,GAAPjB,OAAO,CAAEI,IAAI,cAAAa,cAAA,eAAbA,cAAA,CAAeS,UAAU,EAAE;MAC9ER,aAAa,GAAGvB,uBAAuB,CAACM,UAAU,EAAEe,SAAS,CAACS,OAAO,EAAElB,SAAS,CAAC;IACnF,CAAC,MAGI,CAOL;IAEAS,SAAS,CAACW,IAAI,GAAGT,aAAa;EAChC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EXT_meshopt_compression.js","names":["GLTFScenegraph","meshoptDecodeGltfBuffer","DEFAULT_MESHOPT_OPTIONS","byteOffset","filter","EXT_MESHOPT_COMPRESSION","name","decode","gltfData","options","_options$gltf","_options$gltf2","scenegraph","gltf","decompressMeshes","loadBuffers","promises","bufferViewIndex","json","bufferViews","push","decodeMeshoptBufferView","Promise","all","removeExtension","bufferView","meshoptExtension","getObjectExtension","byteLength","byteStride","count","mode","buffer","bufferIndex","buffers","source","Uint8Array","arrayBuffer","result","removeObjectExtension"],"sources":["../../../../src/lib/extensions/EXT_meshopt_compression.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFBufferView, GLTF_EXT_meshopt_compression} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {meshoptDecodeGltfBuffer} from '../../meshopt/meshopt-decoder';\n\n// @ts-ignore\n// eslint-disable-next-line\nconst DEFAULT_MESHOPT_OPTIONS = {\n byteOffset: 0,\n filter: 'NONE'\n};\n\n/** Extension name */\nconst EXT_MESHOPT_COMPRESSION = 'EXT_meshopt_compression';\n\nexport const name = EXT_MESHOPT_COMPRESSION;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions) {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {\n return;\n }\n\n const promises: Promise<any>[] = [];\n for (const bufferViewIndex of gltfData.json.bufferViews || []) {\n promises.push(decodeMeshoptBufferView(scenegraph, bufferViewIndex));\n }\n\n // Decompress meshes in parallel\n await Promise.all(promises);\n\n // We have now decompressed all primitives, so remove the top-level extension\n scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION);\n}\n\n/** Decode one meshopt buffer view */\nasync function decodeMeshoptBufferView(\n scenegraph: GLTFScenegraph,\n bufferView: GLTFBufferView\n): Promise<void> {\n const meshoptExtension = scenegraph.getObjectExtension<GLTF_EXT_meshopt_compression>(\n bufferView,\n EXT_MESHOPT_COMPRESSION\n );\n if (meshoptExtension) {\n const {\n byteOffset = 0,\n byteLength = 0,\n byteStride,\n count,\n mode,\n filter = 'NONE',\n buffer: bufferIndex\n } = meshoptExtension;\n const buffer = scenegraph.gltf.buffers[bufferIndex];\n\n const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);\n const result = new Uint8Array(\n scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer,\n bufferView.byteOffset,\n bufferView.byteLength\n );\n await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);\n scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);\n }\n}\n"],"mappings":"AAGA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SAAQC,uBAAuB,QAAO,+BAA+B;AAIrE,MAAMC,uBAAuB,GAAG;EAC9BC,UAAU,EAAE,CAAC;EACbC,MAAM,EAAE;AACV,CAAC;AAGD,MAAMC,uBAAuB,GAAG,yBAAyB;AAEzD,OAAO,MAAMC,IAAI,GAAGD,uBAAuB;AAE3C,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAE;EAAA,IAAAC,aAAA,EAAAC,cAAA;EAC/E,MAAMC,UAAU,GAAG,IAAIZ,cAAc,CAACQ,QAAQ,CAAC;EAE/C,IAAI,EAACC,OAAO,aAAPA,OAAO,gBAAAC,aAAA,GAAPD,OAAO,CAAEI,IAAI,cAAAH,aAAA,eAAbA,aAAA,CAAeI,gBAAgB,KAAI,GAAAH,cAAA,GAACF,OAAO,CAACI,IAAI,cAAAF,cAAA,eAAZA,cAAA,CAAcI,WAAW,GAAE;IAClE;EACF;EAEA,MAAMC,QAAwB,GAAG,EAAE;EACnC,KAAK,MAAMC,eAAe,IAAIT,QAAQ,CAACU,IAAI,CAACC,WAAW,IAAI,EAAE,EAAE;IAC7DH,QAAQ,CAACI,IAAI,CAACC,uBAAuB,CAACT,UAAU,EAAEK,eAAe,CAAC,CAAC;EACrE;EAGA,MAAMK,OAAO,CAACC,GAAG,CAACP,QAAQ,CAAC;EAG3BJ,UAAU,CAACY,eAAe,CAACnB,uBAAuB,CAAC;AACrD;AAGA,eAAegB,uBAAuBA,CACpCT,UAA0B,EAC1Ba,UAA0B,EACX;EACf,MAAMC,gBAAgB,GAAGd,UAAU,CAACe,kBAAkB,CACpDF,UAAU,EACVpB,uBACF,CAAC;EACD,IAAIqB,gBAAgB,EAAE;IACpB,MAAM;MACJvB,UAAU,GAAG,CAAC;MACdyB,UAAU,GAAG,CAAC;MACdC,UAAU;MACVC,KAAK;MACLC,IAAI;MACJ3B,MAAM,GAAG,MAAM;MACf4B,MAAM,EAAEC;IACV,CAAC,GAAGP,gBAAgB;IACpB,MAAMM,MAAM,GAAGpB,UAAU,CAACC,IAAI,CAACqB,OAAO,CAACD,WAAW,CAAC;IAEnD,MAAME,MAAM,GAAG,IAAIC,UAAU,CAACJ,MAAM,CAACK,WAAW,EAAEL,MAAM,CAAC7B,UAAU,GAAGA,UAAU,EAAEyB,UAAU,CAAC;IAC7F,MAAMU,MAAM,GAAG,IAAIF,UAAU,CAC3BxB,UAAU,CAACC,IAAI,CAACqB,OAAO,CAACT,UAAU,CAACO,MAAM,CAAC,CAACK,WAAW,EACtDZ,UAAU,CAACtB,UAAU,EACrBsB,UAAU,CAACG,UACb,CAAC;IACD,MAAM3B,uBAAuB,CAACqC,MAAM,EAAER,KAAK,EAAED,UAAU,EAAEM,MAAM,EAAEJ,IAAI,EAAE3B,MAAM,CAAC;IAC9EQ,UAAU,CAAC2B,qBAAqB,CAACd,UAAU,EAAEpB,uBAAuB,CAAC;EACvE;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EXT_structural_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_STRUCTURAL_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtStructuralMetadata","getPropertyTableFromExtStructuralMetadata","extension","metadataClass","propertyTables","firstPropertyTable","propertyTableWithData","propertyName","properties","data","propertyTextures","firstPropertyTexture","console","warn","_options$gltf","_options$gltf2","gltf","loadBuffers","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","json","meshes","mesh","primitive","primitives","processPrimitivePropertyTextures","schema","schemaClasses","classes","schemaName","propertyTable","findPropertyTableByClass","processPropertyTable","schemaClassName","class","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","dataAttributeNames","className","_propertyTexture$prop","attributeName","concat","textureInfoTopLevel","featureTextureTable","propertyData","push","_schema$classes","schemaClass","Error","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","valuesBufferView","values","valuesDataBytes","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","getPropertyDataNumeric","getPropertyDataENUM","array","arrayOffsetType","stringOffsetType","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","length","_schema$enums","enumType","enumEntry","enums","enumValueType","valueType","parseVariableLengthArrayENUM","valuesDataBytesLength","parseFixedLengthArrayENUM","getEnumsArray","params","attributeValueArray","index","arrayOffset","arrayByteSize","typedArrayOffset","elementOffset","offset","i","BigInt64Array","BigUint64Array","value","enumObject","getEnumByValue","enumValue"],"sources":["../../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_structural_metadata\n// https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\n/* eslint-disable camelcase */\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_Enum,\n GLTF_EXT_structural_metadata_EnumValue,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_PropertyTable_Property,\n GLTF_EXT_structural_metadata_Primitive\n} from '../types/gltf-ext-structural-metadata-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {FeatureTableJson} from '../types/gltf-types';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from './utils/3d-tiles-utils';\n\nconst EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';\nexport const name = EXT_STRUCTURAL_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtStructuralMetadata(scenegraph, options);\n}\n\n/**\n * Handles EXT_structural_metadata to get property table.\n * @param extension - Global level of EXT_STRUCTURAL_METADATA extension.\n * @param metadataClass - User selected feature metadata class name.\n * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.\n */\nexport function getPropertyTableFromExtStructuralMetadata(\n extension: GLTF_EXT_structural_metadata_GLTF,\n metadataClass?: string\n): FeatureTableJson | null {\n if (extension.propertyTables) {\n /**\n * Take only first feature table to generate attributes storage info object.\n * TODO: Think about getting data from all feature tables?\n * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.\n * In I3S we should decide which featureIds attribute will be passed to geometry data.\n */\n const firstPropertyTable = extension?.propertyTables[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTable.properties) {\n propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n if (extension.propertyTextures) {\n // TODO: Think about getting data from all property textures.\n const firstPropertyTexture = extension?.propertyTextures[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTexture.properties) {\n propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n // eslint-disable-next-line no-console\n console.warn(\n 'Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.'\n );\n return null;\n}\n\n/*\n// Example of the extension.\n// See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\nconst extensions = {\n \"extensions\": {\n \"EXT_structural_metadata\": {\n \"schema\": {\n \"classes\": {\n \"tree\": {\n \"name\": \"Tree\",\n \"description\": \"Woody, perennial plant.\",\n \"properties\": {\n \"species\": {\n \"description\": \"Type of tree.\",\n \"type\": \"ENUM\",\n \"enumType\": \"speciesEnum\",\n \"required\": true\n },\n \"age\": {\n \"description\": \"The age of the tree, in years\",\n \"type\": \"SCALAR\",\n \"componentType\": \"UINT8\",\n \"required\": true\n }\n }\n }\n },\n \"enums\": {\n \"speciesEnum\": {\n \"name\": \"Species\",\n \"description\": \"An example enum for tree species.\",\n // valueType is not defined here. Default is \"UINT16\"\n \"values\": [\n { \"name\": \"Unspecified\", \"value\": 0 },\n { \"name\": \"Oak\", \"value\": 1 }\n ]\n }\n }\n },\n \"propertyTables\": [{\n \"name\": \"tree_survey_2021-09-29\",\n \"class\": \"tree\",\n \"count\": 10, // The number of elements in each property array (in `species`, in `age`).\n \"properties\": {\n \"species\": {\n \"values\": 0, // It's an index of the buffer view containing property values.\n },\n \"age\": {\n \"values\": 1\n }\n }\n }]\n }\n }\n}\n*/\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtStructuralMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_structural_metadata_GLTF | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const propertyTextures = extension.propertyTextures;\n const json = scenegraph.gltf.json;\n if (propertyTextures && json.meshes) {\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.propertyTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: GLTF_EXT_structural_metadata_PropertyTable[],\n schemaClassName: string\n): GLTF_EXT_structural_metadata_PropertyTable | null {\n for (const propertyTable of propertyTables) {\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\n/**\n * Takes data from property textures reffered by the primitive.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTextures - propertyTexture definition taken from the top-level extention.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTextures(\n scenegraph: GLTFScenegraph,\n propertyTextures: GLTF_EXT_structural_metadata_PropertyTexture[],\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTextures) {\n return;\n }\n const primitiveExtension: GLTF_EXT_structural_metadata_Primitive = primitive.extensions?.[\n EXT_STRUCTURAL_METADATA_NAME\n ] as GLTF_EXT_structural_metadata_Primitive;\n const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;\n if (!primitivePropertyTextureIndices) {\n return;\n }\n\n for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {\n const propertyTexture = propertyTextures[primitivePropertyTextureIndex];\n processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);\n }\n}\n\n/**\n * Takes property data from the texture pointed by the primitive and appends them to `exension.data`.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTexture - propertyTexture definition taken from the top-level extension.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTexture(\n scenegraph: GLTFScenegraph,\n propertyTexture: GLTF_EXT_structural_metadata_PropertyTexture,\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTexture.properties) {\n return;\n }\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n /* Iterate through all properties defined in propertyTexture, e.g. \"speed\" and \"direction\":\n {\n \"class\": \"wind\",\n \"properties\": {\n \"speed\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [0]\n },\n \"direction\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [1, 2]\n }\n }\n }\n */\n const className = propertyTexture.class;\n for (const propertyName in propertyTexture.properties) {\n // propertyName has values like \"speed\", \"direction\"\n // Make attributeName as a combination of the class name and the propertyName like \"wind_speed\" or \"wind_direction\"\n const attributeName = `${className}_${propertyName}`;\n const textureInfoTopLevel: GLTFTextureInfoMetadata | undefined =\n propertyTexture.properties?.[propertyName];\n if (!textureInfoTopLevel) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // The data taken from all meshes/primitives (the same property, e.g. \"speed\" or \"direction\") will be combined into one array and saved in textureInfoTopLevel.data\n // Initially textureInfoTopLevel.data will be initialized with an empty array.\n if (!textureInfoTopLevel.data) {\n textureInfoTopLevel.data = [];\n }\n const featureTextureTable: number[] = textureInfoTopLevel.data as number[];\n\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (propertyData === null) {\n // eslint-disable-next-line no-continue\n continue;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n textureInfoTopLevel.data = featureTextureTable;\n extension.dataAttributeNames.push(attributeName);\n }\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n propertyTable: GLTF_EXT_structural_metadata_PropertyTable\n): void {\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes a propertyTable column from binary source based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - Schema object.\n * @param classProperty - class property object.\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 propertyTableProperty - propertyTable's property metadata.\n * @returns {string[] | number[] | string[][] | number[][]}\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const valuesBufferView = propertyTableProperty.values;\n const valuesDataBytes: Uint8Array = scenegraph.getTypedArrayForBufferView(valuesBufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n propertyTableProperty,\n numberOfElements\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n propertyTableProperty,\n numberOfElements\n );\n\n switch (classProperty.type) {\n case 'SCALAR':\n case 'VEC2':\n case 'VEC3':\n case 'VEC4':\n case 'MAT2':\n case 'MAT3':\n case 'MAT4': {\n data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);\n break;\n }\n case 'BOOLEAN': {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n case 'STRING': {\n data = getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);\n break;\n }\n case 'ENUM': {\n data = getPropertyDataENUM(\n schema,\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets\n );\n break;\n }\n default:\n throw new Error(`Unknown classProperty type ${classProperty.type}`);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n classProperty.array &&\n // `count` is a number of array elements. May only be defined when `array` is true.\n // If `count` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.count === 'undefined' &&\n // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsets !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses propertyTable.property.stringOffsets.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L29C10-L29C23\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsets !== 'undefined' // `stringOffsets` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Decodes properties of SCALAR, VEC-N, MAT-N types from binary sourse.\n * @param classProperty - class property object.\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 * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n let valuesData: BigTypedArray;\n if (classProperty.componentType) {\n valuesData = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n classProperty.componentType as NumericComponentType,\n elementCount\n );\n } else {\n // The spec doesn't provide any info what to do if componentType is not set.\n valuesData = valuesDataBytes;\n }\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Decodes properties of enum type from binary source.\n * @param schema - Schema object.\n * @param classProperty - Class property object.\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 * @returns Strings array of nested strings array.\n */\nfunction getPropertyDataENUM(\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): string[] | string[][] {\n const enumType = classProperty.enumType;\n // Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`.\n if (!enumType) {\n throw new Error(\n 'Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM'\n );\n }\n\n const enumEntry: GLTF_EXT_structural_metadata_Enum | undefined = schema.enums?.[enumType];\n if (!enumEntry) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`\n );\n }\n\n const enumValueType = enumEntry.valueType || 'UINT16';\n const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n let valuesData: BigTypedArray | null = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n enumValueType,\n elementCount\n );\n if (!valuesData) {\n valuesData = valuesDataBytes;\n }\n\n if (classProperty.array) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayENUM({\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength: valuesDataBytes.length,\n elementSize,\n enumEntry\n });\n }\n\n const arrayCount = classProperty.count;\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);\n }\n return [];\n }\n\n // Single value (not an array)\n return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);\n}\n\n/**\n * Parses variable length nested ENUM arrays.\n * @param params.valuesData - Values in a flat typed array.\n * @param params.numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param params.arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param params.valuesDataBytesLength - Byte length of values array.\n * @param params.elementSize - Single element byte size.\n * @param params.enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseVariableLengthArrayENUM(params: {\n valuesData: BigTypedArray;\n numberOfElements: number;\n arrayOffsets: TypedArray;\n valuesDataBytesLength: number;\n elementSize: number;\n enumEntry: GLTF_EXT_structural_metadata_Enum;\n}): string[][] {\n const {\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength,\n elementSize,\n enumEntry\n } = params;\n const attributeValueArray: string[][] = [];\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\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n const array: string[] = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed length ENUM arrays.\n * @param valuesData - Values in a flat typed array.\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 arrayCount - Nested arrays length.\n * @param enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseFixedLengthArrayENUM(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[][] {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = arrayCount * index;\n const array: string[] = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses ENUM values into a string array.\n * @param valuesData - Values in a flat typed array.\n * @param offset - Offset to start parse from.\n * @param count - Values length to parse.\n * @param enumEntry - Enums dictionary.\n * @returns Array of strings with parsed ENUM names.\n */\nfunction getEnumsArray(\n valuesData: BigTypedArray,\n offset: number,\n count: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[] {\n const array: string[] = [];\n for (let i = 0; i < count; i++) {\n // At the moment we don't support BigInt. It requires additional calculations logic\n // and might be an issue in Safari\n if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {\n array.push('');\n } else {\n const value = valuesData[offset + i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n } else {\n array.push('');\n }\n }\n }\n return array;\n}\n\n/**\n * Looks up ENUM whose `value` property matches the specified number in the parameter `value`.\n * @param {GLTF_EXT_structural_metadata_Enum} enumEntry - ENUM entry containing the array of possible enums.\n * @param {number} value - The value of the ENUM to locate.\n * @returns {GLTF_EXT_structural_metadata_EnumValue | null} ENUM matcihng the specified value or null of no ENUM object was found.\n */\nfunction getEnumByValue(\n enumEntry: GLTF_EXT_structural_metadata_Enum,\n value: number\n): GLTF_EXT_structural_metadata_EnumValue | null {\n for (const enumValue of enumEntry.values) {\n if (enumValue.value === value) {\n return enumValue;\n }\n }\n\n return null;\n}\n"],"mappings":"AAmBA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SACEC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAAqB,QAChB,wBAAwB;AAE/B,MAAMC,4BAA4B,GAAG,yBAAyB;AAC9D,OAAO,MAAMC,IAAI,GAAGD,4BAA4B;AAEhD,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAId,cAAc,CAACY,QAAQ,CAAC;EAC/CG,2BAA2B,CAACD,UAAU,EAAED,OAAO,CAAC;AAClD;AAQA,OAAO,SAASG,yCAAyCA,CACvDC,SAA4C,EAC5CC,aAAsB,EACG;EACzB,IAAID,SAAS,CAACE,cAAc,EAAE;IAO5B,MAAMC,kBAAkB,GAAGH,SAAS,aAATA,SAAS,uBAATA,SAA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OAAOG,SAAS;IAClB;EACF;EAEA,OAAO,IAAI;AACb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EXT_texture_webp.js","names":["isImageFormatSupported","GLTFScenegraph","EXT_TEXTURE_WEBP","name","preprocess","gltfData","options","scenegraph","getRequiredExtensions","includes","Error","concat","json","texture","textures","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../../src/lib/extensions/EXT_texture_webp.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_TEXTURE_WEBP\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_TEXTURE_WEBP\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_EXT_texture_webp} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {isImageFormatSupported} from '@loaders.gl/images';\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\nconst EXT_TEXTURE_WEBP = 'EXT_texture_webp';\n\n/** Extension name */\nexport const name = EXT_TEXTURE_WEBP;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n if (!isImageFormatSupported('image/webp')) {\n if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) {\n throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);\n }\n return;\n }\n\n const {json} = scenegraph;\n\n for (const texture of json.textures || []) {\n const extension = scenegraph.getObjectExtension<GLTF_EXT_texture_webp>(\n texture,\n EXT_TEXTURE_WEBP\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n }\n scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP);\n }\n\n // Remove the top-level extension\n scenegraph.removeExtension(EXT_TEXTURE_WEBP);\n}\n"],"mappings":"AAOA,SAAQA,sBAAsB,QAAO,oBAAoB;AACzD,SAAQC,cAAc,QAAO,wBAAwB;AAErD,MAAMC,gBAAgB,GAAG,kBAAkB;AAG3C,OAAO,MAAMC,IAAI,GAAGD,gBAAgB;AAMpC,OAAO,SAASE,UAAUA,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,MAAMC,UAAU,GAAG,IAAIN,cAAc,CAACI,QAAQ,CAAC;EAE/C,IAAI,CAACL,sBAAsB,CAAC,YAAY,CAAC,EAAE;IACzC,IAAIO,UAAU,CAACC,qBAAqB,CAAC,CAAC,CAACC,QAAQ,CAACP,gBAAgB,CAAC,EAAE;MACjE,MAAM,IAAIQ,KAAK,6BAAAC,MAAA,CAA6BT,gBAAgB,8BAA2B,CAAC;IAC1F;IACA;EACF;EAEA,MAAM;IAACU;EAAI,CAAC,GAAGL,UAAU;EAEzB,KAAK,MAAMM,OAAO,IAAID,IAAI,CAACE,QAAQ,IAAI,EAAE,EAAE;IACzC,MAAMC,SAAS,GAAGR,UAAU,CAACS,kBAAkB,CAC7CH,OAAO,EACPX,gBACF,CAAC;IACD,IAAIa,SAAS,EAAE;MAEbF,OAAO,CAACI,MAAM,GAAGF,SAAS,CAACE,MAAM;IACnC;IACAV,UAAU,CAACW,qBAAqB,CAACL,OAAO,EAAEX,gBAAgB,CAAC;EAC7D;EAGAK,UAAU,CAACY,eAAe,CAACjB,gBAAgB,CAAC;AAC9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_binary_gltf.js","names":["GLTFScenegraph","KHR_BINARY_GLTF","name","preprocess","gltfData","gltfScenegraph","json","image","images","extension","getObjectExtension","Object","assign","removeObjectExtension","buffers","uri","removeExtension"],"sources":["../../../../src/lib/extensions/KHR_binary_gltf.ts"],"sourcesContent":["// GLTF 1.0 EXTENSION: KHR_binary_glTF\n// https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_KHR_binary_glTF} from '../types/gltf-json-schema';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\nconst KHR_BINARY_GLTF = 'KHR_binary_glTF';\n\n/** Extension name */\nexport const name = KHR_BINARY_GLTF;\n\nexport function preprocess(gltfData: {json: GLTF}): void {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const {json} = gltfScenegraph;\n\n // Note: json.buffers.binary_glTF also needs to be replaced\n // This is currently done during gltf normalization\n\n // Image and shader nodes can have the extension\n // https://github.com/KhronosGroup/glTF/blob/master/extensions/1.0/Khronos/KHR_binary_glTF/schema/image.KHR_binary_glTF.schema.json\n for (const image of json.images || []) {\n const extension = gltfScenegraph.getObjectExtension<GLTF_KHR_binary_glTF>(\n image,\n KHR_BINARY_GLTF\n );\n // The data in the extension is valid as glTF 2.0 data inside the object, so just copy it in\n if (extension) {\n Object.assign(image, extension);\n }\n gltfScenegraph.removeObjectExtension(image, KHR_BINARY_GLTF);\n }\n\n // TODO shaders - At least traverse and throw error if used?\n // https://github.com/KhronosGroup/glTF/blob/master/extensions/1.0/Khronos/KHR_binary_glTF/schema/shader.KHR_binary_glTF.schema.json\n\n // glTF v1 one files have a partially formed URI field that is not expected in (and causes problems in) 2.0\n if (json.buffers && json.buffers[0]) {\n delete json.buffers[0].uri;\n }\n\n // Remove the top-level extension as it has now been processed\n gltfScenegraph.removeExtension(KHR_BINARY_GLTF);\n}\n\n// KHR_binary_gltf is a 1.0 extension that is supported natively by 2.0\n// export function encode() {\n// throw new Error(KHR_BINARY_GLTF);\n// }\n"],"mappings":"AAMA,SAAQA,cAAc,QAAO,wBAAwB;AAErD,MAAMC,eAAe,GAAG,iBAAiB;AAGzC,OAAO,MAAMC,IAAI,GAAGD,eAAe;AAEnC,OAAO,SAASE,UAAUA,CAACC,QAAsB,EAAQ;EACvD,MAAMC,cAAc,GAAG,IAAIL,cAAc,CAACI,QAAQ,CAAC;EACnD,MAAM;IAACE;EAAI,CAAC,GAAGD,cAAc;EAO7B,KAAK,MAAME,KAAK,IAAID,IAAI,CAACE,MAAM,IAAI,EAAE,EAAE;IACrC,MAAMC,SAAS,GAAGJ,cAAc,CAACK,kBAAkB,CACjDH,KAAK,EACLN,eACF,CAAC;IAED,IAAIQ,SAAS,EAAE;MACbE,MAAM,CAACC,MAAM,CAACL,KAAK,EAAEE,SAAS,CAAC;IACjC;IACAJ,cAAc,CAACQ,qBAAqB,CAACN,KAAK,EAAEN,eAAe,CAAC;EAC9D;EAMA,IAAIK,IAAI,CAACQ,OAAO,IAAIR,IAAI,CAACQ,OAAO,CAAC,CAAC,CAAC,EAAE;IACnC,OAAOR,IAAI,CAACQ,OAAO,CAAC,CAAC,CAAC,CAACC,GAAG;EAC5B;EAGAV,cAAc,CAACW,eAAe,CAACf,eAAe,CAAC;AACjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_draco_mesh_compression.js","names":["sliceArrayBuffer","parseFromContext","DracoLoader","GLTFScenegraph","getGLTFAccessors","getGLTFAccessor","KHR_DRACO_MESH_COMPRESSION","name","preprocess","gltfData","options","context","scenegraph","primitive","makeMeshPrimitiveIterator","getObjectExtension","decode","_options$gltf","gltf","decompressMeshes","promises","push","decompressPrimitive","Promise","all","removeExtension","encode","arguments","length","undefined","mesh","json","meshes","compressMesh","addRequiredExtension","dracoExtension","buffer","getTypedArrayForBufferView","bufferView","bufferCopy","byteOffset","dracoOptions","decodedData","decodedAttributes","attributes","attributeName","decodedAttribute","Object","entries","accessorIndex","accessor","getAccessor","min","max","indices","removeObjectExtension","checkPrimitive","_context$parseSync","mode","DracoWriter","Error","compressedData","encodeSync","parseSync","call","fauxAccessors","_addFauxAttributes","bufferViewIndex","addBufferView","glTFMesh","primitives","extensions","keys"],"sources":["../../../../src/lib/extensions/KHR_draco_mesh_compression.ts"],"sourcesContent":["// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression\n// Only TRIANGLES: 0x0004 and TRIANGLE_STRIP: 0x0005 are supported\n/* eslint-disable camelcase */\n\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport {sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';\n\nimport {DracoLoader} from '@loaders.gl/draco';\nimport {DracoLoaderOptions} from '@loaders.gl/draco';\n\nimport type {\n GLTF,\n GLTFAccessor,\n GLTFMeshPrimitive,\n GLTF_KHR_draco_mesh_compression\n} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getGLTFAccessors, getGLTFAccessor} from '../gltf-utils/gltf-attribute-utils';\n\nconst KHR_DRACO_MESH_COMPRESSION = 'KHR_draco_mesh_compression';\n\n/** Extension name */\nexport const name = KHR_DRACO_MESH_COMPRESSION;\n\nexport function preprocess(\n gltfData: {json: GLTF},\n options: GLTFLoaderOptions,\n context: LoaderContext\n): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n for (const primitive of makeMeshPrimitiveIterator(scenegraph)) {\n if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) {\n // TODO - Remove fallback accessors to make sure we don't load unnecessary buffers\n }\n }\n}\n\nexport async function decode(\n gltfData: {json: GLTF},\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<void> {\n if (!options?.gltf?.decompressMeshes) {\n return;\n }\n\n const scenegraph = new GLTFScenegraph(gltfData);\n const promises: Promise<void>[] = [];\n for (const primitive of makeMeshPrimitiveIterator(scenegraph)) {\n if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) {\n promises.push(decompressPrimitive(scenegraph, primitive, options, context));\n }\n }\n\n // Decompress meshes in parallel\n await Promise.all(promises);\n\n // We have now decompressed all primitives, so remove the top-level extension\n scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION);\n}\n\nexport function encode(gltfData, options: GLTFLoaderOptions = {}): void {\n const scenegraph = new GLTFScenegraph(gltfData);\n\n for (const mesh of scenegraph.json.meshes || []) {\n // eslint-disable-next-line camelcase\n // @ts-ignore\n compressMesh(mesh, options);\n // NOTE: Only add the extension if something was actually compressed\n scenegraph.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION);\n }\n}\n\n// DECODE\n\n// Unpacks one mesh primitive and removes the extension from the primitive\n// DracoDecoder needs to be imported and registered by app\n// Returns: Promise that resolves when all pending draco decoder jobs for this mesh complete\n\n// TODO - Implement fallback behavior per KHR_DRACO_MESH_COMPRESSION spec\n\nasync function decompressPrimitive(\n scenegraph: GLTFScenegraph,\n primitive: GLTFMeshPrimitive,\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<void> {\n const dracoExtension = scenegraph.getObjectExtension<GLTF_KHR_draco_mesh_compression>(\n primitive,\n KHR_DRACO_MESH_COMPRESSION\n );\n if (!dracoExtension) {\n return;\n }\n\n const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);\n // TODO - parse does not yet deal well with byte offsets embedded in typed arrays. Copy buffer\n // TODO - remove when `parse` is fixed to handle `byteOffset`s\n const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset); // , buffer.byteLength);\n\n const dracoOptions: DracoLoaderOptions = {...options};\n\n // TODO - remove hack: The entire tileset might be included, too expensive to serialize\n delete dracoOptions['3d-tiles'];\n const decodedData = await parseFromContext(bufferCopy, DracoLoader, dracoOptions, context);\n\n const decodedAttributes: {[key: string]: GLTFAccessor} = getGLTFAccessors(decodedData.attributes);\n\n // Restore min/max values\n for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {\n if (attributeName in primitive.attributes) {\n const accessorIndex: number = primitive.attributes[attributeName];\n const accessor = scenegraph.getAccessor(accessorIndex);\n if (accessor?.min && accessor?.max) {\n decodedAttribute.min = accessor.min;\n decodedAttribute.max = accessor.max;\n }\n }\n }\n\n // @ts-ignore\n primitive.attributes = decodedAttributes;\n if (decodedData.indices) {\n // @ts-ignore\n primitive.indices = getGLTFAccessor(decodedData.indices);\n }\n\n // Extension has been processed, delete it\n scenegraph.removeObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION);\n\n checkPrimitive(primitive);\n}\n\n// ENCODE\n\n// eslint-disable-next-line max-len\n// Only TRIANGLES: 0x0004 and TRIANGLE_STRIP: 0x0005 are supported\nfunction compressMesh(attributes, indices, mode: number = 4, options, context: LoaderContext) {\n if (!options.DracoWriter) {\n throw new Error('options.gltf.DracoWriter not provided');\n }\n\n // TODO - use DracoWriter using encode w/ registered DracoWriter...\n const compressedData = options.DracoWriter.encodeSync({attributes});\n\n // Draco compression may change the order and number of vertices in a mesh.\n // To satisfy the requirement that accessors properties be correct for both\n // compressed and uncompressed data, generators should create uncompressed\n // attributes and indices using data that has been decompressed from the Draco buffer,\n // rather than the original source data.\n // @ts-ignore TODO this needs to be fixed\n const decodedData = context?.parseSync?.({attributes});\n const fauxAccessors = options._addFauxAttributes(decodedData.attributes);\n\n const bufferViewIndex = options.addBufferView(compressedData);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: fauxAccessors, // TODO - verify with spec\n mode, // GL.POINTS\n extensions: {\n [KHR_DRACO_MESH_COMPRESSION]: {\n bufferView: bufferViewIndex,\n attributes: fauxAccessors // TODO - verify with spec\n }\n }\n }\n ]\n };\n\n return glTFMesh;\n}\n\n// UTILS\n\nfunction checkPrimitive(primitive: GLTFMeshPrimitive) {\n if (!primitive.attributes && Object.keys(primitive.attributes).length > 0) {\n throw new Error('glTF: Empty primitive detected: Draco decompression failure?');\n }\n}\n\nfunction* makeMeshPrimitiveIterator(scenegraph) {\n for (const mesh of scenegraph.json.meshes || []) {\n for (const primitive of mesh.primitives) {\n yield primitive;\n }\n }\n}\n"],"mappings":"AAKA,SAAQA,gBAAgB,EAAEC,gBAAgB,QAAO,0BAA0B;AAE3E,SAAQC,WAAW,QAAO,mBAAmB;AAW7C,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SAAQC,gBAAgB,EAAEC,eAAe,QAAO,oCAAoC;AAEp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,CAAC;EAExE,MAAMuB,eAAe,GAAGzD,OAAO,CAAC0D,aAAa,CAACP,cAAc,CAAC;EAE7D,MAAMQ,QAAQ,GAAG;IACfC,UAAU,EAAE,CACV;MACE1B,UAAU,EAAEqB,aAAa;MACzBP,IAAI;MACJa,UAAU,EAAE;QACV,CAACjE,0BAA0B,GAAG;UAC5BgC,UAAU,EAAE6B,eAAe;UAC3BvB,UAAU,EAAEqB;QACd;MACF;IACF,CAAC;EAEL,CAAC;EAED,OAAOI,QAAQ;AACjB;AAIA,SAASb,cAAcA,CAAC3C,SAA4B,EAAE;EACpD,IAAI,CAACA,SAAS,CAAC+B,UAAU,IAAIG,MAAM,CAACyB,IAAI,CAAC3D,SAAS,CAAC+B,UAAU,CAAC,CAAChB,MAAM,GAAG,CAAC,EAAE;IACzE,MAAM,IAAIgC,KAAK,CAAC,8DAA8D,CAAC;EACjF;AACF;AAEA,UAAU9C,yBAAyBA,CAACF,UAAU,EAAE;EAC9C,KAAK,MAAMkB,IAAI,IAAIlB,UAAU,CAACmB,IAAI,CAACC,MAAM,IAAI,EAAE,EAAE;IAC/C,KAAK,MAAMnB,SAAS,IAAIiB,IAAI,CAACwC,UAAU,EAAE;MACvC,MAAMzD,SAAS;IACjB;EACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_texture_basisu.js","names":["GLTFScenegraph","KHR_TEXTURE_BASISU","name","preprocess","gltfData","options","scene","json","texture","textures","extension","getObjectExtension","source","removeObjectExtension","removeExtension"],"sources":["../../../../src/lib/extensions/KHR_texture_basisu.ts"],"sourcesContent":["// GLTF EXTENSION: KHR_texture_basisu\n// https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_basisu\n/* eslint-disable camelcase */\n\nimport type {GLTF, GLTF_KHR_texture_basisu} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\nconst KHR_TEXTURE_BASISU = 'KHR_texture_basisu';\n\n/** Extension name */\nexport const name = KHR_TEXTURE_BASISU;\n\n/**\n * Replaces a texture source reference with the extension texture\n * Done in preprocess() to prevent load of default image\n */\nexport function preprocess(gltfData: {json: GLTF}, options: GLTFLoaderOptions): void {\n const scene = new GLTFScenegraph(gltfData);\n const {json} = scene;\n\n for (const texture of json.textures || []) {\n const extension = scene.getObjectExtension<GLTF_KHR_texture_basisu>(\n texture,\n KHR_TEXTURE_BASISU\n );\n if (extension) {\n // TODO - if multiple texture extensions are present which one wins?\n texture.source = extension.source;\n scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);\n }\n }\n\n // Remove the top-level extension\n scene.removeExtension(KHR_TEXTURE_BASISU);\n}\n"],"mappings":"AAOA,SAAQA,cAAc,QAAO,wBAAwB;AAErD,MAAMC,kBAAkB,GAAG,oBAAoB;AAG/C,OAAO,MAAMC,IAAI,GAAGD,kBAAkB;AAMtC,OAAO,SAASE,UAAUA,CAACC,QAAsB,EAAEC,OAA0B,EAAQ;EACnF,MAAMC,KAAK,GAAG,IAAIN,cAAc,CAACI,QAAQ,CAAC;EAC1C,MAAM;IAACG;EAAI,CAAC,GAAGD,KAAK;EAEpB,KAAK,MAAME,OAAO,IAAID,IAAI,CAACE,QAAQ,IAAI,EAAE,EAAE;IACzC,MAAMC,SAAS,GAAGJ,KAAK,CAACK,kBAAkB,CACxCH,OAAO,EACPP,kBACF,CAAC;IACD,IAAIS,SAAS,EAAE;MAEbF,OAAO,CAACI,MAAM,GAAGF,SAAS,CAACE,MAAM;MACjCN,KAAK,CAACO,qBAAqB,CAACL,OAAO,EAAEP,kBAAkB,CAAC;IAC1D;EACF;EAGAK,KAAK,CAACQ,eAAe,CAACb,kBAAkB,CAAC;AAC3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_texture_transform.js","names":["Vector3","Matrix3","getAccessorArrayTypeAndLength","BYTES","COMPONENTS","GLTFScenegraph","EXT_MESHOPT_TRANSFORM","name","scratchVector","scratchRotationMatrix","scratchScaleMatrix","decode","gltfData","options","_options$gltf","gltfScenegraph","hasExtension","gltf","loadBuffers","materials","json","i","length","transformTexCoords","materialIndex","_gltfData$json$materi","_material$pbrMetallic","_material$pbrMetallic2","processedTexCoords","material","baseColorTexture","pbrMetallicRoughness","transformPrimitives","emisiveTexture","emissiveTexture","normalTexture","occlusionTexture","metallicRoughnessTexture","texture","transformParameters","getTransformParameters","meshes","mesh","primitive","primitives","Number","isFinite","transformPrimitive","_texture$extensions","textureInfo","extensions","texCoord","originalTexCoord","isProcessed","findIndex","_ref","original","newTexCoord","matrix","makeTransformationMatrix","push","texCoordAccessor","attributes","concat","_gltfData$json$access","accessor","accessors","bufferView","_gltfData$json$buffer","bufferViews","arrayBuffer","byteOffset","bufferByteOffset","buffers","buffer","ArrayType","bytes","componentType","components","type","elementAddressScale","byteStride","result","Float32Array","count","uv","set","transformByMatrix3","updateGltf","createAttribute","newTexCoordArray","byteLength","originalAccessor","extensionData","offset","rotation","scale","translationMatrix","rotationMatrix","Math","cos","sin","scaleMatrix","multiplyRight"],"sources":["../../../../src/lib/extensions/KHR_texture_transform.ts"],"sourcesContent":["/**\n * https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md\n */\n\nimport {Vector3, Matrix3} from '@math.gl/core';\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {\n GLTFMeshPrimitive,\n GLTFAccessor,\n GLTFBufferView,\n GLTFMaterialNormalTextureInfo,\n GLTFMaterialOcclusionTextureInfo,\n GLTFTextureInfo\n} from '../types/gltf-json-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {getAccessorArrayTypeAndLength} from '../gltf-utils/gltf-utils';\nimport {BYTES, COMPONENTS} from '../gltf-utils/gltf-constants';\nimport {} from '../types/gltf-json-schema';\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\n\n/** Extension name */\nconst EXT_MESHOPT_TRANSFORM = 'KHR_texture_transform';\n\nexport const name = EXT_MESHOPT_TRANSFORM;\n\nconst scratchVector = new Vector3();\nconst scratchRotationMatrix = new Matrix3();\nconst scratchScaleMatrix = new Matrix3();\n\n/** Extension textureInfo https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates */\ntype TextureInfo = {\n /** The offset of the UV coordinate origin as a factor of the texture dimensions. */\n offset?: [number, number];\n /** Rotate the UVs by this many radians counter-clockwise around the origin. This is equivalent to a similar rotation of the image clockwise. */\n rotation?: number;\n /** The scale factor applied to the components of the UV coordinates. */\n scale?: [number, number];\n /** Overrides the textureInfo texCoord value if supplied, and if this extension is supported. */\n texCoord?: number;\n};\n/** Intersection of all GLTF textures */\ntype CompoundGLTFTextureInfo = GLTFTextureInfo &\n GLTFMaterialNormalTextureInfo &\n GLTFMaterialOcclusionTextureInfo;\n/** Parameters for TEXCOORD transformation */\ntype TransformParameters = {\n /** Original texCoord value https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#_textureinfo_texcoord */\n originalTexCoord: number;\n /** New texCoord value from extension https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates */\n texCoord: number;\n /** Transformation matrix */\n matrix: Matrix3;\n};\n\n/**\n * The extension entry to process the transformation\n * @param gltfData gltf buffers and json\n * @param options GLTFLoader options\n */\nexport async function decode(gltfData: GLTFWithBuffers, options: GLTFLoaderOptions) {\n const gltfScenegraph = new GLTFScenegraph(gltfData);\n const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);\n if (!hasExtension || !options.gltf?.loadBuffers) {\n return;\n }\n const materials = gltfData.json.materials || [];\n for (let i = 0; i < materials.length; i++) {\n transformTexCoords(i, gltfData);\n }\n}\n\n/**\n * Transform TEXCOORD by material\n * @param materialIndex processing material index\n * @param gltfData gltf buffers and json\n */\nfunction transformTexCoords(materialIndex: number, gltfData: GLTFWithBuffers): void {\n // Save processed texCoords in order no to process the same twice\n const processedTexCoords: [number, number][] = [];\n const material = gltfData.json.materials?.[materialIndex];\n const baseColorTexture = material?.pbrMetallicRoughness?.baseColorTexture;\n if (baseColorTexture) {\n transformPrimitives(gltfData, materialIndex, baseColorTexture, processedTexCoords);\n }\n const emisiveTexture = material?.emissiveTexture;\n if (emisiveTexture) {\n transformPrimitives(gltfData, materialIndex, emisiveTexture, processedTexCoords);\n }\n const normalTexture = material?.normalTexture;\n if (normalTexture) {\n transformPrimitives(gltfData, materialIndex, normalTexture, processedTexCoords);\n }\n const occlusionTexture = material?.occlusionTexture;\n if (occlusionTexture) {\n transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);\n }\n const metallicRoughnessTexture = material?.pbrMetallicRoughness?.metallicRoughnessTexture;\n if (metallicRoughnessTexture) {\n transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);\n }\n}\n\n/**\n * Transform primitives of the particular material\n * @param gltfData gltf data\n * @param materialIndex primitives with this material will be transformed\n * @param texture texture object\n * @param processedTexCoords storage to save already processed texCoords\n */\nfunction transformPrimitives(\n gltfData: GLTFWithBuffers,\n materialIndex: number,\n texture: CompoundGLTFTextureInfo,\n processedTexCoords: [number, number][]\n) {\n const transformParameters = getTransformParameters(texture, processedTexCoords);\n if (!transformParameters) {\n return;\n }\n const meshes = gltfData.json.meshes || [];\n for (const mesh of meshes) {\n for (const primitive of mesh.primitives) {\n const material = primitive.material;\n if (Number.isFinite(material) && materialIndex === material) {\n transformPrimitive(gltfData, primitive, transformParameters);\n }\n }\n }\n}\n\n/**\n * Get parameters for TEXCOORD transformation\n * @param texture texture object\n * @param processedTexCoords storage to save already processed texCoords\n * @returns texCoord couple and transformation matrix\n */\nfunction getTransformParameters(\n texture: CompoundGLTFTextureInfo,\n processedTexCoords: [number, number][]\n): TransformParameters | null {\n const textureInfo = texture.extensions?.[EXT_MESHOPT_TRANSFORM];\n const {texCoord: originalTexCoord = 0} = texture;\n // If texCoord is not set in the extension, original attribute data will be replaced\n const {texCoord = originalTexCoord} = textureInfo;\n // Make sure that couple [originalTexCoord, extensionTexCoord] is not processed twice\n const isProcessed =\n processedTexCoords.findIndex(\n ([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord\n ) !== -1;\n if (!isProcessed) {\n const matrix = makeTransformationMatrix(textureInfo);\n if (originalTexCoord !== texCoord) {\n texture.texCoord = texCoord;\n }\n processedTexCoords.push([originalTexCoord, texCoord]);\n return {originalTexCoord, texCoord, matrix};\n }\n return null;\n}\n\n/**\n * Transform `TEXCOORD_0` attribute in the primitive\n * @param gltfData gltf data\n * @param primitive primitive object\n * @param transformParameters texCoord couple and transformation matrix\n */\nfunction transformPrimitive(\n gltfData: GLTFWithBuffers,\n primitive: GLTFMeshPrimitive,\n transformParameters: TransformParameters\n) {\n const {originalTexCoord, texCoord, matrix} = transformParameters;\n const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];\n if (Number.isFinite(texCoordAccessor)) {\n // Get accessor of the `TEXCOORD_0` attribute\n const accessor = gltfData.json.accessors?.[texCoordAccessor];\n if (accessor && accessor.bufferView) {\n // Get `bufferView` of the `accessor`\n const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];\n if (bufferView) {\n // Get `arrayBuffer` the `bufferView` look at\n const {arrayBuffer, byteOffset: bufferByteOffset} = gltfData.buffers[bufferView.buffer];\n // Resulting byteOffset is sum of the buffer, accessor and bufferView byte offsets\n const byteOffset =\n (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);\n // Deduce TypedArray type and its length from `accessor` and `bufferView` data\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // Number of bytes each component occupies\n const bytes = BYTES[accessor.componentType];\n // Number of components. For the `TEXCOORD_0` with `VEC2` type, it must return 2\n const components = COMPONENTS[accessor.type];\n // Multiplier to calculate the address of the `TEXCOORD_0` element in the arrayBuffer\n const elementAddressScale = bufferView.byteStride || bytes * components;\n // Data transform to Float32Array\n const result = new Float32Array(length);\n for (let i = 0; i < accessor.count; i++) {\n // Take [u, v] couple from the arrayBuffer\n const uv = new ArrayType(arrayBuffer, byteOffset + i * elementAddressScale, 2);\n // Set and transform Vector3 per https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#overview\n scratchVector.set(uv[0], uv[1], 1);\n scratchVector.transformByMatrix3(matrix);\n // Save result in Float32Array\n result.set([scratchVector[0], scratchVector[1]], i * components);\n }\n // If texCoord the same, replace gltf structural data\n if (originalTexCoord === texCoord) {\n updateGltf(accessor, bufferView, gltfData.buffers, result);\n } else {\n // If texCoord change, create new attribute\n createAttribute(texCoord, accessor, primitive, gltfData, result);\n }\n }\n }\n }\n}\n\n/**\n * Update GLTF structural objects with new data as we create new `Float32Array` for `TEXCOORD_0`.\n * @param accessor accessor to change\n * @param bufferView bufferView to change\n * @param buffers binary buffers\n * @param newTexcoordArray typed array with data after transformation\n */\nfunction updateGltf(\n accessor: GLTFAccessor,\n bufferView: GLTFBufferView,\n buffers: {arrayBuffer: ArrayBuffer; byteOffset: number; byteLength: number}[],\n newTexCoordArray: Float32Array\n): void {\n accessor.componentType = 5126;\n buffers.push({\n arrayBuffer: newTexCoordArray.buffer,\n byteOffset: 0,\n byteLength: newTexCoordArray.buffer.byteLength\n });\n bufferView.buffer = buffers.length - 1;\n bufferView.byteLength = newTexCoordArray.buffer.byteLength;\n bufferView.byteOffset = 0;\n delete bufferView.byteStride;\n}\n\n/**\n *\n * @param newTexCoord new `texCoord` value\n * @param originalAccessor original accessor object, that store data before transformation\n * @param primitive primitive object\n * @param gltfData gltf data\n * @param newTexCoordArray typed array with data after transformation\n * @returns\n */\nfunction createAttribute(\n newTexCoord: number,\n originalAccessor: GLTFAccessor,\n primitive: GLTFMeshPrimitive,\n gltfData: GLTFWithBuffers,\n newTexCoordArray: Float32Array\n) {\n gltfData.buffers.push({\n arrayBuffer: newTexCoordArray.buffer,\n byteOffset: 0,\n byteLength: newTexCoordArray.buffer.byteLength\n });\n const bufferViews = gltfData.json.bufferViews;\n if (!bufferViews) {\n return;\n }\n bufferViews.push({\n buffer: gltfData.buffers.length - 1,\n byteLength: newTexCoordArray.buffer.byteLength,\n byteOffset: 0\n });\n const accessors = gltfData.json.accessors;\n if (!accessors) {\n return;\n }\n accessors.push({\n bufferView: bufferViews?.length - 1,\n byteOffset: 0,\n componentType: 5126,\n count: originalAccessor.count,\n type: 'VEC2'\n });\n primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1;\n}\n\n/**\n * Construct transformation matrix from the extension data (transition, rotation, scale)\n * @param extensionData extension data\n * @returns transformation matrix\n */\nfunction makeTransformationMatrix(extensionData: TextureInfo): Matrix3 {\n const {offset = [0, 0], rotation = 0, scale = [1, 1]} = extensionData;\n const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);\n const rotationMatrix = scratchRotationMatrix.set(\n Math.cos(rotation),\n Math.sin(rotation),\n 0,\n -Math.sin(rotation),\n Math.cos(rotation),\n 0,\n 0,\n 0,\n 1\n );\n const scaleMatrix = scratchScaleMatrix.set(scale[0], 0, 0, 0, scale[1], 0, 0, 0, 1);\n return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);\n}\n"],"mappings":"AAIA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAY9C,SAAQC,6BAA6B,QAAO,0BAA0B;AACtE,SAAQC,KAAK,EAAEC,UAAU,QAAO,8BAA8B;AAC9D,OAAe,2BAA2B;AAC1C,SAAQC,cAAc,QAAO,wBAAwB;AAGrD,MAAMC,qBAAqB,GAAG,uBAAuB;AAErD,OAAO,MAAMC,IAAI,GAAGD,qBAAqB;AAEzC,MAAME,aAAa,GAAG,IAAIR,OAAO,CAAC,CAAC;AACnC,MAAMS,qBAAqB,GAAG,IAAIR,OAAO,CAAC,CAAC;AAC3C,MAAMS,kBAAkB,GAAG,IAAIT,OAAO,CA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