@inweb/viewer-three 27.6.3 → 27.7.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/dist/extensions/components/RoomEnvironmentComponent.js +1 -0
- package/dist/extensions/components/RoomEnvironmentComponent.js.map +1 -1
- package/dist/extensions/components/RoomEnvironmentComponent.min.js +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.js +127 -131
- package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.min.js +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.js +127 -131
- package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
- package/dist/extensions/loaders/IFCXLoader.js +10 -9
- package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
- package/dist/extensions/loaders/PotreeLoader.js +5 -5
- package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
- package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
- package/dist/viewer-three.js +5368 -4815
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +5 -5
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +10 -10
- package/src/Viewer/components/SectionsComponent.ts +1 -1
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,t){"use strict";function s(t,s){if(s===e.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(s===e.TriangleFanDrawMode||s===e.TriangleStripDrawMode){let n=t.getIndex();if(null===n){const e=[],s=t.getAttribute("position");if(void 0===s)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<s.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const r=n.count-2,i=[];if(s===e.TriangleFanDrawMode)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=t.clone();return o.setIndex(i),o.clearGroups(),o}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",s),t}class n extends e.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new l(e)}),this.register(function(e){return new u(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new _(e)}),this.register(function(e){return new d(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new p(e)}),this.register(function(e){return new f(e)}),this.register(function(e){return new c(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new h(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new o(e)}),this.register(function(e){return new M(e)}),this.register(function(e){return new w(e)})}load(t,s,n,r){const i=this;let o;if(""!==this.resourcePath)o=this.resourcePath;else if(""!==this.path){const s=e.LoaderUtils.extractUrlBase(t);o=e.LoaderUtils.resolveURL(s,this.path)}else o=e.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){r?r(e):console.error(e),i.manager.itemError(t),i.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{i.parse(e,o,function(e){s(e),i.manager.itemEnd(t)},a)}catch(e){a(e)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let r;const o={},c={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(l.decode(new Uint8Array(e,0,4))===E){try{o[i.KHR_BINARY_GLTF]=new L(e)}catch(e){return void(n&&n(e))}r=JSON.parse(o[i.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new Z(r,{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++){const t=this.pluginCallbacks[e](u);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[t.name]=t,o[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],s=r.extensionsRequired||[];switch(t){case i.KHR_MATERIALS_UNLIT:o[t]=new a;break;case i.KHR_DRACO_MESH_COMPRESSION:o[t]=new S(r,this.dracoLoader);break;case i.KHR_TEXTURE_TRANSFORM:o[t]=new I;break;case i.KHR_MESH_QUANTIZATION:o[t]=new b;break;default:s.indexOf(t)>=0&&void 0===c[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(o),u.setPlugins(c),u.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function r(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const i={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class o{constructor(e){this.parser=e,this.name=i.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const s=this.parser,n="light:"+t;let r=s.cache.get(n);if(r)return r;const i=s.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const c=new e.Color(16777215);void 0!==o.color&&c.setRGB(o.color[0],o.color[1],o.color[2],e.LinearSRGBColorSpace);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new e.DirectionalLight(c),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new e.PointLight(c),a.distance=l;break;case"spot":a=new e.SpotLight(c),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),q(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=s.createUniqueName(o.name||"light_"+t),r=Promise.resolve(a),s.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(e){return s._getNodeRef(t.cache,r,e)})}}class a{constructor(){this.name=i.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,s,n){const r=[];t.color=new e.Color(1,1,1),t.opacity=1;const i=s.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const s=i.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],e.LinearSRGBColorSpace),t.opacity=s[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(t,"map",i.baseColorTexture,e.SRGBColorSpace))}return Promise.all(r)}}class c{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class l{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(s.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(n.assignTexture(s,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(s.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(n.assignTexture(s,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(n.assignTexture(s,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const t=o.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(i)}}class u{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_DISPERSION}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class h{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&r.push(s.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&r.push(s.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class d{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];s.sheenColor=new e.Color(0,0,0),s.sheenRoughness=0,s.sheen=1;const o=r.extensions[this.name];if(void 0!==o.sheenColorFactor){const t=o.sheenColorFactor;s.sheenColor.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return void 0!==o.sheenRoughnessFactor&&(s.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(n.assignTexture(s,"sheenColorMap",o.sheenColorTexture,e.SRGBColorSpace)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(s,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class m{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&r.push(s.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class p{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(n.assignTexture(s,"thicknessMap",o.thicknessTexture)),s.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return s.attenuationColor=(new e.Color).setRGB(a[0],a[1],a[2],e.LinearSRGBColorSpace),Promise.all(i)}}class f{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class g{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(n.assignTexture(s,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return s.specularColor=(new e.Color).setRGB(a[0],a[1],a[2],e.LinearSRGBColorSpace),void 0!==o.specularColorTexture&&i.push(n.assignTexture(s,"specularColorMap",o.specularColorTexture,e.SRGBColorSpace)),Promise.all(i)}}class T{constructor(e){this.parser=e,this.name=i.EXT_MATERIALS_BUMP}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&r.push(s.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(r)}}class x{constructor(e){this.parser=e,this.name=i.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&r.push(s.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class R{constructor(e){this.parser=e,this.name=i.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class v{constructor(e){this.parser=e,this.name=i.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return s.loadTextureImage(e,i.source,a)}}class _{constructor(e){this.parser=e,this.name=i.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return s.loadTextureImage(e,i.source,a)}}class M{constructor(e){this.name=i.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(t){const s=e.byteOffset||0,n=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,s,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then(function(e){return e.buffer}):r.ready.then(function(){const t=new ArrayBuffer(i*o);return r.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t})})}return null}}class w{constructor(e){this.name=i.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(t){const s=this.parser.json,n=s.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=s.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==P.TRIANGLES&&e.mode!==P.TRIANGLE_STRIP&&e.mode!==P.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,o=[],a={};for(const e in i)o.push(this.parser.getDependency("accessor",i[e]).then(t=>(a[e]=t,a[e])));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then(t=>{const s=t.pop(),n=s.isGroup?s.children:[s],r=t[0].count,i=[];for(const t of n){const s=new e.Matrix4,n=new e.Vector3,o=new e.Quaternion,c=new e.Vector3(1,1,1),l=new e.InstancedMesh(t.geometry,t.material,r);for(let e=0;e<r;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,e),a.SCALE&&c.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,s.compose(n,o,c));for(const s in a)if("_COLOR_0"===s){const t=a[s];l.instanceColor=new e.InstancedBufferAttribute(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==s&&"ROTATION"!==s&&"SCALE"!==s&&t.geometry.setAttribute(s,a[s]);e.Object3D.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),i.push(l)}return s.isGroup?(s.clear(),s.add(...i),s):i[0]}))}}const E="glTF",y=1313821514,A=5130562;class L{constructor(e){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==E)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let o=0;for(;o<n;){const t=r.getUint32(o,!0);o+=4;const n=r.getUint32(o,!0);if(o+=4,n===y){const n=new Uint8Array(e,12+o,t);this.content=s.decode(n)}else if(n===A){const s=12+o;this.body=e.slice(s,s+t)}o+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class S{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=i.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(t,s){const n=this.json,r=this.dracoLoader,i=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},c={},l={};for(const e in o){const t=U[e]||e.toLowerCase();a[t]=o[e]}for(const e in t.attributes){const s=U[e]||e.toLowerCase();if(void 0!==o[e]){const r=n.accessors[t.attributes[e]],i=H[r.componentType];l[s]=i.name,c[s]=!0===r.normalized}}return s.getDependency("bufferView",i).then(function(t){return new Promise(function(s,n){r.decodeDracoFile(t,function(e){for(const t in e.attributes){const s=e.attributes[t],n=c[t];void 0!==n&&(s.normalized=n)}s(e)},a,l,e.LinearSRGBColorSpace,n)})})}}class I{constructor(){this.name=i.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class b{constructor(){this.name=i.KHR_MESH_QUANTIZATION}}class C extends e.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=s[r+e];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=n-t,u=(s-t)/l,h=u*u,d=h*u,m=e*c,p=m-c,f=-2*d+3*h,g=d-h,T=1-f,x=g-h+u;for(let e=0;e!==o;e++){const t=i[p+e+o],s=i[p+e+a]*l,n=i[m+e+o],c=i[m+e]*l;r[e]=T*t+x*s+f*n+g*c}return r}}const N=new e.Quaternion;class O extends C{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return N.fromArray(r).normalize().toArray(r),r}}const P={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},H={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},k={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},F={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},D={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},U={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"},G={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},B={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},K="OPAQUE",j="MASK",V="BLEND";function X(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),t.DefaultMaterial}function z(e,t,s){for(const n in s.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=s.extensions[n])}function q(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function W(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,n=t.weights.length;s<n;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,n=s.length;t<n;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Y(e){let t;const s=e.extensions&&e.extensions[i.KHR_DRACO_MESH_COMPRESSION];if(t=s?"draco:"+s.bufferView+":"+s.indices+":"+Q(s.attributes):e.indices+":"+Q(e.attributes)+":"+e.mode,void 0!==e.targets)for(let s=0,n=e.targets.length;s<n;s++)t+=":"+Q(e.targets[s]);return t}function Q(e){let t="";const s=Object.keys(e).sort();for(let n=0,r=s.length;n<r;n++)t+=s[n]+":"+e[s[n]]+";";return t}function $(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 new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const J=new e.Matrix4;class Z{constructor(t={},s={}){this.json=t,this.extensions={},this.plugins={},this.options=s,this.cache=new r,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 n=!1,i=-1,o=!1,a=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);i=n&&t?parseInt(t[1],10):-1,o=e.indexOf("Firefox")>-1,a=o?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||o&&a<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"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=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([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(t){const i={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:s,userData:{}};return z(r,i,n),q(i,n),Promise.all(s._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s].joints;for(let t=0,s=n.length;t<s;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,n]of e.children.entries())r(n,t.children[s])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e)}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map(function(t,n){return s.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(t){const s=this.json.buffers[t],n=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[i.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(t,i){n.load(e.LoaderUtils.resolveURL(s.uri,r.path),t,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)})}loadAccessor(t){const s=this,n=this.json,r=this.json.accessors[t];if(void 0===r.bufferView&&void 0===r.sparse){const t=D[r.type],s=H[r.componentType],n=!0===r.normalized,i=new s(r.count*t);return Promise.resolve(new e.BufferAttribute(i,t,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then(function(t){const i=t[0],o=D[r.type],a=H[r.componentType],c=a.BYTES_PER_ELEMENT,l=c*o,u=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let m,p;if(h&&h!==l){const t=Math.floor(u/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+t+":"+r.count;let l=s.cache.get(n);l||(m=new a(i,t*h,r.count*h/c),l=new e.InterleavedBuffer(m,h/c),s.cache.add(n,l)),p=new e.InterleavedBufferAttribute(l,o,u%h/c,d)}else m=null===i?new a(r.count*o):new a(i,u,r.count*o),p=new e.BufferAttribute(m,o,d);if(void 0!==r.sparse){const s=D.SCALAR,n=H[r.sparse.indices.componentType],c=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(t[1],c,r.sparse.count*s),h=new a(t[2],l,r.sparse.count*o);null!==i&&(p=new e.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(p.setX(t,h[e*o]),o>=2&&p.setY(t,h[e*o+1]),o>=3&&p.setZ(t,h[e*o+2]),o>=4&&p.setW(t,h[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p})}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let i=this.textureLoader;if(r.uri){const e=s.manager.getHandler(r.uri);null!==e&&(i=e)}return this.loadTextureImage(e,n,i)}loadTextureImage(t,s,n){const r=this,i=this.json,o=i.textures[t],a=i.images[s],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(s,n).then(function(s){s.flipY=!1,s.name=o.name||a.name||"",""===s.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(s.name=a.uri);const n=(i.samplers||{})[o.sampler]||{};return s.magFilter=k[n.magFilter]||e.LinearFilter,s.minFilter=k[n.minFilter]||e.LinearMipmapLinearFilter,s.wrapS=F[n.wrapS]||e.RepeatWrapping,s.wrapT=F[n.wrapT]||e.RepeatWrapping,s.generateMipmaps=!s.isCompressedTexture&&s.minFilter!==e.NearestFilter&&s.minFilter!==e.LinearFilter,r.associations.set(s,{textures:t}),s}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(t,s){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(e=>e.clone());const o=r.images[t],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(void 0!==o.bufferView)c=n.getDependency("bufferView",o.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return c=a.createObjectURL(t),c});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(t){return new Promise(function(n,r){let o=n;!0===s.isImageBitmapLoader&&(o=function(t){const s=new e.Texture(t);s.needsUpdate=!0,n(s)}),s.load(e.LoaderUtils.resolveURL(t,i.path),o,void 0,r)})}).then(function(e){var t;return!0===l&&a.revokeObjectURL(c),q(e,o),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),e});return this.sourceCache[t]=u,u}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((o=o.clone()).channel=s.texCoord),r.extensions[i.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(o);o=r.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),r.associations.set(o,t)}}return void 0!==n&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(t){const s=t.geometry;let n=t.material;const r=void 0===s.attributes.tangent,i=void 0!==s.attributes.color,o=void 0===s.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let s=this.cache.get(t);s||(s=new e.PointsMaterial,e.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,s.sizeAttenuation=!1,this.cache.add(t,s)),n=s}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let s=this.cache.get(t);s||(s=new e.LineBasicMaterial,e.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,this.cache.add(t,s)),n=s}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}t.material=n}getMaterialType(){return e.MeshStandardMaterial}loadMaterial(t){const s=this,n=this.json,r=this.extensions,o=n.materials[t];let a;const c={},l=[];if((o.extensions||{})[i.KHR_MATERIALS_UNLIT]){const e=r[i.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(c,o,s))}else{const n=o.pbrMetallicRoughness||{};if(c.color=new e.Color(1,1,1),c.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;c.color.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace),c.opacity=t[3]}void 0!==n.baseColorTexture&&l.push(s.assignTexture(c,"map",n.baseColorTexture,e.SRGBColorSpace)),c.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,c.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(s.assignTexture(c,"metalnessMap",n.metallicRoughnessTexture)),l.push(s.assignTexture(c,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne(function(e){return e.getMaterialType&&e.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,c)})))}!0===o.doubleSided&&(c.side=e.DoubleSide);const u=o.alphaMode||K;if(u===V?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,u===j&&(c.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&a!==e.MeshBasicMaterial&&(l.push(s.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new e.Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;c.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&a!==e.MeshBasicMaterial&&(l.push(s.assignTexture(c,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(c.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&a!==e.MeshBasicMaterial){const t=o.emissiveFactor;c.emissive=(new e.Color).setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return void 0!==o.emissiveTexture&&a!==e.MeshBasicMaterial&&l.push(s.assignTexture(c,"emissiveMap",o.emissiveTexture,e.SRGBColorSpace)),Promise.all(l).then(function(){const e=new a(c);return o.name&&(e.name=o.name),q(e,o),s.associations.set(e,{materials:t}),o.extensions&&z(r,e,o),e})}createUniqueName(t){const s=e.PropertyBinding.sanitizeNodeName(t||"");return s in this.nodeNamesUsed?s+"_"+ ++this.nodeNamesUsed[s]:(this.nodeNamesUsed[s]=0,s)}loadGeometries(t){const s=this,n=this.extensions,r=this.primitiveCache;function o(e){return n[i.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,s).then(function(t){return ee(t,e,s)})}const a=[];for(let n=0,c=t.length;n<c;n++){const c=t[n],l=Y(c),u=r[l];if(u)a.push(u.promise);else{let t;t=c.extensions&&c.extensions[i.KHR_DRACO_MESH_COMPRESSION]?o(c):ee(new e.BufferGeometry,c,s),r[l]={primitive:c,promise:t},a.push(t)}}return Promise.all(a)}loadMesh(t){const n=this,r=this.json,i=this.extensions,o=r.meshes[t],a=o.primitives,c=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?X(this.cache):this.getDependency("material",a[e].material);c.push(t)}return c.push(n.loadGeometries(a)),Promise.all(c).then(function(r){const c=r.slice(0,r.length-1),l=r[r.length-1],u=[];for(let r=0,h=l.length;r<h;r++){const h=l[r],d=a[r];let m;const p=c[r];if(d.mode===P.TRIANGLES||d.mode===P.TRIANGLE_STRIP||d.mode===P.TRIANGLE_FAN||void 0===d.mode)m=!0===o.isSkinnedMesh?new e.SkinnedMesh(h,p):new e.Mesh(h,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),d.mode===P.TRIANGLE_STRIP?m.geometry=s(m.geometry,e.TriangleStripDrawMode):d.mode===P.TRIANGLE_FAN&&(m.geometry=s(m.geometry,e.TriangleFanDrawMode));else if(d.mode===P.LINES)m=new e.LineSegments(h,p);else if(d.mode===P.LINE_STRIP)m=new e.Line(h,p);else if(d.mode===P.LINE_LOOP)m=new e.LineLoop(h,p);else{if(d.mode!==P.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);m=new e.Points(h,p)}Object.keys(m.geometry.morphAttributes).length>0&&W(m,o),m.name=n.createUniqueName(o.name||"mesh_"+t),q(m,o),d.extensions&&z(i,m,d),n.assignFinalMaterial(m),u.push(m)}for(let e=0,s=u.length;e<s;e++)n.associations.set(u[e],{meshes:t,primitives:e});if(1===u.length)return o.extensions&&z(i,u[0],o),u[0];const h=new e.Group;o.extensions&&z(i,h,o),n.associations.set(h,{meshes:t});for(let e=0,t=u.length;e<t;e++)h.add(u[e]);return h})}loadCamera(t){let s;const n=this.json.cameras[t],r=n[n.type];if(r)return"perspective"===n.type?s=new e.PerspectiveCamera(e.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new e.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(s.name=this.createUniqueName(n.name)),q(s,n),Promise.resolve(s);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const s=this.json.skins[t],n=[];for(let e=0,t=s.joints.length;e<t;e++)n.push(this._loadNodeShallow(s.joints[e]));return void 0!==s.inverseBindMatrices?n.push(this.getDependency("accessor",s.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(t){const n=t.pop(),r=t,i=[],o=[];for(let t=0,a=r.length;t<a;t++){const a=r[t];if(a){i.push(a);const s=new e.Matrix4;null!==n&&s.fromArray(n.array,16*t),o.push(s)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[t])}return new e.Skeleton(i,o)})}loadAnimation(t){const s=this.json,n=this,r=s.animations[t],i=r.name?r.name:"animation_"+t,o=[],a=[],c=[],l=[],u=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],s=r.samplers[t.sampler],n=t.target,i=n.node,h=void 0!==r.parameters?r.parameters[s.input]:s.input,d=void 0!==r.parameters?r.parameters[s.output]:s.output;void 0!==n.node&&(o.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),c.push(this.getDependency("accessor",d)),l.push(s),u.push(n))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(t){const s=t[0],o=t[1],a=t[2],c=t[3],l=t[4],u=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],r=o[e],i=a[e],h=c[e],d=l[e];if(void 0===t)continue;t.updateMatrix&&t.updateMatrix();const m=n._createAnimationTracks(t,r,i,h,d);if(m)for(let e=0;e<m.length;e++)u.push(m[e])}const h=new e.AnimationClip(i,void 0,u);return q(h,r),h})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then(function(e){const t=s._getNodeRef(s.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,s=n.weights.length;t<s;t++)e.morphTargetInfluences[t]=n.weights[t]}),t})}loadNode(e){const t=this,s=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],i=s.children||[];for(let e=0,s=i.length;e<s;e++)r.push(t.getDependency("node",i[e]));const o=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([n,Promise.all(r),o]).then(function(e){const t=e[0],s=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,J)});for(let e=0,n=s.length;e<n;e++)t.add(s[e]);return t})}_loadNodeShallow(t){const s=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const i=s.nodes[t],o=i.name?r.createUniqueName(i.name):"",a=[],c=r._invokeOne(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return c&&a.push(c),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(e){a.push(e)}),this.nodeCache[t]=Promise.all(a).then(function(s){let a;if(a=!0===i.isBone?new e.Bone:s.length>1?new e.Group:1===s.length?s[0]:new e.Object3D,a!==s[0])for(let e=0,t=s.length;e<t;e++)a.add(s[e]);if(i.name&&(a.userData.name=i.name,a.name=o),q(a,i),i.extensions&&z(n,a,i),void 0!==i.matrix){const t=new e.Matrix4;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);if(r.associations.has(a)){if(void 0!==i.mesh&&r.meshCache.refs[i.mesh]>1){const e=r.associations.get(a);r.associations.set(a,{...e})}}else r.associations.set(a,{});return r.associations.get(a).nodes=t,a}),this.nodeCache[t]}loadScene(t){const s=this.extensions,n=this.json.scenes[t],r=this,i=new e.Group;n.name&&(i.name=r.createUniqueName(n.name)),q(i,n),n.extensions&&z(s,i,n);const o=n.nodes||[],a=[];for(let e=0,t=o.length;e<t;e++)a.push(r.getDependency("node",o[e]));return Promise.all(a).then(function(t){for(let e=0,s=t.length;e<s;e++)i.add(t[e]);return r.associations=(t=>{const s=new Map;for(const[t,n]of r.associations)(t instanceof e.Material||t instanceof e.Texture)&&s.set(t,n);return t.traverse(e=>{const t=r.associations.get(e);null!=t&&s.set(e,t)}),s})(i),i})}_createAnimationTracks(t,s,n,r,i){const o=[],a=t.name?t.name:t.uuid,c=[];let l;switch(G[i.path]===G.weights?t.traverse(function(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}):c.push(a),G[i.path]){case G.weights:l=e.NumberKeyframeTrack;break;case G.rotation:l=e.QuaternionKeyframeTrack;break;case G.translation:case G.scale:l=e.VectorKeyframeTrack;break;default:if(1===n.itemSize)l=e.NumberKeyframeTrack;else l=e.VectorKeyframeTrack}const u=void 0!==r.interpolation?B[r.interpolation]:e.InterpolateLinear,h=this._getArrayFromAccessor(n);for(let e=0,t=c.length;e<t;e++){const t=new l(c[e]+"."+G[i.path],s.array,h,u);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(t),o.push(t)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=$(t.constructor),s=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)s[n]=t[n]*e;t=s}return t}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?O:C)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ee(t,s,n){const r=s.attributes,i=[];function o(e,s){return n.getDependency("accessor",e).then(function(e){t.setAttribute(s,e)})}for(const e in r){const s=U[e]||e.toLowerCase();s in t.attributes||i.push(o(r[e],s))}if(void 0!==s.indices&&!t.index){const e=n.getDependency("accessor",s.indices).then(function(e){t.setIndex(e)});i.push(e)}return e.ColorManagement.workingColorSpace!==e.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${e.ColorManagement.workingColorSpace}" not supported.`),q(t,s),function(t,s,n){const r=s.attributes,i=new e.Box3;if(void 0===r.POSITION)return;{const t=n.json.accessors[r.POSITION],s=t.min,o=t.max;if(void 0===s||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new e.Vector3(s[0],s[1],s[2]),new e.Vector3(o[0],o[1],o[2])),t.normalized){const e=$(H[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const o=s.targets;if(void 0!==o){const t=new e.Vector3,s=new e.Vector3;for(let e=0,r=o.length;e<r;e++){const r=o[e];if(void 0!==r.POSITION){const e=n.json.accessors[r.POSITION],i=e.min,o=e.max;if(void 0!==i&&void 0!==o){if(s.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),s.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),s.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),e.normalized){const t=$(H[e.componentType]);s.multiplyScalar(t)}t.max(s)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new e.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,s,n),Promise.all(i).then(function(){return void 0!==s.targets?function(e,t,s){let n=!1,r=!1,i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(r=!0),void 0!==s.COLOR_0&&(i=!0),n&&r&&i)break}if(!n&&!r&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(n){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(t){const s=t[0],o=t[1],a=t[2];return n&&(e.morphAttributes.position=s),r&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(t,s.targets,n):t})}class te extends t.Loader{constructor(e){super(),this.viewer=e,this.manager=null}dispose(){this.manager&&this.manager.dispose()}isSupport(e){return"object"==typeof e&&"string"==typeof e.database&&"function"==typeof e.downloadResource&&/.gltf$/i.test(e.database)}async load(e){const s=`${e.httpClient.serverUrl}${e.path}/${e.database}`;this.manager=new t.GLTFLoadingManager(s);const r=new n(this.manager);r.setRequestHeader(e.httpClient.headers);const i=await r.loadAsync(s,t=>{const{lengthComputable:s,loaded:n,total:r}=t,i=s?n/r:1;this.viewer.emitEvent({type:"geometryprogress",data:i,file:e.file,model:e})});if(!this.viewer.scene)return this;const o=new t.ModelImpl(i.scene);return o.id=e.file.id,this.viewer.scene.add(i.scene),this.viewer.models.push(o),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.emitEvent({type:"databasechunk",data:i.scene,file:e.file,model:e}),this.viewer.update(!0),this}}t.loaders.registerLoader("gltf-cloud",e=>new te(e))});
|
|
24
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,t){"use strict";function s(t,s){if(s===e.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(s===e.TriangleFanDrawMode||s===e.TriangleStripDrawMode){let r=t.getIndex();if(null===r){const e=[],s=t.getAttribute("position");if(void 0===s)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<s.count;t++)e.push(t);t.setIndex(e),r=t.getIndex()}const n=r.count-2,i=[];if(s===e.TriangleFanDrawMode)for(let e=1;e<=n;e++)i.push(r.getX(0)),i.push(r.getX(e)),i.push(r.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(i.push(r.getX(e)),i.push(r.getX(e+1)),i.push(r.getX(e+2))):(i.push(r.getX(e+2)),i.push(r.getX(e+1)),i.push(r.getX(e)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=t.clone();return o.setIndex(i),o.clearGroups(),o}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",s),t}function r(e){const t=new Map,s=new Map,r=e.clone();return n(e,r,function(e,r){t.set(r,e),s.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;const r=e,n=t.get(e),i=n.skeleton.bones;r.skeleton=n.skeleton.clone(),r.bindMatrix.copy(n.bindMatrix),r.skeleton.bones=i.map(function(e){return s.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function n(e,t,s){s(e,t);for(let r=0;r<e.children.length;r++)n(e.children[r],t.children[r],s)}class i 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 p(e)}),this.register(function(e){return new M(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new E(e)}),this.register(function(e){return new f(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new h(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new _(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new l(e)}),this.register(function(e){return new y(e,c.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new y(e,c.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new S(e)})}load(t,s,r,n){const i=this;let o;if(""!==this.resourcePath)o=this.resourcePath;else if(""!==this.path){const s=e.LoaderUtils.extractUrlBase(t);o=e.LoaderUtils.resolveURL(s,this.path)}else o=e.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){n?n(e):console.error(e),i.manager.itemError(t),i.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{i.parse(e,o,function(e){s(e),i.manager.itemEnd(t)},a)}catch(e){a(e)}},r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let n;const i={},o={},a=new TextDecoder;if("string"==typeof e)n=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===A){try{i[c.KHR_BINARY_GLTF]=new b(e)}catch(e){return void(r&&r(e))}n=JSON.parse(i[c.KHR_BINARY_GLTF].content)}else n=JSON.parse(a.decode(e))}else n=e;if(void 0===n.asset||n.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new se(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[t.name]=t,i[t.name]=!0}if(n.extensionsUsed)for(let e=0;e<n.extensionsUsed.length;++e){const t=n.extensionsUsed[e],s=n.extensionsRequired||[];switch(t){case c.KHR_MATERIALS_UNLIT:i[t]=new u;break;case c.KHR_DRACO_MESH_COMPRESSION:i[t]=new C(n,this.dracoLoader);break;case c.KHR_TEXTURE_TRANSFORM:i[t]=new N;break;case c.KHR_MESH_QUANTIZATION:i[t]=new O;break;default:s.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(i),l.setPlugins(o),l.parse(s,r)}parseAsync(e,t){const s=this;return new Promise(function(r,n){s.parse(e,t,r,n)})}}function o(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function a(e,t,s){const r=e.json.materials[t];return r.extensions&&r.extensions[s]?r.extensions[s]:null}const c={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"};class l{constructor(e){this.parser=e,this.name=c.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,r=t.length;s<r;s++){const r=t[s];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const s=this.parser,r="light:"+t;let n=s.cache.get(r);if(n)return n;const i=s.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const c=new e.Color(16777215);void 0!==o.color&&c.setRGB(o.color[0],o.color[1],o.color[2],e.LinearSRGBColorSpace);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new e.DirectionalLight(c),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new e.PointLight(c),a.distance=l;break;case"spot":a=new e.SpotLight(c),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),Q(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=s.createUniqueName(o.name||"light_"+t),n=Promise.resolve(a),s.cache.add(r,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],n=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then(function(e){return s._getNodeRef(t.cache,n,e)})}}class u{constructor(){this.name=c.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,s,r){const n=[];t.color=new e.Color(1,1,1),t.opacity=1;const i=s.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const s=i.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],e.LinearSRGBColorSpace),t.opacity=s[3]}void 0!==i.baseColorTexture&&n.push(r.assignTexture(t,"map",i.baseColorTexture,e.SRGBColorSpace))}return Promise.all(n)}}class h{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);return null===s||void 0!==s.emissiveStrength&&(t.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class d{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=a(this.parser,t,this.name);if(null===r)return Promise.resolve();const n=[];if(void 0!==r.clearcoatFactor&&(s.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&n.push(this.parser.assignTexture(s,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(s.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&n.push(this.parser.assignTexture(s,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(n.push(this.parser.assignTexture(s,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const t=r.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(n)}}class p{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_DISPERSION}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);return null===s||(t.dispersion=void 0!==s.dispersion?s.dispersion:0),Promise.resolve()}}class m{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);if(null===s)return Promise.resolve();const r=[];return void 0!==s.iridescenceFactor&&(t.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(this.parser.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(t.iridescenceIOR=s.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(this.parser.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class f{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_SHEEN}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=a(this.parser,t,this.name);if(null===r)return Promise.resolve();const n=[];if(s.sheenColor=new e.Color(0,0,0),s.sheenRoughness=0,s.sheen=1,void 0!==r.sheenColorFactor){const t=r.sheenColorFactor;s.sheenColor.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return void 0!==r.sheenRoughnessFactor&&(s.sheenRoughness=r.sheenRoughnessFactor),void 0!==r.sheenColorTexture&&n.push(this.parser.assignTexture(s,"sheenColorMap",r.sheenColorTexture,e.SRGBColorSpace)),void 0!==r.sheenRoughnessTexture&&n.push(this.parser.assignTexture(s,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(n)}}class g{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);if(null===s)return Promise.resolve();const r=[];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(this.parser.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class T{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_VOLUME}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=a(this.parser,t,this.name);if(null===r)return Promise.resolve();const n=[];s.thickness=void 0!==r.thicknessFactor?r.thicknessFactor:0,void 0!==r.thicknessTexture&&n.push(this.parser.assignTexture(s,"thicknessMap",r.thicknessTexture)),s.attenuationDistance=r.attenuationDistance||1/0;const i=r.attenuationColor||[1,1,1];return s.attenuationColor=(new e.Color).setRGB(i[0],i[1],i[2],e.LinearSRGBColorSpace),Promise.all(n)}}class R{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_IOR}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);return null===s||(t.ior=void 0!==s.ior?s.ior:1.5,0===t.ior&&(t.ior=1e3)),Promise.resolve()}}class x{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_SPECULAR}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=a(this.parser,t,this.name);if(null===r)return Promise.resolve();const n=[];s.specularIntensity=void 0!==r.specularFactor?r.specularFactor:1,void 0!==r.specularTexture&&n.push(this.parser.assignTexture(s,"specularIntensityMap",r.specularTexture));const i=r.specularColorFactor||[1,1,1];return s.specularColor=(new e.Color).setRGB(i[0],i[1],i[2],e.LinearSRGBColorSpace),void 0!==r.specularColorTexture&&n.push(this.parser.assignTexture(s,"specularColorMap",r.specularColorTexture,e.SRGBColorSpace)),Promise.all(n)}}class v{constructor(e){this.parser=e,this.name=c.EXT_MATERIALS_BUMP}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);if(null===s)return Promise.resolve();const r=[];return t.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(this.parser.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class _{constructor(e){this.parser=e,this.name=c.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return null!==a(this.parser,t,this.name)?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=a(this.parser,e,this.name);if(null===s)return Promise.resolve();const r=[];return void 0!==s.anisotropyStrength&&(t.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(t.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(this.parser.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class M{constructor(e){this.parser=e,this.name=c.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const n=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,i)}}class w{constructor(e){this.parser=e,this.name=c.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const i=n.extensions[t],o=r.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return s.loadTextureImage(e,i.source,a)}}class E{constructor(e){this.parser=e,this.name=c.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const i=n.extensions[t],o=r.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return s.loadTextureImage(e,i.source,a)}}class y{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(t){const s=e.byteOffset||0,r=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,s,r);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then(function(e){return e.buffer}):n.ready.then(function(){const t=new ArrayBuffer(i*o);return n.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t})})}return null}}class S{constructor(e){this.name=c.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(t){const s=this.parser.json,r=s.nodes[t];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;const n=s.meshes[r.mesh];for(const e of n.primitives)if(e.mode!==F.TRIANGLES&&e.mode!==F.TRIANGLE_STRIP&&e.mode!==F.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=r.extensions[this.name].attributes,o=[],a={};for(const e in i)o.push(this.parser.getDependency("accessor",i[e]).then(t=>(a[e]=t,a[e])));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then(t=>{const s=t.pop(),r=s.isGroup?s.children:[s],n=t[0].count,i=[];for(const t of r){const s=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,n);for(let e=0;e<n;e++)a.TRANSLATION&&r.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,e),a.SCALE&&c.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,s.compose(r,o,c));for(const s in a)if("_COLOR_0"===s){const t=a[s];l.instanceColor=new e.InstancedBufferAttribute(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==s&&"ROTATION"!==s&&"SCALE"!==s&&t.geometry.setAttribute(s,a[s]);e.Object3D.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),i.push(l)}return s.isGroup?(s.clear(),s.add(...i),s):i[0]}))}}const A="glTF",L=1313821514,I=5130562;class b{constructor(e){this.name=c.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==A)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,n=new DataView(e,12);let i=0;for(;i<r;){const t=n.getUint32(i,!0);i+=4;const r=n.getUint32(i,!0);if(i+=4,r===L){const r=new Uint8Array(e,12+i,t);this.content=s.decode(r)}else if(r===I){const s=12+i;this.body=e.slice(s,s+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class C{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=c.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(t,s){const r=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},c={},l={};for(const e in o){const t=K[e]||e.toLowerCase();a[t]=o[e]}for(const e in t.attributes){const s=K[e]||e.toLowerCase();if(void 0!==o[e]){const n=r.accessors[t.attributes[e]],i=D[n.componentType];l[s]=i.name,c[s]=!0===n.normalized}}return s.getDependency("bufferView",i).then(function(t){return new Promise(function(s,r){n.decodeDracoFile(t,function(e){for(const t in e.attributes){const s=e.attributes[t],r=c[t];void 0!==r&&(s.normalized=r)}s(e)},a,l,e.LinearSRGBColorSpace,r)})})}}class N{constructor(){this.name=c.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class O{constructor(){this.name=c.KHR_MESH_QUANTIZATION}}class P extends e.Interpolant{constructor(e,t,s,r){super(e,t,s,r)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,r=this.valueSize,n=e*r*3+r;for(let e=0;e!==r;e++)t[e]=s[n+e];return t}interpolate_(e,t,s,r){const n=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=r-t,u=(s-t)/l,h=u*u,d=h*u,p=e*c,m=p-c,f=-2*d+3*h,g=d-h,T=1-f,R=g-h+u;for(let e=0;e!==o;e++){const t=i[m+e+o],s=i[m+e+a]*l,r=i[p+e+o],c=i[p+e]*l;n[e]=T*t+R*s+f*r+g*c}return n}}const H=new e.Quaternion;class k extends P{interpolate_(e,t,s,r){const n=super.interpolate_(e,t,s,r);return H.fromArray(n).normalize().toArray(n),n}}const F={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},D={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},U={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},G={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},B={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},K={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"},V={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},j={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},X="OPAQUE",z="MASK",q="BLEND";function W(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),t.DefaultMaterial}function Y(e,t,s){for(const r in s.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=s.extensions[r])}function Q(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function $(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,r=t.weights.length;s<r;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,r=s.length;t<r;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function J(e){let t;const s=e.extensions&&e.extensions[c.KHR_DRACO_MESH_COMPRESSION];if(t=s?"draco:"+s.bufferView+":"+s.indices+":"+Z(s.attributes):e.indices+":"+Z(e.attributes)+":"+e.mode,void 0!==e.targets)for(let s=0,r=e.targets.length;s<r;s++)t+=":"+Z(e.targets[s]);return t}function Z(e){let t="";const s=Object.keys(e).sort();for(let r=0,n=s.length;r<n;r++)t+=s[r]+":"+e[s[r]]+";";return t}function ee(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 new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const te=new e.Matrix4;class se{constructor(t={},s={}){this.json=t,this.extensions={},this.plugins={},this.options=s,this.cache=new o,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,n=-1,i=!1,a=-1;if("undefined"!=typeof navigator&&void 0!==navigator.userAgent){const e=navigator.userAgent;r=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);n=r&&t?parseInt(t[1],10):-1,i=e.indexOf("Firefox")>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||r&&n<17||i&&a<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"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,r=this.json,n=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([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(t){const i={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:s,userData:{}};return Y(n,i,r),Q(i,r),Promise.all(s._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const r=t[s].joints;for(let t=0,s=r.length;t<s;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(s[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const r=s.clone(),n=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,r]of e.children.entries())n(r,t.children[s])};return n(s,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let r=0;r<t.length;r++){const n=e(t[r]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let r=this.cache.get(s);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(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e)}this.cache.add(s,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map(function(t,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(t){const s=this.json.buffers[t],r=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[c.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(t,i){r.load(e.LoaderUtils.resolveURL(s.uri,n.path),t,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+s)})}loadAccessor(t){const s=this,r=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const t=B[n.type],s=D[n.componentType],r=!0===n.normalized,i=new s(n.count*t);return Promise.resolve(new e.BufferAttribute(i,t,r))}const i=[];return void 0!==n.bufferView?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),void 0!==n.sparse&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(t){const i=t[0],o=B[n.type],a=D[n.componentType],c=a.BYTES_PER_ELEMENT,l=c*o,u=n.byteOffset||0,h=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;let p,m;if(h&&h!==l){const t=Math.floor(u/h),r="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let l=s.cache.get(r);l||(p=new a(i,t*h,n.count*h/c),l=new e.InterleavedBuffer(p,h/c),s.cache.add(r,l)),m=new e.InterleavedBufferAttribute(l,o,u%h/c,d)}else p=null===i?new a(n.count*o):new a(i,u,n.count*o),m=new e.BufferAttribute(p,o,d);if(void 0!==n.sparse){const s=B.SCALAR,r=D[n.sparse.indices.componentType],c=n.sparse.indices.byteOffset||0,l=n.sparse.values.byteOffset||0,u=new r(t[1],c,n.sparse.count*s),h=new a(t[2],l,n.sparse.count*o);null!==i&&(m=new e.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(m.setX(t,h[e*o]),o>=2&&m.setY(t,h[e*o+1]),o>=3&&m.setZ(t,h[e*o+2]),o>=4&&m.setW(t,h[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=d}return m})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,n=t.images[r];let i=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(i=e)}return this.loadTextureImage(e,r,i)}loadTextureImage(t,s,r){const n=this,i=this.json,o=i.textures[t],a=i.images[s],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(s,r).then(function(s){s.flipY=!1,s.name=o.name||a.name||"",""===s.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(s.name=a.uri);const r=(i.samplers||{})[o.sampler]||{};return s.magFilter=U[r.magFilter]||e.LinearFilter,s.minFilter=U[r.minFilter]||e.LinearMipmapLinearFilter,s.wrapS=G[r.wrapS]||e.RepeatWrapping,s.wrapT=G[r.wrapT]||e.RepeatWrapping,s.generateMipmaps=!s.isCompressedTexture&&s.minFilter!==e.NearestFilter&&s.minFilter!==e.LinearFilter,n.associations.set(s,{textures:t}),s}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(t,s){const r=this,n=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(e=>e.clone());const o=n.images[t],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(void 0!==o.bufferView)c=r.getDependency("bufferView",o.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return c=a.createObjectURL(t),c});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(t){return new Promise(function(r,n){let o=r;!0===s.isImageBitmapLoader&&(o=function(t){const s=new e.Texture(t);s.needsUpdate=!0,r(s)}),s.load(e.LoaderUtils.resolveURL(t,i.path),o,void 0,n)})}).then(function(e){var t;return!0===l&&a.revokeObjectURL(c),Q(e,o),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),e});return this.sourceCache[t]=u,u}assignTexture(e,t,s,r){const n=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((i=i.clone()).channel=s.texCoord),n.extensions[c.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[c.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(i);i=n.extensions[c.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),n.associations.set(i,t)}}return void 0!==r&&(i.colorSpace=r),e[t]=i,i})}assignFinalMaterial(t){const s=t.geometry;let r=t.material;const n=void 0===s.attributes.tangent,i=void 0!==s.attributes.color,o=void 0===s.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+r.uuid;let s=this.cache.get(t);s||(s=new e.PointsMaterial,e.Material.prototype.copy.call(s,r),s.color.copy(r.color),s.map=r.map,s.sizeAttenuation=!1,this.cache.add(t,s)),r=s}else if(t.isLine){const t="LineBasicMaterial:"+r.uuid;let s=this.cache.get(t);s||(s=new e.LineBasicMaterial,e.Material.prototype.copy.call(s,r),s.color.copy(r.color),s.map=r.map,this.cache.add(t,s)),r=s}if(n||i||o){let e="ClonedMaterial:"+r.uuid+":";n&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),n&&(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){const s=this,r=this.json,n=this.extensions,i=r.materials[t];let o;const a={},l=[];if((i.extensions||{})[c.KHR_MATERIALS_UNLIT]){const e=n[c.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(a,i,s))}else{const r=i.pbrMetallicRoughness||{};if(a.color=new e.Color(1,1,1),a.opacity=1,Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace),a.opacity=t[3]}void 0!==r.baseColorTexture&&l.push(s.assignTexture(a,"map",r.baseColorTexture,e.SRGBColorSpace)),a.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,a.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(l.push(s.assignTexture(a,"metalnessMap",r.metallicRoughnessTexture)),l.push(s.assignTexture(a,"roughnessMap",r.metallicRoughnessTexture))),o=this._invokeOne(function(e){return e.getMaterialType&&e.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)})))}!0===i.doubleSided&&(a.side=e.DoubleSide);const u=i.alphaMode||X;if(u===q?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===z&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&o!==e.MeshBasicMaterial&&(l.push(s.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new e.Vector2(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&o!==e.MeshBasicMaterial&&(l.push(s.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&o!==e.MeshBasicMaterial){const t=i.emissiveFactor;a.emissive=(new e.Color).setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return void 0!==i.emissiveTexture&&o!==e.MeshBasicMaterial&&l.push(s.assignTexture(a,"emissiveMap",i.emissiveTexture,e.SRGBColorSpace)),Promise.all(l).then(function(){const e=new o(a);return i.name&&(e.name=i.name),Q(e,i),s.associations.set(e,{materials:t}),i.extensions&&Y(n,e,i),e})}createUniqueName(t){const s=e.PropertyBinding.sanitizeNodeName(t||"");return s in this.nodeNamesUsed?s+"_"+ ++this.nodeNamesUsed[s]:(this.nodeNamesUsed[s]=0,s)}loadGeometries(t){const s=this,r=this.extensions,n=this.primitiveCache;function i(e){return r[c.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,s).then(function(t){return re(t,e,s)})}const o=[];for(let r=0,a=t.length;r<a;r++){const a=t[r],l=J(a),u=n[l];if(u)o.push(u.promise);else{let t;t=a.extensions&&a.extensions[c.KHR_DRACO_MESH_COMPRESSION]?i(a):re(new e.BufferGeometry,a,s),n[l]={primitive:a,promise:t},o.push(t)}}return Promise.all(o)}loadMesh(t){const r=this,n=this.json,i=this.extensions,o=n.meshes[t],a=o.primitives,c=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?W(this.cache):this.getDependency("material",a[e].material);c.push(t)}return c.push(r.loadGeometries(a)),Promise.all(c).then(function(n){const c=n.slice(0,n.length-1),l=n[n.length-1],u=[];for(let n=0,h=l.length;n<h;n++){const h=l[n],d=a[n];let p;const m=c[n];if(d.mode===F.TRIANGLES||d.mode===F.TRIANGLE_STRIP||d.mode===F.TRIANGLE_FAN||void 0===d.mode)p=!0===o.isSkinnedMesh?new e.SkinnedMesh(h,m):new e.Mesh(h,m),!0===p.isSkinnedMesh&&p.normalizeSkinWeights(),d.mode===F.TRIANGLE_STRIP?p.geometry=s(p.geometry,e.TriangleStripDrawMode):d.mode===F.TRIANGLE_FAN&&(p.geometry=s(p.geometry,e.TriangleFanDrawMode));else if(d.mode===F.LINES)p=new e.LineSegments(h,m);else if(d.mode===F.LINE_STRIP)p=new e.Line(h,m);else if(d.mode===F.LINE_LOOP)p=new e.LineLoop(h,m);else{if(d.mode!==F.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);p=new e.Points(h,m)}Object.keys(p.geometry.morphAttributes).length>0&&$(p,o),p.name=r.createUniqueName(o.name||"mesh_"+t),Q(p,o),d.extensions&&Y(i,p,d),r.assignFinalMaterial(p),u.push(p)}for(let e=0,s=u.length;e<s;e++)r.associations.set(u[e],{meshes:t,primitives:e});if(1===u.length)return o.extensions&&Y(i,u[0],o),u[0];const h=new e.Group;o.extensions&&Y(i,h,o),r.associations.set(h,{meshes:t});for(let e=0,t=u.length;e<t;e++)h.add(u[e]);return h})}loadCamera(t){let s;const r=this.json.cameras[t],n=r[r.type];if(n)return"perspective"===r.type?s=new e.PerspectiveCamera(e.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===r.type&&(s=new e.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(s.name=this.createUniqueName(r.name)),Q(s,r),Promise.resolve(s);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const s=this.json.skins[t],r=[];for(let e=0,t=s.joints.length;e<t;e++)r.push(this._loadNodeShallow(s.joints[e]));return void 0!==s.inverseBindMatrices?r.push(this.getDependency("accessor",s.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(t){const r=t.pop(),n=t,i=[],o=[];for(let t=0,a=n.length;t<a;t++){const a=n[t];if(a){i.push(a);const s=new e.Matrix4;null!==r&&s.fromArray(r.array,16*t),o.push(s)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[t])}return new e.Skeleton(i,o)})}loadAnimation(t){const s=this.json,r=this,n=s.animations[t],i=n.name?n.name:"animation_"+t,o=[],a=[],c=[],l=[],u=[];for(let e=0,t=n.channels.length;e<t;e++){const t=n.channels[e],s=n.samplers[t.sampler],r=t.target,i=r.node,h=void 0!==n.parameters?n.parameters[s.input]:s.input,d=void 0!==n.parameters?n.parameters[s.output]:s.output;void 0!==r.node&&(o.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),c.push(this.getDependency("accessor",d)),l.push(s),u.push(r))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(t){const s=t[0],o=t[1],a=t[2],c=t[3],l=t[4],u=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],n=o[e],i=a[e],h=c[e],d=l[e];if(void 0===t)continue;t.updateMatrix&&t.updateMatrix();const p=r._createAnimationTracks(t,n,i,h,d);if(p)for(let e=0;e<p.length;e++)u.push(p[e])}const h=new e.AnimationClip(i,void 0,u);return Q(h,n),h})}createNodeMesh(e){const t=this.json,s=this,r=t.nodes[e];return void 0===r.mesh?null:s.getDependency("mesh",r.mesh).then(function(e){const t=s._getNodeRef(s.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,s=r.weights.length;t<s;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(t){const s=this,r=this.json.nodes[t],n=s._loadNodeShallow(t),i=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)i.push(s.getDependency("node",o[e]));const a=void 0===r.skin?Promise.resolve(null):s.getDependency("skin",r.skin);return Promise.all([n,Promise.all(i),a]).then(function(t){const s=t[0],r=t[1],n=t[2];null!==n&&s.traverse(function(e){e.isSkinnedMesh&&e.bind(n,te)});for(let e=0,t=r.length;e<t;e++)s.add(r[e]);if(void 0!==s.userData.pivot&&r.length>0){const t=s.userData.pivot,n=r[0];s.pivot=(new e.Vector3).fromArray(t),s.position.x-=t[0],s.position.y-=t[1],s.position.z-=t[2],n.position.set(0,0,0),delete s.userData.pivot}return s})}_loadNodeShallow(t){const s=this.json,r=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const i=s.nodes[t],o=i.name?n.createUniqueName(i.name):"",a=[],c=n._invokeOne(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return c&&a.push(c),void 0!==i.camera&&a.push(n.getDependency("camera",i.camera).then(function(e){return n._getNodeRef(n.cameraCache,i.camera,e)})),n._invokeAll(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(e){a.push(e)}),this.nodeCache[t]=Promise.all(a).then(function(s){let a;if(a=!0===i.isBone?new e.Bone:s.length>1?new e.Group:1===s.length?s[0]:new e.Object3D,a!==s[0])for(let e=0,t=s.length;e<t;e++)a.add(s[e]);if(i.name&&(a.userData.name=i.name,a.name=o),Q(a,i),i.extensions&&Y(r,a,i),void 0!==i.matrix){const t=new e.Matrix4;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);if(n.associations.has(a)){if(void 0!==i.mesh&&n.meshCache.refs[i.mesh]>1){const e=n.associations.get(a);n.associations.set(a,{...e})}}else n.associations.set(a,{});return n.associations.get(a).nodes=t,a}),this.nodeCache[t]}loadScene(t){const s=this.extensions,n=this.json.scenes[t],i=this,o=new e.Group;n.name&&(o.name=i.createUniqueName(n.name)),Q(o,n),n.extensions&&Y(s,o,n);const a=n.nodes||[],c=[];for(let e=0,t=a.length;e<t;e++)c.push(i.getDependency("node",a[e]));return Promise.all(c).then(function(t){for(let e=0,s=t.length;e<s;e++){const s=t[e];null!==s.parent?o.add(r(s)):o.add(s)}return i.associations=(t=>{const s=new Map;for(const[t,r]of i.associations)(t instanceof e.Material||t instanceof e.Texture)&&s.set(t,r);return t.traverse(e=>{const t=i.associations.get(e);null!=t&&s.set(e,t)}),s})(o),o})}_createAnimationTracks(t,s,r,n,i){const o=[],a=t.name?t.name:t.uuid,c=[];function l(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}let u;switch(V[i.path]===V.weights?(l(t),t.isGroup&&t.children.forEach(l)):c.push(a),V[i.path]){case V.weights:u=e.NumberKeyframeTrack;break;case V.rotation:u=e.QuaternionKeyframeTrack;break;case V.translation:case V.scale:u=e.VectorKeyframeTrack;break;default:if(1===r.itemSize)u=e.NumberKeyframeTrack;else u=e.VectorKeyframeTrack}const h=void 0!==n.interpolation?j[n.interpolation]:e.InterpolateLinear,d=this._getArrayFromAccessor(r);for(let e=0,t=c.length;e<t;e++){const t=new u(c[e]+"."+V[i.path],s.array,d,h);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(t),o.push(t)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=ee(t.constructor),s=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r++)s[r]=t[r]*e;t=s}return t}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?k:P)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function re(t,s,r){const n=s.attributes,i=[];function o(e,s){return r.getDependency("accessor",e).then(function(e){t.setAttribute(s,e)})}for(const e in n){const s=K[e]||e.toLowerCase();s in t.attributes||i.push(o(n[e],s))}if(void 0!==s.indices&&!t.index){const e=r.getDependency("accessor",s.indices).then(function(e){t.setIndex(e)});i.push(e)}return e.ColorManagement.workingColorSpace!==e.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${e.ColorManagement.workingColorSpace}" not supported.`),Q(t,s),function(t,s,r){const n=s.attributes,i=new e.Box3;if(void 0===n.POSITION)return;{const t=r.json.accessors[n.POSITION],s=t.min,o=t.max;if(void 0===s||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new e.Vector3(s[0],s[1],s[2]),new e.Vector3(o[0],o[1],o[2])),t.normalized){const e=ee(D[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const o=s.targets;if(void 0!==o){const t=new e.Vector3,s=new e.Vector3;for(let e=0,n=o.length;e<n;e++){const n=o[e];if(void 0!==n.POSITION){const e=r.json.accessors[n.POSITION],i=e.min,o=e.max;if(void 0!==i&&void 0!==o){if(s.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),s.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),s.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),e.normalized){const t=ee(D[e.componentType]);s.multiplyScalar(t)}t.max(s)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new e.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,s,r),Promise.all(i).then(function(){return void 0!==s.targets?function(e,t,s){let r=!1,n=!1,i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(r=!0),void 0!==s.NORMAL&&(n=!0),void 0!==s.COLOR_0&&(i=!0),r&&n&&i)break}if(!r&&!n&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(r){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(n){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(t){const s=t[0],o=t[1],a=t[2];return r&&(e.morphAttributes.position=s),n&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(t,s.targets,r):t})}class ne extends t.Loader{constructor(e){super(),this.viewer=e,this.manager=null}dispose(){this.manager&&this.manager.dispose()}isSupport(e){return"object"==typeof e&&"string"==typeof e.database&&"function"==typeof e.downloadResource&&/.gltf$/i.test(e.database)}async load(e){const s=`${e.httpClient.serverUrl}${e.path}/${e.database}`;this.manager=new t.GLTFLoadingManager(s);const r=new i(this.manager);r.setRequestHeader(e.httpClient.headers);const n=await r.loadAsync(s,t=>{const{lengthComputable:s,loaded:r,total:n}=t,i=s?r/n:1;this.viewer.emitEvent({type:"geometryprogress",data:i,file:e.file,model:e})});if(!this.viewer.scene)return this;const o=new t.ModelImpl(n.scene);return o.id=e.file.id,this.viewer.scene.add(n.scene),this.viewer.models.push(o),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.emitEvent({type:"databasechunk",data:n.scene,file:e.file,model:e}),this.viewer.update(!0),this}}t.loaders.registerLoader("gltf-cloud",e=>new ne(e))});
|