@ridp/threejs 1.3.0 → 1.3.1

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/hooks.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-2awW2QaH.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useGLTFLoader=e.useGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-B6Cm6xQg.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useGLTFLoader=e.useGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as a, o, c as r, b, a as t, u } from "./useGLTFLoader-BBGTGOYm.js";
1
+ import { i as a, o, c as r, b, a as t, u } from "./useGLTFLoader-kuE8ICl_.js";
2
2
  export {
3
3
  a as intersectColor,
4
4
  o as obbObjects,
package/dist/threejs.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var O=(l,e,s)=>e in l?b(l,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[e]=s;var t=(l,e,s)=>O(l,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./useGLTFLoader-2awW2QaH.cjs"),i=require("./modelSerialize-Ds_2KBaA.cjs"),u=require("./common-C1rNPPkt.cjs"),o=require("three"),v="1.2.0",L={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:o.MathUtils.degToRad(60)};class m{constructor(e,s){t(this,"isReady",!1);t(this,"scene",null);t(this,"camera",null);t(this,"renderer",null);t(this,"control",null);t(this,"css3dRenderer",null);t(this,"el",null);t(this,"renderRequested",!1);t(this,"selector",null);t(this,"eventsListener",{});t(this,"stats",null);t(this,"isDispose",!1);t(this,"version","0.0.0");t(this,"initOpt",{css3d:!1,stats:!1,renderType:"change",initListener:"True",control:{init:!0,options:{}}});t(this,"setup",e=>{this.isDispose=!1,this.selector=e,this.el=document.querySelector(e);const s=Math.tan(Math.PI/180*this.camera.fov/2),[r,c]=this.getTargetSize();if(this.camera.aspect=r/c,this.camera.position.set(47,39,100),this.camera.fov=360/Math.PI*Math.atan(s*(c/r)),this.camera.lookAt(0,0,0),this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(r,c),this.el.appendChild(this.renderer.domElement),this.initOpt.control&&this.initOpt.control.init){this.control=i.createOrbitControl(this.camera,this.renderer.domElement);const h=Object.assign(L,this.initOpt.control.options||{});Object.keys(h).forEach(n=>{this.control[n]=h[n]})}setTimeout(()=>{this.isReady=!0},20),this.initOpt.stats&&this.initStats(),this.initOpt.css3d&&this.initCss3dRenderer(),this.initOpt.renderType==="loop"?requestAnimationFrame(this.animate):this.initOpt.renderType==="change"&&this.control&&this.control.addEventListener("change",this.requestRenderIfNotRequested),this.initListener()});t(this,"onContextLost",e=>{e.preventDefault(),cancelAnimationFrame(this.animate)});t(this,"onContextRestored",e=>{e.preventDefault(),this.dispose(),setTimeout(()=>{this.setup(this.selector)},20)});t(this,"initListener",()=>{this.initOpt.initListener=="True"&&window&&window.addEventListener("resize",()=>this.onResize(),!1),this.renderer.domElement.addEventListener("webglcontextlost",this.onContextLost,!1),this.renderer.domElement.addEventListener("webglcontextrestored",this.onContextRestored,!1)});t(this,"removeListener",()=>{window&&window.removeEventListener("resize",this.onResize,!1),this.renderer.domElement.removeEventListener("webglcontextlost",this.onContextLost.bind(m),!1),this.renderer.domElement.removeEventListener("webglcontextrestored",this.onContextRestored.bind(m),!1)});t(this,"animate",()=>{this.initOpt.renderType==="loop"&&this.onRender(),requestAnimationFrame(this.animate)});t(this,"onRender",()=>{this.isDispose||(this.renderRequested=!1,this.stats&&this.stats.update(),this.control&&this.control.update(),this.renderer.render(this.scene,this.camera),this.css3dRenderer&&this.css3dRenderer.render(this.scene,this.camera),this.eventsListener.onRender&&this.eventsListener.onRender.length&&this.eventsListener.onRender.forEach(e=>e()))});t(this,"requestRenderIfNotRequested",()=>{this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.onRender()}))});t(this,"onResize",()=>{setTimeout(()=>{const e=Math.tan(Math.PI/180*this.camera.fov/2),[s,r]=this.getTargetSize();this.camera.aspect=s/r,this.camera.fov=360/Math.PI*Math.atan(e*(r/s)),this.camera.updateProjectionMatrix(),this.camera.lookAt(this.scene.position),this.renderer.setSize(s,r),this.css3dRenderer&&this.css3dRenderer.setSize(s,r),this.onRender()},0)});t(this,"frameArea",(e,s,r)=>{const c=new o.Box3().setFromObject(e),h=c.getSize(new o.Vector3).length(),n=c.getCenter(new o.Vector3);r&&n.add(r);const f=h*s*.5,R=o.MathUtils.degToRad(this.camera.fov*.5),g=f/Math.tan(R),p=new o.Vector3().subVectors(this.camera.position,n).multiply(new o.Vector3(1,1,1)).normalize().multiplyScalar(g).add(n),d={x:p.x,y:p.y,z:p.z,lookAt_x:n.x,lookAt_y:n.y,lookAt_z:n.z};return this.camera.position.set(d.x,d.y,d.z),this.camera.lookAt(d.lookAt_x,d.lookAt_y,d.lookAt_z),this.camera.updateProjectionMatrix(),this.control.target.copy(n),this.control.update(),h});t(this,"on",(e,s)=>{!e||!s||(this.eventsListener[e]||(this.eventsListener[e]=[]),this.eventsListener[e].push(s))});this.isReady=!1,this.scene=new o.Scene({}),this.camera=new o.PerspectiveCamera(50,1,.1,2e3),this.renderer=new o.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),this.version=v,s&&(this.initOpt=Object.assign(this.initOpt,s)),e&&this.setup(e)}initStats(){const e=new Stats;e.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",this.el.appendChild(e.dom)}initCss3dRenderer(){this.css3dRenderer=new i.CSS3DRenderer;const[e,s]=this.getTargetSize();this.css3dRenderer.setSize(e,s),this.css3dRenderer.domElement.style.position="absolute",this.css3dRenderer.domElement.style.pointerEvents="none",this.css3dRenderer.domElement.style.top=0,this.css3dRenderer.domElement.style.left=0,this.el.appendChild(this.css3dRenderer.domElement)}getTargetSize(){const e=document.querySelector(this.selector);return e?[e.clientWidth,e.clientHeight]:[0,0]}off(e){e||(this.eventsListener={}),this.eventsListener[e]&&(this.eventsListener[e]=[])}dispose(){this.isDispose=!0,this.removeListener(),i.disposeThreeObject(this.scene),this.renderer.dispose(),this.renderer.domElement.remove(),this.el=null,this.renderer=null,this.camera=null,this.scene=null,this.control=null,this.css3dRenderer=null}}exports.IDBCache=a.IDBCache;exports.intersectColor=a.intersectColor;exports.obbObjects=a.obbObjects;exports.useGLTFLoader=a.useGLTFLoader;exports.useObb=a.useObb;exports.useRaycaster=a.useRaycaster;exports.useThreeJs=a.useThreeJs;exports.ImageLoader=i.ImageLoader;exports.createArrowHelper=i.createArrowHelper;exports.createAxesHelper=i.createAxesHelper;exports.createBox3Helper=i.createBox3Helper;exports.createCameraHelper=i.createCameraHelper;exports.createGridHelper=i.createGridHelper;exports.createMapControls=i.createMapControls;exports.createOrbitControl=i.createOrbitControl;exports.createRaycaster=i.createRaycaster;exports.createStats=i.createStats;exports.dataToObject3D=i.dataToObject3D;exports.disposeThreeObject=i.disposeThreeObject;exports.initEnvImage=i.initEnvImage;exports.object3DToData=i.object3DToData;exports.createInfoPlane=u.createInfoPlane;exports.createTagPlane=u.createTagPlane;exports.getCommonParent=u.getCommonParent;exports.ThreeIns=m;
1
+ "use strict";var b=Object.defineProperty;var O=(l,e,s)=>e in l?b(l,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[e]=s;var t=(l,e,s)=>O(l,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./useGLTFLoader-B6Cm6xQg.cjs"),i=require("./modelSerialize-Ds_2KBaA.cjs"),u=require("./common-C1rNPPkt.cjs"),o=require("three"),v="1.3.0",L={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:o.MathUtils.degToRad(60)};class m{constructor(e,s){t(this,"isReady",!1);t(this,"scene",null);t(this,"camera",null);t(this,"renderer",null);t(this,"control",null);t(this,"css3dRenderer",null);t(this,"el",null);t(this,"renderRequested",!1);t(this,"selector",null);t(this,"eventsListener",{});t(this,"stats",null);t(this,"isDispose",!1);t(this,"version","0.0.0");t(this,"initOpt",{css3d:!1,stats:!1,renderType:"change",initListener:"True",control:{init:!0,options:{}}});t(this,"setup",e=>{this.isDispose=!1,this.selector=e,this.el=document.querySelector(e);const s=Math.tan(Math.PI/180*this.camera.fov/2),[r,c]=this.getTargetSize();if(this.camera.aspect=r/c,this.camera.position.set(47,39,100),this.camera.fov=360/Math.PI*Math.atan(s*(c/r)),this.camera.lookAt(0,0,0),this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(r,c),this.el.appendChild(this.renderer.domElement),this.initOpt.control&&this.initOpt.control.init){this.control=i.createOrbitControl(this.camera,this.renderer.domElement);const h=Object.assign(L,this.initOpt.control.options||{});Object.keys(h).forEach(n=>{this.control[n]=h[n]})}setTimeout(()=>{this.isReady=!0},20),this.initOpt.stats&&this.initStats(),this.initOpt.css3d&&this.initCss3dRenderer(),this.initOpt.renderType==="loop"?requestAnimationFrame(this.animate):this.initOpt.renderType==="change"&&this.control&&this.control.addEventListener("change",this.requestRenderIfNotRequested),this.initListener()});t(this,"onContextLost",e=>{e.preventDefault(),cancelAnimationFrame(this.animate)});t(this,"onContextRestored",e=>{e.preventDefault(),this.dispose(),setTimeout(()=>{this.setup(this.selector)},20)});t(this,"initListener",()=>{this.initOpt.initListener=="True"&&window&&window.addEventListener("resize",()=>this.onResize(),!1),this.renderer.domElement.addEventListener("webglcontextlost",this.onContextLost,!1),this.renderer.domElement.addEventListener("webglcontextrestored",this.onContextRestored,!1)});t(this,"removeListener",()=>{window&&window.removeEventListener("resize",this.onResize,!1),this.renderer.domElement.removeEventListener("webglcontextlost",this.onContextLost.bind(m),!1),this.renderer.domElement.removeEventListener("webglcontextrestored",this.onContextRestored.bind(m),!1)});t(this,"animate",()=>{this.initOpt.renderType==="loop"&&this.onRender(),requestAnimationFrame(this.animate)});t(this,"onRender",()=>{this.isDispose||(this.renderRequested=!1,this.stats&&this.stats.update(),this.control&&this.control.update(),this.renderer.render(this.scene,this.camera),this.css3dRenderer&&this.css3dRenderer.render(this.scene,this.camera),this.eventsListener.onRender&&this.eventsListener.onRender.length&&this.eventsListener.onRender.forEach(e=>e()))});t(this,"requestRenderIfNotRequested",()=>{this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.onRender()}))});t(this,"onResize",()=>{setTimeout(()=>{const e=Math.tan(Math.PI/180*this.camera.fov/2),[s,r]=this.getTargetSize();this.camera.aspect=s/r,this.camera.fov=360/Math.PI*Math.atan(e*(r/s)),this.camera.updateProjectionMatrix(),this.camera.lookAt(this.scene.position),this.renderer.setSize(s,r),this.css3dRenderer&&this.css3dRenderer.setSize(s,r),this.onRender()},0)});t(this,"frameArea",(e,s,r)=>{const c=new o.Box3().setFromObject(e),h=c.getSize(new o.Vector3).length(),n=c.getCenter(new o.Vector3);r&&n.add(r);const f=h*s*.5,R=o.MathUtils.degToRad(this.camera.fov*.5),g=f/Math.tan(R),p=new o.Vector3().subVectors(this.camera.position,n).multiply(new o.Vector3(1,1,1)).normalize().multiplyScalar(g).add(n),d={x:p.x,y:p.y,z:p.z,lookAt_x:n.x,lookAt_y:n.y,lookAt_z:n.z};return this.camera.position.set(d.x,d.y,d.z),this.camera.lookAt(d.lookAt_x,d.lookAt_y,d.lookAt_z),this.camera.updateProjectionMatrix(),this.control.target.copy(n),this.control.update(),h});t(this,"on",(e,s)=>{!e||!s||(this.eventsListener[e]||(this.eventsListener[e]=[]),this.eventsListener[e].push(s))});this.isReady=!1,this.scene=new o.Scene({}),this.camera=new o.PerspectiveCamera(50,1,.1,2e3),this.renderer=new o.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),this.version=v,s&&(this.initOpt=Object.assign(this.initOpt,s)),e&&this.setup(e)}initStats(){const e=new Stats;e.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",this.el.appendChild(e.dom)}initCss3dRenderer(){this.css3dRenderer=new i.CSS3DRenderer;const[e,s]=this.getTargetSize();this.css3dRenderer.setSize(e,s),this.css3dRenderer.domElement.style.position="absolute",this.css3dRenderer.domElement.style.pointerEvents="none",this.css3dRenderer.domElement.style.top=0,this.css3dRenderer.domElement.style.left=0,this.el.appendChild(this.css3dRenderer.domElement)}getTargetSize(){const e=document.querySelector(this.selector);return e?[e.clientWidth,e.clientHeight]:[0,0]}off(e){e||(this.eventsListener={}),this.eventsListener[e]&&(this.eventsListener[e]=[])}dispose(){this.isDispose=!0,this.removeListener(),i.disposeThreeObject(this.scene),this.renderer.dispose(),this.renderer.domElement.remove(),this.el=null,this.renderer=null,this.camera=null,this.scene=null,this.control=null,this.css3dRenderer=null}}exports.IDBCache=a.IDBCache;exports.intersectColor=a.intersectColor;exports.obbObjects=a.obbObjects;exports.useGLTFLoader=a.useGLTFLoader;exports.useObb=a.useObb;exports.useRaycaster=a.useRaycaster;exports.useThreeJs=a.useThreeJs;exports.ImageLoader=i.ImageLoader;exports.createArrowHelper=i.createArrowHelper;exports.createAxesHelper=i.createAxesHelper;exports.createBox3Helper=i.createBox3Helper;exports.createCameraHelper=i.createCameraHelper;exports.createGridHelper=i.createGridHelper;exports.createMapControls=i.createMapControls;exports.createOrbitControl=i.createOrbitControl;exports.createRaycaster=i.createRaycaster;exports.createStats=i.createStats;exports.dataToObject3D=i.dataToObject3D;exports.disposeThreeObject=i.disposeThreeObject;exports.initEnvImage=i.initEnvImage;exports.object3DToData=i.object3DToData;exports.createInfoPlane=u.createInfoPlane;exports.createTagPlane=u.createTagPlane;exports.getCommonParent=u.getCommonParent;exports.ThreeIns=m;
package/dist/threejs.js CHANGED
@@ -1,12 +1,12 @@
1
1
  var R = Object.defineProperty;
2
2
  var g = (a, e, s) => e in a ? R(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
3
3
  var t = (a, e, s) => g(a, typeof e != "symbol" ? e + "" : e, s);
4
- import { I as q, i as F, o as j, c as I, b as k, a as H, u as W } from "./useGLTFLoader-BBGTGOYm.js";
4
+ import { I as q, i as F, o as j, c as I, b as k, a as H, u as W } from "./useGLTFLoader-kuE8ICl_.js";
5
5
  import { d as x, C as v, j as L } from "./modelSerialize-5oJb1ka7.js";
6
6
  import { I as V, h as _, g as G, b as N, c as J, a as U, e as Y, f as K, i as Q, l as X, k as Z, o as $ } from "./modelSerialize-5oJb1ka7.js";
7
7
  import { c as te, a as se, g as ie } from "./common-D1_IztgM.js";
8
8
  import { MathUtils as m, Scene as O, PerspectiveCamera as b, WebGLRenderer as y, Box3 as z, Vector3 as h } from "three";
9
- const w = "1.2.0", S = {
9
+ const w = "1.3.0", S = {
10
10
  enableDamping: !0,
11
11
  dampingFactor: 0.25,
12
12
  screenSpacePanning: !1,
@@ -0,0 +1,2 @@
1
+ "use strict";const l=require("three"),H=require("vue"),Y=require("./modelSerialize-Ds_2KBaA.cjs"),Oe=require("dexie");function fe(f,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=f.getIndex();if(t===null){const i=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)i.push(o);f.setIndex(i),t=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const r=t.count-2,n=[];if(e===l.TriangleFanDrawMode)for(let i=1;i<=r;i++)n.push(t.getX(0)),n.push(t.getX(i)),n.push(t.getX(i+1));else for(let i=0;i<r;i++)i%2===0?(n.push(t.getX(i)),n.push(t.getX(i+1)),n.push(t.getX(i+2))):(n.push(t.getX(i+2)),n.push(t.getX(i+1)),n.push(t.getX(i)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=f.clone();return s.setIndex(n),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),f}const se=new WeakMap;class Ne extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,n){const s=new l.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,i=>{this.parse(i,t,n)},r,n)}parse(e,t,r=()=>{}){this.decodeDracoFile(e,t,null,null,l.SRGBColorSpace,r).catch(r)}decodeDracoFile(e,t,r,n,s=l.LinearSRGBColorSpace,i=()=>{}){const a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(i)}decodeGeometry(e,t){const r=JSON.stringify(t);if(se.has(e)){const o=se.get(e);if(o.key===r)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const s=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(s,i).then(o=>(n=o,new Promise((c,d)=>{n._callbacks[s]={resolve:c,reject:d},n.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),se.set(e,{key:r,promise:a}),a}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const n=e.attributes[r],s=n.name,i=n.array,a=n.itemSize,o=new l.BufferAttribute(i,a);s==="color"&&(this._assignVertexColorSpace(o,n.vertexColorSpace),o.normalized=!(i instanceof Float32Array)),t.setAttribute(s,o)}return t}_assignVertexColorSpace(e,t){if(t!==l.SRGBColorSpace)return;const r=new l.Color;for(let n=0,s=e.count;n<s;n++)r.fromBufferAttribute(e,n),l.ColorManagement.colorSpaceToWorking(r,l.SRGBColorSpace),e.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(e,t){const r=new l.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((n,s)=>{r.load(e,n,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(r=>{const n=r[0];e||(this.decoderConfig.wasmBinary=r[1]);const s=Pe.toString(),i=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
2
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){const i=s.data;switch(i.type){case"decode":n._callbacks[i.id].resolve(i);break;case"error":n._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Pe(){let f,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":f=a.decoderConfig,e=new Promise(function(d){f.onModuleLoaded=function(u){d({draco:u})},DracoDecoderModule(f)});break;case"decode":const o=a.buffer,c=a.taskConfig;e.then(d=>{const u=d.draco,h=new u.Decoder;try{const p=t(u,h,new Int8Array(o),c),m=p.attributes.map(y=>y.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(h)}});break}};function t(i,a,o,c){const d=c.attributeIDs,u=c.attributeTypes;let h,p;const m=a.GetEncodedGeometryType(o);if(m===i.TRIANGULAR_MESH)h=new i.Mesh,p=a.DecodeArrayToMesh(o,o.byteLength,h);else if(m===i.POINT_CLOUD)h=new i.PointCloud,p=a.DecodeArrayToPointCloud(o,o.byteLength,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const y={index:null,attributes:[]};for(const g in d){const T=self[u[g]];let S,L;if(c.useUniqueIDs)L=d[g],S=a.GetAttributeByUniqueId(h,L);else{if(L=a.GetAttributeId(h,i[d[g]]),L===-1)continue;S=a.GetAttribute(h,L)}const R=n(i,a,h,g,T,S);g==="color"&&(R.vertexColorSpace=c.vertexColorSpace),y.attributes.push(R)}return m===i.TRIANGULAR_MESH&&(y.index=r(i,a,h)),i.destroy(h),y}function r(i,a,o){const d=o.num_faces()*3,u=d*4,h=i._malloc(u);a.GetTrianglesUInt32Array(o,u,h);const p=new Uint32Array(i.HEAPF32.buffer,h,d).slice();return i._free(h),{array:p,itemSize:1}}function n(i,a,o,c,d,u){const h=u.num_components(),m=o.num_points()*h,y=m*d.BYTES_PER_ELEMENT,g=s(i,d),T=i._malloc(y);a.GetAttributeDataArrayForAllPoints(o,u,g,y,T);const S=new d(i.HEAPF32.buffer,T,m).slice();return i._free(T),{name:c,array:S,itemSize:h}}function s(i,a){switch(a){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}class De extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Be(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Ve(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new Ue(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new He(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Fe(t)}),this.register(function(t){return new Ze(t)}),this.register(function(t){return new $e(t)})}load(e,t,r,n){const s=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const c=l.LoaderUtils.extractUrlBase(e);i=l.LoaderUtils.resolveURL(c,this.path)}else i=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{s.parse(c,i,function(d){t(d),s.manager.itemEnd(e)},a)}catch(d){a(d)}},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 this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,n){let s;const i={},a={},o=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Me){try{i[b.KHR_BINARY_GLTF]=new et(e)}catch(u){n&&n(u);return}s=JSON.parse(i[b.KHR_BINARY_GLTF].content)}else s=JSON.parse(o.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ft(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,i[u.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const u=s.extensionsUsed[d],h=s.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:i[u]=new ve;break;case b.KHR_DRACO_MESH_COMPRESSION:i[u]=new tt(s,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:i[u]=new nt;break;case b.KHR_MESH_QUANTIZATION:i[u]=new st;break;default:h.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,s){r.parse(e,t,n,s)})}}function ke(){let f={};return{get:function(e){return f[e]},add:function(e,t){f[e]=t},remove:function(e){delete f[e]},removeAll:function(){f={}}}}const b={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 Fe{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){const s=t[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;const s=t.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const d=new l.Color(16777215);o.color!==void 0&&d.setRGB(o.color[0],o.color[1],o.color[2],l.LinearSRGBColorSpace);const u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new l.DirectionalLight(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new l.PointLight(d),c.distance=u;break;case"spot":c=new l.SpotLight(d),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),v(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=t.createUniqueName(o.name||"light_"+e),n=Promise.resolve(c),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,s=r.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return r._getNodeRef(t.cache,a,o)})}}class ve{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,r){const n=[];e.color=new l.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const i=s.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],l.LinearSRGBColorSpace),e.opacity=i[3]}s.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",s.baseColorTexture,l.SRGBColorSpace))}return Promise.all(n)}}class Ue{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(a,a)}return Promise.all(s)}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class He{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class je{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=n.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,l.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class Ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(r.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),Promise.all(s)}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(r.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&s.push(r.assignTexture(t,"specularColorMap",i.specularColorTexture,l.SRGBColorSpace)),Promise.all(s)}}class qe{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class We{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class Ye{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const s=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}}class Je{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],a=n.images[i.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}}class Qe{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],a=n.images[i.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}}class Ze{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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 s.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,d=n.count,u=n.byteStride,h=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,u,h,n.mode,n.filter).then(function(p){return p.buffer}):i.ready.then(function(){const p=new ArrayBuffer(d*u);return i.decodeGltfBuffer(new Uint8Array(p),d,u,h,n.mode,n.filter),p})})}else return null}}class $e{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=t.meshes[r.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=r.extensions[this.name].attributes,a=[],o={};for(const c in i)a.push(this.parser.getDependency("accessor",i[c]).then(d=>(o[c]=d,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],h=c[0].count,p=[];for(const m of u){const y=new l.Matrix4,g=new l.Vector3,T=new l.Quaternion,S=new l.Vector3(1,1,1),L=new l.InstancedMesh(m.geometry,m.material,h);for(let R=0;R<h;R++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,R),o.SCALE&&S.fromBufferAttribute(o.SCALE,R),L.setMatrixAt(R,y.compose(g,T,S));for(const R in o)if(R==="_COLOR_0"){const C=o[R];L.instanceColor=new l.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&m.geometry.setAttribute(R,o[R]);l.Object3D.prototype.copy.call(L,m),this.parser.assignFinalMaterial(L),p.push(L)}return d.isGroup?(d.clear(),d.add(...p),d):p[0]}))}}const Me="glTF",$=12,pe={JSON:1313821514,BIN:5130562};class et{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,$),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Me)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-$,s=new DataView(e,$);let i=0;for(;i<n;){const a=s.getUint32(i,!0);i+=4;const o=s.getUint32(i,!0);if(i+=4,o===pe.JSON){const c=new Uint8Array(e,$+i,a);this.content=r.decode(c)}else if(o===pe.BIN){const c=$+i;this.body=e.slice(c,c+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},o={},c={};for(const d in i){const u=ae[d]||d.toLowerCase();a[u]=i[d]}for(const d in e.attributes){const u=ae[d]||d.toLowerCase();if(i[d]!==void 0){const h=r.accessors[e.attributes[d]],p=J[h.componentType];c[u]=p.name,o[u]=h.normalized===!0}}return t.getDependency("bufferView",s).then(function(d){return new Promise(function(u,h){n.decodeDracoFile(d,function(p){for(const m in p.attributes){const y=p.attributes[m],g=o[m];g!==void 0&&(y.normalized=g)}u(p)},a,c,l.LinearSRGBColorSpace,h)})})}}class nt{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class st{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class Ae extends l.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let i=0;i!==n;i++)t[i]=r[s+i];return t}interpolate_(e,t,r,n){const s=this.resultBuffer,i=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,d=n-t,u=(r-t)/d,h=u*u,p=h*u,m=e*c,y=m-c,g=-2*p+3*h,T=p-h,S=1-g,L=T-h+u;for(let R=0;R!==a;R++){const C=i[y+R+a],D=i[y+R+o]*d,I=i[m+R+a],U=i[m+R]*d;s[R]=S*C+L*D+g*I+T*U}return s}}const rt=new l.Quaternion;class it extends Ae{interpolate_(e,t,r,n){const s=super.interpolate_(e,t,r,n);return rt.fromArray(s).normalize().toArray(s),s}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},J={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},me={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},ge={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},re={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ae={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"},j={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ot={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},ie={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function at(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),f.DefaultMaterial}function V(f,e,t){for(const r in t.extensions)f[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function v(f,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(f.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ct(f,e,t){let r=!1,n=!1,s=!1;for(let c=0,d=e.length;c<d;c++){const u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(s=!0),r&&n&&s)break}if(!r&&!n&&!s)return Promise.resolve(f);const i=[],a=[],o=[];for(let c=0,d=e.length;c<d;c++){const u=e[c];if(r){const h=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):f.attributes.position;i.push(h)}if(n){const h=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):f.attributes.normal;a.push(h)}if(s){const h=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o)]).then(function(c){const d=c[0],u=c[1],h=c[2];return r&&(f.morphAttributes.position=d),n&&(f.morphAttributes.normal=u),s&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function lt(f,e){if(f.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)f.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(f.morphTargetInfluences.length===t.length){f.morphTargetDictionary={};for(let r=0,n=t.length;r<n;r++)f.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ut(f){let e;const t=f.extensions&&f.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+oe(t.attributes):e=f.indices+":"+oe(f.attributes)+":"+f.mode,f.targets!==void 0)for(let r=0,n=f.targets.length;r<n;r++)e+=":"+oe(f.targets[r]);return e}function oe(f){let e="";const t=Object.keys(f).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+f[t[r]]+";";return e}function ce(f){switch(f){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.")}}function dt(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ht=new l.Matrix4;class ft{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ke,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,s=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=r&&o?parseInt(o[1],10):-1,s=a.indexOf("Firefox")>-1,i=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||s&&i<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(i){const a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:r,userData:{}};return V(s,a,n),v(a,n),Promise.all(r._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n].joints;for(let a=0,o=i.length;a<o;a++)e[i[a]].isBone=!0}for(let n=0,s=e.length;n<s;n++){const i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(r[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const n=r.clone(),s=(i,a)=>{const o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(const[c,d]of i.children.entries())s(d,a.children[c])};return s(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const s=e(t[n]);s&&r.push(s)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.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);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,i){return r.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(s,i){r.load(l.LoaderUtils.resolveURL(t.uri,n.path),s,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){const n=t.byteLength||0,s=t.byteOffset||0;return r.slice(s,s+n)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const i=re[n.type],a=J[n.componentType],o=n.normalized===!0,c=new a(n.count*i);return Promise.resolve(new l.BufferAttribute(c,i,o))}const s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(i){const a=i[0],o=re[n.type],c=J[n.componentType],d=c.BYTES_PER_ELEMENT,u=d*o,h=n.byteOffset||0,p=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let y,g;if(p&&p!==u){const T=Math.floor(h/p),S="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let L=t.cache.get(S);L||(y=new c(a,T*p,n.count*p/d),L=new l.InterleavedBuffer(y,p/d),t.cache.add(S,L)),g=new l.InterleavedBufferAttribute(L,o,h%p/d,m)}else a===null?y=new c(n.count*o):y=new c(a,h,n.count*o),g=new l.BufferAttribute(y,o,m);if(n.sparse!==void 0){const T=re.SCALAR,S=J[n.sparse.indices.componentType],L=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,C=new S(i[1],L,n.sparse.count*T),D=new c(i[2],R,n.sparse.count*o);a!==null&&(g=new l.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let I=0,U=C.length;I<U;I++){const k=C[I];if(g.setX(k,D[I*o]),o>=2&&g.setY(k,D[I*o+1]),o>=3&&g.setZ(k,D[I*o+2]),o>=4&&g.setW(k,D[I*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,r=this.options,s=t.textures[e].source,i=t.images[s];let a=this.textureLoader;if(i.uri){const o=r.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,r){const n=this,s=this.json,i=s.textures[e],a=s.images[t],o=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(t,r).then(function(d){d.flipY=!1,d.name=i.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const h=(s.samplers||{})[i.sampler]||{};return d.magFilter=me[h.magFilter]||l.LinearFilter,d.minFilter=me[h.minFilter]||l.LinearMipmapLinearFilter,d.wrapS=ge[h.wrapS]||l.RepeatWrapping,d.wrapT=ge[h.wrapT]||l.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==l.NearestFilter&&d.minFilter!==l.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){const r=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const i=n.images[e],a=self.URL||self.webkitURL;let o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=r.getDependency("bufferView",i.bufferView).then(function(u){c=!0;const h=new Blob([u],{type:i.mimeType});return o=a.createObjectURL(h),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then(function(u){return new Promise(function(h,p){let m=h;t.isImageBitmapLoader===!0&&(m=function(y){const g=new l.Texture(y);g.needsUpdate=!0,h(g)}),t.load(l.LoaderUtils.resolveURL(u,s.path),m,void 0,p)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),v(u,i),u.userData.mimeType=i.mimeType||dt(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=d,d}assignTexture(e,t,r,n){const s=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(i=i.clone(),i.channel=r.texCoord),s.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=s.associations.get(i);i=s.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new l.PointsMaterial,l.Material.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,o.sizeAttenuation=!1,this.cache.add(a,o)),r=o}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new l.LineBasicMaterial,l.Material.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,this.cache.add(a,o)),r=o}if(n||s||i){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=r.clone(),s&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(r))),r=o}e.material=r}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,n=this.extensions,s=r.materials[e];let i;const a={},o=s.extensions||{},c=[];if(o[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new l.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const h=u.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],l.LinearSRGBColorSpace),a.opacity=h[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,l.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=l.DoubleSide);const d=s.alphaMode||ie.OPAQUE;if(d===ie.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===ie.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new l.Vector2(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial){const u=s.emissiveFactor;a.emissive=new l.Color().setRGB(u[0],u[1],u[2],l.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,l.SRGBColorSpace)),Promise.all(c).then(function(){const u=new i(a);return s.name&&(u.name=s.name),v(u,s),t.associations.set(u,{materials:e}),s.extensions&&V(n,u,s),u})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,n=this.primitiveCache;function s(a){return r[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return Te(o,a,t)})}const i=[];for(let a=0,o=e.length;a<o;a++){const c=e[a],d=ut(c),u=n[d];if(u)i.push(u.promise);else{let h;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?h=s(c):h=Te(new l.BufferGeometry,c,t),n[d]={primitive:c,promise:h},i.push(h)}}return Promise.all(i)}loadMesh(e){const t=this,r=this.json,n=this.extensions,s=r.meshes[e],i=s.primitives,a=[];for(let o=0,c=i.length;o<c;o++){const d=i[o].material===void 0?at(this.cache):this.getDependency("material",i[o].material);a.push(d)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),d=o[o.length-1],u=[];for(let p=0,m=d.length;p<m;p++){const y=d[p],g=i[p];let T;const S=c[p];if(g.mode===N.TRIANGLES||g.mode===N.TRIANGLE_STRIP||g.mode===N.TRIANGLE_FAN||g.mode===void 0)T=s.isSkinnedMesh===!0?new l.SkinnedMesh(y,S):new l.Mesh(y,S),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),g.mode===N.TRIANGLE_STRIP?T.geometry=fe(T.geometry,l.TriangleStripDrawMode):g.mode===N.TRIANGLE_FAN&&(T.geometry=fe(T.geometry,l.TriangleFanDrawMode));else if(g.mode===N.LINES)T=new l.LineSegments(y,S);else if(g.mode===N.LINE_STRIP)T=new l.Line(y,S);else if(g.mode===N.LINE_LOOP)T=new l.LineLoop(y,S);else if(g.mode===N.POINTS)T=new l.Points(y,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(T.geometry.morphAttributes).length>0&&lt(T,s),T.name=t.createUniqueName(s.name||"mesh_"+e),v(T,s),g.extensions&&V(n,T,g),t.assignFinalMaterial(T),u.push(T)}for(let p=0,m=u.length;p<m;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return s.extensions&&V(n,u[0],s),u[0];const h=new l.Group;s.extensions&&V(n,h,s),t.associations.set(h,{meshes:e});for(let p=0,m=u.length;p<m;p++)h.add(u[p]);return h})}loadCamera(e){let t;const r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new l.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),v(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let n=0,s=t.joints.length;n<s;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const s=n.pop(),i=n,a=[],o=[];for(let c=0,d=i.length;c<d;c++){const u=i[c];if(u){a.push(u);const h=new l.Matrix4;s!==null&&h.fromArray(s.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new l.Skeleton(a,o)})}loadAnimation(e){const t=this.json,r=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,i=[],a=[],o=[],c=[],d=[];for(let u=0,h=n.channels.length;u<h;u++){const p=n.channels[u],m=n.samplers[p.sampler],y=p.target,g=y.node,T=n.parameters!==void 0?n.parameters[m.input]:m.input,S=n.parameters!==void 0?n.parameters[m.output]:m.output;y.node!==void 0&&(i.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",S)),c.push(m),d.push(y))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(d)]).then(function(u){const h=u[0],p=u[1],m=u[2],y=u[3],g=u[4],T=[];for(let S=0,L=h.length;S<L;S++){const R=h[S],C=p[S],D=m[S],I=y[S],U=g[S];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const k=r._createAnimationTracks(R,C,D,I,U);if(k)for(let Q=0;Q<k.length;Q++)T.push(k[Q])}return new l.AnimationClip(s,void 0,T)})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(s){const i=r._getNodeRef(r.meshCache,n.mesh,s);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(e){const t=this.json,r=this,n=t.nodes[e],s=r._loadNodeShallow(e),i=[],a=n.children||[];for(let c=0,d=a.length;c<d;c++)i.push(r.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([s,Promise.all(i),o]).then(function(c){const d=c[0],u=c[1],h=c[2];h!==null&&d.traverse(function(p){p.isSkinnedMesh&&p.bind(h,ht)});for(let p=0,m=u.length;p<m;p++)d.add(u[p]);return d})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],i=s.name?n.createUniqueName(s.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return o&&a.push(o),s.camera!==void 0&&a.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let d;if(s.isBone===!0?d=new l.Bone:c.length>1?d=new l.Group:c.length===1?d=c[0]:d=new l.Object3D,d!==c[0])for(let u=0,h=c.length;u<h;u++)d.add(c[u]);if(s.name&&(d.userData.name=s.name,d.name=i),v(d,s),s.extensions&&V(r,d,s),s.matrix!==void 0){const u=new l.Matrix4;u.fromArray(s.matrix),d.applyMatrix4(u)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){const u=n.associations.get(d);n.associations.set(d,{...u})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,s=new l.Group;r.name&&(s.name=n.createUniqueName(r.name)),v(s,r),r.extensions&&V(t,s,r);const i=r.nodes||[],a=[];for(let o=0,c=i.length;o<c;o++)a.push(n.getDependency("node",i[o]));return Promise.all(a).then(function(o){for(let d=0,u=o.length;d<u;d++)s.add(o[d]);const c=d=>{const u=new Map;for(const[h,p]of n.associations)(h instanceof l.Material||h instanceof l.Texture)&&u.set(h,p);return d.traverse(h=>{const p=n.associations.get(h);p!=null&&u.set(h,p)}),u};return n.associations=c(s),s})}_createAnimationTracks(e,t,r,n,s){const i=[],a=e.name?e.name:e.uuid,o=[];j[s.path]===j.weights?e.traverse(function(h){h.morphTargetInfluences&&o.push(h.name?h.name:h.uuid)}):o.push(a);let c;switch(j[s.path]){case j.weights:c=l.NumberKeyframeTrack;break;case j.rotation:c=l.QuaternionKeyframeTrack;break;case j.translation:case j.scale:c=l.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:c=l.NumberKeyframeTrack;break;case 2:case 3:default:c=l.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?ot[n.interpolation]:l.InterpolateLinear,u=this._getArrayFromAccessor(r);for(let h=0,p=o.length;h<p;h++){const m=new c(o[h]+"."+j[s.path],t.array,u,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),i.push(m)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=ce(t.constructor),n=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const n=this instanceof l.QuaternionKeyframeTrack?it:Ae;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pt(f,e,t){const r=e.attributes,n=new l.Box3;if(r.POSITION!==void 0){const a=t.json.accessors[r.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new l.Vector3(o[0],o[1],o[2]),new l.Vector3(c[0],c[1],c[2])),a.normalized){const d=ce(J[a.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new l.Vector3,o=new l.Vector3;for(let c=0,d=s.length;c<d;c++){const u=s[c];if(u.POSITION!==void 0){const h=t.json.accessors[u.POSITION],p=h.min,m=h.max;if(p!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),h.normalized){const y=ce(J[h.componentType]);o.multiplyScalar(y)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}f.boundingBox=n;const i=new l.Sphere;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=i}function Te(f,e,t){const r=e.attributes,n=[];function s(i,a){return t.getDependency("accessor",i).then(function(o){f.setAttribute(a,o)})}for(const i in r){const a=ae[i]||i.toLowerCase();a in f.attributes||n.push(s(r[i],a))}if(e.indices!==void 0&&!f.index){const i=t.getDependency("accessor",e.indices).then(function(a){f.setIndex(a)});n.push(i)}return l.ColorManagement.workingColorSpace!==l.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${l.ColorManagement.workingColorSpace}" not supported.`),v(f,e),pt(f,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ct(f,e.targets,t):f})}const M={c:null,u:[new l.Vector3,new l.Vector3,new l.Vector3],e:[]},A={c:null,u:[new l.Vector3,new l.Vector3,new l.Vector3],e:[]},E=[[],[],[]],x=[[],[],[]],w=[],K=new l.Vector3,X=new l.Vector3,q=new l.Vector3,_=new l.Vector3,ye=new l.Vector3,xe=new l.Vector3,P=new l.Matrix3,Re=new l.Box3,ee=new l.Matrix4,be=new l.Matrix4,Se=new l.Ray;class le{constructor(e=new l.Vector3,t=new l.Vector3,r=new l.Matrix3){this.center=e,this.halfSize=t,this.rotation=r}set(e,t,r){return this.center=e,this.halfSize=t,this.rotation=r,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,t){const r=this.halfSize;_.subVectors(e,this.center),this.rotation.extractBasis(K,X,q),t.copy(this.center);const n=l.MathUtils.clamp(_.dot(K),-r.x,r.x);t.add(K.multiplyScalar(n));const s=l.MathUtils.clamp(_.dot(X),-r.y,r.y);t.add(X.multiplyScalar(s));const i=l.MathUtils.clamp(_.dot(q),-r.z,r.z);return t.add(q.multiplyScalar(i)),t}containsPoint(e){return _.subVectors(e,this.center),this.rotation.extractBasis(K,X,q),Math.abs(_.dot(K))<=this.halfSize.x&&Math.abs(_.dot(X))<=this.halfSize.y&&Math.abs(_.dot(q))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(mt.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,xe),xe.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=Number.EPSILON){M.c=this.center,M.e[0]=this.halfSize.x,M.e[1]=this.halfSize.y,M.e[2]=this.halfSize.z,this.rotation.extractBasis(M.u[0],M.u[1],M.u[2]),A.c=e.center,A.e[0]=e.halfSize.x,A.e[1]=e.halfSize.y,A.e[2]=e.halfSize.z,e.rotation.extractBasis(A.u[0],A.u[1],A.u[2]);for(let s=0;s<3;s++)for(let i=0;i<3;i++)E[s][i]=M.u[s].dot(A.u[i]);_.subVectors(A.c,M.c),w[0]=_.dot(M.u[0]),w[1]=_.dot(M.u[1]),w[2]=_.dot(M.u[2]);for(let s=0;s<3;s++)for(let i=0;i<3;i++)x[s][i]=Math.abs(E[s][i])+t;let r,n;for(let s=0;s<3;s++)if(r=M.e[s],n=A.e[0]*x[s][0]+A.e[1]*x[s][1]+A.e[2]*x[s][2],Math.abs(w[s])>r+n)return!1;for(let s=0;s<3;s++)if(r=M.e[0]*x[0][s]+M.e[1]*x[1][s]+M.e[2]*x[2][s],n=A.e[s],Math.abs(w[0]*E[0][s]+w[1]*E[1][s]+w[2]*E[2][s])>r+n)return!1;return r=M.e[1]*x[2][0]+M.e[2]*x[1][0],n=A.e[1]*x[0][2]+A.e[2]*x[0][1],!(Math.abs(w[2]*E[1][0]-w[1]*E[2][0])>r+n||(r=M.e[1]*x[2][1]+M.e[2]*x[1][1],n=A.e[0]*x[0][2]+A.e[2]*x[0][0],Math.abs(w[2]*E[1][1]-w[1]*E[2][1])>r+n)||(r=M.e[1]*x[2][2]+M.e[2]*x[1][2],n=A.e[0]*x[0][1]+A.e[1]*x[0][0],Math.abs(w[2]*E[1][2]-w[1]*E[2][2])>r+n)||(r=M.e[0]*x[2][0]+M.e[2]*x[0][0],n=A.e[1]*x[1][2]+A.e[2]*x[1][1],Math.abs(w[0]*E[2][0]-w[2]*E[0][0])>r+n)||(r=M.e[0]*x[2][1]+M.e[2]*x[0][1],n=A.e[0]*x[1][2]+A.e[2]*x[1][0],Math.abs(w[0]*E[2][1]-w[2]*E[0][1])>r+n)||(r=M.e[0]*x[2][2]+M.e[2]*x[0][2],n=A.e[0]*x[1][1]+A.e[1]*x[1][0],Math.abs(w[0]*E[2][2]-w[2]*E[0][2])>r+n)||(r=M.e[0]*x[1][0]+M.e[1]*x[0][0],n=A.e[1]*x[2][2]+A.e[2]*x[2][1],Math.abs(w[1]*E[0][0]-w[0]*E[1][0])>r+n)||(r=M.e[0]*x[1][1]+M.e[1]*x[0][1],n=A.e[0]*x[2][2]+A.e[2]*x[2][0],Math.abs(w[1]*E[0][1]-w[0]*E[1][1])>r+n)||(r=M.e[0]*x[1][2]+M.e[1]*x[0][2],n=A.e[0]*x[2][1]+A.e[1]*x[2][0],Math.abs(w[1]*E[0][2]-w[0]*E[1][2])>r+n))}intersectsPlane(e){this.rotation.extractBasis(K,X,q);const t=this.halfSize.x*Math.abs(e.normal.dot(K))+this.halfSize.y*Math.abs(e.normal.dot(X))+this.halfSize.z*Math.abs(e.normal.dot(q)),r=e.normal.dot(this.center)-e.constant;return Math.abs(r)<=t}intersectRay(e,t){return this.getSize(ye),Re.setFromCenterAndSize(_.set(0,0,0),ye),ee.setFromMatrix3(this.rotation),ee.setPosition(this.center),be.copy(ee).invert(),Se.copy(e).applyMatrix4(be),Se.intersectBox(Re,t)?t.applyMatrix4(ee):null}intersectsRay(e){return this.intersectRay(e,_)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){const t=e.elements;let r=_.set(t[0],t[1],t[2]).length();const n=_.set(t[4],t[5],t[6]).length(),s=_.set(t[8],t[9],t[10]).length();e.determinant()<0&&(r=-r),P.setFromMatrix4(e);const a=1/r,o=1/n,c=1/s;return P.elements[0]*=a,P.elements[1]*=a,P.elements[2]*=a,P.elements[3]*=o,P.elements[4]*=o,P.elements[5]*=o,P.elements[6]*=c,P.elements[7]*=c,P.elements[8]*=c,this.rotation.multiply(P),this.halfSize.x*=r,this.halfSize.y*=n,this.halfSize.z*=s,_.setFromMatrixPosition(e),this.center.add(_),this}}const mt=new le,gt={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:l.MathUtils.degToRad(60)};function Tt(f,e){const t=Object.assign({css3d:!1,stats:!1,renderType:"change",control:{init:!0,options:{}}},e||{});let r,n,s,i=[];const a=H.ref(!1),o=H.shallowRef(),c=H.ref(0),d=H.ref(0),u=new l.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),h=new l.Scene({}),p=new l.PerspectiveCamera(50,1,.1,2e3),m=Math.tan(Math.PI/180*p.fov/2);let y=!1;u.setPixelRatio(window.devicePixelRatio);function g(){a.value=!1;const O=U();c.value=O[0],d.value=O[1],p.aspect=c.value/d.value,p.position.set(47,39,100),p.fov=360/Math.PI*Math.atan(m*(d.value/c.value)),p.lookAt(0,0,0),p.updateProjectionMatrix(),u.setSize(c.value,d.value),r.appendChild(u.domElement),t.stats&&k(),t.css3d&&Le();let B;if(t.control&&t.control.init){B=Y.createOrbitControl(p,u.domElement);const G=Object.assign(gt,t.control.options||{});Object.keys(G).forEach(Z=>{B[Z]=G[Z]})}return H.nextTick(()=>a.value=!0),B}function T(O){O.preventDefault(),cancelAnimationFrame(R)}function S(O){O.preventDefault(),g(),R()}function L(O){i.push(O)}function R(O){i&&i.length&&i.forEach(B=>{typeof B=="function"&&B()}),t.renderType==="loop"&&C(),requestAnimationFrame(R)}function C(){y=!1,n&&n.update(),o.value&&o.value.update(),u.render(h,p),s&&s.render(h,p)}function D(){y||(y=!0,requestAnimationFrame(C))}function I(){H.nextTick(()=>{const O=U();c.value=O[0],d.value=O[1],p.aspect=c.value/d.value,p.fov=360/Math.PI*Math.atan(m*(d.value/c.value)),p.updateProjectionMatrix(),p.lookAt(h.position),u.setSize(c.value,d.value),s&&s.setSize(c.value,d.value),C()})}function U(){return r=document.querySelector(f),r?[r.clientWidth,r.clientHeight]:[0,0]}function k(){n=new Y.Stats,n.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.appendChild(n.dom)}function Q(O,B,G,Z,ue){const de=new l.Box3().setFromObject(O),he=de.getSize(new l.Vector3).length(),z=de.getCenter(new l.Vector3);ue&&z.add(ue);const _e=he*B*.5,Ce=l.MathUtils.degToRad(G.fov*.5),Ie=_e/Math.tan(Ce),ne=new l.Vector3().subVectors(G.position,z).multiply(new l.Vector3(1,1,1)).normalize().multiplyScalar(Ie).add(z),W={x:ne.x,y:ne.y,z:ne.z,lookAt_x:z.x,lookAt_y:z.y,lookAt_z:z.z};return G.position.set(W.x,W.y,W.z),G.lookAt(W.lookAt_x,W.lookAt_y,W.lookAt_z),G.updateProjectionMatrix(),Z.target.copy(z),Z.update(),he}function Le(){s=new Y.CSS3DRenderer,s.setSize(c.value,d.value),s.domElement.style.position="absolute",s.domElement.style.top=0,s.domElement.style.left=0,s.domElement.style.pointerEvents="none",r.appendChild(s.domElement)}function Ee(){Y.disposeThreeObject(h)}return H.onMounted(()=>{o.value=g(),window.addEventListener("resize",I,!1),u.domElement.addEventListener("webglcontextlost",T,!1),u.domElement.addEventListener("webglcontextrestored",S,!1),t.renderType==="loop"?requestAnimationFrame(R):t.renderType==="change"&&o.value&&o.value.addEventListener("change",D)}),H.onUnmounted(()=>{cancelAnimationFrame(R),u.domElement.removeEventListener("resize",I,!1),u.domElement.removeEventListener("webglcontextlost",T,!1),u.domElement.removeEventListener("webglcontextrestored",S,!1),Ee()}),{addAnimate:L,frameArea:Q,onRender:C,css3dRenderer:s,scene:h,camera:p,control:o,renderer:u,domWidth:c,domHeight:d,isReady:a}}const yt=(f="app")=>{const e=new l.Raycaster;e.params.Line.threshold=8;const t=new l.Vector2,r=document.getElementById(f);function n(a,o){const{scaleX:c,scaleY:d}=i(r),{clientWidth:u,clientHeight:h}=o,p=o.getBoundingClientRect(),m=u*c,y=h*d,g=a.clientX-p.left,T=a.clientY-p.top;return t.x=(a.clientX-p.left)/m*2-1,t.y=-((a.clientY-p.top)/y)*2+1,{pointer:t,x:g,y:T}}function s(a,o,c,d){const{pointer:u,x:h,y:p}=n(a,o);return e.setFromCamera(u,c),{intersects:e.intersectObjects(d),pointer:u,x:h,y:p}}function i(a){const o=window.getComputedStyle(a),c=o.transform||o.webkitTransform||o.mozTransform;if(c&&c!=="none"){const d=c.match(/^matrix\((.+)\)$/);if(d){const u=d[1].split(", "),h=parseFloat(u[0]),p=parseFloat(u[3]);return{scaleX:h,scaleY:p}}}return{scaleX:1,scaleY:1}}return{raycaster:e,pointer:t,getPointer:n,getScale:i,getIntersects:s}},F=[],xt=new l.Color(16711680),Rt=()=>{const f=()=>{F.splice(0)},e=(a,o)=>{o.traverse(c=>{c&&t(a,c)})},t=(a,o)=>{if(o.userData.needCheck&&(o.autoUpdateMatrix=!1,o.updateMatrix(),o.updateMatrixWorld(),o.isMesh)){const c=new l.Box3(new l.Vector3).setFromObject(o);o.geometry.userData.obb=new le,o.geometry.userData.obb.halfSize.copy(c.getSize(new l.Vector3)).multiplyScalar(.5).multiplyScalar(.88),o.userData.obb=new le,o.userData.originColor=o.material.color.clone(),o.userData.parentUid=a,F.push({object:o,parentUid:a})}};return{resetObbs:f,initObb:e,getObbObjectByParentUid:a=>F.filter(o=>o.parentUid===a),addObbFromArray:(a,o)=>{for(let c=0,d=o.length;c<d;c++)t(a,o[c])},removeObbFromArray:a=>{const o=F.filter(c=>!a.includes(c.object));F.splice(0,F.length,...o)},removeUidObb:a=>{for(let o=F.length-1;o>=0;o--)F[o].parentUid===a&&F.splice(o,1)}}};class we{constructor(e="threeJsIDBCache",t=3){this.version=t,this.dbName=e,this.dbInit()}dbInit(){this.db=new Oe(this.dbName),this.materialMap={},this.db.version(this.version).stores({models:"&path, version, data"})}getDatabase(){return this.db}async cacheModel(e,t,r){try{this.db.table("models").put({version:r,path:e,data:t}).then(()=>{console.log(`Model "${e}" cached successfully in table models`)})}catch{console.log(" 缓存模型失败 =====> ")}return t}async loadCachedModel(e,t){let r=null;try{if(r=await this.db.table("models").get(e),!r)return console.warn(`Model "${t}" not found in table models`),null;if(r.version!==t)return console.log(" =====> 模型版本不一致, 清除当前记录"),await this.db.table("models").delete(e),null}catch{return console.log(" =====> 查询表中模型失败"),this.db.delete().then(()=>{this.init()}),null}return r.data}}let te;const bt=()=>{const f=new De,e=new Ne;e.setDecoderPath("/draco/"),f.setDRACOLoader(e);function t(s,i,a,o){return f.load(s,i,a,o)}function r(s,i){return new Promise((a,o)=>{f.load(s,a,i,o)})}async function n(s,i,a=!0,o){te||(te=new we);const c=await te.loadCachedModel(s,i);return c?a?Y.dataToObject3D(c):c:new Promise((d,u)=>{f.load(s,d,o,u)}).then(async d=>{const u=Y.object3DToData(d);return te.cacheModel(s,d.scene,i),a?d.scene:u})}return{load:t,asyncLoad:r,asyncCacheLoad:n}};exports.IDBCache=we;exports.intersectColor=xt;exports.obbObjects=F;exports.useGLTFLoader=bt;exports.useObb=Rt;exports.useRaycaster=yt;exports.useThreeJs=Tt;