a3js 0.0.13 → 0.0.14
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/a3js.cjs.js +5 -5
- package/dist/a3js.es.js +530 -429
- package/package.json +1 -1
package/dist/a3js.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var nt=Object.create;var ve=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var ct=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rt(e))!at.call(o,s)&&s!==t&&ve(o,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return o};var lt=(o,e,t)=>(t=o!=null?nt(ot(o)):{},ct(e||!o||!o.__esModule?ve(t,"default",{value:o,enumerable:!0}):t,o));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three");function ht(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const b=ht(f);class ut{obj;constructor(e){this.obj=e,console.log(`A3PhysicsEntityDummy is created!(maybe wrong) This may be related to Class ${typeof this.obj}`)}synchronize(e){}setLoc(e){}setQuat(e){}setScale(e){}}class O{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._z}constructor(e,t,n){typeof e=="number"?(this._x=e,this._y=t,this._z=n):typeof e>"u"?this._x=this._y=this._z=0:(this._x=e.x,this._y=e.y,this._z=e.z)}set(e,t,n){return typeof e=="number"?(this._x=e,this._y=t,this._z=n):(this._x=e.x,this._y=e.y,this._z=e.z),this}add(e){return this._x+=e.x,this._y+=e.y,this._z+=e.z,this}lerp(e,t,n){this._x=(1-n)*e.x+n*t.x,this._y=(1-n)*e.y+n*t.y,this._z=(1-n)*e.z+n*t.z}}class J{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._w}constructor(e,t,n,s){typeof e=="number"?(this._x=e,this._y=t,this._z=n,this._w=s):typeof e>"u"?(this._x=this._y=this._z=0,this._w=1):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w)}set(e,t,n,s){return typeof e=="number"?(this._x=e,this._y=t,this._z=n,this._w=s):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w),this}lerp(e,t,n){this._x=(1-n)*e.x+n*t.x,this._y=(1-n)*e.y+n*t.y,this._z=(1-n)*e.z+n*t.z,this._w=(1-n)*e.z+n*t.w}slerp(e,t,n){if(n<0||n>1){console.log("Quat.slerp(): t must be in [0,1]");return}const s=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(s<.9995){const i=Math.acos(s),r=Math.sin((1-n)*i)/Math.sin(i),a=Math.sin(n*i)/Math.sin(i);this._x=r*e.x+a*t.x,this._y=r*e.y+a*t.y,this._z=r*e.z+a*t.z,this._w=r*e.w+a*t.w}else{this._x=(1-n)*e.x+n*t.x,this._y=(1-n)*e.y+n*t.y,this._z=(1-n)*e.z+n*t.z,this._w=(1-n)*e.w+n*t.w;const i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w);i<1e-4?(console.log("Quat.slerp(); ???!"),this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w):(this._x*=1/i,this._y*=1/i,this._z*=1/i,this._w*=1/i)}}}class ft{message;dir;offsetTop;offsetRight;offsetLeft;offsetBottom;constructor(e){this.message=e,this.dir="RIGHT",this.offsetTop={x:0,y:2},this.offsetRight={x:1,y:1},this.offsetLeft={x:-1,y:1},this.offsetBottom={x:0,y:0}}}class dt{firstLoc;firstRot;firstScale;nowLoc;nowRot;nowScale;lastLoc;lastRot;lastScale;nowTime;duration;constructor(e){this.firstLoc=new O(e.location),this.firstRot=new J(e.rot),this.firstScale=new O(e.scale),this.nowLoc=new O(e.location),this.nowRot=new J(e.rot),this.nowScale=new O(e.scale),this.lastLoc=new O(e.location),this.lastRot=new J(e.rot),this.lastScale=new O(e.scale),this.nowTime=0,this.duration=1}setLoc(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastLoc.set(t),this.nowTime=0}setQuat(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastRot.set(t),this.nowTime=0}setScale(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastScale.set(t),this.nowTime=0}smoothstep(e){return e*e*(3-2*e)}interpolate(e,t){this.nowTime+=t,this.nowTime>this.duration&&(this.nowTime=this.duration);const n=this.nowTime/this.duration,s=this.smoothstep(n);this.nowLoc.lerp(this.firstLoc,this.lastLoc,s),this.nowRot.slerp(this.firstRot,this.lastRot,s),this.nowScale.lerp(this.firstScale,this.lastScale,s),e.location.set(this.nowLoc),e.object.position.set(this.nowLoc.x,this.nowLoc.y,this.nowLoc.z),e.rot.set(this.nowRot),e.object.quaternion.set(this.nowRot.x,this.nowRot.y,this.nowRot.z,this.nowRot.w),e.scale.set(this.nowScale),e.object.scale.set(this.nowScale.x,this.nowScale.y,this.nowScale.z)}}class q{_loc=new O(0,0,0);_rot=new J(0,0,0,1);_scale=new O(1,1,1);object;motionControlMode="manual";scene=null;physics=null;balloon=null;interpolation=null;constructor(e){this.object=this.initObject(e)}setMotionControlMode(e){this.motionControlMode=e,e==="interpolated"&&!this.interpolation&&(this.interpolation=new dt(this))}update(e){switch(this.motionControlMode){case"interpolated":this.interpolation&&this.interpolation.interpolate(this,e);break;case"physics":this.physics&&this.physics.synchronize(this);break;case"user":console.log('"user"モードを使う場合は自分でupdateメソッドをオーバーライドして実装して下さい。');break}}initPhysics(e,t){e&&console.log(`physics: ${typeof e}`),t&&console.log(`world: ${typeof t}`),this.physics=new ut(this)}setBalloon(e){this.balloon?this.balloon.message=e:this.balloon=new ft(e)}setLocation(e,t,n){const s=new O;switch(typeof e=="number"?s.set(e,t,n):s.set(e),this.motionControlMode){case"interpolated":this.interpolation&&this.interpolation.setLoc(this,s);break;case"physics":this.physics&&this.physics.setLoc(s);break;default:this.location.set(s),this.object.position.set(s.x,s.y,s.z);break}}get location(){return this._loc}setQuat(e,t,n,s){const i=new J;switch(typeof e=="number"?i.set(e,t,n,s):i.set(e),this.motionControlMode){case"interpolated":this.interpolation&&this.interpolation.setQuat(this,i);break;case"physics":this.physics&&this.physics.setQuat(i);break;default:this.rot.set(i),this.object.quaternion.set(i.x,i.y,i.z,i.w);break}}get rot(){return this._rot}setScale(e,t,n){const s=new O;switch(typeof e=="number"?s.set(e,t,n):s.set(e),this.motionControlMode){case"interpolated":this.interpolation&&this.interpolation.setScale(this,s);break;case"physics":this.physics&&this.physics.setScale(s);break}}get scale(){return this._scale}}class V{static RAPIER;isInitialized=!1;constructor(){}async createWorld(e){if(!V.RAPIER){const s=await import("@dimforge/rapier3d-compat");await s.init(),V.RAPIER=s,this.isInitialized=!0}let t=1/60;this.isRapierOption(e)&&(t=e.timestep);const n=new V.RAPIER.World(e.gravity);return new pt(n,t)}isRapierOption(e){return"enableCCD"in e&&"timestep"in e}}class pt{world;timestep;constructor(e,t){this.world=e,this.timestep=t,this.world.integrationParameters.dt=this.timestep}add(e){Ie(e)&&e.addOneself(this)}remove(e){Ie(e)&&e.removeOneself(this)}update(e){const t=Math.ceil(e/this.timestep);for(let n=0;n<t;n++)this.world.step()}}function Ie(o){return"addOneself"in o&&"removeOneself"in o}class K{scene;objects;static physics;physicsWorld=null;physicsDt=1/60;constructor(){this.scene=new b.Scene,this.objects=[],K.physics||(K.physics=new V)}add(e){this.scene.add(e.object),this.objects.push(e),e.scene=this,e.motionControlMode==="physics"&&(this.physicsWorld||queueMicrotask(async()=>{this.physicsWorld||(this.physicsWorld=await K.physics.createWorld({gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt})),e.physics||e.initPhysics(K.physics,this.physicsWorld),e.physics&&this.physicsWorld.add(e.physics)}))}remove(e){this.scene.remove(e.object);{const t=this.objects.indexOf(e);this.objects[t]=this.objects[this.objects.length-1],this.objects.pop()}e.scene=null,e.motionControlMode==="physics"&&this.physicsWorld&&e.physics&&this.physicsWorld.remove(e.physics)}update(e){this.physicsWorld&&this.physicsWorld.update(e);for(const t of this.objects)t.motionControlMode!=="manual"&&t.update(e)}}class Fe extends q{}class ye{scene;camera;constructor(e){this.scene=new K,this.camera=e,this.scene.scene.add(this.camera.object),this.camera.setLocation(0,0,3)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e)}}class we extends Fe{camera;headLight;constructor(e){super(e),this.camera=e,this.headLight=new b.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new b.Object3D}getHeadLight(){return this.headLight}setAspect(e){mt(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}}function mt(o){return o.isPerspectiveCamera===!0}class Ge extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;constructor(e){super(),e||(e={}),e.camera||(e.camera=new b.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e.camera;const t=new we(e.camera);this.base=new ye(t),this.scene=this.base.scene,this.camera=this.base.camera;const n={antialias:e.antialias?e.antialias:!1,alpha:e.transparent?e.transparent:!1};this.renderer=new b.WebGLRenderer(n),"opaque"in e&&this.renderer.setClearAlpha(0),this.clock=new b.Clock,this.style="display: block; background: rgba(0,0,0,0);",this.renderer.domElement.style="display: block; width: 100%; height: 100%; margin: 0; padding: 0;",this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();gt(this.camera3js)&&(this.camera3js.aspect=e/t),this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js)}}customElements.define("a3-canvas",Ge);function gt(o){return o.isPerspectiveCamera===!0}const Tt=`
|
|
1
|
+
"use strict";var nt=Object.create;var ve=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var ct=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rt(e))!at.call(o,s)&&s!==t&&ve(o,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return o};var lt=(o,e,t)=>(t=o!=null?nt(ot(o)):{},ct(e||!o||!o.__esModule?ve(t,"default",{value:o,enumerable:!0}):t,o));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three");function ht(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const b=ht(f);class V{static RAPIER;isInitialized=!1;constructor(){}async createWorld(e){if(!V.RAPIER){const s=await import("@dimforge/rapier3d-compat");await s.init(),V.RAPIER=s,this.isInitialized=!0}let t=1/60;this.isRapierOption(e)&&(t=e.timestep);const n=new V.RAPIER.World(e.gravity);return new ut(n,t)}isRapierOption(e){return"enableCCD"in e&&"timestep"in e}}class ut{world;timestep;constructor(e,t){this.world=e,this.timestep=t,this.world.integrationParameters.dt=this.timestep}add(e){Ie(e)&&e.addOneself(this)}remove(e){Ie(e)&&e.removeOneself(this)}update(e){const t=Math.ceil(e/this.timestep);for(let n=0;n<t;n++)this.world.step()}}function Ie(o){return"addOneself"in o&&"removeOneself"in o}class K{scene;objects;static physics;physicsWorld=null;physicsDt=1/60;constructor(){this.scene=new b.Scene,this.objects=[],K.physics||(K.physics=new V)}add(e){this.scene.add(e.object),this.objects.push(e),e.scene=this,e.controlMode==="physics"&&(this.physicsWorld||queueMicrotask(async()=>{this.physicsWorld||(this.physicsWorld=await K.physics.createWorld({gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt})),e.physics||e.initPhysics(K.physics,this.physicsWorld),e.physics&&this.physicsWorld.add(e.physics)}))}remove(e){this.scene.remove(e.object);{const t=this.objects.indexOf(e);this.objects[t]=this.objects[this.objects.length-1],this.objects.pop()}e.scene=null,e.controlMode==="physics"&&this.physicsWorld&&e.physics&&this.physicsWorld.remove(e.physics)}update(e){this.physicsWorld&&this.physicsWorld.update(e);for(const t of this.objects)t.controlMode!=="manual"&&t.update(e)}}class ft{obj;constructor(e){this.obj=e,console.log(`A3PhysicsEntityDummy is created!(maybe wrong) This may be related to Class ${typeof this.obj}`)}synchronize(e){}forceSetLoc(e){}forceSetQuat(e){}forceSetScale(e){}}class v{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._z}constructor(e,t,n){typeof e=="number"?(this._x=e,this._y=t,this._z=n):typeof e>"u"?this._x=this._y=this._z=0:(this._x=e.x,this._y=e.y,this._z=e.z)}set(e,t,n){return typeof e=="number"?(this._x=e,this._y=t,this._z=n):(this._x=e.x,this._y=e.y,this._z=e.z),this}add(e){return this._x+=e.x,this._y+=e.y,this._z+=e.z,this}lerp(e,t,n){this._x=(1-n)*e.x+n*t.x,this._y=(1-n)*e.y+n*t.y,this._z=(1-n)*e.z+n*t.z}}class X{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._w}constructor(e,t,n,s){typeof e=="number"?(this._x=e,this._y=t,this._z=n,this._w=s):typeof e>"u"?(this._x=this._y=this._z=0,this._w=1):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w)}set(e,t,n,s){return typeof e=="number"?(this._x=e,this._y=t,this._z=n,this._w=s):(this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w),this}lerp(e,t,n){this._x=(1-n)*e.x+n*t.x,this._y=(1-n)*e.y+n*t.y,this._z=(1-n)*e.z+n*t.z,this._w=(1-n)*e.z+n*t.w}slerp(e,t,n){if(n<0||n>1){console.log("Quat.slerp(): t must be in [0,1]");return}const s=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(s<.9995){const i=Math.acos(s),r=Math.sin((1-n)*i)/Math.sin(i),a=Math.sin(n*i)/Math.sin(i);this._x=r*e.x+a*t.x,this._y=r*e.y+a*t.y,this._z=r*e.z+a*t.z,this._w=r*e.w+a*t.w}else{this._x=(1-n)*e.x+n*t.x,this._y=(1-n)*e.y+n*t.y,this._z=(1-n)*e.z+n*t.z,this._w=(1-n)*e.w+n*t.w;const i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w);i<1e-4?(console.log("Quat.slerp(); ???!"),this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w):(this._x*=1/i,this._y*=1/i,this._z*=1/i,this._w*=1/i)}}}class ${_loc=new v(0,0,0);_rot=new X(0,0,0,1);_scale=new v(1,1,1);object;controlMode="manual";scene=null;physics=null;balloon=null;interpolation=null;constructor(e){this.object=this.initObject(e)}setControlMode(e){this.controlMode=e,e==="interpolated"&&!this.interpolation&&(this.interpolation=new pt(this))}update(e){switch(this.controlMode){case"manual":break;case"interpolated":this.interpolation&&this.interpolation.interpolate(this,e);break;case"physics":this.physics&&this.physics.synchronize(this);break;case"user":console.log('"user"モードを使う場合は自分でupdateメソッドをオーバーライドして実装して下さい。');break}}initPhysics(e,t){e&&console.log(`physics: ${typeof e}`),t&&console.log(`world: ${typeof t}`),this.physics=new ft(this)}setBalloon(e){this.balloon?this.balloon.message=e:this.balloon=new dt(e)}get location(){return this._loc}setLocation(e,t,n){const s=new v;switch(typeof e=="number"?s.set(e,t,n):s.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setLoc(this,s);break;case"physics":break;default:this.location.set(s),this.object.position.set(s.x,s.y,s.z);break}}forceSetLocation(e,t,n){const s=new v;switch(typeof e=="number"?s.set(e,t,n):s.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.forceSetLoc(this,s);break;case"physics":this.physics&&this.physics.forceSetLoc(s);break;default:this.location.set(s),this.object.position.set(s.x,s.y,s.z);break}}get rot(){return this._rot}setQuat(e,t,n,s){const i=new X;switch(typeof e=="number"?i.set(e,t,n,s):i.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setQuat(this,i);break;case"physics":break;default:this.rot.set(i),this.object.quaternion.set(i.x,i.y,i.z,i.w);break}}forceSetQuat(e,t,n,s){const i=new X;switch(typeof e=="number"?i.set(e,t,n,s):i.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.forceSetQuat(this,i);break;case"physics":this.physics&&this.physics.forceSetQuat(i);break;default:this.rot.set(i),this.object.quaternion.set(i.x,i.y,i.z,i.w);break}}get scale(){return this._scale}setScale(e,t,n){const s=new v;switch(typeof e=="number"?s.set(e,t,n):s.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.setScale(this,s);break;case"physics":break;default:this.scale.set(s),this.object.scale.set(s.x,s.y,s.z);break}}forceSetScale(e,t,n){const s=new v;switch(typeof e=="number"?s.set(e,t,n):s.set(e),this.controlMode){case"interpolated":this.interpolation&&this.interpolation.forceSetScale(this,s);break;case"physics":this.physics&&this.physics.forceSetScale(s);break;default:this.scale.set(s),this.object.scale.set(s.x,s.y,s.z);break}}contains(e){let t=!1;return this.object.traverse(n=>{n==e&&(t=!0)}),t}}class dt{message;dir;offsetTop;offsetRight;offsetLeft;offsetBottom;constructor(e){this.message=e,this.dir="RIGHT",this.offsetTop={x:0,y:2},this.offsetRight={x:1,y:1},this.offsetLeft={x:-1,y:1},this.offsetBottom={x:0,y:0}}}class pt{firstLoc;firstRot;firstScale;nowLoc;nowRot;nowScale;lastLoc;lastRot;lastScale;nowTime;duration;constructor(e){this.firstLoc=new v(e.location),this.firstRot=new X(e.rot),this.firstScale=new v(e.scale),this.nowLoc=new v(e.location),this.nowRot=new X(e.rot),this.nowScale=new v(e.scale),this.lastLoc=new v(e.location),this.lastRot=new X(e.rot),this.lastScale=new v(e.scale),this.nowTime=0,this.duration=1}setLoc(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastLoc.set(t),this.nowTime=0}forceSetLoc(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastLoc.set(t),this.nowTime=1}setQuat(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastRot.set(t),this.nowTime=0}forceSetQuat(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastRot.set(t),this.nowTime=1}setScale(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastScale.set(t),this.nowTime=0}forceSetScale(e,t){this.firstLoc.set(e.location),this.firstRot.set(e.rot),this.firstScale.set(e.scale),this.lastScale.set(t),this.nowTime=1}smoothstep(e){return e*e*(3-2*e)}interpolate(e,t){this.nowTime+=t,this.nowTime>this.duration&&(this.nowTime=this.duration);const n=this.nowTime/this.duration,s=this.smoothstep(n);this.nowLoc.lerp(this.firstLoc,this.lastLoc,s),this.nowRot.slerp(this.firstRot,this.lastRot,s),this.nowScale.lerp(this.firstScale,this.lastScale,s),e.location.set(this.nowLoc),e.object.position.set(this.nowLoc.x,this.nowLoc.y,this.nowLoc.z),e.rot.set(this.nowRot),e.object.quaternion.set(this.nowRot.x,this.nowRot.y,this.nowRot.z,this.nowRot.w),e.scale.set(this.nowScale),e.object.scale.set(this.nowScale.x,this.nowScale.y,this.nowScale.z)}}class Fe extends ${}class we{scene;camera;constructor(e){this.scene=new K,this.camera=e,this.scene.scene.add(this.camera.object),this.camera.setLocation(0,0,3)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e)}}class te extends Fe{camera;headLight;constructor(e){super(e),this.camera=e,this.headLight=new b.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new b.Object3D}getHeadLight(){return this.headLight}setAspect(e){mt(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}}function mt(o){return o.isPerspectiveCamera===!0}class Ge extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;constructor(e){super(),e||(e={}),e.camera||(e.camera=new b.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e.camera;const t=new te(e.camera);this.base=new we(t),this.scene=this.base.scene,this.camera=this.base.camera;const n={antialias:e.antialias?e.antialias:!1,alpha:e.transparent?e.transparent:!1};this.renderer=new b.WebGLRenderer(n),"opaque"in e&&this.renderer.setClearAlpha(0),this.clock=new b.Clock,this.style="display: block; background: rgba(0,0,0,0);",this.renderer.domElement.style="display: block; width: 100%; height: 100%; margin: 0; padding: 0;",this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop),this.addEventListener("click",this.myMouseClickedListener)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();gt(this.camera3js)&&(this.camera3js.aspect=e/t),this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js)};myMouseClickedListener=e=>{if(this.camera instanceof te){const t=new b.Raycaster,n=new b.Vector2,s=e.target.getBoundingClientRect(),i=e.clientX-s.left,r=e.clientY-s.top;n.x=2*(i/s.width)-1,n.y=-2*(r/s.height)+1,t.setFromCamera(n,this.camera.camera);const a=t.intersectObjects(this.scene.scene.children),c=[];a.forEach(l=>{for(const u of this.scene.objects)if(u.contains(l.object)){c.push({o1:l.object,o2:u});break}}),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:c}}))}}}customElements.define("a3-canvas",Ge);function gt(o){return o.isPerspectiveCamera===!0}const yt=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 100px;
|
|
4
4
|
left: 100px;
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
border: 1px solid #555;
|
|
7
7
|
background: white;
|
|
8
8
|
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.3);
|
|
9
|
-
`,
|
|
9
|
+
`,Tt=`
|
|
10
10
|
background: #444;
|
|
11
11
|
color: white;
|
|
12
12
|
padding: 8px;
|
|
13
13
|
cursor: move;
|
|
14
14
|
user-select: none; /* 文字選択を防ぐ */
|
|
15
|
-
`;class Be extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;isDragging=!1;offsetX=0;offsetY=0;constructor(e,t){super(),this.camera3js=new b.PerspectiveCamera(75,e/t,.1,1e3);const n=new
|
|
16
|
-
`)c=0,l-=r;else{const d=Lt(h,i,c,l,t);n=="tb"?(c=0,l+=t.ascender*i):c+=d.offsetX,a.push(d.path)}}return a}function Lt(o,e,t,n,s){const i=s.glyphs[o]||s.glyphs["?"];if(!i){console.error('THREE.Font: character "'+o+'" does not exists in font family '+s.familyName+".");return}const r=new f.ShapePath;let a,c,l,u,h,d,p,T;if(i.o){const g=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let m=0,y=g.length;m<y;)switch(g[m++]){case"m":a=g[m++]*e+t,c=g[m++]*e+n,r.moveTo(a,c);break;case"l":a=g[m++]*e+t,c=g[m++]*e+n,r.lineTo(a,c);break;case"q":l=g[m++]*e+t,u=g[m++]*e+n,h=g[m++]*e+t,d=g[m++]*e+n,r.quadraticCurveTo(h,d,l,u);break;case"b":l=g[m++]*e+t,u=g[m++]*e+n,h=g[m++]*e+t,d=g[m++]*e+n,p=g[m++]*e+t,T=g[m++]*e+n,r.bezierCurveTo(h,d,p,T,l,u);break}}return{offsetX:i.ha*e,path:r}}class bt extends f.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const s=n.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(s,t)}this.type="TextGeometry"}}function He(o){return typeof o=="string"}var v=Uint8Array,Y=Uint16Array,At=Int32Array,Ue=new v([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),je=new v([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Et=new v([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ze=function(o,e){for(var t=new Y(31),n=0;n<31;++n)t[n]=e+=1<<o[n-1];for(var s=new At(t[30]),n=1;n<30;++n)for(var i=t[n];i<t[n+1];++i)s[i]=i-t[n]<<5|n;return{b:t,r:s}},Ke=ze(Ue,2),Ve=Ke.b,St=Ke.r;Ve[28]=258,St[258]=28;var Mt=ze(je,0),Ct=Mt.b,de=new Y(32768);for(var L=0;L<32768;++L){var U=(L&43690)>>1|(L&21845)<<1;U=(U&52428)>>2|(U&13107)<<2,U=(U&61680)>>4|(U&3855)<<4,de[L]=((U&65280)>>8|(U&255)<<8)>>1}var ee=(function(o,e,t){for(var n=o.length,s=0,i=new Y(e);s<n;++s)o[s]&&++i[o[s]-1];var r=new Y(e);for(s=1;s<e;++s)r[s]=r[s-1]+i[s-1]<<1;var a;if(t){a=new Y(1<<e);var c=15-e;for(s=0;s<n;++s)if(o[s])for(var l=s<<4|o[s],u=e-o[s],h=r[o[s]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)a[de[h]>>c]=l}else for(a=new Y(n),s=0;s<n;++s)o[s]&&(a[s]=de[r[o[s]-1]++]>>15-o[s]);return a}),te=new v(288);for(var L=0;L<144;++L)te[L]=8;for(var L=144;L<256;++L)te[L]=9;for(var L=256;L<280;++L)te[L]=7;for(var L=280;L<288;++L)te[L]=8;var Xe=new v(32);for(var L=0;L<32;++L)Xe[L]=5;var vt=ee(te,9,1),It=ee(Xe,5,1),oe=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},P=function(o,e,t){var n=e/8|0;return(o[n]|o[n+1]<<8)>>(e&7)&t},ae=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},kt=function(o){return(o+7)/8|0},xe=function(o,e,t){return(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length),new v(o.subarray(e,t))},Nt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],D=function(o,e,t){var n=new Error(e||Nt[o]);if(n.code=o,Error.captureStackTrace&&Error.captureStackTrace(n,D),!t)throw n;return n},Dt=function(o,e,t,n){var s=o.length,i=n?n.length:0;if(!s||e.f&&!e.l)return t||new v(0);var r=!t,a=r||e.i!=2,c=e.i;r&&(t=new v(s*3));var l=function(Se){var Me=t.length;if(Se>Me){var Ce=new v(Math.max(Me*2,Se));Ce.set(t),t=Ce}},u=e.f||0,h=e.p||0,d=e.b||0,p=e.l,T=e.d,g=e.m,m=e.n,y=s*8;do{if(!p){u=P(o,h,1);var _=P(o,h+1,3);if(h+=3,_)if(_==1)p=vt,T=It,g=9,m=5;else if(_==2){var E=P(o,h,31)+257,S=P(o,h+10,15)+4,I=E+P(o,h+5,31)+1;h+=14;for(var C=new v(I),k=new v(19),M=0;M<S;++M)k[Et[M]]=P(o,h+M*3,7);h+=S*3;for(var Re=oe(k),Qe=(1<<Re)-1,Ze=ee(k,Re,1),M=0;M<I;){var _e=Ze[P(o,h,Qe)];h+=_e&15;var w=_e>>4;if(w<16)C[M++]=w;else{var X=0,se=0;for(w==16?(se=3+P(o,h,3),h+=2,X=C[M-1]):w==17?(se=3+P(o,h,7),h+=3):w==18&&(se=11+P(o,h,127),h+=7);se--;)C[M++]=X}}var Le=C.subarray(0,E),H=C.subarray(E);g=oe(Le),m=oe(H),p=ee(Le,g,1),T=ee(H,m,1)}else D(1);else{var w=kt(h)+4,x=o[w-4]|o[w-3]<<8,A=w+x;if(A>s){c&&D(0);break}a&&l(d+x),t.set(o.subarray(w,A),d),e.b=d+=x,e.p=h=A*8,e.f=u;continue}if(h>y){c&&D(0);break}}a&&l(d+131072);for(var et=(1<<g)-1,tt=(1<<m)-1,ne=h;;ne=h){var X=p[ae(o,h)&et],W=X>>4;if(h+=X&15,h>y){c&&D(0);break}if(X||D(2),W<256)t[d++]=W;else if(W==256){ne=h,p=null;break}else{var be=W-254;if(W>264){var M=W-257,Q=Ue[M];be=P(o,h,(1<<Q)-1)+Ve[M],h+=Q}var ie=T[ae(o,h)&tt],re=ie>>4;ie||D(3),h+=ie&15;var H=Ct[re];if(re>3){var Q=je[re];H+=ae(o,h)&(1<<Q)-1,h+=Q}if(h>y){c&&D(0);break}a&&l(d+131072);var Ae=d+be;if(d<H){var Ee=i-H,st=Math.min(H,Ae);for(Ee+d<0&&D(3);d<st;++d)t[d]=n[Ee+d]}for(;d<Ae;++d)t[d]=t[d-H]}}e.l=p,e.p=ne,e.b=d,e.f=u,p&&(u=1,e.m=g,e.d=T,e.n=m)}while(!u);return d!=t.length&&r?xe(t,0,d):t.subarray(0,d)},Pt=new v(0),B=function(o,e){return o[e]|o[e+1]<<8},F=function(o,e){return(o[e]|o[e+1]<<8|o[e+2]<<16|o[e+3]<<24)>>>0},ce=function(o,e){return F(o,e)+F(o,e+4)*4294967296};function Ot(o,e){return Dt(o,{i:2},e&&e.out,e&&e.dictionary)}var pe=typeof TextDecoder<"u"&&new TextDecoder,Ft=0;try{pe.decode(Pt,{stream:!0}),Ft=1}catch{}var Gt=function(o){for(var e="",t=0;;){var n=o[t++],s=(n>127)+(n>223)+(n>239);if(t+s>o.length)return{s:e,r:xe(o,t-1)};s?s==3?(n=((n&15)<<18|(o[t++]&63)<<12|(o[t++]&63)<<6|o[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?e+=String.fromCharCode((n&31)<<6|o[t++]&63):e+=String.fromCharCode((n&15)<<12|(o[t++]&63)<<6|o[t++]&63):e+=String.fromCharCode(n)}};function We(o,e){if(e){for(var t="",n=0;n<o.length;n+=16384)t+=String.fromCharCode.apply(null,o.subarray(n,n+16384));return t}else{if(pe)return pe.decode(o);var s=Gt(o),i=s.s,t=s.r;return t.length&&D(8),i}}var Bt=function(o,e){return e+30+B(o,e+26)+B(o,e+28)},Ht=function(o,e,t){var n=B(o,e+28),s=We(o.subarray(e+46,e+46+n),!(B(o,e+8)&2048)),i=e+46+n,r=F(o,e+20),a=t&&r==4294967295?Ut(o,i):[r,F(o,e+24),F(o,e+42)],c=a[0],l=a[1],u=a[2];return[B(o,e+10),c,l,s,i+B(o,e+30)+B(o,e+32),u]},Ut=function(o,e){for(;B(o,e)!=1;e+=4+B(o,e+2));return[ce(o,e+12),ce(o,e+4),ce(o,e+20)]};function jt(o,e){for(var t={},n=o.length-22;F(o,n)!=101010256;--n)(!n||o.length-n>65558)&&D(13);var s=B(o,n+8);if(!s)return{};var i=F(o,n+16),r=i==4294967295||s==65535;if(r){var a=F(o,n-12);r=F(o,a)==101075792,r&&(s=F(o,a+32),i=F(o,a+48))}for(var c=0;c<s;++c){var l=Ht(o,i,r),u=l[0],h=l[1],d=l[2],p=l[3],T=l[4],g=l[5],m=Bt(o,g);i=T,u?u==8?t[p]=Ot(o.subarray(m,m+h),{out:new v(d)}):D(14,"unknown compression type "+u):t[p]=xe(o,m,m+h)}return t}let me=null;async function zt(o){const e=o.substring(0,o.length-4),t=new b.FileLoader;t.setResponseType("arraybuffer");const n=await t.loadAsync(o),s=jt(new Uint8Array(n)),i=We(new Uint8Array(s[e].buffer));me=new Rt(JSON.parse(i))}class Kt extends q{initObject(e){let t;if(He(e)?t=e:t="ERROR",me==null){const n=new b.BoxGeometry,s=new b.MeshStandardMaterial({color:16711680});return new b.Mesh(n,s)}else{const n={font:me,size:1,depth:.5,curveSegments:12},s=new bt(t,n);s.center();const i=new b.MeshStandardMaterial({color:65280});return new b.Mesh(s,i)}}}function ke(o,e){if(e===f.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===f.TriangleFanDrawMode||e===f.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)r.push(c);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,s=[];if(e===f.TriangleFanDrawMode)for(let r=1;r<=n;r++)s.push(t.getX(0)),s.push(t.getX(r)),s.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(s.push(t.getX(r)),s.push(t.getX(r+1)),s.push(t.getX(r+2))):(s.push(t.getX(r+2)),s.push(t.getX(r+1)),s.push(t.getX(r)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=o.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Vt extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new $t(t)}),this.register(function(t){return new qt(t)}),this.register(function(t){return new os(t)}),this.register(function(t){return new as(t)}),this.register(function(t){return new cs(t)}),this.register(function(t){return new Zt(t)}),this.register(function(t){return new es(t)}),this.register(function(t){return new ts(t)}),this.register(function(t){return new ss(t)}),this.register(function(t){return new Jt(t)}),this.register(function(t){return new ns(t)}),this.register(function(t){return new Qt(t)}),this.register(function(t){return new rs(t)}),this.register(function(t){return new is(t)}),this.register(function(t){return new Wt(t)}),this.register(function(t){return new ls(t)}),this.register(function(t){return new hs(t)})}load(e,t,n,s){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=f.LoaderUtils.extractUrlBase(e);r=f.LoaderUtils.resolveURL(l,this.path)}else r=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){s?s(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},c=new f.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{i.parse(l,r,function(u){t(u),i.manager.itemEnd(e)},a)}catch(u){a(u)}},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 this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let i;const r={},a={},c=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ye){try{r[R.KHR_BINARY_GLTF]=new us(e)}catch(h){s&&s(h);return}i=JSON.parse(r[R.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new bs(i,{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 u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,r[h.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const h=i.extensionsUsed[u],d=i.extensionsRequired||[];switch(h){case R.KHR_MATERIALS_UNLIT:r[h]=new Yt;break;case R.KHR_DRACO_MESH_COMPRESSION:r[h]=new fs(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:r[h]=new ds;break;case R.KHR_MESH_QUANTIZATION:r[h]=new ps;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function Xt(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const R={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 Wt{constructor(e){this.parser=e,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,c=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const u=new f.Color(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],f.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new f.DirectionalLight(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new f.PointLight(u),l.distance=h;break;case"spot":l=new f.SpotLight(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),G(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class Yt{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new f.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],f.LinearSRGBColorSpace),e.opacity=r[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,f.SRGBColorSpace))}return Promise.all(s)}}class Jt{constructor(e){this.parser=e,this.name=R.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 i=s.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class $t{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(a,a)}return Promise.all(i)}}class qt{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Qt{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class Zt{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=s.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,f.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class es{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class ts{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),Promise.all(i)}}class ss{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class ns{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,f.SRGBColorSpace)),Promise.all(i)}}class is{constructor(e){this.parser=e,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(i)}}class rs{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class os{constructor(e){this.parser=e,this.name=R.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,r)}}class as{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],a=s.images[r.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,r.source,c)}}class cs{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],a=s.images[r.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,r.source,c)}}class ls{constructor(e){this.name=R.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.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 i.then(function(a){const c=s.byteOffset||0,l=s.byteLength||0,u=s.count,h=s.byteStride,d=new Uint8Array(a,c,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,h,d,s.mode,s.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(u*h);return r.decodeGltfBuffer(new Uint8Array(p),u,h,d,s.mode,s.filter),p})})}else return null}}class hs{constructor(e){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const l of s.primitives)if(l.mode!==N.TRIANGLES&&l.mode!==N.TRIANGLE_STRIP&&l.mode!==N.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],c={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const u=l.pop(),h=u.isGroup?u.children:[u],d=l[0].count,p=[];for(const T of h){const g=new f.Matrix4,m=new f.Vector3,y=new f.Quaternion,_=new f.Vector3(1,1,1),w=new f.InstancedMesh(T.geometry,T.material,d);for(let x=0;x<d;x++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&y.fromBufferAttribute(c.ROTATION,x),c.SCALE&&_.fromBufferAttribute(c.SCALE,x),w.setMatrixAt(x,g.compose(m,y,_));for(const x in c)if(x==="_COLOR_0"){const A=c[x];w.instanceColor=new f.InstancedBufferAttribute(A.array,A.itemSize,A.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&T.geometry.setAttribute(x,c[x]);f.Object3D.prototype.copy.call(w,T),this.parser.assignFinalMaterial(w),p.push(w)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const Ye="glTF",Z=12,Ne={JSON:1313821514,BIN:5130562};class us{constructor(e){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Z),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ye)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-Z,i=new DataView(e,Z);let r=0;for(;r<s;){const a=i.getUint32(r,!0);r+=4;const c=i.getUint32(r,!0);if(r+=4,c===Ne.JSON){const l=new Uint8Array(e,Z+r,a);this.content=n.decode(l)}else if(c===Ne.BIN){const l=Z+r;this.body=e.slice(l,l+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class fs{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},c={},l={};for(const u in r){const h=ge[u]||u.toLowerCase();a[h]=r[u]}for(const u in e.attributes){const h=ge[u]||u.toLowerCase();if(r[u]!==void 0){const d=n.accessors[e.attributes[u]],p=$[d.componentType];l[h]=p.name,c[h]=d.normalized===!0}}return t.getDependency("bufferView",i).then(function(u){return new Promise(function(h,d){s.decodeDracoFile(u,function(p){for(const T in p.attributes){const g=p.attributes[T],m=c[T];m!==void 0&&(g.normalized=m)}h(p)},a,l,f.LinearSRGBColorSpace,d)})})}}class ds{constructor(){this.name=R.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 ps{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class Je extends f.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let r=0;r!==s;r++)t[r]=n[i+r];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=s-t,h=(n-t)/u,d=h*h,p=d*h,T=e*l,g=T-l,m=-2*p+3*d,y=p-d,_=1-m,w=y-d+h;for(let x=0;x!==a;x++){const A=r[g+x+a],E=r[g+x+c]*u,S=r[T+x+a],I=r[T+x]*u;i[x]=_*A+w*E+m*S+y*I}return i}}const ms=new f.Quaternion;class gs extends Je{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return ms.fromArray(i).normalize().toArray(i),i}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},$={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},De={9728:f.NearestFilter,9729:f.LinearFilter,9984:f.NearestMipmapNearestFilter,9985:f.LinearMipmapNearestFilter,9986:f.NearestMipmapLinearFilter,9987:f.LinearMipmapLinearFilter},Pe={33071:f.ClampToEdgeWrapping,33648:f.MirroredRepeatWrapping,10497:f.RepeatWrapping},le={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ge={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"},Ts={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},he={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ys(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new f.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:f.FrontSide})),o.DefaultMaterial}function z(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function G(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ws(o,e,t){let n=!1,s=!1,i=!1;for(let l=0,u=e.length;l<u;l++){const h=e[l];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(s=!0),h.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(o);const r=[],a=[],c=[];for(let l=0,u=e.length;l<u;l++){const h=e[l];if(n){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):o.attributes.position;r.push(d)}if(s){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):o.attributes.normal;a.push(d)}if(i){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):o.attributes.color;c.push(d)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c)]).then(function(l){const u=l[0],h=l[1],d=l[2];return n&&(o.morphAttributes.position=u),s&&(o.morphAttributes.normal=h),i&&(o.morphAttributes.color=d),o.morphTargetsRelative=!0,o})}function xs(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Rs(o){let e;const t=o.extensions&&o.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ue(t.attributes):e=o.indices+":"+ue(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,s=o.targets.length;n<s;n++)e+=":"+ue(o.targets[n]);return e}function ue(o){let e="";const t=Object.keys(o).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+o[t[n]]+";";return e}function Te(o){switch(o){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 _s(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ls=new f.Matrix4;class bs{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Xt,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,s=-1,i=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);s=n&&c?parseInt(c[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&r<98?this.textureLoader=new f.TextureLoader(this.options.manager):this.textureLoader=new f.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new f.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 n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][s.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:s.asset,parser:n,userData:{}};return z(i,a,s),G(a,s),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const r=t[s].joints;for(let a=0,c=r.length;a<c;a++)e[r[a]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const r=e[s];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(r,a)=>{const c=this.associations.get(r);c!=null&&this.associations.set(a,c);for(const[l,u]of r.children.entries())i(u,a.children[l])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[R.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,r){n.load(f.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){r(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(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const r=le[s.type],a=$[s.componentType],c=s.normalized===!0,l=new a(s.count*r);return Promise.resolve(new f.BufferAttribute(l,r,c))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],c=le[s.type],l=$[s.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,d=s.byteOffset||0,p=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,T=s.normalized===!0;let g,m;if(p&&p!==h){const y=Math.floor(d/p),_="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+y+":"+s.count;let w=t.cache.get(_);w||(g=new l(a,y*p,s.count*p/u),w=new f.InterleavedBuffer(g,p/u),t.cache.add(_,w)),m=new f.InterleavedBufferAttribute(w,c,d%p/u,T)}else a===null?g=new l(s.count*c):g=new l(a,d,s.count*c),m=new f.BufferAttribute(g,c,T);if(s.sparse!==void 0){const y=le.SCALAR,_=$[s.sparse.indices.componentType],w=s.sparse.indices.byteOffset||0,x=s.sparse.values.byteOffset||0,A=new _(r[1],w,s.sparse.count*y),E=new l(r[2],x,s.sparse.count*c);a!==null&&(m=new f.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,I=A.length;S<I;S++){const C=A[S];if(m.setX(C,E[S*c]),c>=2&&m.setY(C,E[S*c+1]),c>=3&&m.setZ(C,E[S*c+2]),c>=4&&m.setW(C,E[S*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=T}return m})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const c=n.manager.getHandler(r.uri);c!==null&&(a=c)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const s=this,i=this.json,r=i.textures[e],a=i.images[t],c=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const d=(i.samplers||{})[r.sampler]||{};return u.magFilter=De[d.magFilter]||f.LinearFilter,u.minFilter=De[d.minFilter]||f.LinearMipmapLinearFilter,u.wrapS=Pe[d.wrapS]||f.RepeatWrapping,u.wrapT=Pe[d.wrapT]||f.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==f.NearestFilter&&u.minFilter!==f.LinearFilter,s.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=s.images[e],a=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const d=new Blob([h],{type:r.mimeType});return c=a.createObjectURL(d),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(h){return new Promise(function(d,p){let T=d;t.isImageBitmapLoader===!0&&(T=function(g){const m=new f.Texture(g);m.needsUpdate=!0,d(m)}),t.load(f.LoaderUtils.resolveURL(h,i.path),T,void 0,p)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),G(h,r),h.userData.mimeType=r.mimeType||_s(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),i.extensions[R.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=i.associations.get(r);r=i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,c)}}return s!==void 0&&(r.colorSpace=s),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new f.PointsMaterial,f.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new f.LineBasicMaterial,f.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(s||i||r){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),i&&(c.vertexColors=!0),r&&(c.flatShading=!0),s&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let r;const a={},c=i.extensions||{},l=[];if(c[R.KHR_MATERIALS_UNLIT]){const h=s[R.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(a,i,t))}else{const h=i.pbrMetallicRoughness||{};if(a.color=new f.Color(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),a.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,f.SRGBColorSpace)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=f.DoubleSide);const u=i.alphaMode||he.OPAQUE;if(u===he.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===he.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==f.MeshBasicMaterial&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new f.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;a.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&r!==f.MeshBasicMaterial&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==f.MeshBasicMaterial){const h=i.emissiveFactor;a.emissive=new f.Color().setRGB(h[0],h[1],h[2],f.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==f.MeshBasicMaterial&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,f.SRGBColorSpace)),Promise.all(l).then(function(){const h=new r(a);return i.name&&(h.name=i.name),G(h,i),t.associations.set(h,{materials:e}),i.extensions&&z(s,h,i),h})}createUniqueName(e){const t=f.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(a){return n[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Oe(c,a,t)})}const r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],u=Rs(l),h=s[u];if(h)r.push(h.promise);else{let d;l.extensions&&l.extensions[R.KHR_DRACO_MESH_COMPRESSION]?d=i(l):d=Oe(new f.BufferGeometry,l,t),s[u]={primitive:l,promise:d},r.push(d)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],r=i.primitives,a=[];for(let c=0,l=r.length;c<l;c++){const u=r[c].material===void 0?ys(this.cache):this.getDependency("material",r[c].material);a.push(u)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let p=0,T=u.length;p<T;p++){const g=u[p],m=r[p];let y;const _=l[p];if(m.mode===N.TRIANGLES||m.mode===N.TRIANGLE_STRIP||m.mode===N.TRIANGLE_FAN||m.mode===void 0)y=i.isSkinnedMesh===!0?new f.SkinnedMesh(g,_):new f.Mesh(g,_),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),m.mode===N.TRIANGLE_STRIP?y.geometry=ke(y.geometry,f.TriangleStripDrawMode):m.mode===N.TRIANGLE_FAN&&(y.geometry=ke(y.geometry,f.TriangleFanDrawMode));else if(m.mode===N.LINES)y=new f.LineSegments(g,_);else if(m.mode===N.LINE_STRIP)y=new f.Line(g,_);else if(m.mode===N.LINE_LOOP)y=new f.LineLoop(g,_);else if(m.mode===N.POINTS)y=new f.Points(g,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(y.geometry.morphAttributes).length>0&&xs(y,i),y.name=t.createUniqueName(i.name||"mesh_"+e),G(y,i),m.extensions&&z(s,y,m),t.assignFinalMaterial(y),h.push(y)}for(let p=0,T=h.length;p<T;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return i.extensions&&z(s,h[0],i),h[0];const d=new f.Group;i.extensions&&z(s,d,i),t.associations.set(d,{meshes:e});for(let p=0,T=h.length;p<T;p++)d.add(h[p]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new f.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),G(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),r=s,a=[],c=[];for(let l=0,u=r.length;l<u;l++){const h=r[l];if(h){a.push(h);const d=new f.Matrix4;i!==null&&d.fromArray(i.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new f.Skeleton(a,c)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,r=[],a=[],c=[],l=[],u=[];for(let h=0,d=s.channels.length;h<d;h++){const p=s.channels[h],T=s.samplers[p.sampler],g=p.target,m=g.node,y=s.parameters!==void 0?s.parameters[T.input]:T.input,_=s.parameters!==void 0?s.parameters[T.output]:T.output;g.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",y)),c.push(this.getDependency("accessor",_)),l.push(T),u.push(g))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){const d=h[0],p=h[1],T=h[2],g=h[3],m=h[4],y=[];for(let w=0,x=d.length;w<x;w++){const A=d[w],E=p[w],S=T[w],I=g[w],C=m[w];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const k=n._createAnimationTracks(A,E,S,I,C);if(k)for(let M=0;M<k.length;M++)y.push(k[M])}const _=new f.AnimationClip(i,void 0,y);return G(_,s),_})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const r=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let c=0,l=s.weights.length;c<l;c++)a.morphTargetInfluences[c]=s.weights[c]}),r})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),r=[],a=s.children||[];for(let l=0,u=a.length;l<u;l++)r.push(n.getDependency("node",a[l]));const c=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(r),c]).then(function(l){const u=l[0],h=l[1],d=l[2];d!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(d,Ls)});for(let p=0,T=h.length;p<T;p++)u.add(h[p]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],r=i.name?s.createUniqueName(i.name):"",a=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),i.camera!==void 0&&a.push(s.getDependency("camera",i.camera).then(function(l){return s._getNodeRef(s.cameraCache,i.camera,l)})),s._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let u;if(i.isBone===!0?u=new f.Bone:l.length>1?u=new f.Group:l.length===1?u=l[0]:u=new f.Object3D,u!==l[0])for(let h=0,d=l.length;h<d;h++)u.add(l[h]);if(i.name&&(u.userData.name=i.name,u.name=r),G(u,i),i.extensions&&z(n,u,i),i.matrix!==void 0){const h=new f.Matrix4;h.fromArray(i.matrix),u.applyMatrix4(h)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!s.associations.has(u))s.associations.set(u,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const h=s.associations.get(u);s.associations.set(u,{...h})}return s.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new f.Group;n.name&&(i.name=s.createUniqueName(n.name)),G(i,n),n.extensions&&z(t,i,n);const r=n.nodes||[],a=[];for(let c=0,l=r.length;c<l;c++)a.push(s.getDependency("node",r[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)i.add(c[u]);const l=u=>{const h=new Map;for(const[d,p]of s.associations)(d instanceof f.Material||d instanceof f.Texture)&&h.set(d,p);return u.traverse(d=>{const p=s.associations.get(d);p!=null&&h.set(d,p)}),h};return s.associations=l(i),i})}_createAnimationTracks(e,t,n,s,i){const r=[],a=e.name?e.name:e.uuid,c=[];j[i.path]===j.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch(j[i.path]){case j.weights:l=f.NumberKeyframeTrack;break;case j.rotation:l=f.QuaternionKeyframeTrack;break;case j.translation:case j.scale:l=f.VectorKeyframeTrack;break;default:n.itemSize===1?l=f.NumberKeyframeTrack:l=f.VectorKeyframeTrack;break}const u=s.interpolation!==void 0?Ts[s.interpolation]:f.InterpolateLinear,h=this._getArrayFromAccessor(n);for(let d=0,p=c.length;d<p;d++){const T=new l(c[d]+"."+j[i.path],t.array,h,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Te(t.constructor),s=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof f.QuaternionKeyframeTrack?gs:Je;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function As(o,e,t){const n=e.attributes,s=new f.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(s.set(new f.Vector3(c[0],c[1],c[2]),new f.Vector3(l[0],l[1],l[2])),a.normalized){const u=Te($[a.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new f.Vector3,c=new f.Vector3;for(let l=0,u=i.length;l<u;l++){const h=i[l];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],p=d.min,T=d.max;if(p!==void 0&&T!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),d.normalized){const g=Te($[d.componentType]);c.multiplyScalar(g)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}o.boundingBox=s;const r=new f.Sphere;s.getCenter(r.center),r.radius=s.min.distanceTo(s.max)/2,o.boundingSphere=r}function Oe(o,e,t){const n=e.attributes,s=[];function i(r,a){return t.getDependency("accessor",r).then(function(c){o.setAttribute(a,c)})}for(const r in n){const a=ge[r]||r.toLowerCase();a in o.attributes||s.push(i(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});s.push(r)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),G(o,e),As(o,e,t),Promise.all(s).then(function(){return e.targets!==void 0?ws(o,e.targets,t):o})}const fe=new WeakMap;class Es extends f.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,n,s){const i=new f.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{this.parse(r,t,s)},n,s)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,f.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,s,i=f.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(fe.has(e)){const c=fe.get(e);if(c.key===n)return c.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 s;const i=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(i,r).then(c=>(s=c,new Promise((l,u)=>{s._callbacks[i]={resolve:l,reject:u},s.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{s&&i&&this._releaseTask(s,i)}),fe.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new f.BufferGeometry;e.index&&t.setIndex(new f.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:s,array:i,itemSize:r,stride:a,vertexColorSpace:c}=e.attributes[n];let l;if(r===a)l=new f.BufferAttribute(i,r);else{const u=new f.InterleavedBuffer(i,a);l=new f.InterleavedBufferAttribute(u,r,0)}s==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(i instanceof Float32Array)),t.setAttribute(s,l)}return t}_assignVertexColorSpace(e,t){if(t!==f.SRGBColorSpace)return;const n=new f.Color;for(let s=0,i=e.count;s<i;s++)n.fromBufferAttribute(e,s),f.ColorManagement.colorSpaceToWorking(n,f.SRGBColorSpace),e.setXYZ(s,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new f.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,i)=>{n.load(e,s,void 0,i)})}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(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const i=Ss.toString(),r=["/* draco decoder */",s,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
17
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(i){const r=i.data;switch(r.type){case"decode":s._callbacks[r.id].resolve(r);break;case"error":s._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,i){return s._taskLoad>i._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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
|
|
15
|
+
`;class Be extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;isDragging=!1;offsetX=0;offsetY=0;constructor(e,t){super(),this.camera3js=new b.PerspectiveCamera(75,e/t,.1,1e3);const n=new te(this.camera3js);this.base=new we(n),this.scene=this.base.scene,this.camera=this.base.camera,this.renderer=new b.WebGLRenderer,this.clock=new b.Clock,this.camera3js.aspect=e/t,this.renderer.setSize(e,t),this.style=yt,document.body?document.body.appendChild(this):document.addEventListener("DOMContentLoaded",()=>{document.body.append(this)},{once:!0});const s=document.createElement("div");s.textContent="A3Window",s.style=Tt,this.appendChild(s),s.addEventListener("mousedown",this.mouseDownListener),document.addEventListener("mousemove",this.mouseMoveListener),document.addEventListener("mouseup",this.mouseUpListener),this.renderer.domElement.style=`display: block; width: ${e}px; height: ${t}px; margin: 0; padding: 0;`,this.renderer.domElement.width=e,this.renderer.domElement.width=t,this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop),this.addEventListener("click",this.myMouseClickedListener)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();this.camera3js.aspect=e/t,this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}mouseDownListener=e=>{this.isDragging=!0,this.offsetX=e.clientX-this.offsetLeft,this.offsetY=e.clientY-this.offsetTop};mouseMoveListener=e=>{this.isDragging&&(this.style.left=e.clientX-this.offsetX+"px",this.style.top=e.clientY-this.offsetY+"px")};mouseUpListener=()=>{this.isDragging=!1};replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.scene&&(this.scene.update(e),this.renderer.render(this.scene.scene,this.camera3js))};myMouseClickedListener=e=>{if(this.camera instanceof te){const t=new b.Raycaster,n=new b.Vector2,s=e.target.getBoundingClientRect(),i=e.clientX-s.left,r=e.clientY-s.top;n.x=2*(i/s.width)-1,n.y=-2*(r/s.height)+1,t.setFromCamera(n,this.camera.camera);const a=t.intersectObjects(this.scene.scene.children),c=[];a.forEach(l=>{for(const u of this.scene.objects)if(u.contains(l.object)){c.push({o1:l.object,o2:u});break}}),this.dispatchEvent(new CustomEvent("click3d",{detail:{value:c}}))}}}customElements.define("a3-window",Be);class wt extends ${constructor(e){super(),e&&e.physics?this.setControlMode("physics"):this.setControlMode("user")}initObject(){const e=new b.BoxGeometry,t=new b.MeshStandardMaterial({color:65280});return new b.Mesh(e,t)}initPhysics(e,t){this.physics=new xt(this)}update(e){this.controlMode==="physics"?super.update(e):this.controlMode==="interpolated"?super.update(e):(this.object.rotation.x+=e,this.object.rotation.y+=e,this.object.rotation.z+=e)}}class xt{object;bodyDesc;body=null;colliderDesc;collider=null;constructor(e){this.object=e,this.bodyDesc=V.RAPIER.RigidBodyDesc.dynamic(),this.bodyDesc.setTranslation(e.location.x,e.location.y,e.location.z),this.colliderDesc=V.RAPIER.ColliderDesc.cuboid(.5,.5,.5),this.colliderDesc.setRestitution(.3).setFriction(.6)}synchronize(e){if(this.body){const t=this.body.translation();e.location.set(t.x,t.y,t.z),e.object.position.set(t.x,t.y,t.z);const n=this.body.rotation();e.rot.set(n.x,n.y,n.z,n.w),e.object.quaternion.set(n.x,n.y,n.z,n.w)}}addOneself(e){this.body=e.world.createRigidBody(this.bodyDesc),this.collider=e.world.createCollider(this.colliderDesc,this.body)}removeOneself(e){this.body&&e.world.removeRigidBody(this.body),this.collider&&e.world.removeCollider(this.collider,!1)}forceSetLoc(e){this.body&&this.body.setTranslation(e,!0)}forceSetQuat(e){this.body&&this.body.setRotation(e,!0)}forceSetScale(e){}}class Rt{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="ltr"){const s=[],i=_t(e,t,this.data,n);for(let r=0,a=i.length;r<a;r++)s.push(...i[r].toShapes());return s}}function _t(o,e,t,n){const s=Array.from(o),i=e/t.resolution,r=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,a=[];let c=0,l=0;(n=="rtl"||n=="tb")&&s.reverse();for(let u=0;u<s.length;u++){const h=s[u];if(h===`
|
|
16
|
+
`)c=0,l-=r;else{const d=bt(h,i,c,l,t);n=="tb"?(c=0,l+=t.ascender*i):c+=d.offsetX,a.push(d.path)}}return a}function bt(o,e,t,n,s){const i=s.glyphs[o]||s.glyphs["?"];if(!i){console.error('THREE.Font: character "'+o+'" does not exists in font family '+s.familyName+".");return}const r=new f.ShapePath;let a,c,l,u,h,d,p,y;if(i.o){const g=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let m=0,T=g.length;m<T;)switch(g[m++]){case"m":a=g[m++]*e+t,c=g[m++]*e+n,r.moveTo(a,c);break;case"l":a=g[m++]*e+t,c=g[m++]*e+n,r.lineTo(a,c);break;case"q":l=g[m++]*e+t,u=g[m++]*e+n,h=g[m++]*e+t,d=g[m++]*e+n,r.quadraticCurveTo(h,d,l,u);break;case"b":l=g[m++]*e+t,u=g[m++]*e+n,h=g[m++]*e+t,d=g[m++]*e+n,p=g[m++]*e+t,y=g[m++]*e+n,r.bezierCurveTo(h,d,p,y,l,u);break}}return{offsetX:i.ha*e,path:r}}class Lt extends f.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const s=n.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(s,t)}this.type="TextGeometry"}}function He(o){return typeof o=="string"}var I=Uint8Array,q=Uint16Array,St=Int32Array,Ue=new I([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),je=new I([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Et=new I([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ze=function(o,e){for(var t=new q(31),n=0;n<31;++n)t[n]=e+=1<<o[n-1];for(var s=new St(t[30]),n=1;n<30;++n)for(var i=t[n];i<t[n+1];++i)s[i]=i-t[n]<<5|n;return{b:t,r:s}},Ke=ze(Ue,2),Ve=Ke.b,At=Ke.r;Ve[28]=258,At[258]=28;var Mt=ze(je,0),Ct=Mt.b,pe=new q(32768);for(var L=0;L<32768;++L){var U=(L&43690)>>1|(L&21845)<<1;U=(U&52428)>>2|(U&13107)<<2,U=(U&61680)>>4|(U&3855)<<4,pe[L]=((U&65280)>>8|(U&255)<<8)>>1}var ee=(function(o,e,t){for(var n=o.length,s=0,i=new q(e);s<n;++s)o[s]&&++i[o[s]-1];var r=new q(e);for(s=1;s<e;++s)r[s]=r[s-1]+i[s-1]<<1;var a;if(t){a=new q(1<<e);var c=15-e;for(s=0;s<n;++s)if(o[s])for(var l=s<<4|o[s],u=e-o[s],h=r[o[s]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)a[pe[h]>>c]=l}else for(a=new q(n),s=0;s<n;++s)o[s]&&(a[s]=pe[r[o[s]-1]++]>>15-o[s]);return a}),se=new I(288);for(var L=0;L<144;++L)se[L]=8;for(var L=144;L<256;++L)se[L]=9;for(var L=256;L<280;++L)se[L]=7;for(var L=280;L<288;++L)se[L]=8;var Xe=new I(32);for(var L=0;L<32;++L)Xe[L]=5;var vt=ee(se,9,1),It=ee(Xe,5,1),ae=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},O=function(o,e,t){var n=e/8|0;return(o[n]|o[n+1]<<8)>>(e&7)&t},ce=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},kt=function(o){return(o+7)/8|0},xe=function(o,e,t){return(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length),new I(o.subarray(e,t))},Nt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],P=function(o,e,t){var n=new Error(e||Nt[o]);if(n.code=o,Error.captureStackTrace&&Error.captureStackTrace(n,P),!t)throw n;return n},Dt=function(o,e,t,n){var s=o.length,i=n?n.length:0;if(!s||e.f&&!e.l)return t||new I(0);var r=!t,a=r||e.i!=2,c=e.i;r&&(t=new I(s*3));var l=function(Ae){var Me=t.length;if(Ae>Me){var Ce=new I(Math.max(Me*2,Ae));Ce.set(t),t=Ce}},u=e.f||0,h=e.p||0,d=e.b||0,p=e.l,y=e.d,g=e.m,m=e.n,T=s*8;do{if(!p){u=O(o,h,1);var _=O(o,h+1,3);if(h+=3,_)if(_==1)p=vt,y=It,g=9,m=5;else if(_==2){var E=O(o,h,31)+257,A=O(o,h+10,15)+4,k=E+O(o,h+5,31)+1;h+=14;for(var C=new I(k),N=new I(19),M=0;M<A;++M)N[Et[M]]=O(o,h+M*3,7);h+=A*3;for(var Re=ae(N),Qe=(1<<Re)-1,Ze=ee(N,Re,1),M=0;M<k;){var _e=Ze[O(o,h,Qe)];h+=_e&15;var w=_e>>4;if(w<16)C[M++]=w;else{var W=0,ne=0;for(w==16?(ne=3+O(o,h,3),h+=2,W=C[M-1]):w==17?(ne=3+O(o,h,7),h+=3):w==18&&(ne=11+O(o,h,127),h+=7);ne--;)C[M++]=W}}var be=C.subarray(0,E),H=C.subarray(E);g=ae(be),m=ae(H),p=ee(be,g,1),y=ee(H,m,1)}else P(1);else{var w=kt(h)+4,x=o[w-4]|o[w-3]<<8,S=w+x;if(S>s){c&&P(0);break}a&&l(d+x),t.set(o.subarray(w,S),d),e.b=d+=x,e.p=h=S*8,e.f=u;continue}if(h>T){c&&P(0);break}}a&&l(d+131072);for(var et=(1<<g)-1,tt=(1<<m)-1,ie=h;;ie=h){var W=p[ce(o,h)&et],Y=W>>4;if(h+=W&15,h>T){c&&P(0);break}if(W||P(2),Y<256)t[d++]=Y;else if(Y==256){ie=h,p=null;break}else{var Le=Y-254;if(Y>264){var M=Y-257,Q=Ue[M];Le=O(o,h,(1<<Q)-1)+Ve[M],h+=Q}var re=y[ce(o,h)&tt],oe=re>>4;re||P(3),h+=re&15;var H=Ct[oe];if(oe>3){var Q=je[oe];H+=ce(o,h)&(1<<Q)-1,h+=Q}if(h>T){c&&P(0);break}a&&l(d+131072);var Se=d+Le;if(d<H){var Ee=i-H,st=Math.min(H,Se);for(Ee+d<0&&P(3);d<st;++d)t[d]=n[Ee+d]}for(;d<Se;++d)t[d]=t[d-H]}}e.l=p,e.p=ie,e.b=d,e.f=u,p&&(u=1,e.m=g,e.d=y,e.n=m)}while(!u);return d!=t.length&&r?xe(t,0,d):t.subarray(0,d)},Pt=new I(0),B=function(o,e){return o[e]|o[e+1]<<8},F=function(o,e){return(o[e]|o[e+1]<<8|o[e+2]<<16|o[e+3]<<24)>>>0},le=function(o,e){return F(o,e)+F(o,e+4)*4294967296};function Ot(o,e){return Dt(o,{i:2},e&&e.out,e&&e.dictionary)}var me=typeof TextDecoder<"u"&&new TextDecoder,Ft=0;try{me.decode(Pt,{stream:!0}),Ft=1}catch{}var Gt=function(o){for(var e="",t=0;;){var n=o[t++],s=(n>127)+(n>223)+(n>239);if(t+s>o.length)return{s:e,r:xe(o,t-1)};s?s==3?(n=((n&15)<<18|(o[t++]&63)<<12|(o[t++]&63)<<6|o[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?e+=String.fromCharCode((n&31)<<6|o[t++]&63):e+=String.fromCharCode((n&15)<<12|(o[t++]&63)<<6|o[t++]&63):e+=String.fromCharCode(n)}};function We(o,e){if(e){for(var t="",n=0;n<o.length;n+=16384)t+=String.fromCharCode.apply(null,o.subarray(n,n+16384));return t}else{if(me)return me.decode(o);var s=Gt(o),i=s.s,t=s.r;return t.length&&P(8),i}}var Bt=function(o,e){return e+30+B(o,e+26)+B(o,e+28)},Ht=function(o,e,t){var n=B(o,e+28),s=We(o.subarray(e+46,e+46+n),!(B(o,e+8)&2048)),i=e+46+n,r=F(o,e+20),a=t&&r==4294967295?Ut(o,i):[r,F(o,e+24),F(o,e+42)],c=a[0],l=a[1],u=a[2];return[B(o,e+10),c,l,s,i+B(o,e+30)+B(o,e+32),u]},Ut=function(o,e){for(;B(o,e)!=1;e+=4+B(o,e+2));return[le(o,e+12),le(o,e+4),le(o,e+20)]};function jt(o,e){for(var t={},n=o.length-22;F(o,n)!=101010256;--n)(!n||o.length-n>65558)&&P(13);var s=B(o,n+8);if(!s)return{};var i=F(o,n+16),r=i==4294967295||s==65535;if(r){var a=F(o,n-12);r=F(o,a)==101075792,r&&(s=F(o,a+32),i=F(o,a+48))}for(var c=0;c<s;++c){var l=Ht(o,i,r),u=l[0],h=l[1],d=l[2],p=l[3],y=l[4],g=l[5],m=Bt(o,g);i=y,u?u==8?t[p]=Ot(o.subarray(m,m+h),{out:new I(d)}):P(14,"unknown compression type "+u):t[p]=xe(o,m,m+h)}return t}let ge=null;async function zt(o){const e=o.substring(0,o.length-4),t=new b.FileLoader;t.setResponseType("arraybuffer");const n=await t.loadAsync(o),s=jt(new Uint8Array(n)),i=We(new Uint8Array(s[e].buffer));ge=new Rt(JSON.parse(i))}class Kt extends ${initObject(e){let t;if(He(e)?t=e:t="ERROR",ge==null){const n=new b.BoxGeometry,s=new b.MeshStandardMaterial({color:16711680});return new b.Mesh(n,s)}else{const n={font:ge,size:1,depth:.5,curveSegments:12},s=new Lt(t,n);s.center();const i=new b.MeshStandardMaterial({color:65280});return new b.Mesh(s,i)}}}function ke(o,e){if(e===f.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===f.TriangleFanDrawMode||e===f.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)r.push(c);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,s=[];if(e===f.TriangleFanDrawMode)for(let r=1;r<=n;r++)s.push(t.getX(0)),s.push(t.getX(r)),s.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(s.push(t.getX(r)),s.push(t.getX(r+1)),s.push(t.getX(r+2))):(s.push(t.getX(r+2)),s.push(t.getX(r+1)),s.push(t.getX(r)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=o.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Vt extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Jt(t)}),this.register(function(t){return new $t(t)}),this.register(function(t){return new os(t)}),this.register(function(t){return new as(t)}),this.register(function(t){return new cs(t)}),this.register(function(t){return new Zt(t)}),this.register(function(t){return new es(t)}),this.register(function(t){return new ts(t)}),this.register(function(t){return new ss(t)}),this.register(function(t){return new qt(t)}),this.register(function(t){return new ns(t)}),this.register(function(t){return new Qt(t)}),this.register(function(t){return new rs(t)}),this.register(function(t){return new is(t)}),this.register(function(t){return new Wt(t)}),this.register(function(t){return new ls(t)}),this.register(function(t){return new hs(t)})}load(e,t,n,s){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=f.LoaderUtils.extractUrlBase(e);r=f.LoaderUtils.resolveURL(l,this.path)}else r=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){s?s(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},c=new f.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{i.parse(l,r,function(u){t(u),i.manager.itemEnd(e)},a)}catch(u){a(u)}},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 this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let i;const r={},a={},c=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ye){try{r[R.KHR_BINARY_GLTF]=new us(e)}catch(h){s&&s(h);return}i=JSON.parse(r[R.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Ls(i,{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 u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,r[h.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const h=i.extensionsUsed[u],d=i.extensionsRequired||[];switch(h){case R.KHR_MATERIALS_UNLIT:r[h]=new Yt;break;case R.KHR_DRACO_MESH_COMPRESSION:r[h]=new fs(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:r[h]=new ds;break;case R.KHR_MESH_QUANTIZATION:r[h]=new ps;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function Xt(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const R={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 Wt{constructor(e){this.parser=e,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,c=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const u=new f.Color(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],f.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new f.DirectionalLight(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new f.PointLight(u),l.distance=h;break;case"spot":l=new f.SpotLight(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),G(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class Yt{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new f.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],f.LinearSRGBColorSpace),e.opacity=r[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,f.SRGBColorSpace))}return Promise.all(s)}}class qt{constructor(e){this.parser=e,this.name=R.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 i=s.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class Jt{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(a,a)}return Promise.all(i)}}class $t{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Qt{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class Zt{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=s.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,f.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class es{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class ts{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),Promise.all(i)}}class ss{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class ns{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,f.SRGBColorSpace)),Promise.all(i)}}class is{constructor(e){this.parser=e,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(i)}}class rs{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class os{constructor(e){this.parser=e,this.name=R.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,r)}}class as{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],a=s.images[r.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,r.source,c)}}class cs{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],a=s.images[r.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,r.source,c)}}class ls{constructor(e){this.name=R.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.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 i.then(function(a){const c=s.byteOffset||0,l=s.byteLength||0,u=s.count,h=s.byteStride,d=new Uint8Array(a,c,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,h,d,s.mode,s.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(u*h);return r.decodeGltfBuffer(new Uint8Array(p),u,h,d,s.mode,s.filter),p})})}else return null}}class hs{constructor(e){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const l of s.primitives)if(l.mode!==D.TRIANGLES&&l.mode!==D.TRIANGLE_STRIP&&l.mode!==D.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],c={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const u=l.pop(),h=u.isGroup?u.children:[u],d=l[0].count,p=[];for(const y of h){const g=new f.Matrix4,m=new f.Vector3,T=new f.Quaternion,_=new f.Vector3(1,1,1),w=new f.InstancedMesh(y.geometry,y.material,d);for(let x=0;x<d;x++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&T.fromBufferAttribute(c.ROTATION,x),c.SCALE&&_.fromBufferAttribute(c.SCALE,x),w.setMatrixAt(x,g.compose(m,T,_));for(const x in c)if(x==="_COLOR_0"){const S=c[x];w.instanceColor=new f.InstancedBufferAttribute(S.array,S.itemSize,S.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&y.geometry.setAttribute(x,c[x]);f.Object3D.prototype.copy.call(w,y),this.parser.assignFinalMaterial(w),p.push(w)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const Ye="glTF",Z=12,Ne={JSON:1313821514,BIN:5130562};class us{constructor(e){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Z),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ye)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-Z,i=new DataView(e,Z);let r=0;for(;r<s;){const a=i.getUint32(r,!0);r+=4;const c=i.getUint32(r,!0);if(r+=4,c===Ne.JSON){const l=new Uint8Array(e,Z+r,a);this.content=n.decode(l)}else if(c===Ne.BIN){const l=Z+r;this.body=e.slice(l,l+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class fs{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},c={},l={};for(const u in r){const h=ye[u]||u.toLowerCase();a[h]=r[u]}for(const u in e.attributes){const h=ye[u]||u.toLowerCase();if(r[u]!==void 0){const d=n.accessors[e.attributes[u]],p=J[d.componentType];l[h]=p.name,c[h]=d.normalized===!0}}return t.getDependency("bufferView",i).then(function(u){return new Promise(function(h,d){s.decodeDracoFile(u,function(p){for(const y in p.attributes){const g=p.attributes[y],m=c[y];m!==void 0&&(g.normalized=m)}h(p)},a,l,f.LinearSRGBColorSpace,d)})})}}class ds{constructor(){this.name=R.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 ps{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class qe extends f.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let r=0;r!==s;r++)t[r]=n[i+r];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=s-t,h=(n-t)/u,d=h*h,p=d*h,y=e*l,g=y-l,m=-2*p+3*d,T=p-d,_=1-m,w=T-d+h;for(let x=0;x!==a;x++){const S=r[g+x+a],E=r[g+x+c]*u,A=r[y+x+a],k=r[y+x]*u;i[x]=_*S+w*E+m*A+T*k}return i}}const ms=new f.Quaternion;class gs extends qe{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return ms.fromArray(i).normalize().toArray(i),i}}const D={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},De={9728:f.NearestFilter,9729:f.LinearFilter,9984:f.NearestMipmapNearestFilter,9985:f.LinearMipmapNearestFilter,9986:f.NearestMipmapLinearFilter,9987:f.LinearMipmapLinearFilter},Pe={33071:f.ClampToEdgeWrapping,33648:f.MirroredRepeatWrapping,10497:f.RepeatWrapping},he={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ye={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"},ys={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},ue={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ts(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new f.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:f.FrontSide})),o.DefaultMaterial}function z(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function G(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ws(o,e,t){let n=!1,s=!1,i=!1;for(let l=0,u=e.length;l<u;l++){const h=e[l];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(s=!0),h.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(o);const r=[],a=[],c=[];for(let l=0,u=e.length;l<u;l++){const h=e[l];if(n){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):o.attributes.position;r.push(d)}if(s){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):o.attributes.normal;a.push(d)}if(i){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):o.attributes.color;c.push(d)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c)]).then(function(l){const u=l[0],h=l[1],d=l[2];return n&&(o.morphAttributes.position=u),s&&(o.morphAttributes.normal=h),i&&(o.morphAttributes.color=d),o.morphTargetsRelative=!0,o})}function xs(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Rs(o){let e;const t=o.extensions&&o.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+fe(t.attributes):e=o.indices+":"+fe(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,s=o.targets.length;n<s;n++)e+=":"+fe(o.targets[n]);return e}function fe(o){let e="";const t=Object.keys(o).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+o[t[n]]+";";return e}function Te(o){switch(o){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 _s(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const bs=new f.Matrix4;class Ls{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Xt,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,s=-1,i=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);s=n&&c?parseInt(c[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&r<98?this.textureLoader=new f.TextureLoader(this.options.manager):this.textureLoader=new f.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new f.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 n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][s.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:s.asset,parser:n,userData:{}};return z(i,a,s),G(a,s),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const r=t[s].joints;for(let a=0,c=r.length;a<c;a++)e[r[a]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const r=e[s];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(r,a)=>{const c=this.associations.get(r);c!=null&&this.associations.set(a,c);for(const[l,u]of r.children.entries())i(u,a.children[l])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[R.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,r){n.load(f.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){r(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(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const r=he[s.type],a=J[s.componentType],c=s.normalized===!0,l=new a(s.count*r);return Promise.resolve(new f.BufferAttribute(l,r,c))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],c=he[s.type],l=J[s.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,d=s.byteOffset||0,p=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0;let g,m;if(p&&p!==h){const T=Math.floor(d/p),_="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+T+":"+s.count;let w=t.cache.get(_);w||(g=new l(a,T*p,s.count*p/u),w=new f.InterleavedBuffer(g,p/u),t.cache.add(_,w)),m=new f.InterleavedBufferAttribute(w,c,d%p/u,y)}else a===null?g=new l(s.count*c):g=new l(a,d,s.count*c),m=new f.BufferAttribute(g,c,y);if(s.sparse!==void 0){const T=he.SCALAR,_=J[s.sparse.indices.componentType],w=s.sparse.indices.byteOffset||0,x=s.sparse.values.byteOffset||0,S=new _(r[1],w,s.sparse.count*T),E=new l(r[2],x,s.sparse.count*c);a!==null&&(m=new f.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let A=0,k=S.length;A<k;A++){const C=S[A];if(m.setX(C,E[A*c]),c>=2&&m.setY(C,E[A*c+1]),c>=3&&m.setZ(C,E[A*c+2]),c>=4&&m.setW(C,E[A*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=y}return m})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const c=n.manager.getHandler(r.uri);c!==null&&(a=c)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const s=this,i=this.json,r=i.textures[e],a=i.images[t],c=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const d=(i.samplers||{})[r.sampler]||{};return u.magFilter=De[d.magFilter]||f.LinearFilter,u.minFilter=De[d.minFilter]||f.LinearMipmapLinearFilter,u.wrapS=Pe[d.wrapS]||f.RepeatWrapping,u.wrapT=Pe[d.wrapT]||f.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==f.NearestFilter&&u.minFilter!==f.LinearFilter,s.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=s.images[e],a=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const d=new Blob([h],{type:r.mimeType});return c=a.createObjectURL(d),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(h){return new Promise(function(d,p){let y=d;t.isImageBitmapLoader===!0&&(y=function(g){const m=new f.Texture(g);m.needsUpdate=!0,d(m)}),t.load(f.LoaderUtils.resolveURL(h,i.path),y,void 0,p)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),G(h,r),h.userData.mimeType=r.mimeType||_s(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),i.extensions[R.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=i.associations.get(r);r=i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,c)}}return s!==void 0&&(r.colorSpace=s),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new f.PointsMaterial,f.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new f.LineBasicMaterial,f.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(s||i||r){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),i&&(c.vertexColors=!0),r&&(c.flatShading=!0),s&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let r;const a={},c=i.extensions||{},l=[];if(c[R.KHR_MATERIALS_UNLIT]){const h=s[R.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(a,i,t))}else{const h=i.pbrMetallicRoughness||{};if(a.color=new f.Color(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),a.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,f.SRGBColorSpace)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=f.DoubleSide);const u=i.alphaMode||ue.OPAQUE;if(u===ue.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===ue.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==f.MeshBasicMaterial&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new f.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;a.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&r!==f.MeshBasicMaterial&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==f.MeshBasicMaterial){const h=i.emissiveFactor;a.emissive=new f.Color().setRGB(h[0],h[1],h[2],f.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==f.MeshBasicMaterial&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,f.SRGBColorSpace)),Promise.all(l).then(function(){const h=new r(a);return i.name&&(h.name=i.name),G(h,i),t.associations.set(h,{materials:e}),i.extensions&&z(s,h,i),h})}createUniqueName(e){const t=f.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(a){return n[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Oe(c,a,t)})}const r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],u=Rs(l),h=s[u];if(h)r.push(h.promise);else{let d;l.extensions&&l.extensions[R.KHR_DRACO_MESH_COMPRESSION]?d=i(l):d=Oe(new f.BufferGeometry,l,t),s[u]={primitive:l,promise:d},r.push(d)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],r=i.primitives,a=[];for(let c=0,l=r.length;c<l;c++){const u=r[c].material===void 0?Ts(this.cache):this.getDependency("material",r[c].material);a.push(u)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let p=0,y=u.length;p<y;p++){const g=u[p],m=r[p];let T;const _=l[p];if(m.mode===D.TRIANGLES||m.mode===D.TRIANGLE_STRIP||m.mode===D.TRIANGLE_FAN||m.mode===void 0)T=i.isSkinnedMesh===!0?new f.SkinnedMesh(g,_):new f.Mesh(g,_),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===D.TRIANGLE_STRIP?T.geometry=ke(T.geometry,f.TriangleStripDrawMode):m.mode===D.TRIANGLE_FAN&&(T.geometry=ke(T.geometry,f.TriangleFanDrawMode));else if(m.mode===D.LINES)T=new f.LineSegments(g,_);else if(m.mode===D.LINE_STRIP)T=new f.Line(g,_);else if(m.mode===D.LINE_LOOP)T=new f.LineLoop(g,_);else if(m.mode===D.POINTS)T=new f.Points(g,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&xs(T,i),T.name=t.createUniqueName(i.name||"mesh_"+e),G(T,i),m.extensions&&z(s,T,m),t.assignFinalMaterial(T),h.push(T)}for(let p=0,y=h.length;p<y;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return i.extensions&&z(s,h[0],i),h[0];const d=new f.Group;i.extensions&&z(s,d,i),t.associations.set(d,{meshes:e});for(let p=0,y=h.length;p<y;p++)d.add(h[p]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new f.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),G(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),r=s,a=[],c=[];for(let l=0,u=r.length;l<u;l++){const h=r[l];if(h){a.push(h);const d=new f.Matrix4;i!==null&&d.fromArray(i.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new f.Skeleton(a,c)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,r=[],a=[],c=[],l=[],u=[];for(let h=0,d=s.channels.length;h<d;h++){const p=s.channels[h],y=s.samplers[p.sampler],g=p.target,m=g.node,T=s.parameters!==void 0?s.parameters[y.input]:y.input,_=s.parameters!==void 0?s.parameters[y.output]:y.output;g.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),c.push(this.getDependency("accessor",_)),l.push(y),u.push(g))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){const d=h[0],p=h[1],y=h[2],g=h[3],m=h[4],T=[];for(let w=0,x=d.length;w<x;w++){const S=d[w],E=p[w],A=y[w],k=g[w],C=m[w];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const N=n._createAnimationTracks(S,E,A,k,C);if(N)for(let M=0;M<N.length;M++)T.push(N[M])}const _=new f.AnimationClip(i,void 0,T);return G(_,s),_})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const r=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let c=0,l=s.weights.length;c<l;c++)a.morphTargetInfluences[c]=s.weights[c]}),r})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),r=[],a=s.children||[];for(let l=0,u=a.length;l<u;l++)r.push(n.getDependency("node",a[l]));const c=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(r),c]).then(function(l){const u=l[0],h=l[1],d=l[2];d!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(d,bs)});for(let p=0,y=h.length;p<y;p++)u.add(h[p]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],r=i.name?s.createUniqueName(i.name):"",a=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),i.camera!==void 0&&a.push(s.getDependency("camera",i.camera).then(function(l){return s._getNodeRef(s.cameraCache,i.camera,l)})),s._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let u;if(i.isBone===!0?u=new f.Bone:l.length>1?u=new f.Group:l.length===1?u=l[0]:u=new f.Object3D,u!==l[0])for(let h=0,d=l.length;h<d;h++)u.add(l[h]);if(i.name&&(u.userData.name=i.name,u.name=r),G(u,i),i.extensions&&z(n,u,i),i.matrix!==void 0){const h=new f.Matrix4;h.fromArray(i.matrix),u.applyMatrix4(h)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!s.associations.has(u))s.associations.set(u,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const h=s.associations.get(u);s.associations.set(u,{...h})}return s.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new f.Group;n.name&&(i.name=s.createUniqueName(n.name)),G(i,n),n.extensions&&z(t,i,n);const r=n.nodes||[],a=[];for(let c=0,l=r.length;c<l;c++)a.push(s.getDependency("node",r[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)i.add(c[u]);const l=u=>{const h=new Map;for(const[d,p]of s.associations)(d instanceof f.Material||d instanceof f.Texture)&&h.set(d,p);return u.traverse(d=>{const p=s.associations.get(d);p!=null&&h.set(d,p)}),h};return s.associations=l(i),i})}_createAnimationTracks(e,t,n,s,i){const r=[],a=e.name?e.name:e.uuid,c=[];j[i.path]===j.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch(j[i.path]){case j.weights:l=f.NumberKeyframeTrack;break;case j.rotation:l=f.QuaternionKeyframeTrack;break;case j.translation:case j.scale:l=f.VectorKeyframeTrack;break;default:n.itemSize===1?l=f.NumberKeyframeTrack:l=f.VectorKeyframeTrack;break}const u=s.interpolation!==void 0?ys[s.interpolation]:f.InterpolateLinear,h=this._getArrayFromAccessor(n);for(let d=0,p=c.length;d<p;d++){const y=new l(c[d]+"."+j[i.path],t.array,h,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),r.push(y)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Te(t.constructor),s=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof f.QuaternionKeyframeTrack?gs:qe;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ss(o,e,t){const n=e.attributes,s=new f.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(s.set(new f.Vector3(c[0],c[1],c[2]),new f.Vector3(l[0],l[1],l[2])),a.normalized){const u=Te(J[a.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new f.Vector3,c=new f.Vector3;for(let l=0,u=i.length;l<u;l++){const h=i[l];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],p=d.min,y=d.max;if(p!==void 0&&y!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(y[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(y[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(y[2]))),d.normalized){const g=Te(J[d.componentType]);c.multiplyScalar(g)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}o.boundingBox=s;const r=new f.Sphere;s.getCenter(r.center),r.radius=s.min.distanceTo(s.max)/2,o.boundingSphere=r}function Oe(o,e,t){const n=e.attributes,s=[];function i(r,a){return t.getDependency("accessor",r).then(function(c){o.setAttribute(a,c)})}for(const r in n){const a=ye[r]||r.toLowerCase();a in o.attributes||s.push(i(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});s.push(r)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),G(o,e),Ss(o,e,t),Promise.all(s).then(function(){return e.targets!==void 0?ws(o,e.targets,t):o})}const de=new WeakMap;class Es extends f.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,n,s){const i=new f.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{this.parse(r,t,s)},n,s)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,f.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,s,i=f.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(de.has(e)){const c=de.get(e);if(c.key===n)return c.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 s;const i=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(i,r).then(c=>(s=c,new Promise((l,u)=>{s._callbacks[i]={resolve:l,reject:u},s.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{s&&i&&this._releaseTask(s,i)}),de.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new f.BufferGeometry;e.index&&t.setIndex(new f.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:s,array:i,itemSize:r,stride:a,vertexColorSpace:c}=e.attributes[n];let l;if(r===a)l=new f.BufferAttribute(i,r);else{const u=new f.InterleavedBuffer(i,a);l=new f.InterleavedBufferAttribute(u,r,0)}s==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(i instanceof Float32Array)),t.setAttribute(s,l)}return t}_assignVertexColorSpace(e,t){if(t!==f.SRGBColorSpace)return;const n=new f.Color;for(let s=0,i=e.count;s<i;s++)n.fromBufferAttribute(e,s),f.ColorManagement.colorSpaceToWorking(n,f.SRGBColorSpace),e.setXYZ(s,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new f.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,i)=>{n.load(e,s,void 0,i)})}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(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const i=As.toString(),r=["/* draco decoder */",s,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
17
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(i){const r=i.data;switch(r.type){case"decode":s._callbacks[r.id].resolve(r);break;case"error":s._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,i){return s._taskLoad>i._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 As(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(u){o.onModuleLoaded=function(h){u({draco:h})},DracoDecoderModule(o)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(u=>{const h=u.draco,d=new h.Decoder;try{const p=t(h,d,new Int8Array(c),l),y=p.attributes.map(g=>g.array.buffer);p.index&&y.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},y)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(d)}});break}};function t(r,a,c,l){const u=l.attributeIDs,h=l.attributeTypes;let d,p;const y=a.GetEncodedGeometryType(c);if(y===r.TRIANGULAR_MESH)d=new r.Mesh,p=a.DecodeArrayToMesh(c,c.byteLength,d);else if(y===r.POINT_CLOUD)d=new r.PointCloud,p=a.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const g={index:null,attributes:[]};for(const m in u){const T=self[h[m]];let _,w;if(l.useUniqueIDs)w=u[m],_=a.GetAttributeByUniqueId(d,w);else{if(w=a.GetAttributeId(d,r[u[m]]),w===-1)continue;_=a.GetAttribute(d,w)}const x=s(r,a,d,m,T,_);m==="color"&&(x.vertexColorSpace=l.vertexColorSpace),g.attributes.push(x)}return y===r.TRIANGULAR_MESH&&(g.index=n(r,a,d)),r.destroy(d),g}function n(r,a,c){const u=c.num_faces()*3,h=u*4,d=r._malloc(h);a.GetTrianglesUInt32Array(c,h,d);const p=new Uint32Array(r.HEAPF32.buffer,d,u).slice();return r._free(d),{array:p,itemSize:1}}function s(r,a,c,l,u,h){const d=c.num_points(),p=h.num_components(),y=i(r,u),g=p*u.BYTES_PER_ELEMENT,m=Math.ceil(g/4)*4,T=m/u.BYTES_PER_ELEMENT,_=d*g,w=d*m,x=r._malloc(_);a.GetAttributeDataArrayForAllPoints(c,h,y,_,x);const S=new u(r.HEAPF32.buffer,x,_/u.BYTES_PER_ELEMENT);let E;if(g===m)E=S.slice();else{E=new u(w/u.BYTES_PER_ELEMENT);let A=0;for(let k=0,C=S.length;k<C;k++){for(let N=0;N<p;N++)E[A+N]=S[k*p+N];A+=T}}return r._free(x),{name:l,count:d,itemSize:p,array:E,stride:T}}function i(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}function Ms(o){return"morphTargetDictionary"in o&&o.morphTargetDictionary!==void 0&&"morphTargetInfluences"in o&&Array.isArray(o.morphTargetInfluences)}const Je=new Vt,$e=new Es;$e.setDecoderPath("/examples/jsm/libs/draco/");Je.setDRACOLoader($e);class Cs extends ${ready;model=null;constructor(e){super(),this.ready=this.asyncInit(e),this.setControlMode("user")}initObject(){return new b.Object3D}async asyncInit(e){if(He(e)){const t=await Je.loadAsync(e),n=new b.AnimationMixer(t.scene),s={};console.log(`File: ${e}`),console.log(" actions:");for(let r=0;r<t.animations.length;r++){const a=t.animations[r],c=n.clipAction(a);s[a.name]=c,console.log(` ${a.name}`)}console.log(" morphs:");const i={};t.scene.traverse(r=>{if(Ms(r)){const{morphTargetDictionary:a,morphTargetInfluences:c}=r;Object.keys(a).forEach(l=>{const u=r.name+"."+l,h=a[l];i[u]={array:c,idx:h},console.log(` ${u}`)})}}),this.model={gltf:t,mixer:n,actions:s,morphs:i},this.object.add(this.model.gltf.scene)}else{const t=new b.BoxGeometry,n=new b.MeshStandardMaterial({color:16711680}),s=new b.Mesh(t,n);this.object.add(s)}return this}action(e){if(this.model){this.model.mixer.stopAllAction();const t=this.model.actions[e];t&&t.play()}}morph(e,t){if(this.model){const{array:n,idx:s}=this.model.morphs[e];n[s]=t}}update(e){this.model&&this.model.mixer.update(e)}}class vs extends ${constructor(e){super(e)}initObject(e){return e}}function Is(o){return 2*o}function ks(o){return new Promise(e=>{setTimeout(()=>{e()},o)})}exports.A3Camera=Fe;exports.A3Canvas=Ge;exports.A3Object=$;exports.A3Scene=K;exports.A3Test=wt;exports.A3Text3D=Kt;exports.A3ViewBase=we;exports.A3Window=Be;exports.A3glTF=Cs;exports.GeneralCamera=te;exports.Quat=X;exports.ThreeJS=vs;exports.Vec3=v;exports.asyncSleep=ks;exports.initFont=zt;exports.times2=Is;
|