a3js 0.0.53 → 0.0.54

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var wr=Object.create;var Sn=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var Rr=Object.getPrototypeOf,Qr=Object.prototype.hasOwnProperty;var kr=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vr(e))!Qr.call(i,r)&&r!==t&&Sn(i,r,{get:()=>e[r],enumerable:!(n=Tr(e,r))||n.enumerable});return i};var Sr=(i,e,t)=>(t=i!=null?wr(Rr(i)):{},kr(e||!i||!i.__esModule?Sn(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("three"),Yn=require("fflate");function xr(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const K=xr(b);class ce{x=0;y=0;z=0;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)}clone(){return new ce(this)}write(e){e.x=this.x,e.y=this.y,e.z=this.z}normalize(){const e=this.x*this.x+this.y*this.y+this.z*this.z,t=Math.sqrt(e);return t!==0?(this.x/=t,this.y/=t,this.z/=t):console.warn("Vec3.normalize."),this}negate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.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,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}sub(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}scale(e){return this.x*=e,this.y*=e,this.z*=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e,t){return this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this}apply(e,t,n,r){let o,s,c,A;typeof e=="number"?(o=e,s=t,c=n,A=r):(o=e.x,s=e.y,c=e.z,A=e.w);const a=2*(s*this.z-c*this.y),h=2*(c*this.x-o*this.z),u=2*(o*this.y-s*this.x);return this.x+=A*a+s*u-c*h,this.y+=A*h+c*a-o*u,this.z+=A*u+o*h-s*a,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 Me{x=0;y=0;z=0;w=1;constructor(e,t,n,r){typeof e=="number"?(this.x=e,this.y=t,this.z=n,this.w=r):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)}clone(){return new Me(this)}write(e){e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w}normalize(){const e=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w,t=Math.sqrt(e);return t!==0?(this.x/=t,this.y/=t,this.z/=t,this.w/=t):console.warn("Quat.normalize."),this}conjugate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}set(e,t,n,r){return typeof e=="number"?(this.x=e,this.y=t,this.z=n,this.w=r):(this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w),this}mul(e,t,n,r){const o=this.x,s=this.y,c=this.z,A=this.w;let a,h,u,m;return typeof e=="number"?(a=e,h=t,u=n,m=r):(a=e.x,h=e.y,u=e.z,m=e.w),this.x=A*a+o*m+s*u-c*h,this.y=A*h-o*u+s*m+c*a,this.z=A*u+o*h-s*a+c*m,this.w=A*m-o*a-s*h-c*u,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.w+n*t.w}slerp(e,t,n){if(n<0||n>1){console.warn("Quat.slerp(): t must be in [0,1]");return}let r=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(Xe.set(t),r<0&&(r*=-1,Xe.set(-Xe.x,-Xe.y,-Xe.z,-Xe.w)),r>.9995){this.x=(1-n)*e.x+n*Xe.x,this.y=(1-n)*e.y+n*Xe.y,this.z=(1-n)*e.z+n*Xe.z,this.w=(1-n)*e.w+n*Xe.w;const o=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);o<1e-4?(console.warn("Quat.slerp(); ???!"),this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w):(this.x*=1/o,this.y*=1/o,this.z*=1/o,this.w*=1/o)}else{const o=Math.acos(r),s=Math.sin((1-n)*o)/Math.sin(o),c=Math.sin(n*o)/Math.sin(o);this.x=s*e.x+c*Xe.x,this.y=s*e.y+c*Xe.y,this.z=s*e.z+c*Xe.z,this.w=s*e.w+c*Xe.w}}}const Xe=new Me;function st(i,e,t,n){t.normalize();const r=i.clone().sub(e).normalize(),o=new ce().cross(r,t).normalize(),s=new ce().cross(o,r),c=o.x,A=s.x,a=-r.x,h=o.y,u=s.y,m=-r.y,p=o.z,E=s.z,g=-r.z;let l,d,f,C;const I=c+u+g;if(I>0){const v=Math.sqrt(I+1)*2;l=(E-m)/v,d=(a-p)/v,f=(h-A)/v,C=.25*v}else if(c>u&&c>g){const v=Math.sqrt(1+c-u-g)*2;l=.25*v,d=(A+h)/v,f=(a+p)/v,C=(E-m)/v}else if(u>g){const v=Math.sqrt(1+u-c-g)*2;l=(A+h)/v,d=.25*v,f=(m+E)/v,C=(a-p)/v}else{const v=Math.sqrt(1+g-c-u)*2;l=(a+p)/v,d=(m+E)/v,f=.25*v,C=(h-A)/v}const y=n??new Me;return y.set(l,d,f,C),y}function ht(i,e="ZXY",t){const n=t!==void 0?t.set(0,0,0,1):new Me(0,0,0,1);for(let r=0;r<3;r++)switch(e.charAt(r)){case"X":n.mul(Math.sin(i.x),0,0,Math.cos(i.x));break;case"Y":n.mul(0,Math.sin(i.y),0,Math.cos(i.y));break;case"Z":n.mul(0,0,Math.sin(i.z),Math.cos(i.z));break}return n}function Lr(i){const e=[[],[],[]],t=i.x+i.x,n=i.y+i.y,r=i.z+i.z,o=i.x*t,s=i.x*n,c=i.x*r,A=i.y*n,a=i.y*r,h=i.z*r,u=i.w*t,m=i.w*n,p=i.w*r;return e[0][0]=1-(A+h),e[0][1]=s-p,e[0][2]=c+m,e[1][0]=s+p,e[1][1]=1-(o+h),e[1][2]=a-u,e[2][0]=c-m,e[2][1]=a+u,e[2][2]=1-(o+A),e}const gt=i=>Math.max(-1,Math.min(1,i));function xn(i,e="ZXY",t){const n=Lr(i),r=t??new ce;let o=0,s=0,c=0;switch(e){case"XYZ":s=Math.asin(gt(n[0][2])),Math.abs(n[0][2])<.9999999?(o=Math.atan2(-n[1][2],n[2][2]),c=Math.atan2(-n[0][1],n[0][0])):(o=Math.atan2(n[2][1],n[1][1]),c=0);break;case"YXZ":o=Math.asin(-gt(n[1][2])),Math.abs(n[1][2])<.9999999?(s=Math.atan2(n[0][2],n[2][2]),c=Math.atan2(n[1][0],n[1][1])):(s=Math.atan2(-n[2][0],n[0][0]),c=0);break;case"ZXY":o=Math.asin(gt(n[2][1])),Math.abs(n[2][1])<.9999999?(s=Math.atan2(-n[2][0],n[2][2]),c=Math.atan2(-n[0][1],n[1][1])):(s=0,c=Math.atan2(n[1][0],n[0][0]));break;case"ZYX":s=Math.asin(-gt(n[2][0])),Math.abs(n[2][0])<.9999999?(o=Math.atan2(n[2][1],n[2][2]),c=Math.atan2(n[1][0],n[0][0])):(o=0,c=Math.atan2(-n[0][1],n[1][1]));break;case"YZX":c=Math.asin(gt(n[1][0])),Math.abs(n[1][0])<.9999999?(o=Math.atan2(-n[1][2],n[1][1]),s=Math.atan2(-n[2][0],n[0][0])):(o=0,s=Math.atan2(n[0][2],n[2][2]));break;case"XZY":c=Math.asin(-gt(n[0][1])),Math.abs(n[0][1])<.9999999?(o=Math.atan2(n[2][1],n[1][1]),s=Math.atan2(n[0][2],n[0][0])):(o=Math.atan2(-n[1][2],n[2][2]),s=0);break}return r.set(o,s,c),r}class qe{loc;quat;scale;constructor(){this.loc=new ce,this.quat=new Me,this.scale=new ce(1,1,1)}set(e){return e instanceof qe?(this.loc.set(e.loc),this.quat.set(e.quat),this.scale.set(e.scale)):(e.getPosition(this.loc),e.getQuat(this.quat),e.getScale(this.scale)),this}write(e){e instanceof Oe?(e.object3D.position.set(this.loc.x,this.loc.y,this.loc.z),e.object3D.quaternion.set(this.quat.x,this.quat.y,this.quat.z,this.quat.w),e.object3D.scale.set(this.scale.x,this.scale.y,this.scale.z)):(e.position.set(this.loc.x,this.loc.y,this.loc.z),e.quaternion.set(this.quat.x,this.quat.y,this.quat.z,this.quat.w),e.scale.set(this.scale.x,this.scale.y,this.scale.z))}blend(e,t){return this.loc.lerp(this.loc,e.loc,t),this.quat.slerp(this.quat,e.quat,t),this.scale.lerp(this.scale,e.scale,t),this}clone(){const e=new qe;return e.set(this),e}}class vt{transform;constructor(){this.transform=new qe}init(e,t){this.transform.set(e)}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}isGrounded(){return this.transform.loc.y<=0}setPosition(e){this.transform.loc.set(e)}setPositionNow(e){this.transform.loc.set(e)}setQuat(e){this.transform.quat.set(e)}setQuatNow(e){this.transform.quat.set(e)}setScale(e){this.transform.scale.set(e)}setScaleNow(e){this.transform.scale.set(e)}setLinearVelocity(e){}getLinearVelocity(e){return e||new ce}setAngularVelocity(e){}getAngularVelocity(e){return e||new ce}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}update(e){}}class Jn{transform;constructor(){this.transform=new qe}init(e,t){this.transform.set(e)}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}isGrounded(){return this.transform.loc.y<=0}setPosition(e){}setPositionNow(e){}setQuat(e){}setQuatNow(e){}setScale(e){}setScaleNow(e){}setLinearVelocity(e){}getLinearVelocity(e){return e||new ce}setAngularVelocity(e){}getAngularVelocity(e){return e||new ce}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}update(e){}}const Xn={duration:1};class mn{options;startTransform;transform;endTransform;currentTime;duration;constructor(e={}){this.options={...Xn,...e},this.startTransform=new qe,this.transform=new qe,this.endTransform=new qe,this.currentTime=0,this.duration=this.options.duration}init(e,t){this.startTransform.set(e),this.transform.set(e),this.endTransform.set(e)}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}isGrounded(){return this.transform.loc.y<=0}setPosition(e){this.startTransform.set(this.transform),this.endTransform.loc.set(e),this.currentTime=0}setPositionNow(e){this.setPosition(e),this.currentTime=1}setQuat(e){this.startTransform.set(this.transform),this.endTransform.quat.set(e),this.currentTime=0}setQuatNow(e){this.setQuat(e),this.currentTime=1}setScale(e){this.startTransform.set(this.transform),this.endTransform.scale.set(e),this.currentTime=0}setScaleNow(e){this.setScale(e),this.currentTime=1}setLinearVelocity(e){}getLinearVelocity(e){e||(e=new ce);const t=this.endTransform.loc.x-this.startTransform.loc.x,n=this.endTransform.loc.y-this.startTransform.loc.y,r=this.endTransform.loc.z-this.startTransform.loc.z;e.set(t,n,r);const o=this.currentTime<this.duration?this.currentTime:this.duration;return e.scale((-6*o*o+6*o)/this.duration),e}setAngularVelocity(e){}getAngularVelocity(e){e||(e=new ce),xn(this.startTransform.quat,"ZXY",Nt),xn(this.endTransform.quat,"ZXY",Ft),e.set(Ft.x-Nt.x,Ft.y-Nt.y,Ft.z-Nt.z);const t=this.currentTime<this.duration?this.currentTime:this.duration;return e.scale((-6*t*t+6*t)/this.duration),e}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}smoothstep(e){return e*e*(3-2*e)}update(e){this.currentTime+=e,this.currentTime>this.duration&&(this.currentTime=this.duration);const t=this.currentTime/this.duration,n=this.smoothstep(t);this.transform.set(this.startTransform),this.transform.blend(this.endTransform,n)}}const ot=new ce,yt=new ce,ft=new Me,Dt=new qe,Nt=new ce,Ft=new ce,_r={up:new ce(0,1,0)};class Zn extends vt{up;target;constructor(e){super();const t={..._r,...e};this.target=t.target,this.up=t.up}setTarget(e){this.target=e}init(e,t){super.init(e,t),t.upVector?this.up=t.upVector:this.up=Oe.defaultUpVector}setQuat(e){}setQuatNow(e){}update(e){ot.set(this.transform.loc),this.target.getPosition(yt),st(ot,yt,this.up,ft),this.transform.quat.set(ft)}}const Dr={up:new ce(0,1,0),duration:1};class $n extends mn{up;target;constructor(e){super();const t={...Dr,...e};this.target=t.target,this.up=t.up,this.duration=t.duration}init(e,t){super.init(e,t),t.upVector?this.up=t.upVector:this.up=Oe.defaultUpVector}setQuat(e){}setQuatNow(e){}update(e){super.update(e),ot.set(this.transform.loc),this.target.getPosition(yt),st(ot,yt,this.up,ft),this.transform.quat.set(ft)}}const ei={lookFrom:{x:0,y:5,z:-10},smoothness:.9};class ti extends Jn{target;lookFrom;up;smoothness;constructor(e){super();const t={...ei,...e};this.target=t.target,this.lookFrom=t.lookFrom,this.target.upVector?this.up=this.target.upVector:this.up=Oe.defaultUpVector,this.smoothness=t.smoothness}init(e,t){super.init(e,t)}update(e){super.update(e),ot.set(this.transform.loc),this.target.getPosition(yt),st(ot,yt,this.up,ft),ft.mul(0,1,0,0),Dt.quat.set(ft),ot.set(this.lookFrom),ot.apply(this.target.getQuat()),ot.add(this.target.getPosition()),Dt.loc.set(ot),this.transform.loc.lerp(this.transform.loc,Dt.loc,1-this.smoothness),this.transform.quat.slerp(this.transform.quat,Dt.quat,1-this.smoothness)}}function Nr(i){return typeof i=="string"}function En(i){return i.isMesh===!0}function Fr(i){return i.type==="RoundedBoxGeometry"}function Or(i){return i.type==="BoxGeometry"}function Mr(i){return i.type==="SphereGeometry"}function Pr(i){return i.type==="IcosahedronGeometry"}function Gr(i){return i.type==="CylinderGeometry"}function Ur(i){return i.type==="CapsuleGeometry"}function jr(i){return i.isBone===!0}function Hr(i){return i.isPerspectiveCamera===!0}const qr={rigidBody:"dynamic",collider:"solid",meshCollider:"convex_hull",mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};let Pe;const tt=new Map;class Rt{static RAPIER;isInitialized=!1;constructor(){}async init(){if(!Rt.RAPIER){const e=await import("@dimforge/rapier3d-compat");await e.init(),Rt.RAPIER=e,Pe=e,this.isInitialized=!0}}createWorld(e){let t=.016666666666666666;this.isRapierWorldOptions(e)&&(t=e.timestep);const n=new Pe.World(e.gravity);return new In(n,t)}isRapierWorldOptions(e){return"timestep"in e}}class In{world;timestep;collisionEventQueue;kinematicCharacterCollisionEventQueue;constructor(e,t){this.world=e,this.timestep=t,this.collisionEventQueue=new Pe.EventQueue(!0),this.world.integrationParameters.dt=this.timestep,this.kinematicCharacterCollisionEventQueue=[]}add(e){e.addOneselfToPhysics(this)}remove(e){e.removeOneselfFromPhysics(this)}update(e){const t=Math.ceil(e/this.timestep);for(let n=0;n<t;n++)this.world.step(this.collisionEventQueue)}getCollisions(){const e=[];return this.collisionEventQueue.drainCollisionEvents((t,n,r)=>{const o=tt.get(t),s=tt.get(n);o&&s&&e.push({objectA:o,partOfA:t,objectB:s,partOfB:n,started:r})}),e.push(...this.kinematicCharacterCollisionEventQueue),this.kinematicCharacterCollisionEventQueue.length=0,e}}class zr{transform;objectA3;bodyDesc;body;colliderDescs;colliders;completeOptions;constructor(e={}){this.completeOptions={...qr,...e},this.transform=new qe,this.colliderDescs=[],this.colliders=[]}makeBodyDesc(){let e;switch(this.completeOptions.rigidBody){case"dynamic":e=Pe.RigidBodyDesc.dynamic();break;case"kinematic":e=Pe.RigidBodyDesc.kinematicPositionBased();break;case"fixed":e=Pe.RigidBodyDesc.fixed();break}return e.setTranslation(this.transform.loc.x,this.transform.loc.y,this.transform.loc.z),e.setRotation({x:this.transform.quat.x,y:this.transform.quat.y,z:this.transform.quat.z,w:this.transform.quat.w}),e}configColliderDescs(){if(!this.objectA3)return;const e=this.completeOptions,t=[];this.objectA3.object3D.traverse(r=>{if(En(r)){const o=Wr(r.geometry),s=e.membership<<16|e.filter;if(o)o.colliderDesc.setCollisionGroups(s),e.collisionDetection&&o.colliderDesc.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(o.colliderDesc),o.colliderDesc.setRestitution(e.restitution).setFriction(e.friction),t.push(o.volume);else{let c,A;switch(e.meshCollider){case"tri_mesh":c=Vr(r),A=Ln(r.geometry);break;case"convex_hull":c=Kr(r),A=Ln(r.geometry);break}c&&(c.setCollisionGroups(s),e.collisionDetection&&c.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),c.setRestitution(e.restitution).setFriction(e.friction),this.colliderDescs.push(c),t.push(A))}}});let n=t.reduce((r,o)=>r+o,0);for(let r=0;r<this.colliderDescs.length;r++)this.colliderDescs[r].setRestitution(e.restitution),this.colliderDescs[r].setFriction(e.friction),this.colliderDescs[r].setMass(e.mass*(t[r]/n))}init(e,t){this.transform.set(e),this.objectA3=t,this.colliderDescs=[],this.colliders=[],this.bodyDesc=this.makeBodyDesc(),this.configColliderDescs(),this.bodyDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.bodyDesc.setRotation(e.quat)}addOneselfToPhysics(e){this.bodyDesc&&(this.body=e.world.createRigidBody(this.bodyDesc),this.colliderDescs.forEach(t=>{const n=e.world.createCollider(t,this.body);this.colliders.push(n),this.objectA3&&tt.set(n.handle,this.objectA3)}),this.body.setTranslation(this.transform.loc,!0),this.body.setRotation(this.transform.quat,!0))}removeOneselfFromPhysics(e){this.colliders.forEach(t=>{e.world.removeCollider(t,!0),tt.delete(t.handle)}),this.colliders.length=0,this.body&&(e.world.removeRigidBody(this.body),this.body=void 0)}isGrounded(){return this.transform.loc.y<=0}setPosition(e){}setPositionNow(e){this.body?this.body.setTranslation(e,!0):this.bodyDesc?.setTranslation(e.x,e.y,e.z),this.transform.loc.set(e)}setQuat(e){}setQuatNow(e){this.body?this.body.setRotation(e,!0):this.bodyDesc?.setRotation(e),this.transform.quat.set(e)}setScale(e){}setScaleNow(e){}setLinearVelocity(e){this.body?this.body.setLinvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setLinvel(e.x,e.y,e.z)}getLinearVelocity(e){return e||(e=new ce),this.body?e.set(this.body.linvel()):this.bodyDesc&&e.set(this.bodyDesc.linvel),e}setAngularVelocity(e){this.body?this.body.setAngvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setAngvel({x:e.x,y:e.y,z:e.z})}getAngularVelocity(e){return e||(e=new ce),this.body?e.set(this.body.angvel()):this.bodyDesc&&e.set(this.bodyDesc.angvel),e}resetForce(){this.body?.resetForces(!0)}addForce(e){this.body?.addForce({x:e.x,y:e.y,z:e.z},!0)}addForceAtPoint(e,t){this.body?.addForceAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}resetTorque(){this.body?.resetTorques(!0)}addTorque(e){this.body?.addTorque({x:e.x,y:e.y,z:e.z},!0)}applyImpulse(e){this.body?.applyImpulse({x:e.x,y:e.y,z:e.z},!0)}applyImpulseAtPoint(e,t){this.body?.applyImpulseAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}applyTorqueImpulse(e){this.body?.applyTorqueImpulse({x:e.x,y:e.y,z:e.z},!0)}update(e){if(this.body){const t=this.body.translation();this.transform.loc.set(t.x,t.y,t.z);const n=this.body.rotation();this.transform.quat.set(n.x,n.y,n.z,n.w)}}}function Vr(i){let e=null;if(En(i)){const t=i;t.updateWorldMatrix(!0,!0);const n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);const r=n.attributes.position.array;let o=n.index?n.index.array:null;if(o)o instanceof Uint32Array||(o=new Uint32Array(o));else{const s=n.attributes.position.count;o=new Uint32Array(s);for(let c=0;c<s;c++)o[c]=c}r instanceof Float32Array&&(e=Pe.ColliderDesc.trimesh(r,o))}return e}function Kr(i){let e=null;if(En(i)){const t=i;t.updateWorldMatrix(!0,!0);const n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);const r=n.attributes.position.array;r instanceof Float32Array&&(e=Pe.ColliderDesc.convexHull(r))}return e}function Ln(i){const e=i.attributes.position;if(!e)throw new Error("position attribute not found");const t=i.index,n=e.array;let r=0;const o=new K.Vector3,s=new K.Vector3,c=new K.Vector3;if(t){const A=t.array;for(let a=0;a<A.length;a+=3){const h=A[a]*3,u=A[a+1]*3,m=A[a+2]*3;o.set(n[h],n[h+1],n[h+2]),s.set(n[u],n[u+1],n[u+2]),c.set(n[m],n[m+1],n[m+2]),r+=o.dot(s.clone().cross(c))}}else for(let A=0;A<n.length;A+=9)o.set(n[A],n[A+1],n[A+2]),s.set(n[A+3],n[A+4],n[A+5]),c.set(n[A+6],n[A+7],n[A+8]),r+=o.dot(s.clone().cross(c));return Math.abs(r)/6}function Wr(i){if(Fr(i)){const e=i.parameters,t=typeof e?.width=="number"?e.width/2:.5,n=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5,o=.1;return{colliderDesc:Pe.ColliderDesc.roundCuboid(t-o,n-o,r-o,o),volume:2*t*2*n*2*r}}else if(Or(i)){const e=i.parameters,t=typeof e?.width=="number"?e.width/2:.5,n=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5;return{colliderDesc:Pe.ColliderDesc.cuboid(t,n,r),volume:2*t*2*n*2*r}}else if(Mr(i)){const e=i.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Pe.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Pr(i)){const e=i.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Pe.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Gr(i)){const e=i.parameters,t=typeof e?.radiusBottom=="number"?e.radiusBottom:.5,n=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Pe.ColliderDesc.cylinder(n/2,t),volume:Math.PI*t*t*n}}else if(Ur(i)){const e=i.parameters,t=typeof e?.radius=="number"?e.radius:.5,n=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Pe.ColliderDesc.capsule(n/2,t),volume:4/3*Math.PI*t*t*t+Math.PI*t*t*n}}return null}const An=new Rt;async function Yr(){await An.init()}const x={v0:new ce,v1:new ce,v2:new ce,v3:new ce,v4:new ce,q0:new Me,q1:new Me,q2:new Me,q3:new Me,q4:new Me,t0:new qe,t1:new qe,t2:new qe,t3:new qe,t4:new qe};function Jr(i){return new Promise(e=>{setTimeout(()=>{e()},i)})}async function ni(i){const t=await(await fetch(i)).arrayBuffer(),n=await new Promise((r,o)=>{Yn.unzip(new Uint8Array(t),(s,c)=>{s?o(s):r(c)})});return{zipUrl:i,unzipped:n}}function Ot(i,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),i.unzipped[e])return Yn.strFromU8(i.unzipped[e]);throw new Error(`readStringFromUnzippedA3(): no file at ${e}`)}function cn(i,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),i.unzipped[e]){const t=Zr(e);return new Blob([new Uint8Array(i.unzipped[e])],{type:t})}else throw new Error(`readBlobFromUnzippedA3(): no file at ${e}`)}const Xr={"image/png":/\.png$/i,"image/jpeg":/\.(jpg|jpeg)$/i,"image/gif":/\.gif$/i,"model/vrml":/\.wrl$/i,"application/xml":/\.xml$/i,"application/octet-stream":/\.bvh/i,"audio/x-wav":/\.wav/i,"audio/mpeg":/\.mp3/i,"audio/ogg":/\.ogg/i,"text/plain":/\.(txt|text)$/i,"model/gltf+json":/\.gltf$/i,"model/gltf-binary":/\.glb$/i};function Zr(i){for(const[e,t]of Object.entries(Xr))if(t.test(i))return e;return"application/octet-stream"}function Pt(i,e){if(!e)return i;const t={...i};for(const n in e)typeof i[n]=="object"&&typeof e[n]=="object"?t[n]=Pt(i[n],e[n]):t[n]=e[n];return t}const ii={offset:.01,auto:!0,height:1.5,radius:.3,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1,pushDynamic:!1};class ri{transform;objectA3;completeOptions;controller;colliderDesc;collider;capsuleCenter;nextLocation;tmpV1;tmpV2;tmpQ1;world;constructor(e={}){this.completeOptions={...ii,...e},this.transform=new qe,this.capsuleCenter=new ce,this.nextLocation=new ce,this.tmpV1=new ce,this.tmpV2=new ce,this.tmpQ1=new Me}init(e,t){if(this.transform.set(e),this.objectA3=t,this.completeOptions.auto){const o=new K.Vector3,s=new K.Quaternion,c=new K.Object3D;c.add(t.object3D),t.getPosition(this.tmpV1),this.tmpV1.write(o),c.position.set(o.x,o.y,o.z),t.getQuat(this.tmpQ1),this.tmpQ1.write(s),c.quaternion.set(s.x,s.y,s.z,s.w),t.getScale(this.tmpV2),this.tmpV2.write(o),c.scale.set(o.x,o.y,o.z);const A=new K.Box3().setFromObject(c);c.remove(t.object3D),A.getSize(o),this.completeOptions.radius=Math.max(o.x,o.z)/2,this.completeOptions.height=o.y-this.completeOptions.radius*2,A.getCenter(o),this.capsuleCenter.set(o)}const n=this.completeOptions;this.colliderDesc=Pe.ColliderDesc.capsule(this.completeOptions.height,this.completeOptions.radius);const r=n.membership<<16|n.filter;this.colliderDesc.setCollisionGroups(r),n.collisionDetection&&this.colliderDesc.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),this.colliderDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.colliderDesc.setRotation({x:e.quat.x,y:e.quat.y,z:e.quat.z,w:e.quat.w})}addOneselfToPhysics(e){this.world=e,this.controller=e.world.createCharacterController(this.completeOptions.offset),this.controller.setApplyImpulsesToDynamicBodies(this.completeOptions.pushDynamic),this.colliderDesc&&(this.collider=e.world.createCollider(this.colliderDesc)),this.collider&&this.objectA3&&tt.set(this.collider.handle,this.objectA3)}removeOneselfFromPhysics(e){this.collider&&(e.world.removeCollider(this.collider,!1),tt.delete(this.collider.handle),this.collider=void 0),this.controller&&e.world.removeCharacterController(this.controller)}setPosition(e){this.tmpV1.set(e),this.tmpV1.add(this.capsuleCenter),this.nextLocation.set(this.tmpV1)}setPositionNow(e){this.tmpV1.set(e),this.tmpV1.add(this.capsuleCenter),this.collider&&this.collider.setTranslation(this.tmpV1),this.transform.loc.set(e),this.nextLocation.set(this.tmpV1)}setQuat(e){this.collider&&this.collider.setRotation(e),this.transform.quat.set(e)}setQuatNow(e){this.collider&&this.collider.setRotation(e),this.transform.quat.set(e)}setScale(e){}setScaleNow(e){}setLinearVelocity(e){}getLinearVelocity(e){return e||(e=new ce),e.set(0,0,0),e}setAngularVelocity(e){}getAngularVelocity(e){return e||(e=new ce),e.set(0,0,0),e}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}isGrounded(){return this.controller?this.controller.computedGrounded():!1}update(e){if(!this.controller||!this.collider)return;this.transform.quat.set(this.collider.rotation()),this.tmpV1.set(this.collider.translation()),this.tmpV2.set(this.nextLocation),this.tmpV2.sub(this.tmpV1),this.controller.computeColliderMovement(this.collider,this.tmpV2);const t=this.controller.computedMovement();if(this.tmpV1.add(t),this.collider.setTranslation(this.tmpV1),this.tmpV1.sub(this.capsuleCenter),this.transform.loc.set(this.tmpV1),this.nextLocation.set(this.tmpV1),!this.collider||!this.world||!this.objectA3)return;const r=(this.collider.activeEvents()&Pe.ActiveEvents.COLLISION_EVENTS)!==0,o=this.collider.collisionGroups();for(let s=0;s<this.controller.numComputedCollisions();s++){let c=this.controller.computedCollision(s);if(c&&c.collider){const a=(c.collider.activeEvents()&Pe.ActiveEvents.COLLISION_EVENTS)!==0;if(!r&&!a)continue;const h=tt.get(c.collider.handle);if(!h)continue;const u=c.collider.collisionGroups();$r(o,u)&&this.world.kinematicCharacterCollisionEventQueue.push({objectA:this.objectA3,partOfA:this.collider.handle,objectB:h,partOfB:c.collider.handle,started:!0})}}}}function $r(i,e){const t=i>>>16,n=i&65535,r=e>>>16,o=e&65535;return(n&r)!==0&&(o&t)!==0}const oi={auto:!0,height:1.5,radius:.3,mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};class si{transform;objectA3;completeOptions;colliderDesc;collider;bodyDesc;body;capsuleCenter;tmpV1;tmpV2;tmpQ1;physicsWorld;constructor(e={}){this.completeOptions={...oi,...e},this.transform=new qe,this.capsuleCenter=new ce,this.tmpV1=new ce,this.tmpV2=new ce,this.tmpQ1=new Me}init(e,t){if(this.transform.set(e),this.objectA3=t,this.completeOptions.auto){const o=new K.Vector3,s=new K.Quaternion,c=new K.Object3D;c.add(t.object3D),t.getPosition(this.tmpV1),this.tmpV1.write(o),c.position.set(o.x,o.y,o.z),t.getQuat(this.tmpQ1),this.tmpQ1.write(s),c.quaternion.set(s.x,s.y,s.z,s.w),t.getScale(this.tmpV2),this.tmpV2.write(o),c.scale.set(o.x,o.y,o.z);const A=new K.Box3().setFromObject(c);A.getSize(o),this.completeOptions.radius=Math.max(o.x,o.z)/2,this.completeOptions.height=o.y-this.completeOptions.radius*2,A.getCenter(o),this.capsuleCenter.set(o)}const n=this.completeOptions;this.bodyDesc=Pe.RigidBodyDesc.dynamic(),this.bodyDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.bodyDesc.setRotation(e.quat),this.colliderDesc=Pe.ColliderDesc.capsule(this.completeOptions.height,this.completeOptions.radius),this.colliderDesc.setMass(n.mass);const r=n.membership<<16|n.filter;this.colliderDesc.setCollisionGroups(r),n.collisionDetection&&this.colliderDesc.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),this.colliderDesc.setRestitution(n.restitution).setFriction(n.friction)}addOneselfToPhysics(e){this.physicsWorld=e,this.bodyDesc&&(this.body=e.world.createRigidBody(this.bodyDesc),this.body.setEnabledRotations(!1,!1,!1,!0),this.body.setTranslation(this.transform.loc,!0),this.body.setRotation(this.transform.quat,!0)),this.colliderDesc&&(this.collider=e.world.createCollider(this.colliderDesc,this.body)),this.collider&&this.objectA3&&tt.set(this.collider.handle,this.objectA3)}removeOneselfFromPhysics(e){this.collider&&(e.world.removeCollider(this.collider,!0),tt.delete(this.collider.handle),this.collider=void 0),this.body&&(e.world.removeRigidBody(this.body),this.body=void 0),this.physicsWorld=void 0}setPosition(e){}setPositionNow(e){this.tmpV1.set(e),this.tmpV1.add(this.capsuleCenter),this.body?this.body.setTranslation(this.tmpV1,!0):this.bodyDesc?.setTranslation(this.tmpV1.x,this.tmpV1.y,this.tmpV1.z),this.transform.loc.set(e)}setQuat(e){this.body?this.body.setRotation(e,!0):this.bodyDesc?.setRotation(e),this.transform.quat.set(e)}setQuatNow(e){this.body?this.body.setRotation(e,!0):this.bodyDesc?.setRotation(e),this.transform.quat.set(e)}setScale(e){}setScaleNow(e){}setLinearVelocity(e){this.body?this.body.setLinvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setLinvel(e.x,e.y,e.z)}getLinearVelocity(e){return e||(e=new ce),this.body?e.set(this.body.linvel()):this.bodyDesc&&e.set(this.bodyDesc.linvel),e}setAngularVelocity(e){this.body?this.body.setAngvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setAngvel({x:e.x,y:e.y,z:e.z})}getAngularVelocity(e){return e||(e=new ce),this.body?e.set(this.body.angvel()):this.bodyDesc&&e.set(this.bodyDesc.angvel),e}resetForce(){this.body?.resetForces(!0)}addForce(e){this.body?.addForce({x:e.x,y:e.y,z:e.z},!0)}addForceAtPoint(e,t){this.body?.addForceAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}resetTorque(){this.body?.resetTorques(!0)}addTorque(e){this.body?.addTorque({x:e.x,y:e.y,z:e.z},!0)}applyImpulse(e){this.body?.applyImpulse({x:e.x,y:e.y,z:e.z},!0)}applyImpulseAtPoint(e,t){this.body?.applyImpulseAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}applyTorqueImpulse(e){this.body?.applyTorqueImpulse({x:e.x,y:e.y,z:e.z},!0)}isGrounded(){if(this.body&&this.physicsWorld){const e=this.body.translation(),t=new Pe.Ray(e,{x:0,y:-1,z:0}),n=1.1*(this.completeOptions.height+this.completeOptions.radius);return this.physicsWorld.world.castRay(t,n,!0,void 0,void 0,this.collider)!==null}else return this.transform.loc.y<=0}update(e){if(!this.body)return;const t=new ce(this.body.translation());t.sub(this.capsuleCenter),this.transform.loc.set(t),this.transform.quat.set(this.body.rotation())}}const eo=new K.SphereGeometry,to=new K.MeshStandardMaterial({color:16711680});let no=new K.Mesh(eo,to);class Oe{static defaultRotationOrder="ZXY";static defaultUpVector=new ce(0,1,0);rotationOrder;upVector;object3D;scene;balloon;transformer;parent;children=[];clickListener;constructor(e){this.transformer=this.initTransformer(e),this.object3D=new K.Object3D;const t=this.initObject(e);t&&this.object3D.add(t),this.object3D.traverse(n=>{n.userData.a3js={objectA3:this}})}initObject(e){return no.clone()}initTransformer(e){return new vt}setTransformer(e){x.t0.set(this.transformer.transform),e.init(x.t0,this),this.transformer=e}getTransformer(){return this.transformer}setMode(e,t){e==="Default"?this.setTransformer(new vt):e==="Smooth"?this.setTransformer(new mn(t)):e==="Follow"?this.setTransformer(new ti(t)):e==="Billboard"?this.setTransformer(new Zn(t)):e==="SmoothBillboard"?this.setTransformer(new $n(t)):e==="SimplePhysics"?this.setTransformer(new zr(t)):e==="KinematicCharacter"?this.setTransformer(new ri(t)):e==="DynamicCharacter"&&this.setTransformer(new si(t))}update(e){this.transformer.update(e),this.transformer.transform.write(this),this.children.forEach(t=>{t.update(e)})}add(e){if(e.scene){console.warn("ObjectA3.add(obj) is ignored.");return}if(e.parent){console.warn("ObjectA3.add(obj) is ignored.");return}this.children.push(e),e.parent=this,this.object3D.add(e.object3D)}remove(e){if(e.parent!==this){console.warn("ObjectA3.remove(obj) is ignored.");return}const t=this.children.indexOf(e);this.children.splice(t,1),e.parent=void 0,this.object3D.remove(e.object3D)}setSpeechBubble(e){this.balloon?this.balloon.message=e:this.balloon=new io(e)}setClickListener(e){this.clickListener=e}handleCollision(e,t,n,r){}async clicked(){this.clickListener&&await this.clickListener(this)}setCastShadow(e){this.object3D.traverse(t=>{t instanceof K.Mesh&&(t.castShadow=e)})}setReceiveShadow(e){this.object3D.traverse(t=>{t instanceof K.Mesh&&(t.receiveShadow=e)})}setLightShadow(e){this.object3D.traverse(t=>{(t instanceof K.DirectionalLight||t instanceof K.SpotLight||t instanceof K.PointLight)&&(t.castShadow=e)})}getPosition(e){return e?(e.set(this.transformer.transform.loc),e):this.transformer.transform.loc.clone()}setPosition(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setPosition(x.v0)}setPositionNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setPositionNow(x.v0)}getQuat(e){return e?(e.set(this.transformer.transform.quat),e):this.transformer.transform.quat.clone()}setQuat(e,t,n,r){typeof e=="number"?x.q0.set(e,t,n,r):x.q0.set(e),this.transformer.setQuat(x.q0)}setQuatNow(e,t,n,r){typeof e=="number"?x.q0.set(e,t,n,r):x.q0.set(e),this.transformer.setQuatNow(x.q0)}getScale(e){return e?(e.set(this.transformer.transform.scale),e):this.transformer.transform.scale.clone()}setScale(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setScale(x.v0)}setScaleNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setScaleNow(x.v0)}setRotation(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q1),this.setQuat(x.q1)}setRotationNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q0),this.setQuatNow(x.q0)}lookAt(e,t,n){typeof e=="number"?x.v1.set(e,t,n):e instanceof Oe?x.v1.set(e.transformer.transform.loc):x.v1.set(e);const r=this.upVector?this.upVector:Oe.defaultUpVector;st(this.transformer.transform.loc,x.v1,r,x.q1),this.setQuat(x.q1)}lookAtNow(e,t,n){typeof e=="number"?x.v1.set(e,t,n):e instanceof Oe?x.v1.set(e.transformer.transform.loc):x.v1.set(e);const r=this.upVector?this.upVector:Oe.defaultUpVector;st(this.transformer.transform.loc,x.v1,r,x.q1),this.setQuatNow(x.q1)}getUnitVecX(e){return e?(e.set(1,0,0),e.apply(this.object3D.quaternion)):new ce(1,0,0).apply(this.object3D.quaternion)}getUnitVecY(e){return e?(e.set(0,1,0),e.apply(this.object3D.quaternion)):new ce(0,1,0).apply(this.object3D.quaternion)}getUnitVecZ(e){return e?(e.set(0,0,1),e.apply(this.object3D.quaternion)):new ce(0,0,1).apply(this.object3D.quaternion)}translate(e,t,n){x.v1.set(this.transformer.transform.loc),typeof e=="number"?x.v1.add(e,t,n):x.v1.add(e),this.setPosition(x.v1)}translateNow(e,t,n){x.v1.set(this.transformer.transform.loc),typeof e=="number"?x.v1.add(e,t,n):x.v1.add(e),this.setPositionNow(x.v1)}mulQuat(e,t,n,r){x.q1.set(this.transformer.transform.quat),typeof e=="number"?x.q1.mul(e,t,n,r):x.q1.mul(e),this.setQuat(x.q1)}mulQuatNow(e,t,n,r){x.q1.set(this.transformer.transform.quat),typeof e=="number"?x.q1.mul(e,t,n,r):x.q1.mul(e),this.setQuatNow(x.q1)}mulRotation(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q1),this.getQuat(x.q0),x.q0.mul(x.q1),this.setQuat(x.q0)}mulRotationNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q1),this.getQuat(x.q0),x.q0.mul(x.q1),this.setQuatNow(x.q0)}scaleBy(e,t,n){this.getScale(x.v0),typeof e=="number"?x.v0.set(x.v0.x*e,x.v0.y*t,x.v0.z*n):x.v0.set(x.v0.x*e.x,x.v0.y*e.y,x.v0.z*e.z),this.setScale(x.v0)}mulScaleNow(e,t,n){this.getScale(x.v0),typeof e=="number"?x.v0.set(x.v0.x*e,x.v0.y*t,x.v0.z*n):x.v0.set(x.v0.x*e.x,x.v0.y*e.y,x.v0.z*e.z),this.setScaleNow(x.v0)}moveForward(e){this.getUnitVecZ(x.v0),x.v0.scale(e),this.translate(x.v0)}moveForwardNow(e){this.getUnitVecZ(x.v0),x.v0.scale(e),this.translateNow(x.v0)}moveBackward(e){this.getUnitVecZ(x.v0),x.v0.scale(-e),this.translate(x.v0)}moveBackwardNow(e){this.getUnitVecZ(x.v0),x.v0.scale(-e),this.translateNow(x.v0)}moveRight(e){this.getUnitVecX(x.v0),x.v0.scale(-e),this.translate(x.v0)}moveRightNow(e){this.getUnitVecX(x.v0),x.v0.scale(-e),this.translateNow(x.v0)}moveLeft(e){this.getUnitVecX(x.v0),x.v0.scale(e),this.translate(x.v0)}moveLeftNow(e){this.getUnitVecX(x.v0),x.v0.scale(e),this.translateNow(x.v0)}moveUp(e){this.getUnitVecY(x.v0),x.v0.scale(e),this.translate(x.v0)}moveUpNow(e){this.getUnitVecY(x.v0),x.v0.scale(e),this.translateNow(x.v0)}moveDown(e){this.getUnitVecY(x.v0),x.v0.scale(-e),this.translate(x.v0)}moveDownNow(e){this.getUnitVecY(x.v0),x.v0.scale(-e),this.translateNow(x.v0)}turnUp(e){this.mulRotation(-e,0,0)}turnUpNow(e){this.mulRotationNow(-e,0,0)}turnDown(e){this.mulRotation(e,0,0)}turnDownNow(e){this.mulRotationNow(e,0,0)}turnRight(e){this.mulRotation(0,-e,0)}turnRightNow(e){this.mulRotationNow(0,-e,0)}turnLeft(e){this.mulRotation(0,e,0)}turnLeftNow(e){this.mulRotationNow(0,e,0)}rollRight(e){this.mulRotation(0,0,e)}rollRightNow(e){this.mulRotationNow(0,0,e)}rollLeft(e){this.mulRotation(0,0,-e)}rollLeftNow(e){this.mulRotationNow(0,0,-e)}setLinearVelocity(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setLinearVelocity(x.v0)}getLinearVelocity(e){return this.transformer.getLinearVelocity(e)}setAngularVelocity(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setAngularVelocity(x.v0)}getAngularVelocity(e){return this.transformer.getAngularVelocity(e)}resetForce(){this.transformer.resetForce()}addForce(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.addForce(x.v0)}addForceAtPoint(e,t,n,r,o,s){if(typeof e=="number")if(typeof t=="number")x.v0.set(e,t,n),x.v1.set(r,o,s);else{console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else if(typeof t=="number"){console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else x.v0.set(e),x.v1.set(t);this.transformer.addForceAtPoint(x.v0,x.v1)}resetTorque(){this.transformer.resetTorque()}addTorque(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.addTorque(x.v0)}applyImpulse(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.applyImpulse(x.v0)}applyImpulseAtPoint(e,t,n,r,o,s){if(typeof e=="number")if(typeof t=="number")x.v0.set(e,t,n),x.v1.set(r,o,s);else{console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else if(typeof t=="number"){console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else x.v0.set(e),x.v1.set(t);this.transformer.applyImpulseAtPoint(x.v0,x.v1)}applyTorqueImpulse(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.applyTorqueImpulse(x.v0)}addOneselfToPhysics(e){this.transformer.addOneselfToPhysics(e)}removeOneselfFromPhysics(e){this.transformer.removeOneselfFromPhysics(e)}isGrounded(){return this.transformer.isGrounded()}}class io{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 bn{shape;motion;constructor(e,t){this.shape=e,this.motion=t}enable(e,t){this.motion.playCount=0,this.motion.time=0,e.add(this.shape.root)}disable(e,t){e.remove(this.shape.root)}}class bt extends Oe{ready;actions;currentAction;stateAction;emoteAction;morphs;overwriteMorphs;autoAction=!1;autoDirection=!1;haltActionName="default";walkActionName="walk";runActionName="run";minWalkSpeed=.1;minRunSpeed=1;constructor(e){super(e),this.actions={},this.morphs={},this.overwriteMorphs=!1,this.ready=this.asyncInit(e),this.autoAction=!1,this.autoDirection=!1}syncInit(e,t,n={}){this.actions=t,this.stateAction=this.actions[e],this.currentAction=this.stateAction,this.object3D.clear(),this.morphs=n,this.stateAction?.enable(this.object3D,this.scene)}setActions(e){this.actions=e}getAction(e){return this.actions[e]}addAction(e,t){this.actions[e]=t}removeAction(e){const t=this.actions[e];return delete this.actions[e],t}getActionNames(){return Object.keys(this.actions)}setState(e){const t=this.actions[e];t&&(this.currentAction&&this.currentAction.disable(this.object3D,this.scene),t.enable(this.object3D,this.scene),this.currentAction=t,this.stateAction=t)}setEmote(e){const t=this.actions[e];t&&(this.currentAction&&this.currentAction.disable(this.object3D,this.scene),t.enable(this.object3D,this.scene),this.currentAction=t,this.emoteAction=t)}setMorphsOverwrite(e){this.overwriteMorphs=e}setMorph(e,t){if(e in this.morphs){const{array:n,idx:r}=this.morphs[e];n[r]=t}}getMorphNames(){return Object.keys(this.morphs)}pose={};update(e){super.update(e);let t;if(this.emoteAction&&this.emoteAction.motion.playCount<=0?(t=this.emoteAction.motion.update(e),this.emoteAction.motion.playCount>0&&(this.emoteAction.disable(this.object3D,this.scene),this.emoteAction=void 0,this.stateAction&&(this.stateAction.enable(this.object3D,this.scene),this.currentAction=this.stateAction))):this.stateAction&&(t=this.stateAction.motion.update(e)),t&&this.currentAction&&this.currentAction.shape.bones)for(const[o,s]of Object.entries(t)){const c=this.currentAction.shape.bones[o];if(c&&(s.loc&&c.position.set(s.loc.x,s.loc.y,s.loc.z),s.quat&&c.quaternion.set(s.quat.x,s.quat.y,s.quat.z,s.quat.w),s.scale&&c.scale.set(s.scale.x,s.scale.y,s.scale.z)),!this.overwriteMorphs&&s.morphs){for(const A of s.morphs)for(const a of Object.keys(this.morphs))if(a.startsWith(A.name)){const{array:h}=this.morphs[a];for(let u=0;u<h.length;u++)h[u]=A.vals[u];break}}}this.object3D.updateMatrixWorld(!0),this.currentAction&&this.currentAction.shape.skeleton?.update();const n=this.getLinearVelocity(),r=n.length();if(this.autoAction&&(r<this.minWalkSpeed?this.actions[this.haltActionName]!==this.stateAction&&this.setState(this.haltActionName):r<this.minRunSpeed?this.actions[this.walkActionName]!==this.stateAction&&this.setState(this.walkActionName):this.actions[this.runActionName]!==this.stateAction&&this.setState(this.runActionName)),this.autoDirection&&r>1e-4){n.normalize(),x.v0.set(0,0,0);const o=this.upVector?this.upVector:Oe.defaultUpVector;st(x.v0,n,o,x.q0),this.setQuatNow(x.q0)}}setAutoAction(e){this.autoAction=e}setAutoDirection(e){this.autoDirection=e}}class _n{name;playCount;time;finishListener;constructor(){this.name="dummy",this.playCount=0,this.time=0}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}setPause(e){}setTime(e){}setFinishListener(e){this.finishListener=e}update(e){return{}}}var ve=(i,e)=>()=>(e||(e={exports:{}},i(e.exports,e)),e.exports),ai=ve(i=>{Object.defineProperty(i,"__esModule",{value:!0}),i.VERSION=void 0,i.VERSION="9.0.1"}),Ne=ve((i,e)=>{var t=i&&i.__spreadArray||function(O,J){for(var q=0,re=J.length,fe=O.length;q<re;q++,fe++)O[fe]=J[q];return O};Object.defineProperty(i,"__esModule",{value:!0}),i.toFastProperties=i.timer=i.peek=i.isES2015MapSupported=i.PRINT_WARNING=i.PRINT_ERROR=i.packArray=i.IDENTITY=i.NOOP=i.merge=i.groupBy=i.defaults=i.assignNoOverwrite=i.assign=i.zipObject=i.sortBy=i.indexOf=i.some=i.difference=i.every=i.isObject=i.isRegExp=i.isArray=i.partial=i.uniq=i.compact=i.reduce=i.findAll=i.find=i.cloneObj=i.cloneArr=i.contains=i.has=i.pick=i.reject=i.filter=i.dropRight=i.drop=i.isFunction=i.isUndefined=i.isString=i.forEach=i.last=i.first=i.flatten=i.map=i.mapValues=i.values=i.keys=i.isEmpty=void 0;function n(O){return O&&O.length===0}i.isEmpty=n;function r(O){return O==null?[]:Object.keys(O)}i.keys=r;function o(O){for(var J=[],q=Object.keys(O),re=0;re<q.length;re++)J.push(O[q[re]]);return J}i.values=o;function s(O,J){for(var q=[],re=r(O),fe=0;fe<re.length;fe++){var Qe=re[fe];q.push(J.call(null,O[Qe],Qe))}return q}i.mapValues=s;function c(O,J){for(var q=[],re=0;re<O.length;re++)q.push(J.call(null,O[re],re));return q}i.map=c;function A(O){for(var J=[],q=0;q<O.length;q++){var re=O[q];Array.isArray(re)?J=J.concat(A(re)):J.push(re)}return J}i.flatten=A;function a(O){return n(O)?void 0:O[0]}i.first=a;function h(O){var J=O&&O.length;return J?O[J-1]:void 0}i.last=h;function u(O,J){if(Array.isArray(O))for(var q=0;q<O.length;q++)J.call(null,O[q],q);else if(Z(O))for(var re=r(O),q=0;q<re.length;q++){var fe=re[q],Qe=O[fe];J.call(null,Qe,fe)}else throw Error("non exhaustive match")}i.forEach=u;function m(O){return typeof O=="string"}i.isString=m;function p(O){return O===void 0}i.isUndefined=p;function E(O){return O instanceof Function}i.isFunction=E;function g(O,J){return J===void 0&&(J=1),O.slice(J,O.length)}i.drop=g;function l(O,J){return J===void 0&&(J=1),O.slice(0,O.length-J)}i.dropRight=l;function d(O,J){var q=[];if(Array.isArray(O))for(var re=0;re<O.length;re++){var fe=O[re];J.call(null,fe)&&q.push(fe)}return q}i.filter=d;function f(O,J){return d(O,function(q){return!J(q)})}i.reject=f;function C(O,J){for(var q=Object.keys(O),re={},fe=0;fe<q.length;fe++){var Qe=q[fe],ye=O[Qe];J(ye)&&(re[Qe]=ye)}return re}i.pick=C;function I(O,J){return Z(O)?O.hasOwnProperty(J):!1}i.has=I;function y(O,J){return H(O,function(q){return q===J})!==void 0}i.contains=y;function v(O){for(var J=[],q=0;q<O.length;q++)J.push(O[q]);return J}i.cloneArr=v;function L(O){var J={};for(var q in O)Object.prototype.hasOwnProperty.call(O,q)&&(J[q]=O[q]);return J}i.cloneObj=L;function H(O,J){for(var q=0;q<O.length;q++){var re=O[q];if(J.call(null,re))return re}}i.find=H;function Q(O,J){for(var q=[],re=0;re<O.length;re++){var fe=O[re];J.call(null,fe)&&q.push(fe)}return q}i.findAll=Q;function P(O,J,q){for(var re=Array.isArray(O),fe=re?O:o(O),Qe=re?[]:r(O),ye=q,le=0;le<fe.length;le++)ye=J.call(null,ye,fe[le],re?le:Qe[le]);return ye}i.reduce=P;function D(O){return f(O,function(J){return J==null})}i.compact=D;function R(O,J){J===void 0&&(J=function(re){return re});var q=[];return P(O,function(re,fe){var Qe=J(fe);return y(q,Qe)?re:(q.push(Qe),re.concat(fe))},[])}i.uniq=R;function F(O){for(var J=[],q=1;q<arguments.length;q++)J[q-1]=arguments[q];var re=[null],fe=re.concat(J);return Function.bind.apply(O,fe)}i.partial=F;function _(O){return Array.isArray(O)}i.isArray=_;function X(O){return O instanceof RegExp}i.isRegExp=X;function Z(O){return O instanceof Object}i.isObject=Z;function V(O,J){for(var q=0;q<O.length;q++)if(!J(O[q],q))return!1;return!0}i.every=V;function $(O,J){return f(O,function(q){return y(J,q)})}i.difference=$;function ie(O,J){for(var q=0;q<O.length;q++)if(J(O[q]))return!0;return!1}i.some=ie;function ue(O,J){for(var q=0;q<O.length;q++)if(O[q]===J)return q;return-1}i.indexOf=ue;function ae(O,J){var q=v(O);return q.sort(function(re,fe){return J(re)-J(fe)}),q}i.sortBy=ae;function se(O,J){if(O.length!==J.length)throw Error("can't zipObject with different number of keys and values!");for(var q={},re=0;re<O.length;re++)q[O[re]]=J[re];return q}i.zipObject=se;function ee(O){for(var J=[],q=1;q<arguments.length;q++)J[q-1]=arguments[q];for(var re=0;re<J.length;re++)for(var fe=J[re],Qe=r(fe),ye=0;ye<Qe.length;ye++){var le=Qe[ye];O[le]=fe[le]}return O}i.assign=ee;function de(O){for(var J=[],q=1;q<arguments.length;q++)J[q-1]=arguments[q];for(var re=0;re<J.length;re++)for(var fe=J[re],Qe=r(fe),ye=0;ye<Qe.length;ye++){var le=Qe[ye];I(O,le)||(O[le]=fe[le])}return O}i.assignNoOverwrite=de;function G(){for(var O=[],J=0;J<arguments.length;J++)O[J]=arguments[J];return de.apply(void 0,t([{}],O))}i.defaults=G;function j(O,J){var q={};return u(O,function(re){var fe=J(re),Qe=q[fe];Qe?Qe.push(re):q[fe]=[re]}),q}i.groupBy=j;function Y(O,J){for(var q=L(O),re=r(J),fe=0;fe<re.length;fe++){var Qe=re[fe],ye=J[Qe];q[Qe]=ye}return q}i.merge=Y;function z(){}i.NOOP=z;function te(O){return O}i.IDENTITY=te;function oe(O){for(var J=[],q=0;q<O.length;q++){var re=O[q];J.push(re!==void 0?re:void 0)}return J}i.packArray=oe;function Be(O){console&&console.error&&console.error("Error: "+O)}i.PRINT_ERROR=Be;function we(O){console&&console.warn&&console.warn("Warning: "+O)}i.PRINT_WARNING=we;function De(){return typeof Map=="function"}i.isES2015MapSupported=De;function ze(O){return O[O.length-1]}i.peek=ze;function Je(O){var J=new Date().getTime(),q=O(),re=new Date().getTime(),fe=re-J;return{time:fe,value:q}}i.timer=Je;function Ve(O){function J(){}J.prototype=O;var q=new J;function re(){return typeof q.bar}return re(),re(),O}i.toFastProperties=Ve}),Cn=ve((i,e)=>{(function(t,n){typeof define=="function"&&define.amd?define([],n):typeof e=="object"&&e.exports?e.exports=n():t.regexpToAst=n()})(typeof self<"u"?self:i,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(l){this.idx=l.idx,this.input=l.input,this.groupIdx=l.groupIdx},t.prototype.pattern=function(l){this.idx=0,this.input=l,this.groupIdx=0,this.consumeChar("/");var d=this.disjunction();this.consumeChar("/");for(var f={type:"Flags",loc:{begin:this.idx,end:l.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":A(f,"global");break;case"i":A(f,"ignoreCase");break;case"m":A(f,"multiLine");break;case"u":A(f,"unicode");break;case"y":A(f,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:f,value:d,loc:this.loc(0)}},t.prototype.disjunction=function(){var l=[],d=this.idx;for(l.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),l.push(this.alternative());return{type:"Disjunction",value:l,loc:this.loc(d)}},t.prototype.alternative=function(){for(var l=[],d=this.idx;this.isTerm();)l.push(this.term());return{type:"Alternative",value:l,loc:this.loc(d)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var l=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(l)};case"$":return{type:"EndAnchor",loc:this.loc(l)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(l)};case"B":return{type:"NonWordBoundary",loc:this.loc(l)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var d;switch(this.popChar()){case"=":d="Lookahead";break;case"!":d="NegativeLookahead";break}a(d);var f=this.disjunction();return this.consumeChar(")"),{type:d,value:f,loc:this.loc(l)}}h()},t.prototype.quantifier=function(l){var d,f=this.idx;switch(this.popChar()){case"*":d={atLeast:0,atMost:1/0};break;case"+":d={atLeast:1,atMost:1/0};break;case"?":d={atLeast:0,atMost:1};break;case"{":var C=this.integerIncludingZero();switch(this.popChar()){case"}":d={atLeast:C,atMost:C};break;case",":var I;this.isDigit()?(I=this.integerIncludingZero(),d={atLeast:C,atMost:I}):d={atLeast:C,atMost:1/0},this.consumeChar("}");break}if(l===!0&&d===void 0)return;a(d);break}if(!(l===!0&&d===void 0))return a(d),this.peekChar(0)==="?"?(this.consumeChar("?"),d.greedy=!1):d.greedy=!0,d.type="Quantifier",d.loc=this.loc(f),d},t.prototype.atom=function(){var l,d=this.idx;switch(this.peekChar()){case".":l=this.dotAll();break;case"\\":l=this.atomEscape();break;case"[":l=this.characterClass();break;case"(":l=this.group();break}return l===void 0&&this.isPatternCharacter()&&(l=this.patternCharacter()),a(l),l.loc=this.loc(d),this.isQuantifier()&&(l.quantifier=this.quantifier()),l},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[s(`
1
+ "use strict";var wr=Object.create;var Sn=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var Rr=Object.getPrototypeOf,Qr=Object.prototype.hasOwnProperty;var kr=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vr(e))!Qr.call(i,r)&&r!==t&&Sn(i,r,{get:()=>e[r],enumerable:!(n=Tr(e,r))||n.enumerable});return i};var Sr=(i,e,t)=>(t=i!=null?wr(Rr(i)):{},kr(e||!i||!i.__esModule?Sn(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("three"),Yn=require("fflate");function xr(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const K=xr(b);class ce{x=0;y=0;z=0;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)}clone(){return new ce(this)}write(e){e.x=this.x,e.y=this.y,e.z=this.z}normalize(){const e=this.x*this.x+this.y*this.y+this.z*this.z,t=Math.sqrt(e);return t!==0?(this.x/=t,this.y/=t,this.z/=t):console.warn("Vec3.normalize."),this}negate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.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,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}sub(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}scale(e){return this.x*=e,this.y*=e,this.z*=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e,t){return this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this}apply(e,t,n,r){let o,s,c,A;typeof e=="number"?(o=e,s=t,c=n,A=r):(o=e.x,s=e.y,c=e.z,A=e.w);const a=2*(s*this.z-c*this.y),h=2*(c*this.x-o*this.z),u=2*(o*this.y-s*this.x);return this.x+=A*a+s*u-c*h,this.y+=A*h+c*a-o*u,this.z+=A*u+o*h-s*a,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 Me{x=0;y=0;z=0;w=1;constructor(e,t,n,r){typeof e=="number"?(this.x=e,this.y=t,this.z=n,this.w=r):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)}clone(){return new Me(this)}write(e){e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w}normalize(){const e=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w,t=Math.sqrt(e);return t!==0?(this.x/=t,this.y/=t,this.z/=t,this.w/=t):console.warn("Quat.normalize."),this}conjugate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}set(e,t,n,r){return typeof e=="number"?(this.x=e,this.y=t,this.z=n,this.w=r):(this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w),this}mul(e,t,n,r){const o=this.x,s=this.y,c=this.z,A=this.w;let a,h,u,m;return typeof e=="number"?(a=e,h=t,u=n,m=r):(a=e.x,h=e.y,u=e.z,m=e.w),this.x=A*a+o*m+s*u-c*h,this.y=A*h-o*u+s*m+c*a,this.z=A*u+o*h-s*a+c*m,this.w=A*m-o*a-s*h-c*u,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.w+n*t.w}slerp(e,t,n){if(n<0||n>1){console.warn("Quat.slerp(): t must be in [0,1]");return}let r=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(Xe.set(t),r<0&&(r*=-1,Xe.set(-Xe.x,-Xe.y,-Xe.z,-Xe.w)),r>.9995){this.x=(1-n)*e.x+n*Xe.x,this.y=(1-n)*e.y+n*Xe.y,this.z=(1-n)*e.z+n*Xe.z,this.w=(1-n)*e.w+n*Xe.w;const o=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);o<1e-4?(console.warn("Quat.slerp(); ???!"),this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w):(this.x*=1/o,this.y*=1/o,this.z*=1/o,this.w*=1/o)}else{const o=Math.acos(r),s=Math.sin((1-n)*o)/Math.sin(o),c=Math.sin(n*o)/Math.sin(o);this.x=s*e.x+c*Xe.x,this.y=s*e.y+c*Xe.y,this.z=s*e.z+c*Xe.z,this.w=s*e.w+c*Xe.w}}}const Xe=new Me;function st(i,e,t,n){t.normalize();const r=i.clone().sub(e).normalize(),o=new ce().cross(r,t).normalize(),s=new ce().cross(o,r),c=o.x,A=s.x,a=-r.x,h=o.y,u=s.y,m=-r.y,p=o.z,E=s.z,g=-r.z;let l,d,f,C;const I=c+u+g;if(I>0){const v=Math.sqrt(I+1)*2;l=(E-m)/v,d=(a-p)/v,f=(h-A)/v,C=.25*v}else if(c>u&&c>g){const v=Math.sqrt(1+c-u-g)*2;l=.25*v,d=(A+h)/v,f=(a+p)/v,C=(E-m)/v}else if(u>g){const v=Math.sqrt(1+u-c-g)*2;l=(A+h)/v,d=.25*v,f=(m+E)/v,C=(a-p)/v}else{const v=Math.sqrt(1+g-c-u)*2;l=(a+p)/v,d=(m+E)/v,f=.25*v,C=(h-A)/v}const y=n??new Me;return y.set(l,d,f,C),y}function ht(i,e="ZXY",t){const n=t!==void 0?t.set(0,0,0,1):new Me(0,0,0,1);for(let r=0;r<3;r++)switch(e.charAt(r)){case"X":n.mul(Math.sin(i.x),0,0,Math.cos(i.x));break;case"Y":n.mul(0,Math.sin(i.y),0,Math.cos(i.y));break;case"Z":n.mul(0,0,Math.sin(i.z),Math.cos(i.z));break}return n}function Lr(i){const e=[[],[],[]],t=i.x+i.x,n=i.y+i.y,r=i.z+i.z,o=i.x*t,s=i.x*n,c=i.x*r,A=i.y*n,a=i.y*r,h=i.z*r,u=i.w*t,m=i.w*n,p=i.w*r;return e[0][0]=1-(A+h),e[0][1]=s-p,e[0][2]=c+m,e[1][0]=s+p,e[1][1]=1-(o+h),e[1][2]=a-u,e[2][0]=c-m,e[2][1]=a+u,e[2][2]=1-(o+A),e}const gt=i=>Math.max(-1,Math.min(1,i));function xn(i,e="ZXY",t){const n=Lr(i),r=t??new ce;let o=0,s=0,c=0;switch(e){case"XYZ":s=Math.asin(gt(n[0][2])),Math.abs(n[0][2])<.9999999?(o=Math.atan2(-n[1][2],n[2][2]),c=Math.atan2(-n[0][1],n[0][0])):(o=Math.atan2(n[2][1],n[1][1]),c=0);break;case"YXZ":o=Math.asin(-gt(n[1][2])),Math.abs(n[1][2])<.9999999?(s=Math.atan2(n[0][2],n[2][2]),c=Math.atan2(n[1][0],n[1][1])):(s=Math.atan2(-n[2][0],n[0][0]),c=0);break;case"ZXY":o=Math.asin(gt(n[2][1])),Math.abs(n[2][1])<.9999999?(s=Math.atan2(-n[2][0],n[2][2]),c=Math.atan2(-n[0][1],n[1][1])):(s=0,c=Math.atan2(n[1][0],n[0][0]));break;case"ZYX":s=Math.asin(-gt(n[2][0])),Math.abs(n[2][0])<.9999999?(o=Math.atan2(n[2][1],n[2][2]),c=Math.atan2(n[1][0],n[0][0])):(o=0,c=Math.atan2(-n[0][1],n[1][1]));break;case"YZX":c=Math.asin(gt(n[1][0])),Math.abs(n[1][0])<.9999999?(o=Math.atan2(-n[1][2],n[1][1]),s=Math.atan2(-n[2][0],n[0][0])):(o=0,s=Math.atan2(n[0][2],n[2][2]));break;case"XZY":c=Math.asin(-gt(n[0][1])),Math.abs(n[0][1])<.9999999?(o=Math.atan2(n[2][1],n[1][1]),s=Math.atan2(n[0][2],n[0][0])):(o=Math.atan2(-n[1][2],n[2][2]),s=0);break}return r.set(o,s,c),r}class qe{loc;quat;scale;constructor(){this.loc=new ce,this.quat=new Me,this.scale=new ce(1,1,1)}set(e){return e instanceof qe?(this.loc.set(e.loc),this.quat.set(e.quat),this.scale.set(e.scale)):(e.getPosition(this.loc),e.getQuat(this.quat),e.getScale(this.scale)),this}write(e){e instanceof Oe?(e.object3D.position.set(this.loc.x,this.loc.y,this.loc.z),e.object3D.quaternion.set(this.quat.x,this.quat.y,this.quat.z,this.quat.w),e.object3D.scale.set(this.scale.x,this.scale.y,this.scale.z)):(e.position.set(this.loc.x,this.loc.y,this.loc.z),e.quaternion.set(this.quat.x,this.quat.y,this.quat.z,this.quat.w),e.scale.set(this.scale.x,this.scale.y,this.scale.z))}blend(e,t){return this.loc.lerp(this.loc,e.loc,t),this.quat.slerp(this.quat,e.quat,t),this.scale.lerp(this.scale,e.scale,t),this}clone(){const e=new qe;return e.set(this),e}}class vt{transform;constructor(){this.transform=new qe}init(e,t){this.transform.set(e)}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}isGrounded(){return this.transform.loc.y<=0}setPosition(e){this.transform.loc.set(e)}setPositionNow(e){this.transform.loc.set(e)}setQuat(e){this.transform.quat.set(e)}setQuatNow(e){this.transform.quat.set(e)}setScale(e){this.transform.scale.set(e)}setScaleNow(e){this.transform.scale.set(e)}setLinearVelocity(e){}getLinearVelocity(e){return e||new ce}setAngularVelocity(e){}getAngularVelocity(e){return e||new ce}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}update(e){}}class Jn{transform;constructor(){this.transform=new qe}init(e,t){this.transform.set(e)}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}isGrounded(){return this.transform.loc.y<=0}setPosition(e){}setPositionNow(e){}setQuat(e){}setQuatNow(e){}setScale(e){}setScaleNow(e){}setLinearVelocity(e){}getLinearVelocity(e){return e||new ce}setAngularVelocity(e){}getAngularVelocity(e){return e||new ce}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}update(e){}}const Xn={duration:1};class mn{options;startTransform;transform;endTransform;currentTime;duration;constructor(e={}){this.options={...Xn,...e},this.startTransform=new qe,this.transform=new qe,this.endTransform=new qe,this.currentTime=0,this.duration=this.options.duration}init(e,t){this.startTransform.set(e),this.transform.set(e),this.endTransform.set(e)}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}isGrounded(){return this.transform.loc.y<=0}setPosition(e){this.startTransform.set(this.transform),this.endTransform.loc.set(e),this.currentTime=0}setPositionNow(e){this.setPosition(e),this.currentTime=1}setQuat(e){this.startTransform.set(this.transform),this.endTransform.quat.set(e),this.currentTime=0}setQuatNow(e){this.setQuat(e),this.currentTime=1}setScale(e){this.startTransform.set(this.transform),this.endTransform.scale.set(e),this.currentTime=0}setScaleNow(e){this.setScale(e),this.currentTime=1}setLinearVelocity(e){}getLinearVelocity(e){e||(e=new ce);const t=this.endTransform.loc.x-this.startTransform.loc.x,n=this.endTransform.loc.y-this.startTransform.loc.y,r=this.endTransform.loc.z-this.startTransform.loc.z;e.set(t,n,r);const o=this.currentTime<this.duration?this.currentTime:this.duration;return e.scale((-6*o*o+6*o)/this.duration),e}setAngularVelocity(e){}getAngularVelocity(e){e||(e=new ce),xn(this.startTransform.quat,"ZXY",Nt),xn(this.endTransform.quat,"ZXY",Ft),e.set(Ft.x-Nt.x,Ft.y-Nt.y,Ft.z-Nt.z);const t=this.currentTime<this.duration?this.currentTime:this.duration;return e.scale((-6*t*t+6*t)/this.duration),e}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}smoothstep(e){return e*e*(3-2*e)}update(e){this.currentTime+=e,this.currentTime>this.duration&&(this.currentTime=this.duration);const t=this.currentTime/this.duration,n=this.smoothstep(t);this.transform.set(this.startTransform),this.transform.blend(this.endTransform,n)}}const ot=new ce,yt=new ce,ft=new Me,Dt=new qe,Nt=new ce,Ft=new ce,_r={up:new ce(0,1,0)};class Zn extends vt{up;target;constructor(e){super();const t={..._r,...e};this.target=t.target,this.up=t.up}setTarget(e){this.target=e}init(e,t){super.init(e,t),t.upVector?this.up=t.upVector:this.up=Oe.defaultUpVector}setQuat(e){}setQuatNow(e){}update(e){ot.set(this.transform.loc),this.target.getPosition(yt),st(ot,yt,this.up,ft),this.transform.quat.set(ft)}}const Dr={up:new ce(0,1,0),duration:1};class $n extends mn{up;target;constructor(e){super();const t={...Dr,...e};this.target=t.target,this.up=t.up,this.duration=t.duration}init(e,t){super.init(e,t),t.upVector?this.up=t.upVector:this.up=Oe.defaultUpVector}setQuat(e){}setQuatNow(e){}update(e){super.update(e),ot.set(this.transform.loc),this.target.getPosition(yt),st(ot,yt,this.up,ft),this.transform.quat.set(ft)}}const ei={lookFrom:{x:0,y:5,z:-10},smoothness:.9};class ti extends Jn{target;lookFrom;up;smoothness;constructor(e){super();const t={...ei,...e};this.target=t.target,this.lookFrom=t.lookFrom,this.target.upVector?this.up=this.target.upVector:this.up=Oe.defaultUpVector,this.smoothness=t.smoothness}init(e,t){super.init(e,t)}update(e){super.update(e),ot.set(this.transform.loc),this.target.getPosition(yt),st(ot,yt,this.up,ft),ft.mul(0,1,0,0),Dt.quat.set(ft),ot.set(this.lookFrom),ot.apply(this.target.getQuat()),ot.add(this.target.getPosition()),Dt.loc.set(ot),this.transform.loc.lerp(this.transform.loc,Dt.loc,1-this.smoothness),this.transform.quat.slerp(this.transform.quat,Dt.quat,1-this.smoothness)}}function Nr(i){return typeof i=="string"}function En(i){return i.isMesh===!0}function Fr(i){return i.type==="RoundedBoxGeometry"}function Or(i){return i.type==="BoxGeometry"}function Mr(i){return i.type==="SphereGeometry"}function Pr(i){return i.type==="IcosahedronGeometry"}function Gr(i){return i.type==="CylinderGeometry"}function Ur(i){return i.type==="CapsuleGeometry"}function jr(i){return i.isBone===!0}function Hr(i){return i.isPerspectiveCamera===!0}const qr={rigidBody:"dynamic",collider:"solid",meshCollider:"convex_hull",mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};let Pe;const tt=new Map;class Rt{static RAPIER;isInitialized=!1;constructor(){}async init(){if(!Rt.RAPIER){const e=await import("@dimforge/rapier3d-compat");await e.init(),Rt.RAPIER=e,Pe=e,this.isInitialized=!0}}createWorld(e){let t=.016666666666666666;this.isRapierWorldOptions(e)&&(t=e.timestep);const n=new Pe.World(e.gravity);return new In(n,t)}isRapierWorldOptions(e){return"timestep"in e}}class In{world;timestep;collisionEventQueue;kinematicCharacterCollisionEventQueue;constructor(e,t){this.world=e,this.timestep=t,this.collisionEventQueue=new Pe.EventQueue(!0),this.world.integrationParameters.dt=this.timestep,this.kinematicCharacterCollisionEventQueue=[]}add(e){e.addOneselfToPhysics(this)}remove(e){e.removeOneselfFromPhysics(this)}update(e){const t=Math.ceil(e/this.timestep);for(let n=0;n<t;n++)this.world.step(this.collisionEventQueue)}getCollisions(){const e=[];return this.collisionEventQueue.drainCollisionEvents((t,n,r)=>{const o=tt.get(t),s=tt.get(n);o&&s&&e.push({objectA:o,partOfA:t,objectB:s,partOfB:n,started:r})}),e.push(...this.kinematicCharacterCollisionEventQueue),this.kinematicCharacterCollisionEventQueue.length=0,e}}class zr{transform;objectA3;bodyDesc;body;colliderDescs;colliders;completeOptions;constructor(e={}){this.completeOptions={...qr,...e},this.transform=new qe,this.colliderDescs=[],this.colliders=[]}makeBodyDesc(){let e;switch(this.completeOptions.rigidBody){case"dynamic":e=Pe.RigidBodyDesc.dynamic();break;case"kinematic":e=Pe.RigidBodyDesc.kinematicPositionBased();break;case"fixed":e=Pe.RigidBodyDesc.fixed();break}return e.setTranslation(this.transform.loc.x,this.transform.loc.y,this.transform.loc.z),e.setRotation({x:this.transform.quat.x,y:this.transform.quat.y,z:this.transform.quat.z,w:this.transform.quat.w}),e}configColliderDescs(){if(!this.objectA3)return;const e=this.completeOptions,t=[];this.objectA3.object3D.traverse(r=>{if(En(r)){const o=Wr(r.geometry),s=e.membership<<16|e.filter;if(o)o.colliderDesc.setCollisionGroups(s),e.collisionDetection&&o.colliderDesc.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),this.colliderDescs.push(o.colliderDesc),o.colliderDesc.setRestitution(e.restitution).setFriction(e.friction),t.push(o.volume);else{let c,A;switch(e.meshCollider){case"tri_mesh":c=Vr(r),A=Ln(r.geometry);break;case"convex_hull":c=Kr(r),A=Ln(r.geometry);break}c&&(c.setCollisionGroups(s),e.collisionDetection&&c.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),c.setRestitution(e.restitution).setFriction(e.friction),this.colliderDescs.push(c),t.push(A))}}});let n=t.reduce((r,o)=>r+o,0);for(let r=0;r<this.colliderDescs.length;r++)this.colliderDescs[r].setRestitution(e.restitution),this.colliderDescs[r].setFriction(e.friction),this.colliderDescs[r].setMass(e.mass*(t[r]/n))}init(e,t){this.transform.set(e),this.objectA3=t,this.colliderDescs=[],this.colliders=[],this.bodyDesc=this.makeBodyDesc(),this.configColliderDescs(),this.bodyDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.bodyDesc.setRotation(e.quat)}addOneselfToPhysics(e){this.bodyDesc&&(this.body=e.world.createRigidBody(this.bodyDesc),this.colliderDescs.forEach(t=>{const n=e.world.createCollider(t,this.body);this.colliders.push(n),this.objectA3&&tt.set(n.handle,this.objectA3)}),this.body.setTranslation(this.transform.loc,!0),this.body.setRotation(this.transform.quat,!0))}removeOneselfFromPhysics(e){this.colliders.forEach(t=>{e.world.removeCollider(t,!0),tt.delete(t.handle)}),this.colliders.length=0,this.body&&(e.world.removeRigidBody(this.body),this.body=void 0)}isGrounded(){return this.transform.loc.y<=0}setPosition(e){}setPositionNow(e){this.body?this.body.setTranslation(e,!0):this.bodyDesc?.setTranslation(e.x,e.y,e.z),this.transform.loc.set(e)}setQuat(e){}setQuatNow(e){this.body?this.body.setRotation(e,!0):this.bodyDesc?.setRotation(e),this.transform.quat.set(e)}setScale(e){}setScaleNow(e){}setLinearVelocity(e){this.body?this.body.setLinvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setLinvel(e.x,e.y,e.z)}getLinearVelocity(e){return e||(e=new ce),this.body?e.set(this.body.linvel()):this.bodyDesc&&e.set(this.bodyDesc.linvel),e}setAngularVelocity(e){this.body?this.body.setAngvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setAngvel({x:e.x,y:e.y,z:e.z})}getAngularVelocity(e){return e||(e=new ce),this.body?e.set(this.body.angvel()):this.bodyDesc&&e.set(this.bodyDesc.angvel),e}resetForce(){this.body?.resetForces(!0)}addForce(e){this.body?.addForce({x:e.x,y:e.y,z:e.z},!0)}addForceAtPoint(e,t){this.body?.addForceAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}resetTorque(){this.body?.resetTorques(!0)}addTorque(e){this.body?.addTorque({x:e.x,y:e.y,z:e.z},!0)}applyImpulse(e){this.body?.applyImpulse({x:e.x,y:e.y,z:e.z},!0)}applyImpulseAtPoint(e,t){this.body?.applyImpulseAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}applyTorqueImpulse(e){this.body?.applyTorqueImpulse({x:e.x,y:e.y,z:e.z},!0)}update(e){if(this.body){const t=this.body.translation();this.transform.loc.set(t.x,t.y,t.z);const n=this.body.rotation();this.transform.quat.set(n.x,n.y,n.z,n.w)}}}function Vr(i){let e=null;if(En(i)){const t=i;t.updateWorldMatrix(!0,!0);const n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);const r=n.attributes.position.array;let o=n.index?n.index.array:null;if(o)o instanceof Uint32Array||(o=new Uint32Array(o));else{const s=n.attributes.position.count;o=new Uint32Array(s);for(let c=0;c<s;c++)o[c]=c}r instanceof Float32Array&&(e=Pe.ColliderDesc.trimesh(r,o))}return e}function Kr(i){let e=null;if(En(i)){const t=i;t.updateWorldMatrix(!0,!0);const n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);const r=n.attributes.position.array;r instanceof Float32Array&&(e=Pe.ColliderDesc.convexHull(r))}return e}function Ln(i){const e=i.attributes.position;if(!e)throw new Error("position attribute not found");const t=i.index,n=e.array;let r=0;const o=new K.Vector3,s=new K.Vector3,c=new K.Vector3;if(t){const A=t.array;for(let a=0;a<A.length;a+=3){const h=A[a]*3,u=A[a+1]*3,m=A[a+2]*3;o.set(n[h],n[h+1],n[h+2]),s.set(n[u],n[u+1],n[u+2]),c.set(n[m],n[m+1],n[m+2]),r+=o.dot(s.clone().cross(c))}}else for(let A=0;A<n.length;A+=9)o.set(n[A],n[A+1],n[A+2]),s.set(n[A+3],n[A+4],n[A+5]),c.set(n[A+6],n[A+7],n[A+8]),r+=o.dot(s.clone().cross(c));return Math.abs(r)/6}function Wr(i){if(Fr(i)){const e=i.parameters,t=typeof e?.width=="number"?e.width/2:.5,n=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5,o=.1;return{colliderDesc:Pe.ColliderDesc.roundCuboid(t-o,n-o,r-o,o),volume:2*t*2*n*2*r}}else if(Or(i)){const e=i.parameters,t=typeof e?.width=="number"?e.width/2:.5,n=typeof e?.height=="number"?e.height/2:.5,r=typeof e?.depth=="number"?e.depth/2:.5;return{colliderDesc:Pe.ColliderDesc.cuboid(t,n,r),volume:2*t*2*n*2*r}}else if(Mr(i)){const e=i.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Pe.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Pr(i)){const e=i.parameters,t=typeof e?.radius=="number"?e.radius:1;return{colliderDesc:Pe.ColliderDesc.ball(t),volume:4/3*Math.PI*t*t*t}}else if(Gr(i)){const e=i.parameters,t=typeof e?.radiusBottom=="number"?e.radiusBottom:.5,n=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Pe.ColliderDesc.cylinder(n/2,t),volume:Math.PI*t*t*n}}else if(Ur(i)){const e=i.parameters,t=typeof e?.radius=="number"?e.radius:.5,n=typeof e?.height=="number"?e.height:.5;return{colliderDesc:Pe.ColliderDesc.capsule(n/2,t),volume:4/3*Math.PI*t*t*t+Math.PI*t*t*n}}return null}const An=new Rt;async function Yr(){await An.init()}const x={v0:new ce,v1:new ce,v2:new ce,v3:new ce,v4:new ce,q0:new Me,q1:new Me,q2:new Me,q3:new Me,q4:new Me,t0:new qe,t1:new qe,t2:new qe,t3:new qe,t4:new qe};function Jr(i){return new Promise(e=>{setTimeout(()=>{e()},i)})}async function ni(i){const t=await(await fetch(i)).arrayBuffer(),n=await new Promise((r,o)=>{Yn.unzip(new Uint8Array(t),(s,c)=>{s?o(s):r(c)})});return{zipUrl:i,unzipped:n}}function Ot(i,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),i.unzipped[e])return Yn.strFromU8(i.unzipped[e]);throw new Error(`readStringFromUnzippedA3(): no file at ${e}`)}function cn(i,e){if(e=e.replace(/^\.\//,"").replace(/^\//,""),i.unzipped[e]){const t=Zr(e);return new Blob([new Uint8Array(i.unzipped[e])],{type:t})}else throw new Error(`readBlobFromUnzippedA3(): no file at ${e}`)}const Xr={"image/png":/\.png$/i,"image/jpeg":/\.(jpg|jpeg)$/i,"image/gif":/\.gif$/i,"model/vrml":/\.wrl$/i,"application/xml":/\.xml$/i,"application/octet-stream":/\.bvh/i,"audio/x-wav":/\.wav/i,"audio/mpeg":/\.mp3/i,"audio/ogg":/\.ogg/i,"text/plain":/\.(txt|text)$/i,"model/gltf+json":/\.gltf$/i,"model/gltf-binary":/\.glb$/i};function Zr(i){for(const[e,t]of Object.entries(Xr))if(t.test(i))return e;return"application/octet-stream"}function Pt(i,e){if(!e)return i;const t={...i};for(const n in e)typeof i[n]=="object"&&typeof e[n]=="object"?t[n]=Pt(i[n],e[n]):t[n]=e[n];return t}const ii={offset:.01,auto:!0,height:1.5,radius:.3,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1,pushDynamic:!1};class ri{transform;objectA3;completeOptions;controller;colliderDesc;collider;capsuleCenter;nextLocation;tmpV1;tmpV2;tmpQ1;world;constructor(e={}){this.completeOptions={...ii,...e},this.transform=new qe,this.capsuleCenter=new ce,this.nextLocation=new ce,this.tmpV1=new ce,this.tmpV2=new ce,this.tmpQ1=new Me}init(e,t){if(this.transform.set(e),this.objectA3=t,this.completeOptions.auto){const o=new K.Vector3,s=new K.Quaternion,c=new K.Object3D;c.add(t.object3D),t.getPosition(this.tmpV1),this.tmpV1.write(o),c.position.set(o.x,o.y,o.z),t.getQuat(this.tmpQ1),this.tmpQ1.write(s),c.quaternion.set(s.x,s.y,s.z,s.w),t.getScale(this.tmpV2),this.tmpV2.write(o),c.scale.set(o.x,o.y,o.z);const A=new K.Box3().setFromObject(c);c.remove(t.object3D),A.getSize(o),this.completeOptions.radius=Math.max(o.x,o.z)/2,this.completeOptions.height=o.y-this.completeOptions.radius*2,A.getCenter(o),this.capsuleCenter.set(o)}const n=this.completeOptions;this.colliderDesc=Pe.ColliderDesc.capsule(this.completeOptions.height,this.completeOptions.radius);const r=n.membership<<16|n.filter;this.colliderDesc.setCollisionGroups(r),n.collisionDetection&&this.colliderDesc.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),this.colliderDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.colliderDesc.setRotation({x:e.quat.x,y:e.quat.y,z:e.quat.z,w:e.quat.w})}addOneselfToPhysics(e){this.world=e,this.controller=e.world.createCharacterController(this.completeOptions.offset),this.controller.setApplyImpulsesToDynamicBodies(this.completeOptions.pushDynamic),this.colliderDesc&&(this.collider=e.world.createCollider(this.colliderDesc)),this.collider&&this.objectA3&&tt.set(this.collider.handle,this.objectA3)}removeOneselfFromPhysics(e){this.collider&&(e.world.removeCollider(this.collider,!1),tt.delete(this.collider.handle),this.collider=void 0),this.controller&&e.world.removeCharacterController(this.controller)}setPosition(e){this.tmpV1.set(e),this.tmpV1.add(this.capsuleCenter),this.nextLocation.set(this.tmpV1)}setPositionNow(e){this.tmpV1.set(e),this.tmpV1.add(this.capsuleCenter),this.collider&&this.collider.setTranslation(this.tmpV1),this.transform.loc.set(e),this.nextLocation.set(this.tmpV1)}setQuat(e){this.collider&&this.collider.setRotation(e),this.transform.quat.set(e)}setQuatNow(e){this.collider&&this.collider.setRotation(e),this.transform.quat.set(e)}setScale(e){}setScaleNow(e){}setLinearVelocity(e){}getLinearVelocity(e){return e||(e=new ce),e.set(0,0,0),e}setAngularVelocity(e){}getAngularVelocity(e){return e||(e=new ce),e.set(0,0,0),e}resetForce(){}addForce(e){}addForceAtPoint(e,t){}resetTorque(){}addTorque(e){}applyImpulse(e){}applyImpulseAtPoint(e,t){}applyTorqueImpulse(e){}isGrounded(){return this.controller?this.controller.computedGrounded():!1}update(e){if(!this.controller||!this.collider)return;this.transform.quat.set(this.collider.rotation()),this.tmpV1.set(this.collider.translation()),this.tmpV2.set(this.nextLocation),this.tmpV2.sub(this.tmpV1),this.controller.computeColliderMovement(this.collider,this.tmpV2);const t=this.controller.computedMovement();if(this.tmpV1.add(t),this.collider.setTranslation(this.tmpV1),this.tmpV1.sub(this.capsuleCenter),this.transform.loc.set(this.tmpV1),this.nextLocation.set(this.tmpV1),!this.collider||!this.world||!this.objectA3)return;const r=(this.collider.activeEvents()&Pe.ActiveEvents.COLLISION_EVENTS)!==0,o=this.collider.collisionGroups();for(let s=0;s<this.controller.numComputedCollisions();s++){let c=this.controller.computedCollision(s);if(c&&c.collider){const a=(c.collider.activeEvents()&Pe.ActiveEvents.COLLISION_EVENTS)!==0;if(!r&&!a)continue;const h=tt.get(c.collider.handle);if(!h)continue;const u=c.collider.collisionGroups();$r(o,u)&&this.world.kinematicCharacterCollisionEventQueue.push({objectA:this.objectA3,partOfA:this.collider.handle,objectB:h,partOfB:c.collider.handle,started:!0})}}}}function $r(i,e){const t=i>>>16,n=i&65535,r=e>>>16,o=e&65535;return(n&r)!==0&&(o&t)!==0}const oi={auto:!0,height:1.5,radius:.3,mass:1,friction:.5,restitution:.5,membership:1,filter:1,collisionDetection:!1};class si{transform;objectA3;completeOptions;colliderDesc;collider;bodyDesc;body;capsuleCenter;tmpV1;tmpV2;tmpQ1;physicsWorld;constructor(e={}){this.completeOptions={...oi,...e},this.transform=new qe,this.capsuleCenter=new ce,this.tmpV1=new ce,this.tmpV2=new ce,this.tmpQ1=new Me}init(e,t){if(this.transform.set(e),this.objectA3=t,this.completeOptions.auto){const o=new K.Vector3,s=new K.Quaternion,c=new K.Object3D;c.add(t.object3D),t.getPosition(this.tmpV1),this.tmpV1.write(o),c.position.set(o.x,o.y,o.z),t.getQuat(this.tmpQ1),this.tmpQ1.write(s),c.quaternion.set(s.x,s.y,s.z,s.w),t.getScale(this.tmpV2),this.tmpV2.write(o),c.scale.set(o.x,o.y,o.z);const A=new K.Box3().setFromObject(c);A.getSize(o),this.completeOptions.radius=Math.max(o.x,o.z)/2,this.completeOptions.height=o.y-this.completeOptions.radius*2,A.getCenter(o),this.capsuleCenter.set(o)}const n=this.completeOptions;this.bodyDesc=Pe.RigidBodyDesc.dynamic(),this.bodyDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.bodyDesc.setRotation(e.quat),this.colliderDesc=Pe.ColliderDesc.capsule(this.completeOptions.height,this.completeOptions.radius),this.colliderDesc.setMass(n.mass);const r=n.membership<<16|n.filter;this.colliderDesc.setCollisionGroups(r),n.collisionDetection&&this.colliderDesc.setActiveEvents(Pe.ActiveEvents.COLLISION_EVENTS),this.colliderDesc.setRestitution(n.restitution).setFriction(n.friction)}addOneselfToPhysics(e){this.physicsWorld=e,this.bodyDesc&&(this.body=e.world.createRigidBody(this.bodyDesc),this.body.setEnabledRotations(!1,!1,!1,!0),this.body.setTranslation(this.transform.loc,!0),this.body.setRotation(this.transform.quat,!0)),this.colliderDesc&&(this.collider=e.world.createCollider(this.colliderDesc,this.body)),this.collider&&this.objectA3&&tt.set(this.collider.handle,this.objectA3)}removeOneselfFromPhysics(e){this.collider&&(e.world.removeCollider(this.collider,!0),tt.delete(this.collider.handle),this.collider=void 0),this.body&&(e.world.removeRigidBody(this.body),this.body=void 0),this.physicsWorld=void 0}setPosition(e){}setPositionNow(e){this.tmpV1.set(e),this.tmpV1.add(this.capsuleCenter),this.body?this.body.setTranslation(this.tmpV1,!0):this.bodyDesc?.setTranslation(this.tmpV1.x,this.tmpV1.y,this.tmpV1.z),this.transform.loc.set(e)}setQuat(e){this.body?this.body.setRotation(e,!0):this.bodyDesc?.setRotation(e),this.transform.quat.set(e)}setQuatNow(e){this.body?this.body.setRotation(e,!0):this.bodyDesc?.setRotation(e),this.transform.quat.set(e)}setScale(e){}setScaleNow(e){}setLinearVelocity(e){this.body?this.body.setLinvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setLinvel(e.x,e.y,e.z)}getLinearVelocity(e){return e||(e=new ce),this.body?e.set(this.body.linvel()):this.bodyDesc&&e.set(this.bodyDesc.linvel),e}setAngularVelocity(e){this.body?this.body.setAngvel({x:e.x,y:e.y,z:e.z},!0):this.bodyDesc?.setAngvel({x:e.x,y:e.y,z:e.z})}getAngularVelocity(e){return e||(e=new ce),this.body?e.set(this.body.angvel()):this.bodyDesc&&e.set(this.bodyDesc.angvel),e}resetForce(){this.body?.resetForces(!0)}addForce(e){this.body?.addForce({x:e.x,y:e.y,z:e.z},!0)}addForceAtPoint(e,t){this.body?.addForceAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}resetTorque(){this.body?.resetTorques(!0)}addTorque(e){this.body?.addTorque({x:e.x,y:e.y,z:e.z},!0)}applyImpulse(e){this.body?.applyImpulse({x:e.x,y:e.y,z:e.z},!0)}applyImpulseAtPoint(e,t){this.body?.applyImpulseAtPoint({x:e.x,y:e.y,z:e.z},{x:t.x,y:t.y,z:t.z},!0)}applyTorqueImpulse(e){this.body?.applyTorqueImpulse({x:e.x,y:e.y,z:e.z},!0)}isGrounded(){if(this.body&&this.physicsWorld){const e=this.body.translation(),t=new Pe.Ray(e,{x:0,y:-1,z:0}),n=1.1*(this.completeOptions.height+this.completeOptions.radius);return this.physicsWorld.world.castRay(t,n,!0,void 0,void 0,this.collider)!==null}else return this.transform.loc.y<=0}update(e){if(!this.body)return;const t=new ce(this.body.translation());t.sub(this.capsuleCenter),this.transform.loc.set(t),this.transform.quat.set(this.body.rotation())}}const eo=new K.SphereGeometry,to=new K.MeshStandardMaterial({color:16711680});let no=new K.Mesh(eo,to);class Oe{static defaultRotationOrder="ZXY";static defaultUpVector=new ce(0,1,0);rotationOrder;upVector;object3D;scene;balloon;transformer;parent;children=[];clickListener;constructor(e){this.transformer=this.initTransformer(e),this.object3D=new K.Object3D;const t=this.initObject(e);t&&this.object3D.add(t),this.object3D.traverse(n=>{n.userData.a3js={objectA3:this}})}initObject(e){return no.clone()}initTransformer(e){return new vt}setTransformer(e){x.t0.set(this.transformer.transform),e.init(x.t0,this),this.transformer=e}getTransformer(){return this.transformer}setMode(e,t){e==="Default"?this.setTransformer(new vt):e==="Smooth"?this.setTransformer(new mn(t)):e==="Follow"?this.setTransformer(new ti(t)):e==="Billboard"?this.setTransformer(new Zn(t)):e==="SmoothBillboard"?this.setTransformer(new $n(t)):e==="SimplePhysics"?this.setTransformer(new zr(t)):e==="KinematicCharacter"?this.setTransformer(new ri(t)):e==="DynamicCharacter"&&this.setTransformer(new si(t))}update(e){this.transformer.update(e),this.transformer.transform.write(this),this.children.forEach(t=>{t.update(e)})}add(e){if(e.scene){console.warn("ObjectA3.add(obj) is ignored.");return}if(e.parent){console.warn("ObjectA3.add(obj) is ignored.");return}this.children.push(e),e.parent=this,this.object3D.add(e.object3D)}remove(e){if(e.parent!==this){console.warn("ObjectA3.remove(obj) is ignored.");return}const t=this.children.indexOf(e);this.children.splice(t,1),e.parent=void 0,this.object3D.remove(e.object3D)}setSpeechBubble(e){this.balloon?this.balloon.message=e:this.balloon=new io(e)}setClickListener(e){this.clickListener=e}handleCollision(e,t,n,r){}async clicked(){this.clickListener&&await this.clickListener(this)}setCastShadow(e){this.object3D.traverse(t=>{t instanceof K.Mesh&&(t.castShadow=e)})}setReceiveShadow(e){this.object3D.traverse(t=>{t instanceof K.Mesh&&(t.receiveShadow=e)})}setLightShadow(e){this.object3D.traverse(t=>{(t instanceof K.DirectionalLight||t instanceof K.SpotLight||t instanceof K.PointLight)&&(t.castShadow=e)})}getPosition(e){return e?(e.set(this.transformer.transform.loc),e):this.transformer.transform.loc.clone()}setPosition(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setPosition(x.v0)}setPositionNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setPositionNow(x.v0)}getQuat(e){return e?(e.set(this.transformer.transform.quat),e):this.transformer.transform.quat.clone()}setQuat(e,t,n,r){typeof e=="number"?x.q0.set(e,t,n,r):x.q0.set(e),this.transformer.setQuat(x.q0)}setQuatNow(e,t,n,r){typeof e=="number"?x.q0.set(e,t,n,r):x.q0.set(e),this.transformer.setQuatNow(x.q0)}getScale(e){return e?(e.set(this.transformer.transform.scale),e):this.transformer.transform.scale.clone()}setScale(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setScale(x.v0)}setScaleNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setScaleNow(x.v0)}setRotation(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q1),this.setQuat(x.q1)}setRotationNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q0),this.setQuatNow(x.q0)}lookAt(e,t,n){typeof e=="number"?x.v1.set(e,t,n):e instanceof Oe?x.v1.set(e.transformer.transform.loc):x.v1.set(e);const r=this.upVector?this.upVector:Oe.defaultUpVector;st(this.transformer.transform.loc,x.v1,r,x.q1),this.setQuat(x.q1)}lookAtNow(e,t,n){typeof e=="number"?x.v1.set(e,t,n):e instanceof Oe?x.v1.set(e.transformer.transform.loc):x.v1.set(e);const r=this.upVector?this.upVector:Oe.defaultUpVector;st(this.transformer.transform.loc,x.v1,r,x.q1),this.setQuatNow(x.q1)}getUnitVecX(e){return e?(e.set(1,0,0),e.apply(this.object3D.quaternion)):new ce(1,0,0).apply(this.object3D.quaternion)}getUnitVecY(e){return e?(e.set(0,1,0),e.apply(this.object3D.quaternion)):new ce(0,1,0).apply(this.object3D.quaternion)}getUnitVecZ(e){return e?(e.set(0,0,1),e.apply(this.object3D.quaternion)):new ce(0,0,1).apply(this.object3D.quaternion)}translate(e,t,n){x.v1.set(this.transformer.transform.loc),typeof e=="number"?x.v1.add(e,t,n):x.v1.add(e),this.setPosition(x.v1)}translateNow(e,t,n){x.v1.set(this.transformer.transform.loc),typeof e=="number"?x.v1.add(e,t,n):x.v1.add(e),this.setPositionNow(x.v1)}mulQuat(e,t,n,r){x.q1.set(this.transformer.transform.quat),typeof e=="number"?x.q1.mul(e,t,n,r):x.q1.mul(e),this.setQuat(x.q1)}mulQuatNow(e,t,n,r){x.q1.set(this.transformer.transform.quat),typeof e=="number"?x.q1.mul(e,t,n,r):x.q1.mul(e),this.setQuatNow(x.q1)}mulRotation(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q1),this.getQuat(x.q0),x.q0.mul(x.q1),this.setQuat(x.q0)}mulRotationNow(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),x.v0.scale(Math.PI/360);const r=this.rotationOrder?this.rotationOrder:Oe.defaultRotationOrder;ht(x.v0,r,x.q1),this.getQuat(x.q0),x.q0.mul(x.q1),this.setQuatNow(x.q0)}scaleBy(e,t,n){this.getScale(x.v0),typeof e=="number"?x.v0.set(x.v0.x*e,x.v0.y*t,x.v0.z*n):x.v0.set(x.v0.x*e.x,x.v0.y*e.y,x.v0.z*e.z),this.setScale(x.v0)}mulScaleNow(e,t,n){this.getScale(x.v0),typeof e=="number"?x.v0.set(x.v0.x*e,x.v0.y*t,x.v0.z*n):x.v0.set(x.v0.x*e.x,x.v0.y*e.y,x.v0.z*e.z),this.setScaleNow(x.v0)}moveForward(e){this.getUnitVecZ(x.v0),x.v0.scale(e),this.translate(x.v0)}moveForwardNow(e){this.getUnitVecZ(x.v0),x.v0.scale(e),this.translateNow(x.v0)}moveBackward(e){this.getUnitVecZ(x.v0),x.v0.scale(-e),this.translate(x.v0)}moveBackwardNow(e){this.getUnitVecZ(x.v0),x.v0.scale(-e),this.translateNow(x.v0)}moveRight(e){this.getUnitVecX(x.v0),x.v0.scale(-e),this.translate(x.v0)}moveRightNow(e){this.getUnitVecX(x.v0),x.v0.scale(-e),this.translateNow(x.v0)}moveLeft(e){this.getUnitVecX(x.v0),x.v0.scale(e),this.translate(x.v0)}moveLeftNow(e){this.getUnitVecX(x.v0),x.v0.scale(e),this.translateNow(x.v0)}moveUp(e){this.getUnitVecY(x.v0),x.v0.scale(e),this.translate(x.v0)}moveUpNow(e){this.getUnitVecY(x.v0),x.v0.scale(e),this.translateNow(x.v0)}moveDown(e){this.getUnitVecY(x.v0),x.v0.scale(-e),this.translate(x.v0)}moveDownNow(e){this.getUnitVecY(x.v0),x.v0.scale(-e),this.translateNow(x.v0)}turnUp(e){this.mulRotation(-e,0,0)}turnUpNow(e){this.mulRotationNow(-e,0,0)}turnDown(e){this.mulRotation(e,0,0)}turnDownNow(e){this.mulRotationNow(e,0,0)}turnRight(e){this.mulRotation(0,-e,0)}turnRightNow(e){this.mulRotationNow(0,-e,0)}turnLeft(e){this.mulRotation(0,e,0)}turnLeftNow(e){this.mulRotationNow(0,e,0)}rollRight(e){this.mulRotation(0,0,e)}rollRightNow(e){this.mulRotationNow(0,0,e)}rollLeft(e){this.mulRotation(0,0,-e)}rollLeftNow(e){this.mulRotationNow(0,0,-e)}setLinearVelocity(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setLinearVelocity(x.v0)}getLinearVelocity(e){return this.transformer.getLinearVelocity(e)}setAngularVelocity(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.setAngularVelocity(x.v0)}getAngularVelocity(e){return this.transformer.getAngularVelocity(e)}resetForce(){this.transformer.resetForce()}addForce(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.addForce(x.v0)}addForceAtPoint(e,t,n,r,o,s){if(typeof e=="number")if(typeof t=="number")x.v0.set(e,t,n),x.v1.set(r,o,s);else{console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else if(typeof t=="number"){console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else x.v0.set(e),x.v1.set(t);this.transformer.addForceAtPoint(x.v0,x.v1)}resetTorque(){this.transformer.resetTorque()}addTorque(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.addTorque(x.v0)}applyImpulse(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.applyImpulse(x.v0)}applyImpulseAtPoint(e,t,n,r,o,s){if(typeof e=="number")if(typeof t=="number")x.v0.set(e,t,n),x.v1.set(r,o,s);else{console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else if(typeof t=="number"){console.warn("ObjectA3.addForceAtPoint(): type of arguments mismatch.");return}else x.v0.set(e),x.v1.set(t);this.transformer.applyImpulseAtPoint(x.v0,x.v1)}applyTorqueImpulse(e,t,n){typeof e=="number"?x.v0.set(e,t,n):x.v0.set(e),this.transformer.applyTorqueImpulse(x.v0)}addOneselfToPhysics(e){this.transformer.addOneselfToPhysics(e)}removeOneselfFromPhysics(e){this.transformer.removeOneselfFromPhysics(e)}isGrounded(){return this.transformer.isGrounded()}}class io{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 bn{shape;motion;constructor(e,t){this.shape=e,this.motion=t}enable(e,t){this.motion.playCount=0,this.motion.time=0,e.add(this.shape.root)}disable(e,t){e.remove(this.shape.root)}}class bt extends Oe{ready;actions;currentAction;stateAction;emoteAction;morphs;overwriteMorphs;autoAction=!1;autoDirection=!1;haltActionName="default";walkActionName="walk";runActionName="run";minWalkSpeed=.1;minRunSpeed=1;constructor(e){super(e),this.actions={},this.morphs={},this.overwriteMorphs=!1,this.ready=this.asyncInit(e),this.autoAction=!1,this.autoDirection=!1}syncInit(e,t,n={}){this.actions=t,this.stateAction=this.actions[e],this.currentAction=this.stateAction,this.object3D.clear(),this.morphs=n,this.stateAction?.enable(this.object3D,this.scene)}setActions(e){this.actions=e}getAction(e){return this.actions[e]}addAction(e,t){this.actions[e]=t}removeAction(e){const t=this.actions[e];return delete this.actions[e],t}getActionNames(){return Object.keys(this.actions)}setState(e){const t=this.actions[e];t&&(this.currentAction&&this.currentAction.disable(this.object3D,this.scene),t.enable(this.object3D,this.scene),this.currentAction=t,this.stateAction=t)}setEmote(e){const t=this.actions[e];t&&(this.currentAction&&this.currentAction.disable(this.object3D,this.scene),t.enable(this.object3D,this.scene),this.currentAction=t,this.emoteAction=t)}setMorphsOverwrite(e){this.overwriteMorphs=e}setMorph(e,t){if(e in this.morphs){const{array:n,idx:r}=this.morphs[e];n[r]=t}}getMorphNames(){return Object.keys(this.morphs)}pose={};update(e){super.update(e);let t;if(this.emoteAction&&this.emoteAction.motion.playCount<=0?(t=this.emoteAction.motion.update(e),this.emoteAction.motion.playCount>0&&(this.emoteAction.disable(this.object3D,this.scene),this.emoteAction=void 0,this.stateAction&&(this.stateAction.enable(this.object3D,this.scene),this.currentAction=this.stateAction))):this.stateAction&&(t=this.stateAction.motion.update(e)),t&&this.currentAction&&this.currentAction.shape.bones)for(const[o,s]of Object.entries(t)){const c=this.currentAction.shape.bones[o];if(c&&(s.loc&&c.position.set(s.loc.x,s.loc.y,s.loc.z),s.quat&&c.quaternion.set(s.quat.x,s.quat.y,s.quat.z,s.quat.w),s.scale&&c.scale.set(s.scale.x,s.scale.y,s.scale.z)),!this.overwriteMorphs&&s.morphs){for(const A of s.morphs)for(const a of Object.keys(this.morphs))if(a.startsWith(A.name)){const{array:h}=this.morphs[a];for(let u=0;u<h.length;u++)h[u]=A.vals[u];break}}}this.object3D.updateMatrixWorld(!0),this.currentAction&&this.currentAction.shape.skeleton?.update();const n=this.getLinearVelocity(),r=n.length();if(this.autoAction&&(r<this.minWalkSpeed?this.actions[this.haltActionName]!==this.stateAction&&this.setState(this.haltActionName):r<this.minRunSpeed?this.actions[this.walkActionName]!==this.stateAction&&this.setState(this.walkActionName):this.actions[this.runActionName]!==this.stateAction&&this.setState(this.runActionName)),this.autoDirection&&r>1e-4){n.normalize();const o=this.upVector?this.upVector:Oe.defaultUpVector;x.v0.cross(n,o),x.v0.length()>1e-4&&(x.v0.set(0,0,0),st(x.v0,n,o,x.q0),this.setQuatNow(x.q0))}}setAutoAction(e){this.autoAction=e}setAutoDirection(e){this.autoDirection=e}}class _n{name;playCount;time;finishListener;constructor(){this.name="dummy",this.playCount=0,this.time=0}addOneselfToPhysics(e){}removeOneselfFromPhysics(e){}setPause(e){}setTime(e){}setFinishListener(e){this.finishListener=e}update(e){return{}}}var ve=(i,e)=>()=>(e||(e={exports:{}},i(e.exports,e)),e.exports),ai=ve(i=>{Object.defineProperty(i,"__esModule",{value:!0}),i.VERSION=void 0,i.VERSION="9.0.1"}),Ne=ve((i,e)=>{var t=i&&i.__spreadArray||function(O,J){for(var q=0,re=J.length,fe=O.length;q<re;q++,fe++)O[fe]=J[q];return O};Object.defineProperty(i,"__esModule",{value:!0}),i.toFastProperties=i.timer=i.peek=i.isES2015MapSupported=i.PRINT_WARNING=i.PRINT_ERROR=i.packArray=i.IDENTITY=i.NOOP=i.merge=i.groupBy=i.defaults=i.assignNoOverwrite=i.assign=i.zipObject=i.sortBy=i.indexOf=i.some=i.difference=i.every=i.isObject=i.isRegExp=i.isArray=i.partial=i.uniq=i.compact=i.reduce=i.findAll=i.find=i.cloneObj=i.cloneArr=i.contains=i.has=i.pick=i.reject=i.filter=i.dropRight=i.drop=i.isFunction=i.isUndefined=i.isString=i.forEach=i.last=i.first=i.flatten=i.map=i.mapValues=i.values=i.keys=i.isEmpty=void 0;function n(O){return O&&O.length===0}i.isEmpty=n;function r(O){return O==null?[]:Object.keys(O)}i.keys=r;function o(O){for(var J=[],q=Object.keys(O),re=0;re<q.length;re++)J.push(O[q[re]]);return J}i.values=o;function s(O,J){for(var q=[],re=r(O),fe=0;fe<re.length;fe++){var Qe=re[fe];q.push(J.call(null,O[Qe],Qe))}return q}i.mapValues=s;function c(O,J){for(var q=[],re=0;re<O.length;re++)q.push(J.call(null,O[re],re));return q}i.map=c;function A(O){for(var J=[],q=0;q<O.length;q++){var re=O[q];Array.isArray(re)?J=J.concat(A(re)):J.push(re)}return J}i.flatten=A;function a(O){return n(O)?void 0:O[0]}i.first=a;function h(O){var J=O&&O.length;return J?O[J-1]:void 0}i.last=h;function u(O,J){if(Array.isArray(O))for(var q=0;q<O.length;q++)J.call(null,O[q],q);else if(Z(O))for(var re=r(O),q=0;q<re.length;q++){var fe=re[q],Qe=O[fe];J.call(null,Qe,fe)}else throw Error("non exhaustive match")}i.forEach=u;function m(O){return typeof O=="string"}i.isString=m;function p(O){return O===void 0}i.isUndefined=p;function E(O){return O instanceof Function}i.isFunction=E;function g(O,J){return J===void 0&&(J=1),O.slice(J,O.length)}i.drop=g;function l(O,J){return J===void 0&&(J=1),O.slice(0,O.length-J)}i.dropRight=l;function d(O,J){var q=[];if(Array.isArray(O))for(var re=0;re<O.length;re++){var fe=O[re];J.call(null,fe)&&q.push(fe)}return q}i.filter=d;function f(O,J){return d(O,function(q){return!J(q)})}i.reject=f;function C(O,J){for(var q=Object.keys(O),re={},fe=0;fe<q.length;fe++){var Qe=q[fe],ye=O[Qe];J(ye)&&(re[Qe]=ye)}return re}i.pick=C;function I(O,J){return Z(O)?O.hasOwnProperty(J):!1}i.has=I;function y(O,J){return H(O,function(q){return q===J})!==void 0}i.contains=y;function v(O){for(var J=[],q=0;q<O.length;q++)J.push(O[q]);return J}i.cloneArr=v;function L(O){var J={};for(var q in O)Object.prototype.hasOwnProperty.call(O,q)&&(J[q]=O[q]);return J}i.cloneObj=L;function H(O,J){for(var q=0;q<O.length;q++){var re=O[q];if(J.call(null,re))return re}}i.find=H;function Q(O,J){for(var q=[],re=0;re<O.length;re++){var fe=O[re];J.call(null,fe)&&q.push(fe)}return q}i.findAll=Q;function P(O,J,q){for(var re=Array.isArray(O),fe=re?O:o(O),Qe=re?[]:r(O),ye=q,le=0;le<fe.length;le++)ye=J.call(null,ye,fe[le],re?le:Qe[le]);return ye}i.reduce=P;function D(O){return f(O,function(J){return J==null})}i.compact=D;function R(O,J){J===void 0&&(J=function(re){return re});var q=[];return P(O,function(re,fe){var Qe=J(fe);return y(q,Qe)?re:(q.push(Qe),re.concat(fe))},[])}i.uniq=R;function F(O){for(var J=[],q=1;q<arguments.length;q++)J[q-1]=arguments[q];var re=[null],fe=re.concat(J);return Function.bind.apply(O,fe)}i.partial=F;function _(O){return Array.isArray(O)}i.isArray=_;function X(O){return O instanceof RegExp}i.isRegExp=X;function Z(O){return O instanceof Object}i.isObject=Z;function V(O,J){for(var q=0;q<O.length;q++)if(!J(O[q],q))return!1;return!0}i.every=V;function $(O,J){return f(O,function(q){return y(J,q)})}i.difference=$;function ie(O,J){for(var q=0;q<O.length;q++)if(J(O[q]))return!0;return!1}i.some=ie;function ue(O,J){for(var q=0;q<O.length;q++)if(O[q]===J)return q;return-1}i.indexOf=ue;function ae(O,J){var q=v(O);return q.sort(function(re,fe){return J(re)-J(fe)}),q}i.sortBy=ae;function se(O,J){if(O.length!==J.length)throw Error("can't zipObject with different number of keys and values!");for(var q={},re=0;re<O.length;re++)q[O[re]]=J[re];return q}i.zipObject=se;function ee(O){for(var J=[],q=1;q<arguments.length;q++)J[q-1]=arguments[q];for(var re=0;re<J.length;re++)for(var fe=J[re],Qe=r(fe),ye=0;ye<Qe.length;ye++){var le=Qe[ye];O[le]=fe[le]}return O}i.assign=ee;function de(O){for(var J=[],q=1;q<arguments.length;q++)J[q-1]=arguments[q];for(var re=0;re<J.length;re++)for(var fe=J[re],Qe=r(fe),ye=0;ye<Qe.length;ye++){var le=Qe[ye];I(O,le)||(O[le]=fe[le])}return O}i.assignNoOverwrite=de;function G(){for(var O=[],J=0;J<arguments.length;J++)O[J]=arguments[J];return de.apply(void 0,t([{}],O))}i.defaults=G;function j(O,J){var q={};return u(O,function(re){var fe=J(re),Qe=q[fe];Qe?Qe.push(re):q[fe]=[re]}),q}i.groupBy=j;function Y(O,J){for(var q=L(O),re=r(J),fe=0;fe<re.length;fe++){var Qe=re[fe],ye=J[Qe];q[Qe]=ye}return q}i.merge=Y;function z(){}i.NOOP=z;function te(O){return O}i.IDENTITY=te;function oe(O){for(var J=[],q=0;q<O.length;q++){var re=O[q];J.push(re!==void 0?re:void 0)}return J}i.packArray=oe;function Be(O){console&&console.error&&console.error("Error: "+O)}i.PRINT_ERROR=Be;function we(O){console&&console.warn&&console.warn("Warning: "+O)}i.PRINT_WARNING=we;function De(){return typeof Map=="function"}i.isES2015MapSupported=De;function ze(O){return O[O.length-1]}i.peek=ze;function Je(O){var J=new Date().getTime(),q=O(),re=new Date().getTime(),fe=re-J;return{time:fe,value:q}}i.timer=Je;function Ve(O){function J(){}J.prototype=O;var q=new J;function re(){return typeof q.bar}return re(),re(),O}i.toFastProperties=Ve}),Cn=ve((i,e)=>{(function(t,n){typeof define=="function"&&define.amd?define([],n):typeof e=="object"&&e.exports?e.exports=n():t.regexpToAst=n()})(typeof self<"u"?self:i,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(l){this.idx=l.idx,this.input=l.input,this.groupIdx=l.groupIdx},t.prototype.pattern=function(l){this.idx=0,this.input=l,this.groupIdx=0,this.consumeChar("/");var d=this.disjunction();this.consumeChar("/");for(var f={type:"Flags",loc:{begin:this.idx,end:l.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":A(f,"global");break;case"i":A(f,"ignoreCase");break;case"m":A(f,"multiLine");break;case"u":A(f,"unicode");break;case"y":A(f,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:f,value:d,loc:this.loc(0)}},t.prototype.disjunction=function(){var l=[],d=this.idx;for(l.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),l.push(this.alternative());return{type:"Disjunction",value:l,loc:this.loc(d)}},t.prototype.alternative=function(){for(var l=[],d=this.idx;this.isTerm();)l.push(this.term());return{type:"Alternative",value:l,loc:this.loc(d)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var l=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(l)};case"$":return{type:"EndAnchor",loc:this.loc(l)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(l)};case"B":return{type:"NonWordBoundary",loc:this.loc(l)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var d;switch(this.popChar()){case"=":d="Lookahead";break;case"!":d="NegativeLookahead";break}a(d);var f=this.disjunction();return this.consumeChar(")"),{type:d,value:f,loc:this.loc(l)}}h()},t.prototype.quantifier=function(l){var d,f=this.idx;switch(this.popChar()){case"*":d={atLeast:0,atMost:1/0};break;case"+":d={atLeast:1,atMost:1/0};break;case"?":d={atLeast:0,atMost:1};break;case"{":var C=this.integerIncludingZero();switch(this.popChar()){case"}":d={atLeast:C,atMost:C};break;case",":var I;this.isDigit()?(I=this.integerIncludingZero(),d={atLeast:C,atMost:I}):d={atLeast:C,atMost:1/0},this.consumeChar("}");break}if(l===!0&&d===void 0)return;a(d);break}if(!(l===!0&&d===void 0))return a(d),this.peekChar(0)==="?"?(this.consumeChar("?"),d.greedy=!1):d.greedy=!0,d.type="Quantifier",d.loc=this.loc(f),d},t.prototype.atom=function(){var l,d=this.idx;switch(this.peekChar()){case".":l=this.dotAll();break;case"\\":l=this.atomEscape();break;case"[":l=this.characterClass();break;case"(":l=this.group();break}return l===void 0&&this.isPatternCharacter()&&(l=this.patternCharacter()),a(l),l.loc=this.loc(d),this.isQuantifier()&&(l.quantifier=this.quantifier()),l},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[s(`
2
2
  `),s("\r"),s("\u2028"),s("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){var l=this.positiveInteger();return{type:"GroupBackReference",value:l}},t.prototype.characterClassEscape=function(){var l,d=!1;switch(this.popChar()){case"d":l=m;break;case"D":l=m,d=!0;break;case"s":l=E;break;case"S":l=E,d=!0;break;case"w":l=p;break;case"W":l=p,d=!0;break}return a(l),{type:"Set",value:l,complement:d}},t.prototype.controlEscapeAtom=function(){var l;switch(this.popChar()){case"f":l=s("\f");break;case"n":l=s(`
3
3
  `);break;case"r":l=s("\r");break;case"t":l=s(" ");break;case"v":l=s("\v");break}return a(l),{type:"Character",value:l}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var l=this.popChar();if(/[a-zA-Z]/.test(l)===!1)throw Error("Invalid ");var d=l.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:d}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:s("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){var l=this.popChar();return{type:"Character",value:s(l)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
4
4
  `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var l=this.popChar();return{type:"Character",value:s(l)}}},t.prototype.characterClass=function(){var l=[],d=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),d=!0);this.isClassAtom();){var f=this.classAtom(),C=f.type==="Character";if(C&&this.isRangeDash()){this.consumeChar("-");var I=this.classAtom(),y=I.type==="Character";if(y){if(I.value<f.value)throw Error("Range out of order in character class");l.push({from:f.value,to:I.value})}else c(f.value,l),l.push(s("-")),c(I.value,l)}else c(f.value,l)}return this.consumeChar("]"),{type:"Set",complement:d,value:l}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
@@ -206,13 +206,13 @@ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return E}
206
206
  font-size: 14px;
207
207
  pointer-events: none; /* マウスイベントを透過させて背後の操作を邪魔しない */
208
208
  `,gn={testMode:!0};class zs extends Oe{constructor(e={}){super(e);const t={...gn,...e};this.setTransformer(new Wn(t))}initObject(){const e=new K.BoxGeometry,t=new K.MeshStandardMaterial({color:65280}),n=new K.Mesh(e,t),r=document.createElement("div");r.textContent="Hello Box!",r.style.cssText=qs;const o=new Ii(r);return o.position.set(0,.8,0),n.add(o),n}initTransformer(e){const t=Pt(gn,e);return new Wn(t)}}class Wn extends vt{testMode=!0;rot=new ce;constructor(e){super(),this.testMode=e.testMode}update(e){super.update(e),this.testMode&&(this.rot.add(e,e,e),ht(this.rot,"ZXY",this.transform.quat))}}class Vs extends b.Loader{constructor(e){super(e)}load(e,t,n,r){const o=this,s=new b.FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(c){const A=o.parse(JSON.parse(c));t&&t(A)},n,r)}parse(e){return new dr(e)}}class dr{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="ltr"){const r=[],o=Ks(e,t,this.data,n);for(let s=0,c=o.length;s<c;s++)r.push(...o[s].toShapes());return r}}function Ks(i,e,t,n){const r=Array.from(i),o=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*o,c=[];let A=0,a=0;(n=="rtl"||n=="tb")&&r.reverse();for(let h=0;h<r.length;h++){const u=r[h];if(u===`
209
- `)A=0,a-=s;else{const m=Ws(u,o,A,a,t);n=="tb"?(A=0,a+=t.ascender*o):A+=m.offsetX,c.push(m.path)}}return c}function Ws(i,e,t,n,r){const o=r.glyphs[i]||r.glyphs["?"];if(!o){console.error('THREE.Font: character "'+i+'" does not exists in font family '+r.familyName+".");return}const s=new b.ShapePath;let c,A,a,h,u,m,p,E;if(o.o){const g=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let l=0,d=g.length;l<d;)switch(g[l++]){case"m":c=g[l++]*e+t,A=g[l++]*e+n,s.moveTo(c,A);break;case"l":c=g[l++]*e+t,A=g[l++]*e+n,s.lineTo(c,A);break;case"q":a=g[l++]*e+t,h=g[l++]*e+n,u=g[l++]*e+t,m=g[l++]*e+n,s.quadraticCurveTo(u,m,a,h);break;case"b":a=g[l++]*e+t,h=g[l++]*e+n,u=g[l++]*e+t,m=g[l++]*e+n,p=g[l++]*e+t,E=g[l++]*e+n,s.bezierCurveTo(u,m,p,E,a,h);break}}return{offsetX:o.ha*e,path:s}}class Ys extends b.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const r=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(r,t)}this.type="TextGeometry"}}let Mt=null;async function Js(i){if(i.match(/.zip$/i)){let e=i.substring(i.lastIndexOf("/"));e=e.substring(0,e.length-4);const t=await ni(i),n=Ot(t,e);Mt=new dr(JSON.parse(n))}else Mt=await new Vs().loadAsync(i)}const fr={color:16711680};class Xs extends Oe{options;constructor(e,t){const n={...fr,...t},r={text:e,color:n.color};super(r),this.options=n}initObject(e){let t=e.text;if(Mt==null){const n=new K.BoxGeometry,r=new K.MeshStandardMaterial({color:16711680});return new K.Mesh(n,r)}else{const n={font:Mt,size:1,depth:.5,curveSegments:12},r=new Ys(t,n);r.center();const o=new K.MeshStandardMaterial({color:e.color});return new K.Mesh(r,o)}}}class Zs extends Oe{constructor(e){super(e)}initObject(e){return e}}class $s extends Oe{constructor(...e){super(e)}initObject(e){const t=e.filter(A=>typeof A=="number"),n=e.filter(A=>typeof A=="string"),r=new K.BoxGeometry(...t),o=n.length>0?n[0]:"rgb(128,128,128)",s=new K.MeshStandardMaterial({color:o});return new K.Mesh(r,s)}}class ea extends Oe{constructor(...e){super(e)}initObject(e){const t=e.filter(A=>typeof A=="number"),n=e.filter(A=>typeof A=="string"),r=new K.SphereGeometry(...t),o=n.length>0?n[0]:"rgb(128,128,128)",s=new K.MeshStandardMaterial({color:o});return new K.Mesh(r,s)}}const an={direction:{x:-1,y:-1,z:-1},colorDL:16777215,colorAL:16777215,intensityDL:1,intensityAL:.4};function ta(i){let e=!0;return e&&=typeof i.x=="number",e&&=typeof i.y=="number",e&&=typeof i.z=="number",e}function na(i){let e=!0;return e&&=ta(i.direction),e&&=typeof i.colorDL=="number",e&&=typeof i.colorAL=="number",e&&=typeof i.intensityDL=="number",e&&=typeof i.intensityAL=="number",e}class ia extends Oe{completeOptions;constructor(e=an){const t={...an,...e};super(t),this.completeOptions=t}initObject(e){let t=an;na(e)&&(t=e);const n=new K.Object3D;return this.directionalLight=new K.DirectionalLight(t.colorDL,t.intensityDL),this.directionalLight.target.position.set(t.direction.x,t.direction.y,t.direction.z),n.add(this.directionalLight),n.add(this.directionalLight.target),this.ambientLight=new K.AmbientLight(t.colorAL,t.intensityAL),n.add(this.ambientLight),n}setDebugMode(e){this.directionalLight&&(e?(this.cameraHelper||(this.cameraHelper=new K.CameraHelper(this.directionalLight.shadow.camera)),this.object3D.add(this.cameraHelper)):this.cameraHelper&&this.object3D.remove(this.cameraHelper))}}class ra extends Oe{constructor(e){super(e)}initObject(e){const t=new K.PlaneGeometry(1,1),n=new K.TextureLoader().load(e),r=new K.MeshBasicMaterial({map:n});return new K.Mesh(t,r)}}class oa extends Oe{constructor(e){super(e);const t=this.object3D.children[0];this.object3D.addEventListener("removed",()=>{t.element.remove()})}initObject(e){return new Ii(e)}}const pr={touchDevice:navigator.maxTouchPoints>0};class gr extends HTMLElement{options;canvas;scene;camera;controller;_maxDistance;_leftActive;_leftCenter;leftJoystick;_rightActive;_rightCenter;rightJoystick;leftButton;rightButton;_leftButtonCount;_rightButtonCount;keys;_ro;constructor(e={}){super(),this.options={...pr,...e},this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
209
+ `)A=0,a-=s;else{const m=Ws(u,o,A,a,t);n=="tb"?(A=0,a+=t.ascender*o):A+=m.offsetX,c.push(m.path)}}return c}function Ws(i,e,t,n,r){const o=r.glyphs[i]||r.glyphs["?"];if(!o){console.error('THREE.Font: character "'+i+'" does not exists in font family '+r.familyName+".");return}const s=new b.ShapePath;let c,A,a,h,u,m,p,E;if(o.o){const g=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let l=0,d=g.length;l<d;)switch(g[l++]){case"m":c=g[l++]*e+t,A=g[l++]*e+n,s.moveTo(c,A);break;case"l":c=g[l++]*e+t,A=g[l++]*e+n,s.lineTo(c,A);break;case"q":a=g[l++]*e+t,h=g[l++]*e+n,u=g[l++]*e+t,m=g[l++]*e+n,s.quadraticCurveTo(u,m,a,h);break;case"b":a=g[l++]*e+t,h=g[l++]*e+n,u=g[l++]*e+t,m=g[l++]*e+n,p=g[l++]*e+t,E=g[l++]*e+n,s.bezierCurveTo(u,m,p,E,a,h);break}}return{offsetX:o.ha*e,path:s}}class Ys extends b.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const r=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(r,t)}this.type="TextGeometry"}}let Mt=null;async function Js(i){if(i.match(/.zip$/i)){let e=i.substring(i.lastIndexOf("/"));e=e.substring(0,e.length-4);const t=await ni(i),n=Ot(t,e);Mt=new dr(JSON.parse(n))}else Mt=await new Vs().loadAsync(i)}const fr={color:16711680};class Xs extends Oe{options;constructor(e,t){const n={...fr,...t},r={text:e,color:n.color};super(r),this.options=n}initObject(e){let t=e.text;if(Mt==null){const n=new K.BoxGeometry,r=new K.MeshStandardMaterial({color:16711680});return new K.Mesh(n,r)}else{const n={font:Mt,size:1,depth:.5,curveSegments:12},r=new Ys(t,n);r.center();const o=new K.MeshStandardMaterial({color:e.color});return new K.Mesh(r,o)}}}class Zs extends Oe{constructor(e){super(e)}initObject(e){return e}}class $s extends Oe{constructor(...e){super(e)}initObject(e){const t=e.filter(A=>typeof A=="number"),n=e.filter(A=>typeof A=="string"),r=new K.BoxGeometry(...t),o=n.length>0?n[0]:"rgb(128,128,128)",s=new K.MeshStandardMaterial({color:o});return new K.Mesh(r,s)}}class ea extends Oe{constructor(...e){super(e)}initObject(e){const t=e.filter(A=>typeof A=="number"),n=e.filter(A=>typeof A=="string"),r=new K.SphereGeometry(...t),o=n.length>0?n[0]:"rgb(128,128,128)",s=new K.MeshStandardMaterial({color:o});return new K.Mesh(r,s)}}const an={direction:{x:-1,y:-1,z:-1},colorDL:16777215,colorAL:16777215,intensityDL:1,intensityAL:.4};function ta(i){let e=!0;return e&&=typeof i.x=="number",e&&=typeof i.y=="number",e&&=typeof i.z=="number",e}function na(i){let e=!0;return e&&=ta(i.direction),e&&=typeof i.colorDL=="number",e&&=typeof i.colorAL=="number",e&&=typeof i.intensityDL=="number",e&&=typeof i.intensityAL=="number",e}class ia extends Oe{completeOptions;constructor(e=an){const t={...an,...e};super(t),this.completeOptions=t}initObject(e){let t=an;na(e)&&(t=e);const n=new K.Object3D;return this.directionalLight=new K.DirectionalLight(t.colorDL,t.intensityDL),this.directionalLight.target.position.set(t.direction.x,t.direction.y,t.direction.z),n.add(this.directionalLight),n.add(this.directionalLight.target),this.ambientLight=new K.AmbientLight(t.colorAL,t.intensityAL),n.add(this.ambientLight),n}setDebugMode(e){this.directionalLight&&(e?(this.cameraHelper||(this.cameraHelper=new K.CameraHelper(this.directionalLight.shadow.camera)),this.object3D.add(this.cameraHelper)):this.cameraHelper&&this.object3D.remove(this.cameraHelper))}}class ra extends Oe{constructor(e){super(e)}initObject(e){const t=new K.PlaneGeometry(1,1),n=new K.TextureLoader().load(e),r=new K.MeshBasicMaterial({map:n});return new K.Mesh(t,r)}}class oa extends Oe{constructor(e){super(e);const t=this.object3D.children[0];this.object3D.addEventListener("removed",()=>{t.element.remove()})}initObject(e){return new Ii(e)}}const pr={touchDevice:navigator.maxTouchPoints>0,width:"600px",height:"300px"};class gr extends HTMLElement{options;canvas;scene;camera;controller;_maxDistance;_leftActive;_leftCenter;leftJoystick;_rightActive;_rightCenter;rightJoystick;leftButton;rightButton;_leftButtonCount;_rightButtonCount;keys;_ro;constructor(e={}){super(),this.options={...pr,...e},this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
210
210
  <style>
211
211
  :host {
212
212
  display: block;
213
213
  position: relative;
214
- width: 600px;
215
- height: 300px;
214
+ width: ${this.options.width};
215
+ height: ${this.options.height};
216
216
 
217
217
  canvas-a3 {
218
218
  position: absolute;