UNPKG

agentscript

Version:

AgentScript Model in Model/View architecture

2 lines (1 loc) 39.5 kB
const t=[];for(let s=0;s<256;s++)t[s]=(s<16?"0":"")+s.toString(16);let s=1234567;const e={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const s=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(t[255&s]+t[s>>8&255]+t[s>>16&255]+t[s>>24&255]+"-"+t[255&e]+t[e>>8&255]+"-"+t[e>>16&15|64]+t[e>>24&255]+"-"+t[63&i|128]+t[i>>8&255]+"-"+t[i>>16&255]+t[i>>24&255]+t[255&r]+t[r>>8&255]+t[r>>16&255]+t[r>>24&255]).toUpperCase()},clamp:function(t,s,e){return Math.max(s,Math.min(e,t))},euclideanModulo:function(t,s){return(t%s+s)%s},mapLinear:function(t,s,e,i,r){return i+(t-s)*(r-i)/(e-s)},lerp:function(t,s,e){return(1-e)*t+e*s},smoothstep:function(t,s,e){return t<=s?0:t>=e?1:(t=(t-s)/(e-s))*t*(3-2*t)},smootherstep:function(t,s,e){return t<=s?0:t>=e?1:(t=(t-s)/(e-s))*t*t*(t*(6*t-15)+10)},randInt:function(t,s){return t+Math.floor(Math.random()*(s-t+1))},randFloat:function(t,s){return t+Math.random()*(s-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(s=t%2147483647),s=16807*s%2147483647,(s-1)/2147483646},degToRad:function(t){return t*e.DEG2RAD},radToDeg:function(t){return t*e.RAD2DEG},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,s,e,i,r){const n=Math.cos,h=Math.sin,a=n(e/2),o=h(e/2),l=n((s+i)/2),u=h((s+i)/2),c=n((s-i)/2),m=h((s-i)/2),d=n((i-s)/2),x=h((i-s)/2);switch(r){case"XYX":t.set(a*u,o*c,o*m,a*l);break;case"YZY":t.set(o*m,a*u,o*c,a*l);break;case"ZXZ":t.set(o*c,o*m,a*u,a*l);break;case"XZX":t.set(a*u,o*x,o*d,a*l);break;case"YXY":t.set(o*d,a*u,o*x,a*l);break;case"ZYZ":t.set(o*x,o*d,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class i{constructor(t=0,s=0,e=0,i=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=s,this._z=e,this._w=i}static slerp(t,s,e,i){return e.copy(t).slerp(s,i)}static slerpFlat(t,s,e,i,r,n,h){let a=e[i+0],o=e[i+1],l=e[i+2],u=e[i+3];const c=r[n+0],m=r[n+1],d=r[n+2],x=r[n+3];if(u!==x||a!==c||o!==m||l!==d){let t=1-h;const s=a*c+o*m+l*d+u*x,e=s>=0?1:-1,i=1-s*s;if(i>Number.EPSILON){const r=Math.sqrt(i),n=Math.atan2(r,s*e);t=Math.sin(t*n)/r,h=Math.sin(h*n)/r}const r=h*e;if(a=a*t+c*r,o=o*t+m*r,l=l*t+d*r,u=u*t+x*r,t===1-h){const t=1/Math.sqrt(a*a+o*o+l*l+u*u);a*=t,o*=t,l*=t,u*=t}}t[s]=a,t[s+1]=o,t[s+2]=l,t[s+3]=u}static multiplyQuaternionsFlat(t,s,e,i,r,n){const h=e[i],a=e[i+1],o=e[i+2],l=e[i+3],u=r[n],c=r[n+1],m=r[n+2],d=r[n+3];return t[s]=h*d+l*u+a*m-o*c,t[s+1]=a*d+l*c+o*u-h*m,t[s+2]=o*d+l*m+h*c-a*u,t[s+3]=l*d-h*u-a*c-o*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,s,e,i){return this._x=t,this._y=s,this._z=e,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,s){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const e=t._x,i=t._y,r=t._z,n=t._order,h=Math.cos,a=Math.sin,o=h(e/2),l=h(i/2),u=h(r/2),c=a(e/2),m=a(i/2),d=a(r/2);switch(n){case"XYZ":this._x=c*l*u+o*m*d,this._y=o*m*u-c*l*d,this._z=o*l*d+c*m*u,this._w=o*l*u-c*m*d;break;case"YXZ":this._x=c*l*u+o*m*d,this._y=o*m*u-c*l*d,this._z=o*l*d-c*m*u,this._w=o*l*u+c*m*d;break;case"ZXY":this._x=c*l*u-o*m*d,this._y=o*m*u+c*l*d,this._z=o*l*d+c*m*u,this._w=o*l*u-c*m*d;break;case"ZYX":this._x=c*l*u-o*m*d,this._y=o*m*u+c*l*d,this._z=o*l*d-c*m*u,this._w=o*l*u+c*m*d;break;case"YZX":this._x=c*l*u+o*m*d,this._y=o*m*u+c*l*d,this._z=o*l*d-c*m*u,this._w=o*l*u-c*m*d;break;case"XZY":this._x=c*l*u-o*m*d,this._y=o*m*u-c*l*d,this._z=o*l*d+c*m*u,this._w=o*l*u+c*m*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!1!==s&&this._onChangeCallback(),this}setFromAxisAngle(t,s){const e=s/2,i=Math.sin(e);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const s=t.elements,e=s[0],i=s[4],r=s[8],n=s[1],h=s[5],a=s[9],o=s[2],l=s[6],u=s[10],c=e+h+u;if(c>0){const t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(l-a)*t,this._y=(r-o)*t,this._z=(n-i)*t}else if(e>h&&e>u){const t=2*Math.sqrt(1+e-h-u);this._w=(l-a)/t,this._x=.25*t,this._y=(i+n)/t,this._z=(r+o)/t}else if(h>u){const t=2*Math.sqrt(1+h-e-u);this._w=(r-o)/t,this._x=(i+n)/t,this._y=.25*t,this._z=(a+l)/t}else{const t=2*Math.sqrt(1+u-e-h);this._w=(n-i)/t,this._x=(r+o)/t,this._y=(a+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,s){let e=t.dot(s)+1;return e<1e-6?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*s.z-t.z*s.y,this._y=t.z*s.x-t.x*s.z,this._z=t.x*s.y-t.y*s.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(e.clamp(this.dot(t),-1,1)))}rotateTowards(t,s){const e=this.angleTo(t);if(0===e)return this;const i=Math.min(1,s/e);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}inverse(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,s){return void 0!==s?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,s)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,s){const e=t._x,i=t._y,r=t._z,n=t._w,h=s._x,a=s._y,o=s._z,l=s._w;return this._x=e*l+n*h+i*o-r*a,this._y=i*l+n*a+r*h-e*o,this._z=r*l+n*o+e*a-i*h,this._w=n*l-e*h-i*a-r*o,this._onChangeCallback(),this}slerp(t,s){if(0===s)return this;if(1===s)return this.copy(t);const e=this._x,i=this._y,r=this._z,n=this._w;let h=n*t._w+e*t._x+i*t._y+r*t._z;if(h<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,h=-h):this.copy(t),h>=1)return this._w=n,this._x=e,this._y=i,this._z=r,this;const a=1-h*h;if(a<=Number.EPSILON){const t=1-s;return this._w=t*n+s*this._w,this._x=t*e+s*this._x,this._y=t*i+s*this._y,this._z=t*r+s*this._z,this.normalize(),this._onChangeCallback(),this}const o=Math.sqrt(a),l=Math.atan2(o,h),u=Math.sin((1-s)*l)/o,c=Math.sin(s*l)/o;return this._w=n*u+this._w*c,this._x=e*u+this._x*c,this._y=i*u+this._y*c,this._z=r*u+this._z*c,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,s){return void 0===s&&(s=0),this._x=t[s],this._y=t[s+1],this._z=t[s+2],this._w=t[s+3],this._onChangeCallback(),this}toArray(t,s){return void 0===t&&(t=[]),void 0===s&&(s=0),t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t[s+3]=this._w,t}fromBufferAttribute(t,s){return this._x=t.getX(s),this._y=t.getY(s),this._z=t.getZ(s),this._w=t.getW(s),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}class r{constructor(t=0,s=0,e=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=s,this.z=e}set(t,s,e){return void 0===e&&(e=this.z),this.x=t,this.y=s,this.z=e,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,s){return void 0!==s?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,s)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this.z=t.z+s.z,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this}sub(t,s){return void 0!==s?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,s)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this.z=t.z-s.z,this}multiply(t,s){return void 0!==s?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,s)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,s){return this.x=t.x*s.x,this.y=t.y*s.y,this.z=t.z*s.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(h.setFromEuler(t))}applyAxisAngle(t,s){return this.applyQuaternion(h.setFromAxisAngle(t,s))}applyMatrix3(t){const s=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*s+r[3]*e+r[6]*i,this.y=r[1]*s+r[4]*e+r[7]*i,this.z=r[2]*s+r[5]*e+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const s=this.x,e=this.y,i=this.z,r=t.elements,n=1/(r[3]*s+r[7]*e+r[11]*i+r[15]);return this.x=(r[0]*s+r[4]*e+r[8]*i+r[12])*n,this.y=(r[1]*s+r[5]*e+r[9]*i+r[13])*n,this.z=(r[2]*s+r[6]*e+r[10]*i+r[14])*n,this}applyQuaternion(t){const s=this.x,e=this.y,i=this.z,r=t.x,n=t.y,h=t.z,a=t.w,o=a*s+n*i-h*e,l=a*e+h*s-r*i,u=a*i+r*e-n*s,c=-r*s-n*e-h*i;return this.x=o*a+c*-r+l*-h-u*-n,this.y=l*a+c*-n+u*-r-o*-h,this.z=u*a+c*-h+o*-n-l*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const s=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*s+r[4]*e+r[8]*i,this.y=r[1]*s+r[5]*e+r[9]*i,this.z=r[2]*s+r[6]*e+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,s){return this.x=Math.max(t.x,Math.min(s.x,this.x)),this.y=Math.max(t.y,Math.min(s.y,this.y)),this.z=Math.max(t.z,Math.min(s.z,this.z)),this}clampScalar(t,s){return this.x=Math.max(t,Math.min(s,this.x)),this.y=Math.max(t,Math.min(s,this.y)),this.z=Math.max(t,Math.min(s,this.z)),this}clampLength(t,s){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(s,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this.z+=(t.z-this.z)*s,this}lerpVectors(t,s,e){return this.x=t.x+(s.x-t.x)*e,this.y=t.y+(s.y-t.y)*e,this.z=t.z+(s.z-t.z)*e,this}cross(t,s){return void 0!==s?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,s)):this.crossVectors(this,t)}crossVectors(t,s){const e=t.x,i=t.y,r=t.z,n=s.x,h=s.y,a=s.z;return this.x=i*a-r*h,this.y=r*n-e*a,this.z=e*h-i*n,this}projectOnVector(t){const s=t.lengthSq();if(0===s)return this.set(0,0,0);const e=t.dot(this)/s;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return n.copy(this).projectOnVector(t),this.sub(n)}reflect(t){return this.sub(n.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===s)return Math.PI/2;const i=this.dot(t)/s;return Math.acos(e.clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,e=this.y-t.y,i=this.z-t.z;return s*s+e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,s,e){const i=Math.sin(s)*t;return this.x=i*Math.sin(e),this.y=Math.cos(s)*t,this.z=i*Math.cos(e),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,s,e){return this.x=t*Math.sin(s),this.y=e,this.z=t*Math.cos(s),this}setFromMatrixPosition(t){const s=t.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this}setFromMatrixScale(t){const s=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=s,this.y=e,this.z=i,this}setFromMatrixColumn(t,s){return this.fromArray(t.elements,4*s)}setFromMatrix3Column(t,s){return this.fromArray(t.elements,3*s)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,s){return void 0===s&&(s=0),this.x=t[s],this.y=t[s+1],this.z=t[s+2],this}toArray(t,s){return void 0===t&&(t=[]),void 0===s&&(s=0),t[s]=this.x,t[s+1]=this.y,t[s+2]=this.z,t}fromBufferAttribute(t,s,e){return void 0!==e&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(s),this.y=t.getY(s),this.z=t.getZ(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}const n=new r,h=new i;class a{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,s,e,i,r,n,h,a,o,l,u,c,m,d,x,y){const _=this.elements;return _[0]=t,_[4]=s,_[8]=e,_[12]=i,_[1]=r,_[5]=n,_[9]=h,_[13]=a,_[2]=o,_[6]=l,_[10]=u,_[14]=c,_[3]=m,_[7]=d,_[11]=x,_[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new a).fromArray(this.elements)}copy(t){const s=this.elements,e=t.elements;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=e[12],s[13]=e[13],s[14]=e[14],s[15]=e[15],this}copyPosition(t){const s=this.elements,e=t.elements;return s[12]=e[12],s[13]=e[13],s[14]=e[14],this}extractBasis(t,s,e){return t.setFromMatrixColumn(this,0),s.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(t,s,e){return this.set(t.x,s.x,e.x,0,t.y,s.y,e.y,0,t.z,s.z,e.z,0,0,0,0,1),this}extractRotation(t){const s=this.elements,e=t.elements,i=1/o.setFromMatrixColumn(t,0).length(),r=1/o.setFromMatrixColumn(t,1).length(),n=1/o.setFromMatrixColumn(t,2).length();return s[0]=e[0]*i,s[1]=e[1]*i,s[2]=e[2]*i,s[3]=0,s[4]=e[4]*r,s[5]=e[5]*r,s[6]=e[6]*r,s[7]=0,s[8]=e[8]*n,s[9]=e[9]*n,s[10]=e[10]*n,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const s=this.elements,e=t.x,i=t.y,r=t.z,n=Math.cos(e),h=Math.sin(e),a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){const t=n*l,e=n*u,i=h*l,r=h*u;s[0]=a*l,s[4]=-a*u,s[8]=o,s[1]=e+i*o,s[5]=t-r*o,s[9]=-h*a,s[2]=r-t*o,s[6]=i+e*o,s[10]=n*a}else if("YXZ"===t.order){const t=a*l,e=a*u,i=o*l,r=o*u;s[0]=t+r*h,s[4]=i*h-e,s[8]=n*o,s[1]=n*u,s[5]=n*l,s[9]=-h,s[2]=e*h-i,s[6]=r+t*h,s[10]=n*a}else if("ZXY"===t.order){const t=a*l,e=a*u,i=o*l,r=o*u;s[0]=t-r*h,s[4]=-n*u,s[8]=i+e*h,s[1]=e+i*h,s[5]=n*l,s[9]=r-t*h,s[2]=-n*o,s[6]=h,s[10]=n*a}else if("ZYX"===t.order){const t=n*l,e=n*u,i=h*l,r=h*u;s[0]=a*l,s[4]=i*o-e,s[8]=t*o+r,s[1]=a*u,s[5]=r*o+t,s[9]=e*o-i,s[2]=-o,s[6]=h*a,s[10]=n*a}else if("YZX"===t.order){const t=n*a,e=n*o,i=h*a,r=h*o;s[0]=a*l,s[4]=r-t*u,s[8]=i*u+e,s[1]=u,s[5]=n*l,s[9]=-h*l,s[2]=-o*l,s[6]=e*u+i,s[10]=t-r*u}else if("XZY"===t.order){const t=n*a,e=n*o,i=h*a,r=h*o;s[0]=a*l,s[4]=-u,s[8]=o*l,s[1]=t*u+r,s[5]=n*l,s[9]=e*u-i,s[2]=i*u-e,s[6]=h*l,s[10]=r*u+t}return s[3]=0,s[7]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromQuaternion(t){return this.compose(u,t,c)}lookAt(t,s,e){const i=this.elements;return x.subVectors(t,s),0===x.lengthSq()&&(x.z=1),x.normalize(),m.crossVectors(e,x),0===m.lengthSq()&&(1===Math.abs(e.z)?x.x+=1e-4:x.z+=1e-4,x.normalize(),m.crossVectors(e,x)),m.normalize(),d.crossVectors(x,m),i[0]=m.x,i[4]=d.x,i[8]=x.x,i[1]=m.y,i[5]=d.y,i[9]=x.y,i[2]=m.z,i[6]=d.z,i[10]=x.z,this}multiply(t,s){return void 0!==s?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,s)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const e=t.elements,i=s.elements,r=this.elements,n=e[0],h=e[4],a=e[8],o=e[12],l=e[1],u=e[5],c=e[9],m=e[13],d=e[2],x=e[6],y=e[10],_=e[14],p=e[3],M=e[7],f=e[11],z=e[15],g=i[0],w=i[4],b=i[8],v=i[12],C=i[1],E=i[5],k=i[9],A=i[13],O=i[2],F=i[6],S=i[10],R=i[14],W=i[3],q=i[7],T=i[11],j=i[15];return r[0]=n*g+h*C+a*O+o*W,r[4]=n*w+h*E+a*F+o*q,r[8]=n*b+h*k+a*S+o*T,r[12]=n*v+h*A+a*R+o*j,r[1]=l*g+u*C+c*O+m*W,r[5]=l*w+u*E+c*F+m*q,r[9]=l*b+u*k+c*S+m*T,r[13]=l*v+u*A+c*R+m*j,r[2]=d*g+x*C+y*O+_*W,r[6]=d*w+x*E+y*F+_*q,r[10]=d*b+x*k+y*S+_*T,r[14]=d*v+x*A+y*R+_*j,r[3]=p*g+M*C+f*O+z*W,r[7]=p*w+M*E+f*F+z*q,r[11]=p*b+M*k+f*S+z*T,r[15]=p*v+M*A+f*R+z*j,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[4]*=t,s[8]*=t,s[12]*=t,s[1]*=t,s[5]*=t,s[9]*=t,s[13]*=t,s[2]*=t,s[6]*=t,s[10]*=t,s[14]*=t,s[3]*=t,s[7]*=t,s[11]*=t,s[15]*=t,this}determinant(){const t=this.elements,s=t[0],e=t[4],i=t[8],r=t[12],n=t[1],h=t[5],a=t[9],o=t[13],l=t[2],u=t[6],c=t[10],m=t[14];return t[3]*(+r*a*u-i*o*u-r*h*c+e*o*c+i*h*m-e*a*m)+t[7]*(+s*a*m-s*o*c+r*n*c-i*n*m+i*o*l-r*a*l)+t[11]*(+s*o*u-s*h*m-r*n*u+e*n*m+r*h*l-e*o*l)+t[15]*(-i*h*l-s*a*u+s*h*c+i*n*u-e*n*c+e*a*l)}transpose(){const t=this.elements;let s;return s=t[1],t[1]=t[4],t[4]=s,s=t[2],t[2]=t[8],t[8]=s,s=t[6],t[6]=t[9],t[9]=s,s=t[3],t[3]=t[12],t[12]=s,s=t[7],t[7]=t[13],t[13]=s,s=t[11],t[11]=t[14],t[14]=s,this}setPosition(t,s,e){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=s,i[14]=e),this}getInverse(t,s){void 0!==s&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");const e=this.elements,i=t.elements,r=i[0],n=i[1],h=i[2],a=i[3],o=i[4],l=i[5],u=i[6],c=i[7],m=i[8],d=i[9],x=i[10],y=i[11],_=i[12],p=i[13],M=i[14],f=i[15],z=d*M*c-p*x*c+p*u*y-l*M*y-d*u*f+l*x*f,g=_*x*c-m*M*c-_*u*y+o*M*y+m*u*f-o*x*f,w=m*p*c-_*d*c+_*l*y-o*p*y-m*l*f+o*d*f,b=_*d*u-m*p*u-_*l*x+o*p*x+m*l*M-o*d*M,v=r*z+n*g+h*w+a*b;if(0===v)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/v;return e[0]=z*C,e[1]=(p*x*a-d*M*a-p*h*y+n*M*y+d*h*f-n*x*f)*C,e[2]=(l*M*a-p*u*a+p*h*c-n*M*c-l*h*f+n*u*f)*C,e[3]=(d*u*a-l*x*a-d*h*c+n*x*c+l*h*y-n*u*y)*C,e[4]=g*C,e[5]=(m*M*a-_*x*a+_*h*y-r*M*y-m*h*f+r*x*f)*C,e[6]=(_*u*a-o*M*a-_*h*c+r*M*c+o*h*f-r*u*f)*C,e[7]=(o*x*a-m*u*a+m*h*c-r*x*c-o*h*y+r*u*y)*C,e[8]=w*C,e[9]=(_*d*a-m*p*a-_*n*y+r*p*y+m*n*f-r*d*f)*C,e[10]=(o*p*a-_*l*a+_*n*c-r*p*c-o*n*f+r*l*f)*C,e[11]=(m*l*a-o*d*a-m*n*c+r*d*c+o*n*y-r*l*y)*C,e[12]=b*C,e[13]=(m*p*h-_*d*h+_*n*x-r*p*x-m*n*M+r*d*M)*C,e[14]=(_*l*h-o*p*h-_*n*u+r*p*u+o*n*M-r*l*M)*C,e[15]=(o*d*h-m*l*h+m*n*u-r*d*u-o*n*x+r*l*x)*C,this}scale(t){const s=this.elements,e=t.x,i=t.y,r=t.z;return s[0]*=e,s[4]*=i,s[8]*=r,s[1]*=e,s[5]*=i,s[9]*=r,s[2]*=e,s[6]*=i,s[10]*=r,s[3]*=e,s[7]*=i,s[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,s=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(s,e,i))}makeTranslation(t,s,e){return this.set(1,0,0,t,0,1,0,s,0,0,1,e,0,0,0,1),this}makeRotationX(t){const s=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,s,-e,0,0,e,s,0,0,0,0,1),this}makeRotationY(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,0,e,0,0,1,0,0,-e,0,s,0,0,0,0,1),this}makeRotationZ(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,-e,0,0,e,s,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,s){const e=Math.cos(s),i=Math.sin(s),r=1-e,n=t.x,h=t.y,a=t.z,o=r*n,l=r*h;return this.set(o*n+e,o*h-i*a,o*a+i*h,0,o*h+i*a,l*h+e,l*a-i*n,0,o*a-i*h,l*a+i*n,r*a*a+e,0,0,0,0,1),this}makeScale(t,s,e){return this.set(t,0,0,0,0,s,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,s,e){return this.set(1,s,e,0,t,1,e,0,t,s,1,0,0,0,0,1),this}compose(t,s,e){const i=this.elements,r=s._x,n=s._y,h=s._z,a=s._w,o=r+r,l=n+n,u=h+h,c=r*o,m=r*l,d=r*u,x=n*l,y=n*u,_=h*u,p=a*o,M=a*l,f=a*u,z=e.x,g=e.y,w=e.z;return i[0]=(1-(x+_))*z,i[1]=(m+f)*z,i[2]=(d-M)*z,i[3]=0,i[4]=(m-f)*g,i[5]=(1-(c+_))*g,i[6]=(y+p)*g,i[7]=0,i[8]=(d+M)*w,i[9]=(y-p)*w,i[10]=(1-(c+x))*w,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,s,e){const i=this.elements;let r=o.set(i[0],i[1],i[2]).length();const n=o.set(i[4],i[5],i[6]).length(),h=o.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],l.copy(this);const a=1/r,u=1/n,c=1/h;return l.elements[0]*=a,l.elements[1]*=a,l.elements[2]*=a,l.elements[4]*=u,l.elements[5]*=u,l.elements[6]*=u,l.elements[8]*=c,l.elements[9]*=c,l.elements[10]*=c,s.setFromRotationMatrix(l),e.x=r,e.y=n,e.z=h,this}makePerspective(t,s,e,i,r,n){void 0===n&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const h=this.elements,a=2*r/(s-t),o=2*r/(e-i),l=(s+t)/(s-t),u=(e+i)/(e-i),c=-(n+r)/(n-r),m=-2*n*r/(n-r);return h[0]=a,h[4]=0,h[8]=l,h[12]=0,h[1]=0,h[5]=o,h[9]=u,h[13]=0,h[2]=0,h[6]=0,h[10]=c,h[14]=m,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,s,e,i,r,n){const h=this.elements,a=1/(s-t),o=1/(e-i),l=1/(n-r),u=(s+t)*a,c=(e+i)*o,m=(n+r)*l;return h[0]=2*a,h[4]=0,h[8]=0,h[12]=-u,h[1]=0,h[5]=2*o,h[9]=0,h[13]=-c,h[2]=0,h[6]=0,h[10]=-2*l,h[14]=-m,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(t){const s=this.elements,e=t.elements;for(let t=0;t<16;t++)if(s[t]!==e[t])return!1;return!0}fromArray(t,s){void 0===s&&(s=0);for(let e=0;e<16;e++)this.elements[e]=t[e+s];return this}toArray(t,s){void 0===t&&(t=[]),void 0===s&&(s=0);const e=this.elements;return t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3],t[s+4]=e[4],t[s+5]=e[5],t[s+6]=e[6],t[s+7]=e[7],t[s+8]=e[8],t[s+9]=e[9],t[s+10]=e[10],t[s+11]=e[11],t[s+12]=e[12],t[s+13]=e[13],t[s+14]=e[14],t[s+15]=e[15],t}}const o=new r,l=new a,u=new r(0,0,0),c=new r(1,1,1),m=new r,d=new r,x=new r;function y(){}Object.assign(y.prototype,{addEventListener:function(t,s){void 0===this._listeners&&(this._listeners={});const e=this._listeners;void 0===e[t]&&(e[t]=[]),-1===e[t].indexOf(s)&&e[t].push(s)},hasEventListener:function(t,s){if(void 0===this._listeners)return!1;const e=this._listeners;return void 0!==e[t]&&-1!==e[t].indexOf(s)},removeEventListener:function(t,s){if(void 0===this._listeners)return;const e=this._listeners[t];if(void 0!==e){const t=e.indexOf(s);-1!==t&&e.splice(t,1)}},dispatchEvent:function(t){if(void 0===this._listeners)return;const s=this._listeners[t.type];if(void 0!==s){t.target=this;const e=s.slice(0);for(let s=0,i=e.length;s<i;s++)e[s].call(this,t)}}});class _{constructor(t=0,s=0,e=0,i=_.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=s,this._z=e,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,s,e,i){return this._x=t,this._y=s,this._z=e,this._order=i||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,s,i){const r=e.clamp,n=t.elements,h=n[0],a=n[4],o=n[8],l=n[1],u=n[5],c=n[9],m=n[2],d=n[6],x=n[10];switch(s=s||this._order){case"XYZ":this._y=Math.asin(r(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,x),this._z=Math.atan2(-a,h)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-r(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,x),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-m,h),this._z=0);break;case"ZXY":this._x=Math.asin(r(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-m,x),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,h));break;case"ZYX":this._y=Math.asin(-r(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(d,x),this._z=Math.atan2(l,h)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-m,h)):(this._x=0,this._y=Math.atan2(o,x));break;case"XZY":this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(o,h)):(this._x=Math.atan2(-c,x),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+s)}return this._order=s,!1!==i&&this._onChangeCallback(),this}setFromQuaternion(t,s,e){return p.makeRotationFromQuaternion(t),this.setFromRotationMatrix(p,s,e)}setFromVector3(t,s){return this.set(t.x,t.y,t.z,s||this._order)}reorder(t){return M.setFromEuler(this),this.setFromQuaternion(M,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t,s){return void 0===t&&(t=[]),void 0===s&&(s=0),t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t[s+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new r(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}_.DefaultOrder="XYZ",_.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const p=new a,M=new i;class f{constructor(){this.mask=1}set(t){this.mask=1<<t}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return!!(this.mask&t.mask)}}class z{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,s,e,i,r,n,h,a,o){const l=this.elements;return l[0]=t,l[1]=i,l[2]=h,l[3]=s,l[4]=r,l[5]=a,l[6]=e,l[7]=n,l[8]=o,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return(new this.constructor).fromArray(this.elements)}copy(t){const s=this.elements,e=t.elements;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],this}extractBasis(t,s,e){return t.setFromMatrix3Column(this,0),s.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const s=t.elements;return this.set(s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const e=t.elements,i=s.elements,r=this.elements,n=e[0],h=e[3],a=e[6],o=e[1],l=e[4],u=e[7],c=e[2],m=e[5],d=e[8],x=i[0],y=i[3],_=i[6],p=i[1],M=i[4],f=i[7],z=i[2],g=i[5],w=i[8];return r[0]=n*x+h*p+a*z,r[3]=n*y+h*M+a*g,r[6]=n*_+h*f+a*w,r[1]=o*x+l*p+u*z,r[4]=o*y+l*M+u*g,r[7]=o*_+l*f+u*w,r[2]=c*x+m*p+d*z,r[5]=c*y+m*M+d*g,r[8]=c*_+m*f+d*w,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[3]*=t,s[6]*=t,s[1]*=t,s[4]*=t,s[7]*=t,s[2]*=t,s[5]*=t,s[8]*=t,this}determinant(){const t=this.elements,s=t[0],e=t[1],i=t[2],r=t[3],n=t[4],h=t[5],a=t[6],o=t[7],l=t[8];return s*n*l-s*h*o-e*r*l+e*h*a+i*r*o-i*n*a}getInverse(t,s){void 0!==s&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");const e=t.elements,i=this.elements,r=e[0],n=e[1],h=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],m=e[8],d=m*o-l*c,x=l*u-m*a,y=c*a-o*u,_=r*d+n*x+h*y;if(0===_)return this.set(0,0,0,0,0,0,0,0,0);const p=1/_;return i[0]=d*p,i[1]=(h*c-m*n)*p,i[2]=(l*n-h*o)*p,i[3]=x*p,i[4]=(m*r-h*u)*p,i[5]=(h*a-l*r)*p,i[6]=y*p,i[7]=(n*u-c*r)*p,i[8]=(o*r-n*a)*p,this}transpose(){let t;const s=this.elements;return t=s[1],s[1]=s[3],s[3]=t,t=s[2],s[2]=s[6],s[6]=t,t=s[5],s[5]=s[7],s[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).getInverse(this).transpose()}transposeIntoArray(t){const s=this.elements;return t[0]=s[0],t[1]=s[3],t[2]=s[6],t[3]=s[1],t[4]=s[4],t[5]=s[7],t[6]=s[2],t[7]=s[5],t[8]=s[8],this}setUvTransform(t,s,e,i,r,n,h){const a=Math.cos(r),o=Math.sin(r);this.set(e*a,e*o,-e*(a*n+o*h)+n+t,-i*o,i*a,-i*(-o*n+a*h)+h+s,0,0,1)}scale(t,s){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=s,e[4]*=s,e[7]*=s,this}rotate(t){const s=Math.cos(t),e=Math.sin(t),i=this.elements,r=i[0],n=i[3],h=i[6],a=i[1],o=i[4],l=i[7];return i[0]=s*r+e*a,i[3]=s*n+e*o,i[6]=s*h+e*l,i[1]=-e*r+s*a,i[4]=-e*n+s*o,i[7]=-e*h+s*l,this}translate(t,s){const e=this.elements;return e[0]+=t*e[2],e[3]+=t*e[5],e[6]+=t*e[8],e[1]+=s*e[2],e[4]+=s*e[5],e[7]+=s*e[8],this}equals(t){const s=this.elements,e=t.elements;for(let t=0;t<9;t++)if(s[t]!==e[t])return!1;return!0}fromArray(t,s){void 0===s&&(s=0);for(let e=0;e<9;e++)this.elements[e]=t[e+s];return this}toArray(t,s){void 0===t&&(t=[]),void 0===s&&(s=0);const e=this.elements;return t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3],t[s+4]=e[4],t[s+5]=e[5],t[s+6]=e[6],t[s+7]=e[7],t[s+8]=e[8],t}}let g=0;const w=new r,b=new i,v=new a,C=new r,E=new r,k=new r,A=new i,O=new r(1,0,0),F=new r(0,1,0),S=new r(0,0,1),R={type:"added"},W={type:"removed"};function q(){Object.defineProperty(this,"id",{value:g++}),this.uuid=e.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=q.DefaultUp.clone();const t=new r,s=new _,n=new i,h=new r(1,1,1);s._onChange((function(){n.setFromEuler(s,!1)})),n._onChange((function(){s.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:s},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:h},modelViewMatrix:{value:new a},normalMatrix:{value:new z}}),this.matrix=new a,this.matrixWorld=new a,this.matrixAutoUpdate=q.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new f,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}q.DefaultUp=new r(0,1,0),q.DefaultMatrixAutoUpdate=!0,q.prototype=Object.assign(Object.create(y.prototype),{constructor:q,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,s){this.quaternion.setFromAxisAngle(t,s)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,s){return b.setFromAxisAngle(t,s),this.quaternion.multiply(b),this},rotateOnWorldAxis:function(t,s){return b.setFromAxisAngle(t,s),this.quaternion.premultiply(b),this},rotateX:function(t){return this.rotateOnAxis(O,t)},rotateY:function(t){return this.rotateOnAxis(F,t)},rotateZ:function(t){return this.rotateOnAxis(S,t)},translateOnAxis:function(t,s){return w.copy(t).applyQuaternion(this.quaternion),this.position.add(w.multiplyScalar(s)),this},translateX:function(t){return this.translateOnAxis(O,t)},translateY:function(t){return this.translateOnAxis(F,t)},translateZ:function(t){return this.translateOnAxis(S,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(v.getInverse(this.matrixWorld))},lookAt:function(t,s,e){t.isVector3?C.copy(t):C.set(t,s,e);const i=this.parent;this.updateWorldMatrix(!0,!1),E.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?v.lookAt(E,C,this.up):v.lookAt(C,E,this.up),this.quaternion.setFromRotationMatrix(v),i&&(v.extractRotation(i.matrixWorld),b.setFromRotationMatrix(v),this.quaternion.premultiply(b.inverse()))},add:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(R)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const s=this.children.indexOf(t);return-1!==s&&(t.parent=null,this.children.splice(s,1),t.dispatchEvent(W)),this},attach:function(t){return this.updateWorldMatrix(!0,!1),v.getInverse(this.matrixWorld),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),v.multiply(t.parent.matrixWorld)),t.applyMatrix4(v),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,s){if(this[t]===s)return this;for(let e=0,i=this.children.length;e<i;e++){const i=this.children[e].getObjectByProperty(t,s);if(void 0!==i)return i}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new r),this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new i),this.updateMatrixWorld(!0),this.matrixWorld.decompose(E,t,k),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new r),this.updateMatrixWorld(!0),this.matrixWorld.decompose(E,A,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new r),this.updateMatrixWorld(!0);const s=this.matrixWorld.elements;return t.set(s[8],s[9],s[10]).normalize()},raycast:function(){},traverse:function(t){t(this);const s=this.children;for(let e=0,i=s.length;e<i;e++)s[e].traverse(t)},traverseVisible:function(t){if(!1===this.visible)return;t(this);const s=this.children;for(let e=0,i=s.length;e<i;e++)s[e].traverseVisible(t)},traverseAncestors:function(t){const s=this.parent;null!==s&&(t(s),s.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const s=this.children;for(let e=0,i=s.length;e<i;e++)s[e].updateMatrixWorld(t)},updateWorldMatrix:function(t,s){const e=this.parent;if(!0===t&&null!==e&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===s){const t=this.children;for(let s=0,e=t.length;s<e;s++)t[s].updateWorldMatrix(!1,!0)}},toJSON:function(t){const s=void 0===t||"string"==typeof t,e={};s&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const i={};function r(s,e){return void 0===s[e.uuid]&&(s[e.uuid]=e.toJSON(t)),e.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const s=this.geometry.parameters;if(void 0!==s&&void 0!==s.shapes){const e=s.shapes;if(Array.isArray(e))for(let s=0,i=e.length;s<i;s++){const i=e[s];r(t.shapes,i)}else r(t.shapes,e)}}if(void 0!==this.material)if(Array.isArray(this.material)){const s=[];for(let e=0,i=this.material.length;e<i;e++)s.push(r(t.materials,this.material[e]));i.material=s}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let s=0;s<this.children.length;s++)i.children.push(this.children[s].toJSON(t).object)}if(s){const s=n(t.geometries),i=n(t.materials),r=n(t.textures),h=n(t.images),a=n(t.shapes);s.length>0&&(e.geometries=s),i.length>0&&(e.materials=i),r.length>0&&(e.textures=r),h.length>0&&(e.images=h),a.length>0&&(e.shapes=a)}return e.object=i,e;function n(t){const s=[];for(const e in t){const i=t[e];delete i.metadata,s.push(i)}return s}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,s){if(void 0===s&&(s=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===s)for(let s=0;s<t.children.length;s++){const e=t.children[s];this.add(e.clone())}return this}});export{q as Object3D};