@vctrl/hooks 0.16.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/GLTFLoader-CygFefRr.cjs +1 -0
- package/GLTFLoader-NiJ7qzh1.js +1381 -0
- package/README.md +0 -20
- package/__vite-browser-external-Bn_csQuM.js +7 -0
- package/__vite-browser-external-CVmj8TrW.cjs +1 -0
- package/chunk-foFoljWS.js +23 -0
- package/chunk-gGpyby2o.cjs +1 -0
- package/index.cjs.js +1 -0
- package/index.d.ts +5 -0
- package/index.es.js +4 -0
- package/lib-DKn2MJ9X.js +4111 -0
- package/lib-DZ-MihdJ.cjs +2 -0
- package/model-exporter-SMSAY90N.cjs +1 -0
- package/model-exporter-cvguDGnn.js +6512 -0
- package/package.json +1 -1
- package/server-communication-Bj6ZxFw2.js +4659 -0
- package/server-communication-yXZR8eso.cjs +18 -0
- package/use-export-model/use-export-model.d.ts +14 -0
- package/use-export-model-CaijtW1c.cjs +1 -0
- package/use-export-model-DzVKdqnY.js +49 -0
- package/use-export-model.cjs.js +1 -0
- package/use-export-model.es.js +2 -0
- package/use-load-model/event-system.d.ts +7 -0
- package/use-load-model/index.d.ts +4 -0
- package/use-load-model/state.d.ts +19 -0
- package/use-load-model/types.d.ts +231 -0
- package/use-load-model/use-load-model.d.ts +30 -0
- package/use-load-model/utils/calculate-referenced-bytes.d.ts +8 -0
- package/use-load-model/utils/index.d.ts +4 -0
- package/use-load-model/utils/read-directory.d.ts +8 -0
- package/use-load-model/utils/reconstruct-files.d.ts +29 -0
- package/use-load-model/utils/resolve-scene-payload.d.ts +6 -0
- package/use-load-model-B6UXiFWh.js +517 -0
- package/use-load-model-CH-WPQ_s.cjs +1 -0
- package/use-load-model.cjs.js +1 -0
- package/use-load-model.es.js +18 -0
- package/{src/use-optimize-model/index.ts → use-optimize-model/index.d.ts} +2 -2
- package/use-optimize-model/state.d.ts +13 -0
- package/use-optimize-model/types.d.ts +39 -0
- package/use-optimize-model/use-calc-optimization-info.d.ts +6 -0
- package/use-optimize-model/use-optimize-model.d.ts +119 -0
- package/use-optimize-model/utils/index.d.ts +2 -0
- package/use-optimize-model/utils/texture-optimization.d.ts +17 -0
- package/use-optimize-model/utils/validation.d.ts +8 -0
- package/use-optimize-model-C-fzzKh6.cjs +1 -0
- package/use-optimize-model-Cb3WMvDZ.js +299 -0
- package/use-optimize-model.cjs.js +1 -0
- package/use-optimize-model.es.js +2 -0
- package/utils/server-communication.d.ts +122 -0
- package/project.json +0 -55
- package/src/index.ts +0 -38
- package/src/use-export-model/use-export-model.ts +0 -113
- package/src/use-load-model/event-system.ts +0 -46
- package/src/use-load-model/index.ts +0 -15
- package/src/use-load-model/model-context.tsx +0 -174
- package/src/use-load-model/state.ts +0 -75
- package/src/use-load-model/types.ts +0 -284
- package/src/use-load-model/use-load-model.ts +0 -682
- package/src/use-load-model/utils/calculate-referenced-bytes.ts +0 -123
- package/src/use-load-model/utils/index.ts +0 -7
- package/src/use-load-model/utils/read-directory.ts +0 -35
- package/src/use-load-model/utils/reconstruct-files.ts +0 -85
- package/src/use-load-model/utils/resolve-scene-payload.ts +0 -151
- package/src/use-optimize-model/state.ts +0 -40
- package/src/use-optimize-model/types.ts +0 -37
- package/src/use-optimize-model/use-calc-optimization-info.ts +0 -101
- package/src/use-optimize-model/use-optimize-model.ts +0 -467
- package/src/use-optimize-model/utils/index.ts +0 -29
- package/src/use-optimize-model/utils/texture-optimization.ts +0 -292
- package/src/use-optimize-model/utils/validation.ts +0 -62
- package/src/utils/server-communication.ts +0 -351
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -16
- package/vite.config.ts +0 -77
- /package/{src/use-export-model/index.ts → use-export-model/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.18.0](https://github.com/Vectreal/vectreal-platform/compare/hooks-v0.17.0...hooks-v0.18.0) (2026-04-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add camera transition and snapshot functionality ([#435](https://github.com/Vectreal/vectreal-platform/issues/435)) ([da2de12](https://github.com/Vectreal/vectreal-platform/commit/da2de12c51376877b1cbf6e87066383024aff78a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @vctrl/core bumped to 0.18.0
|
|
16
|
+
|
|
17
|
+
## [0.17.0](https://github.com/Vectreal/vectreal-platform/compare/hooks-v0.16.2...hooks-v0.17.0) (2026-04-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* update dashboard action buttons and sidebar links ([#403](https://github.com/Vectreal/vectreal-platform/issues/403)) ([c144470](https://github.com/Vectreal/vectreal-platform/commit/c1444705dce5bd9a625880d0a8d9535f240aa353))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @vctrl/core bumped to 0.17.0
|
|
30
|
+
|
|
3
31
|
## [0.16.2](https://github.com/Vectreal/vectreal-platform/compare/hooks-v0.16.1...hooks-v0.16.2) (2026-04-12)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./chunk-gGpyby2o.cjs`);let e=require(`three`);function t(t,n){if(n===e.TrianglesDrawMode)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),t;if(n===e.TriangleFanDrawMode||n===e.TriangleStripDrawMode){let r=t.getIndex();if(r===null){let e=[],n=t.getAttribute(`position`);if(n!==void 0){for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),r=t.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),t}let i=r.count-2,a=[];if(n===e.TriangleFanDrawMode)for(let e=1;e<=i;e++)a.push(r.getX(0)),a.push(r.getX(e)),a.push(r.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(a.push(r.getX(e)),a.push(r.getX(e+1)),a.push(r.getX(e+2))):(a.push(r.getX(e+2)),a.push(r.getX(e+1)),a.push(r.getX(e)));a.length/3!==i&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let o=t.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,n),t}function n(e){let t=new Map,n=new Map,i=e.clone();return r(e,i,function(e,r){t.set(r,e),n.set(e,r)}),i.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),i}function r(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)r(e.children[i],t.children[i],n)}var i=class extends e.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new d(e)}),this.register(function(e){return new f(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new S(e)}),this.register(function(e){return new C(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new h(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new _(e)}),this.register(function(e){return new u(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new p(e)}),this.register(function(e){return new b(e)}),this.register(function(e){return new y(e)}),this.register(function(e){return new c(e)}),this.register(function(e){return new w(e,s.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new w(e,s.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new T(e)})}load(t,n,r,i){let a=this,o;if(this.resourcePath!==``)o=this.resourcePath;else if(this.path!==``){let n=e.LoaderUtils.extractUrlBase(t);o=e.LoaderUtils.resolveURL(n,this.path)}else o=e.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);let s=function(e){i?i(e):console.error(e),a.manager.itemError(t),a.manager.itemEnd(t)},c=new e.FileLoader(this.manager);c.setPath(this.path),c.setResponseType(`arraybuffer`),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(t,function(e){try{a.parse(e,o,function(e){n(e),a.manager.itemEnd(t)},s)}catch(e){s(e)}},r,s)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},c=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===E){try{a[s.KHR_BINARY_GLTF]=new k(e)}catch(e){r&&r(e);return}i=JSON.parse(a[s.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let u=new ne(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](u);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case s.KHR_MATERIALS_UNLIT:a[t]=new l;break;case s.KHR_DRACO_MESH_COMPRESSION:a[t]=new A(i,this.dracoLoader);break;case s.KHR_TEXTURE_TRANSFORM:a[t]=new j;break;case s.KHR_MESH_QUANTIZATION:a[t]=new M;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}u.setExtensions(a),u.setPlugins(o),u.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function a(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function o(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var s={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},c=class{constructor(e){this.parser=e,this.name=s.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){let n=this.parser,r=`light:`+t,i=n.cache.get(r);if(i)return i;let a=n.json,o=((a.extensions&&a.extensions[this.name]||{}).lights||[])[t],s,c=new e.Color(16777215);o.color!==void 0&&c.setRGB(o.color[0],o.color[1],o.color[2],e.LinearSRGBColorSpace);let l=o.range===void 0?0:o.range;switch(o.type){case`directional`:s=new e.DirectionalLight(c),s.target.position.set(0,0,-1),s.add(s.target);break;case`point`:s=new e.PointLight(c),s.distance=l;break;case`spot`:s=new e.SpotLight(c),s.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle===void 0?0:o.spot.innerConeAngle,o.spot.outerConeAngle=o.spot.outerConeAngle===void 0?Math.PI/4:o.spot.outerConeAngle,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+o.type)}return s.position.set(0,0,0),q(s,o),o.intensity!==void 0&&(s.intensity=o.intensity),s.name=n.createUniqueName(o.name||`light_`+t),i=Promise.resolve(s),n.cache.add(r,i),i}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},l=class{constructor(){this.name=s.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,n,r){let i=[];t.color=new e.Color(1,1,1),t.opacity=1;let a=n.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){let n=a.baseColorFactor;t.color.setRGB(n[0],n[1],n[2],e.LinearSRGBColorSpace),t.opacity=n[3]}a.baseColorTexture!==void 0&&i.push(r.assignTexture(t,`map`,a.baseColorTexture,e.SRGBColorSpace))}return Promise.all(i)}},u=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},d=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(t,n){let r=o(this.parser,t,this.name);if(r===null)return Promise.resolve();let i=[];if(r.clearcoatFactor!==void 0&&(n.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(n,`clearcoatMap`,r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(n,`clearcoatRoughnessMap`,r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(n,`clearcoatNormalMap`,r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){let t=r.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(i)}},f=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_DISPERSION}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},p=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},m=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_SHEEN}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(t,n){let r=o(this.parser,t,this.name);if(r===null)return Promise.resolve();let i=[];if(n.sheenColor=new e.Color(0,0,0),n.sheenRoughness=0,n.sheen=1,r.sheenColorFactor!==void 0){let t=r.sheenColorFactor;n.sheenColor.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(n,`sheenColorMap`,r.sheenColorTexture,e.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(n,`sheenRoughnessMap`,r.sheenRoughnessTexture)),Promise.all(i)}},h=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},g=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_VOLUME}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(t,n){let r=o(this.parser,t,this.name);if(r===null)return Promise.resolve();let i=[];n.thickness=r.thicknessFactor===void 0?0:r.thicknessFactor,r.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(n,`thicknessMap`,r.thicknessTexture)),n.attenuationDistance=r.attenuationDistance||1/0;let a=r.attenuationColor||[1,1,1];return n.attenuationColor=new e.Color().setRGB(a[0],a[1],a[2],e.LinearSRGBColorSpace),Promise.all(i)}},_=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_IOR}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);return n===null?Promise.resolve():(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3),Promise.resolve())}},v=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_SPECULAR}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(t,n){let r=o(this.parser,t,this.name);if(r===null)return Promise.resolve();let i=[];n.specularIntensity=r.specularFactor===void 0?1:r.specularFactor,r.specularTexture!==void 0&&i.push(this.parser.assignTexture(n,`specularIntensityMap`,r.specularTexture));let a=r.specularColorFactor||[1,1,1];return n.specularColor=new e.Color().setRGB(a[0],a[1],a[2],e.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(n,`specularColorMap`,r.specularColorTexture,e.SRGBColorSpace)),Promise.all(i)}},y=class{constructor(e){this.parser=e,this.name=s.EXT_MATERIALS_BUMP}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},b=class{constructor(e){this.parser=e,this.name=s.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return o(this.parser,t,this.name)===null?null:e.MeshPhysicalMaterial}extendMaterialParams(e,t){let n=o(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},x=class{constructor(e){this.parser=e,this.name=s.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},S=class{constructor(e){this.parser=e,this.name=s.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},C=class{constructor(e){this.parser=e,this.name=s.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},w=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}else return null}},T=class{constructor(e){this.name=s.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(t){let n=this.parser.json,r=n.nodes[t];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;let i=n.meshes[r.mesh];for(let e of i.primitives)if(e.mode!==I.TRIANGLES&&e.mode!==I.TRIANGLE_STRIP&&e.mode!==I.TRIANGLE_FAN&&e.mode!==void 0)return null;let a=r.extensions[this.name].attributes,o=[],s={};for(let e in a)o.push(this.parser.getDependency(`accessor`,a[e]).then(t=>(s[e]=t,s[e])));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then(t=>{let n=t.pop(),r=n.isGroup?n.children:[n],i=t[0].count,a=[];for(let t of r){let n=new e.Matrix4,r=new e.Vector3,o=new e.Quaternion,c=new e.Vector3(1,1,1),l=new e.InstancedMesh(t.geometry,t.material,i);for(let e=0;e<i;e++)s.TRANSLATION&&r.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&o.fromBufferAttribute(s.ROTATION,e),s.SCALE&&c.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,n.compose(r,o,c));for(let n in s)if(n===`_COLOR_0`){let t=s[n];l.instanceColor=new e.InstancedBufferAttribute(t.array,t.itemSize,t.normalized)}else n!==`TRANSLATION`&&n!==`ROTATION`&&n!==`SCALE`&&t.geometry.setAttribute(n,s[n]);e.Object3D.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),a.push(l)}return n.isGroup?(n.clear(),n.add(...a),n):a[0]}))}},E=`glTF`,D=12,O={JSON:1313821514,BIN:5130562},k=class{constructor(e){this.name=s.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,D),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==E)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-D,i=new DataView(e,D),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===O.JSON){let r=new Uint8Array(e,D+a,t);this.content=n.decode(r)}else if(r===O.BIN){let n=D+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},A=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=s.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(t,n){let r=this.json,i=this.dracoLoader,a=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,s={},c={},l={};for(let e in o){let t=V[e]||e.toLowerCase();s[t]=o[e]}for(let e in t.attributes){let n=V[e]||e.toLowerCase();if(o[e]!==void 0){let i=r.accessors[t.attributes[e]];l[n]=L[i.componentType].name,c[n]=i.normalized===!0}}return n.getDependency(`bufferView`,a).then(function(t){return new Promise(function(n,r){i.decodeDracoFile(t,function(e){for(let t in e.attributes){let n=e.attributes[t],r=c[t];r!==void 0&&(n.normalized=r)}n(e)},s,l,e.LinearSRGBColorSpace,r)})})}},j=class{constructor(){this.name=s.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},M=class{constructor(){this.name=s.KHR_MESH_QUANTIZATION}},N=class extends e.Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},P=new e.Quaternion,F=class extends N{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return P.fromArray(i).normalize().toArray(i),i}},I={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},L={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},R={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},z={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},B={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},V={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},H={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},U={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},W={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function G(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),t.DefaultMaterial}function K(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function q(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function J(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function Y(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function X(e){let t,n=e.extensions&&e.extensions[s.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Z(n.attributes):e.indices+`:`+Z(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Z(e.targets[n]);return t}function Z(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function Q(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function ee(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var te=new e.Matrix4,ne=class{constructor(t={},n={}){this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new a,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=-1,o=!1,s=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);i=r&&t?parseInt(t[1],10):-1,o=e.indexOf(`Firefox`)>-1,s=o?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||r&&i<17||o&&s<98?this.textureLoader=new e.TextureLoader(this.options.manager):this.textureLoader=new e.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new e.FileLoader(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return K(i,a,r),q(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+ e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(t){let n=this.json.buffers[t],r=this.fileLoader;if(n.type&&n.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+n.type+` buffer type is not supported.`);if(n.uri===void 0&&t===0)return Promise.resolve(this.extensions[s.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(t,a){r.load(e.LoaderUtils.resolveURL(n.uri,i.path),t,void 0,function(){a(Error(`THREE.GLTFLoader: Failed to load buffer "`+n.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(t){let n=this,r=this.json,i=this.json.accessors[t];if(i.bufferView===void 0&&i.sparse===void 0){let t=B[i.type],n=L[i.componentType],r=i.normalized===!0,a=new n(i.count*t);return Promise.resolve(new e.BufferAttribute(a,t,r))}let a=[];return i.bufferView===void 0?a.push(null):a.push(this.getDependency(`bufferView`,i.bufferView)),i.sparse!==void 0&&(a.push(this.getDependency(`bufferView`,i.sparse.indices.bufferView)),a.push(this.getDependency(`bufferView`,i.sparse.values.bufferView))),Promise.all(a).then(function(t){let a=t[0],o=B[i.type],s=L[i.componentType],c=s.BYTES_PER_ELEMENT,l=c*o,u=i.byteOffset||0,d=i.bufferView===void 0?void 0:r.bufferViews[i.bufferView].byteStride,f=i.normalized===!0,p,m;if(d&&d!==l){let t=Math.floor(u/d),r=`InterleavedBuffer:`+i.bufferView+`:`+i.componentType+`:`+t+`:`+i.count,l=n.cache.get(r);l||(p=new s(a,t*d,i.count*d/c),l=new e.InterleavedBuffer(p,d/c),n.cache.add(r,l)),m=new e.InterleavedBufferAttribute(l,o,u%d/c,f)}else p=a===null?new s(i.count*o):new s(a,u,i.count*o),m=new e.BufferAttribute(p,o,f);if(i.sparse!==void 0){let n=B.SCALAR,r=L[i.sparse.indices.componentType],c=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,u=new r(t[1],c,i.sparse.count*n),d=new s(t[2],l,i.sparse.count*o);a!==null&&(m=new e.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let e=0,t=u.length;e<t;e++){let t=u[e];if(m.setX(t,d[e*o]),o>=2&&m.setY(t,d[e*o+1]),o>=3&&m.setZ(t,d[e*o+2]),o>=4&&m.setW(t,d[e*o+3]),o>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}m.normalized=f}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(t,n,r){let i=this,a=this.json,o=a.textures[t],s=a.images[n],c=(s.uri||s.bufferView)+`:`+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(n,r).then(function(n){n.flipY=!1,n.name=o.name||s.name||``,n.name===``&&typeof s.uri==`string`&&s.uri.startsWith(`data:image/`)===!1&&(n.name=s.uri);let r=(a.samplers||{})[o.sampler]||{};return n.magFilter=R[r.magFilter]||e.LinearFilter,n.minFilter=R[r.minFilter]||e.LinearMipmapLinearFilter,n.wrapS=z[r.wrapS]||e.RepeatWrapping,n.wrapT=z[r.wrapT]||e.RepeatWrapping,n.generateMipmaps=!n.isCompressedTexture&&n.minFilter!==e.NearestFilter&&n.minFilter!==e.LinearFilter,i.associations.set(n,{textures:t}),n}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(t,n){let r=this,i=this.json,a=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(e=>e.clone());let o=i.images[t],s=self.URL||self.webkitURL,c=o.uri||``,l=!1;if(o.bufferView!==void 0)c=r.getDependency(`bufferView`,o.bufferView).then(function(e){l=!0;let t=new Blob([e],{type:o.mimeType});return c=s.createObjectURL(t),c});else if(o.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+t+` is missing URI and bufferView`);let u=Promise.resolve(c).then(function(t){return new Promise(function(r,i){let o=r;n.isImageBitmapLoader===!0&&(o=function(t){let n=new e.Texture(t);n.needsUpdate=!0,r(n)}),n.load(e.LoaderUtils.resolveURL(t,a.path),o,void 0,i)})}).then(function(e){return l===!0&&s.revokeObjectURL(c),q(e,o),e.userData.mimeType=o.mimeType||ee(o.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,c),e});return this.sourceCache[t]=u,u}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[s.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[s.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[s.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(t){let n=t.geometry,r=t.material,i=n.attributes.tangent===void 0,a=n.attributes.color!==void 0,o=n.attributes.normal===void 0;if(t.isPoints){let t=`PointsMaterial:`+r.uuid,n=this.cache.get(t);n||(n=new e.PointsMaterial,e.Material.prototype.copy.call(n,r),n.color.copy(r.color),n.map=r.map,n.sizeAttenuation=!1,this.cache.add(t,n)),r=n}else if(t.isLine){let t=`LineBasicMaterial:`+r.uuid,n=this.cache.get(t);n||(n=new e.LineBasicMaterial,e.Material.prototype.copy.call(n,r),n.color.copy(r.color),n.map=r.map,this.cache.add(t,n)),r=n}if(i||a||o){let e=`ClonedMaterial:`+r.uuid+`:`;i&&(e+=`derivative-tangents:`),a&&(e+=`vertex-colors:`),o&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=r.clone(),a&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}t.material=r}getMaterialType(){return e.MeshStandardMaterial}loadMaterial(t){let n=this,r=this.json,i=this.extensions,a=r.materials[t],o,c={},l=a.extensions||{},u=[];if(l[s.KHR_MATERIALS_UNLIT]){let e=i[s.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),u.push(e.extendParams(c,a,n))}else{let r=a.pbrMetallicRoughness||{};if(c.color=new e.Color(1,1,1),c.opacity=1,Array.isArray(r.baseColorFactor)){let t=r.baseColorFactor;c.color.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace),c.opacity=t[3]}r.baseColorTexture!==void 0&&u.push(n.assignTexture(c,`map`,r.baseColorTexture,e.SRGBColorSpace)),c.metalness=r.metallicFactor===void 0?1:r.metallicFactor,c.roughness=r.roughnessFactor===void 0?1:r.roughnessFactor,r.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(c,`metalnessMap`,r.metallicRoughnessTexture)),u.push(n.assignTexture(c,`roughnessMap`,r.metallicRoughnessTexture))),o=this._invokeOne(function(e){return e.getMaterialType&&e.getMaterialType(t)}),u.push(Promise.all(this._invokeAll(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,c)})))}a.doubleSided===!0&&(c.side=e.DoubleSide);let d=a.alphaMode||W.OPAQUE;if(d===W.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,d===W.MASK&&(c.alphaTest=a.alphaCutoff===void 0?.5:a.alphaCutoff)),a.normalTexture!==void 0&&o!==e.MeshBasicMaterial&&(u.push(n.assignTexture(c,`normalMap`,a.normalTexture)),c.normalScale=new e.Vector2(1,1),a.normalTexture.scale!==void 0)){let e=a.normalTexture.scale;c.normalScale.set(e,e)}if(a.occlusionTexture!==void 0&&o!==e.MeshBasicMaterial&&(u.push(n.assignTexture(c,`aoMap`,a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==e.MeshBasicMaterial){let t=a.emissiveFactor;c.emissive=new e.Color().setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return a.emissiveTexture!==void 0&&o!==e.MeshBasicMaterial&&u.push(n.assignTexture(c,`emissiveMap`,a.emissiveTexture,e.SRGBColorSpace)),Promise.all(u).then(function(){let e=new o(c);return a.name&&(e.name=a.name),q(e,a),n.associations.set(e,{materials:t}),a.extensions&&K(i,e,a),e})}createUniqueName(t){let n=e.PropertyBinding.sanitizeNodeName(t||``);return n in this.nodeNamesUsed?n+`_`+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(t){let n=this,r=this.extensions,i=this.primitiveCache;function a(e){return r[s.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,n).then(function(t){return $(t,e,n)})}let o=[];for(let r=0,c=t.length;r<c;r++){let c=t[r],l=X(c),u=i[l];if(u)o.push(u.promise);else{let t;t=c.extensions&&c.extensions[s.KHR_DRACO_MESH_COMPRESSION]?a(c):$(new e.BufferGeometry,c,n),i[l]={primitive:c,promise:t},o.push(t)}}return Promise.all(o)}loadMesh(n){let r=this,i=this.json,a=this.extensions,o=i.meshes[n],s=o.primitives,c=[];for(let e=0,t=s.length;e<t;e++){let t=s[e].material===void 0?G(this.cache):this.getDependency(`material`,s[e].material);c.push(t)}return c.push(r.loadGeometries(s)),Promise.all(c).then(function(i){let c=i.slice(0,i.length-1),l=i[i.length-1],u=[];for(let i=0,d=l.length;i<d;i++){let d=l[i],f=s[i],p,m=c[i];if(f.mode===I.TRIANGLES||f.mode===I.TRIANGLE_STRIP||f.mode===I.TRIANGLE_FAN||f.mode===void 0)p=o.isSkinnedMesh===!0?new e.SkinnedMesh(d,m):new e.Mesh(d,m),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),f.mode===I.TRIANGLE_STRIP?p.geometry=t(p.geometry,e.TriangleStripDrawMode):f.mode===I.TRIANGLE_FAN&&(p.geometry=t(p.geometry,e.TriangleFanDrawMode));else if(f.mode===I.LINES)p=new e.LineSegments(d,m);else if(f.mode===I.LINE_STRIP)p=new e.Line(d,m);else if(f.mode===I.LINE_LOOP)p=new e.LineLoop(d,m);else if(f.mode===I.POINTS)p=new e.Points(d,m);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+f.mode);Object.keys(p.geometry.morphAttributes).length>0&&Y(p,o),p.name=r.createUniqueName(o.name||`mesh_`+n),q(p,o),f.extensions&&K(a,p,f),r.assignFinalMaterial(p),u.push(p)}for(let e=0,t=u.length;e<t;e++)r.associations.set(u[e],{meshes:n,primitives:e});if(u.length===1)return o.extensions&&K(a,u[0],o),u[0];let d=new e.Group;o.extensions&&K(a,d,o),r.associations.set(d,{meshes:n});for(let e=0,t=u.length;e<t;e++)d.add(u[e]);return d})}loadCamera(t){let n,r=this.json.cameras[t],i=r[r.type];if(!i){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return r.type===`perspective`?n=new e.PerspectiveCamera(e.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):r.type===`orthographic`&&(n=new e.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),r.name&&(n.name=this.createUniqueName(r.name)),q(n,r),Promise.resolve(n)}loadSkin(t){let n=this.json.skins[t],r=[];for(let e=0,t=n.joints.length;e<t;e++)r.push(this._loadNodeShallow(n.joints[e]));return n.inverseBindMatrices===void 0?r.push(null):r.push(this.getDependency(`accessor`,n.inverseBindMatrices)),Promise.all(r).then(function(t){let r=t.pop(),i=t,a=[],o=[];for(let t=0,s=i.length;t<s;t++){let s=i[t];if(s){a.push(s);let n=new e.Matrix4;r!==null&&n.fromArray(r.array,t*16),o.push(n)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,n.joints[t])}return new e.Skeleton(a,o)})}loadAnimation(t){let n=this.json,r=this,i=n.animations[t],a=i.name?i.name:`animation_`+t,o=[],s=[],c=[],l=[],u=[];for(let e=0,t=i.channels.length;e<t;e++){let t=i.channels[e],n=i.samplers[t.sampler],r=t.target,a=r.node,d=i.parameters===void 0?n.input:i.parameters[n.input],f=i.parameters===void 0?n.output:i.parameters[n.output];r.node!==void 0&&(o.push(this.getDependency(`node`,a)),s.push(this.getDependency(`accessor`,d)),c.push(this.getDependency(`accessor`,f)),l.push(n),u.push(r))}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(t){let n=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=[];for(let e=0,t=n.length;e<t;e++){let t=n[e],i=o[e],a=s[e],d=c[e],f=l[e];if(t===void 0)continue;t.updateMatrix&&t.updateMatrix();let p=r._createAnimationTracks(t,i,a,d,f);if(p)for(let e=0;e<p.length;e++)u.push(p[e])}let d=new e.AnimationClip(a,void 0,u);return q(d,i),d})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(t){let n=this.json,r=this,i=n.nodes[t],a=r._loadNodeShallow(t),o=[],s=i.children||[];for(let e=0,t=s.length;e<t;e++)o.push(r.getDependency(`node`,s[e]));let c=i.skin===void 0?Promise.resolve(null):r.getDependency(`skin`,i.skin);return Promise.all([a,Promise.all(o),c]).then(function(t){let n=t[0],r=t[1],i=t[2];i!==null&&n.traverse(function(e){e.isSkinnedMesh&&e.bind(i,te)});for(let e=0,t=r.length;e<t;e++)n.add(r[e]);if(n.userData.pivot!==void 0&&r.length>0){let t=n.userData.pivot,i=r[0];n.pivot=new e.Vector3().fromArray(t),n.position.x-=t[0],n.position.y-=t[1],n.position.z-=t[2],i.position.set(0,0,0),delete n.userData.pivot}return n})}_loadNodeShallow(t){let n=this.json,r=this.extensions,i=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];let a=n.nodes[t],o=a.name?i.createUniqueName(a.name):``,s=[],c=i._invokeOne(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return c&&s.push(c),a.camera!==void 0&&s.push(i.getDependency(`camera`,a.camera).then(function(e){return i._getNodeRef(i.cameraCache,a.camera,e)})),i._invokeAll(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(e){s.push(e)}),this.nodeCache[t]=Promise.all(s).then(function(n){let s;if(s=a.isBone===!0?new e.Bone:n.length>1?new e.Group:n.length===1?n[0]:new e.Object3D,s!==n[0])for(let e=0,t=n.length;e<t;e++)s.add(n[e]);if(a.name&&(s.userData.name=a.name,s.name=o),q(s,a),a.extensions&&K(r,s,a),a.matrix!==void 0){let t=new e.Matrix4;t.fromArray(a.matrix),s.applyMatrix4(t)}else a.translation!==void 0&&s.position.fromArray(a.translation),a.rotation!==void 0&&s.quaternion.fromArray(a.rotation),a.scale!==void 0&&s.scale.fromArray(a.scale);if(!i.associations.has(s))i.associations.set(s,{});else if(a.mesh!==void 0&&i.meshCache.refs[a.mesh]>1){let e=i.associations.get(s);i.associations.set(s,{...e})}return i.associations.get(s).nodes=t,s}),this.nodeCache[t]}loadScene(t){let r=this.extensions,i=this.json.scenes[t],a=this,o=new e.Group;i.name&&(o.name=a.createUniqueName(i.name)),q(o,i),i.extensions&&K(r,o,i);let s=i.nodes||[],c=[];for(let e=0,t=s.length;e<t;e++)c.push(a.getDependency(`node`,s[e]));return Promise.all(c).then(function(t){for(let e=0,r=t.length;e<r;e++){let r=t[e];r.parent===null?o.add(r):o.add(n(r))}return a.associations=(t=>{let n=new Map;for(let[t,r]of a.associations)(t instanceof e.Material||t instanceof e.Texture)&&n.set(t,r);return t.traverse(e=>{let t=a.associations.get(e);t!=null&&n.set(e,t)}),n})(o),o})}_createAnimationTracks(t,n,r,i,a){let o=[],s=t.name?t.name:t.uuid,c=[];function l(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}H[a.path]===H.weights?(l(t),t.isGroup&&t.children.forEach(l)):c.push(s);let u;switch(H[a.path]){case H.weights:u=e.NumberKeyframeTrack;break;case H.rotation:u=e.QuaternionKeyframeTrack;break;case H.translation:case H.scale:u=e.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:u=e.NumberKeyframeTrack;break;default:u=e.VectorKeyframeTrack;break}break}let d=i.interpolation===void 0?e.InterpolateLinear:U[i.interpolation],f=this._getArrayFromAccessor(r);for(let e=0,t=c.length;e<t;e++){let t=new u(c[e]+`.`+H[a.path],n.array,f,d);i.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(t),o.push(t)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=Q(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?F:N)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function re(t,n,r){let i=n.attributes,a=new e.Box3;if(i.POSITION!==void 0){let t=r.json.accessors[i.POSITION],n=t.min,o=t.max;if(n!==void 0&&o!==void 0){if(a.set(new e.Vector3(n[0],n[1],n[2]),new e.Vector3(o[0],o[1],o[2])),t.normalized){let e=Q(L[t.componentType]);a.min.multiplyScalar(e),a.max.multiplyScalar(e)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let o=n.targets;if(o!==void 0){let t=new e.Vector3,n=new e.Vector3;for(let e=0,i=o.length;e<i;e++){let i=o[e];if(i.POSITION!==void 0){let e=r.json.accessors[i.POSITION],a=e.min,o=e.max;if(a!==void 0&&o!==void 0){if(n.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),n.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),n.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),e.normalized){let t=Q(L[e.componentType]);n.multiplyScalar(t)}t.max(n)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}a.expandByVector(t)}t.boundingBox=a;let s=new e.Sphere;a.getCenter(s.center),s.radius=a.min.distanceTo(a.max)/2,t.boundingSphere=s}function $(t,n,r){let i=n.attributes,a=[];function o(e,n){return r.getDependency(`accessor`,e).then(function(e){t.setAttribute(n,e)})}for(let e in i){let n=V[e]||e.toLowerCase();n in t.attributes||a.push(o(i[e],n))}if(n.indices!==void 0&&!t.index){let e=r.getDependency(`accessor`,n.indices).then(function(e){t.setIndex(e)});a.push(e)}return e.ColorManagement.workingColorSpace!==e.LinearSRGBColorSpace&&`COLOR_0`in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${e.ColorManagement.workingColorSpace}" not supported.`),q(t,n),re(t,n,r),Promise.all(a).then(function(){return n.targets===void 0?t:J(t,n.targets,r)})}exports.GLTFLoader=i;
|