From b70c697b887bc8bfd231c5ad01358170193a4a41 Mon Sep 17 00:00:00 2001 From: Nathan White Date: Tue, 16 Jul 2024 07:18:37 -0700 Subject: [PATCH] Updates --- .../{compile-worker-dMA9xPCI.js => compile-worker-CjCt9Tta.js} | 2 +- assets/{index-zfQAfM59.js => index-BC1ykvt1.js} | 2 +- index.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename assets/{compile-worker-dMA9xPCI.js => compile-worker-CjCt9Tta.js} (99%) rename assets/{index-zfQAfM59.js => index-BC1ykvt1.js} (99%) diff --git a/assets/compile-worker-dMA9xPCI.js b/assets/compile-worker-CjCt9Tta.js similarity index 99% rename from assets/compile-worker-dMA9xPCI.js rename to assets/compile-worker-CjCt9Tta.js index 04b5df13..5908e251 100644 --- a/assets/compile-worker-dMA9xPCI.js +++ b/assets/compile-worker-CjCt9Tta.js @@ -2,4 +2,4 @@ const Zt=180/Math.PI,j=Math.PI,ot=.079,pt=2*Math.PI*ot*180/1.5,mt=45,et=1e3,me=3 * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT - */const Ce="162",Re=300,ge=1e3,It=1001,Me=1002,we=1003,ds=1006,_s=1008,ys=1009,xs=1014,ps=1020,ms=1023,$t=1026,ze=1027,fs="",gs=515,Ot=2e3,ve=2001;class Ie{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const s=this._listeners[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let n=0,h=i.length;n>8&255]+R[f>>16&255]+R[f>>24&255]+"-"+R[t&255]+R[t>>8&255]+"-"+R[t>>16&15|64]+R[t>>24&255]+"-"+R[e&63|128]+R[e>>8&255]+"-"+R[e>>16&255]+R[e>>24&255]+R[s&255]+R[s>>8&255]+R[s>>16&255]+R[s>>24&255]).toLowerCase()}function $(f,t,e){return Math.max(t,Math.min(e,f))}class Dt{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;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;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos($(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,h=this.y-t.y;return this.x=n*s-h*i+t.x,this.y=n*i+h*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Tt{constructor(t,e,s,i,n,h,a,r,o){Tt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,h,a,r,o)}set(t,e,s,i,n,h,a,r,o){const l=this.elements;return l[0]=t,l[1]=i,l[2]=a,l[3]=e,l[4]=n,l[5]=r,l[6]=s,l[7]=h,l[8]=o,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,h=s[0],a=s[3],r=s[6],o=s[1],l=s[4],u=s[7],d=s[2],_=s[5],y=s[8],x=i[0],g=i[3],m=i[6],D=i[1],T=i[4],c=i[7],p=i[2],v=i[5],M=i[8];return n[0]=h*x+a*D+r*p,n[3]=h*g+a*T+r*v,n[6]=h*m+a*c+r*M,n[1]=o*x+l*D+u*p,n[4]=o*g+l*T+u*v,n[7]=o*m+l*c+u*M,n[2]=d*x+_*D+y*p,n[5]=d*g+_*T+y*v,n[8]=d*m+_*c+y*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],h=t[4],a=t[5],r=t[6],o=t[7],l=t[8];return e*h*l-e*a*o-s*n*l+s*a*r+i*n*o-i*h*r}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],h=t[4],a=t[5],r=t[6],o=t[7],l=t[8],u=l*h-a*o,d=a*r-l*n,_=o*n-h*r,y=e*u+s*d+i*_;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/y;return t[0]=u*x,t[1]=(i*o-l*s)*x,t[2]=(a*s-i*h)*x,t[3]=d*x,t[4]=(l*e-i*r)*x,t[5]=(i*n-a*e)*x,t[6]=_*x,t[7]=(s*r-o*e)*x,t[8]=(h*e-s*n)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,h,a){const r=Math.cos(n),o=Math.sin(n);return this.set(s*r,s*o,-s*(r*h+o*a)+h+t,-i*o,i*r,-i*(-o*h+r*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Qt.makeScale(t,e)),this}rotate(t){return this.premultiply(Qt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Qt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Qt=new Tt;function be(f){return document.createElementNS("http://www.w3.org/1999/xhtml",f)}function Kt(f){return f<.04045?f*.0773993808:Math.pow(f*.9478672986+.0521327014,2.4)}let ft;class Ms{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ft===void 0&&(ft=be("canvas")),ft.width=t.width,ft.height=t.height;const s=ft.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=ft}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=be("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let h=0;h0&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Re)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ge:t.x=t.x-Math.floor(t.x);break;case It:t.x=t.x<0?0:1;break;case Me:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ge:t.y=t.y-Math.floor(t.y);break;case It:t.y=t.y<0?0:1;break;case Me:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}}it.DEFAULT_IMAGE=null;it.DEFAULT_MAPPING=Re;it.DEFAULT_ANISOTROPY=1;class ct{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,h,a){let r=s[i+0],o=s[i+1],l=s[i+2],u=s[i+3];const d=n[h+0],_=n[h+1],y=n[h+2],x=n[h+3];if(a===0){t[e+0]=r,t[e+1]=o,t[e+2]=l,t[e+3]=u;return}if(a===1){t[e+0]=d,t[e+1]=_,t[e+2]=y,t[e+3]=x;return}if(u!==x||r!==d||o!==_||l!==y){let g=1-a;const m=r*d+o*_+l*y+u*x,D=m>=0?1:-1,T=1-m*m;if(T>Number.EPSILON){const p=Math.sqrt(T),v=Math.atan2(p,m*D);g=Math.sin(g*v)/p,a=Math.sin(a*v)/p}const c=a*D;if(r=r*g+d*c,o=o*g+_*c,l=l*g+y*c,u=u*g+x*c,g===1-a){const p=1/Math.sqrt(r*r+o*o+l*l+u*u);r*=p,o*=p,l*=p,u*=p}}t[e]=r,t[e+1]=o,t[e+2]=l,t[e+3]=u}static multiplyQuaternionsFlat(t,e,s,i,n,h){const a=s[i],r=s[i+1],o=s[i+2],l=s[i+3],u=n[h],d=n[h+1],_=n[h+2],y=n[h+3];return t[e]=a*y+l*u+r*_-o*d,t[e+1]=r*y+l*d+o*u-a*_,t[e+2]=o*y+l*_+a*d-r*u,t[e+3]=l*y-a*u-r*d-o*_,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,e,s,i){return this._x=t,this._y=e,this._z=s,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,e=!0){const s=t._x,i=t._y,n=t._z,h=t._order,a=Math.cos,r=Math.sin,o=a(s/2),l=a(i/2),u=a(n/2),d=r(s/2),_=r(i/2),y=r(n/2);switch(h){case"XYZ":this._x=d*l*u+o*_*y,this._y=o*_*u-d*l*y,this._z=o*l*y+d*_*u,this._w=o*l*u-d*_*y;break;case"YXZ":this._x=d*l*u+o*_*y,this._y=o*_*u-d*l*y,this._z=o*l*y-d*_*u,this._w=o*l*u+d*_*y;break;case"ZXY":this._x=d*l*u-o*_*y,this._y=o*_*u+d*l*y,this._z=o*l*y+d*_*u,this._w=o*l*u-d*_*y;break;case"ZYX":this._x=d*l*u-o*_*y,this._y=o*_*u+d*l*y,this._z=o*l*y-d*_*u,this._w=o*l*u+d*_*y;break;case"YZX":this._x=d*l*u+o*_*y,this._y=o*_*u+d*l*y,this._z=o*l*y-d*_*u,this._w=o*l*u-d*_*y;break;case"XZY":this._x=d*l*u-o*_*y,this._y=o*_*u-d*l*y,this._z=o*l*y+d*_*u,this._w=o*l*u+d*_*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+h)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],n=e[8],h=e[1],a=e[5],r=e[9],o=e[2],l=e[6],u=e[10],d=s+a+u;if(d>0){const _=.5/Math.sqrt(d+1);this._w=.25/_,this._x=(l-r)*_,this._y=(n-o)*_,this._z=(h-i)*_}else if(s>a&&s>u){const _=2*Math.sqrt(1+s-a-u);this._w=(l-r)/_,this._x=.25*_,this._y=(i+h)/_,this._z=(n+o)/_}else if(a>u){const _=2*Math.sqrt(1+a-s-u);this._w=(n-o)/_,this._x=(i+h)/_,this._y=.25*_,this._z=(r+l)/_}else{const _=2*Math.sqrt(1+u-s-a);this._w=(h-i)/_,this._x=(n+o)/_,this._y=(r+l)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return sMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs($(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){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 t===0?(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){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,n=t._z,h=t._w,a=e._x,r=e._y,o=e._z,l=e._w;return this._x=s*l+h*a+i*o-n*r,this._y=i*l+h*r+n*a-s*o,this._z=n*l+h*o+s*r-i*a,this._w=h*l-s*a-i*r-n*o,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,i=this._y,n=this._z,h=this._w;let a=h*t._w+s*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=h,this._x=s,this._y=i,this._z=n,this;const r=1-a*a;if(r<=Number.EPSILON){const _=1-e;return this._w=_*h+e*this._w,this._x=_*s+e*this._x,this._y=_*i+e*this._y,this._z=_*n+e*this._z,this.normalize(),this}const o=Math.sqrt(r),l=Math.atan2(o,a),u=Math.sin((1-e)*l)/o,d=Math.sin(e*l)/o;return this._w=h*u+this._w*d,this._x=s*u+this._x*d,this._y=i*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{constructor(t=0,e=0,s=0){L.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,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,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;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){return 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,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return 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,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return 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,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ee.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ee.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=t.elements,h=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*h,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*h,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*h,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,h=t.y,a=t.z,r=t.w,o=2*(h*i-a*s),l=2*(a*e-n*i),u=2*(n*s-h*e);return this.x=e+r*o+h*u-a*l,this.y=s+r*l+a*o-n*u,this.z=i+r*u+n*l-h*o,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[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,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(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,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,n=t.z,h=e.x,a=e.y,r=e.z;return this.x=i*r-n*a,this.y=n*h-s*r,this.z=s*a-i*h,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ee.copy(this).projectOnVector(t),this.sub(ee)}reflect(t){return this.sub(ee.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos($(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+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,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ee=new L,Ee=new ct;class Q{constructor(t,e,s,i,n,h,a,r,o,l,u,d,_,y,x,g){Q.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,h,a,r,o,l,u,d,_,y,x,g)}set(t,e,s,i,n,h,a,r,o,l,u,d,_,y,x,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=s,m[12]=i,m[1]=n,m[5]=h,m[9]=a,m[13]=r,m[2]=o,m[6]=l,m[10]=u,m[14]=d,m[3]=_,m[7]=y,m[11]=x,m[15]=g,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 Q().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/gt.setFromMatrixColumn(t,0).length(),n=1/gt.setFromMatrixColumn(t,1).length(),h=1/gt.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*h,e[9]=s[9]*h,e[10]=s[10]*h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,n=t.z,h=Math.cos(s),a=Math.sin(s),r=Math.cos(i),o=Math.sin(i),l=Math.cos(n),u=Math.sin(n);if(t.order==="XYZ"){const d=h*l,_=h*u,y=a*l,x=a*u;e[0]=r*l,e[4]=-r*u,e[8]=o,e[1]=_+y*o,e[5]=d-x*o,e[9]=-a*r,e[2]=x-d*o,e[6]=y+_*o,e[10]=h*r}else if(t.order==="YXZ"){const d=r*l,_=r*u,y=o*l,x=o*u;e[0]=d+x*a,e[4]=y*a-_,e[8]=h*o,e[1]=h*u,e[5]=h*l,e[9]=-a,e[2]=_*a-y,e[6]=x+d*a,e[10]=h*r}else if(t.order==="ZXY"){const d=r*l,_=r*u,y=o*l,x=o*u;e[0]=d-x*a,e[4]=-h*u,e[8]=y+_*a,e[1]=_+y*a,e[5]=h*l,e[9]=x-d*a,e[2]=-h*o,e[6]=a,e[10]=h*r}else if(t.order==="ZYX"){const d=h*l,_=h*u,y=a*l,x=a*u;e[0]=r*l,e[4]=y*o-_,e[8]=d*o+x,e[1]=r*u,e[5]=x*o+d,e[9]=_*o-y,e[2]=-o,e[6]=a*r,e[10]=h*r}else if(t.order==="YZX"){const d=h*r,_=h*o,y=a*r,x=a*o;e[0]=r*l,e[4]=x-d*u,e[8]=y*u+_,e[1]=u,e[5]=h*l,e[9]=-a*l,e[2]=-o*l,e[6]=_*u+y,e[10]=d-x*u}else if(t.order==="XZY"){const d=h*r,_=h*o,y=a*r,x=a*o;e[0]=r*l,e[4]=-u,e[8]=o*l,e[1]=d*u+x,e[5]=h*l,e[9]=_*u-y,e[2]=y*u-_,e[6]=a*l,e[10]=x*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bs,t,Es)}lookAt(t,e,s){const i=this.elements;return O.subVectors(t,e),O.lengthSq()===0&&(O.z=1),O.normalize(),st.crossVectors(s,O),st.lengthSq()===0&&(Math.abs(s.z)===1?O.x+=1e-4:O.z+=1e-4,O.normalize(),st.crossVectors(s,O)),st.normalize(),kt.crossVectors(O,st),i[0]=st.x,i[4]=kt.x,i[8]=O.x,i[1]=st.y,i[5]=kt.y,i[9]=O.y,i[2]=st.z,i[6]=kt.z,i[10]=O.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,h=s[0],a=s[4],r=s[8],o=s[12],l=s[1],u=s[5],d=s[9],_=s[13],y=s[2],x=s[6],g=s[10],m=s[14],D=s[3],T=s[7],c=s[11],p=s[15],v=i[0],M=i[4],N=i[8],W=i[12],q=i[1],Y=i[5],ut=i[9],dt=i[13],_t=i[2],B=i[6],G=i[10],J=i[14],F=i[3],C=i[7],K=i[11],tt=i[15];return n[0]=h*v+a*q+r*_t+o*F,n[4]=h*M+a*Y+r*B+o*C,n[8]=h*N+a*ut+r*G+o*K,n[12]=h*W+a*dt+r*J+o*tt,n[1]=l*v+u*q+d*_t+_*F,n[5]=l*M+u*Y+d*B+_*C,n[9]=l*N+u*ut+d*G+_*K,n[13]=l*W+u*dt+d*J+_*tt,n[2]=y*v+x*q+g*_t+m*F,n[6]=y*M+x*Y+g*B+m*C,n[10]=y*N+x*ut+g*G+m*K,n[14]=y*W+x*dt+g*J+m*tt,n[3]=D*v+T*q+c*_t+p*F,n[7]=D*M+T*Y+c*B+p*C,n[11]=D*N+T*ut+c*G+p*K,n[15]=D*W+T*dt+c*J+p*tt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],h=t[1],a=t[5],r=t[9],o=t[13],l=t[2],u=t[6],d=t[10],_=t[14],y=t[3],x=t[7],g=t[11],m=t[15];return y*(+n*r*u-i*o*u-n*a*d+s*o*d+i*a*_-s*r*_)+x*(+e*r*_-e*o*d+n*h*d-i*h*_+i*o*l-n*r*l)+g*(+e*o*u-e*a*_-n*h*u+s*h*_+n*a*l-s*o*l)+m*(-i*a*l-e*r*u+e*a*d+i*h*u-s*h*d+s*r*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],h=t[4],a=t[5],r=t[6],o=t[7],l=t[8],u=t[9],d=t[10],_=t[11],y=t[12],x=t[13],g=t[14],m=t[15],D=u*g*o-x*d*o+x*r*_-a*g*_-u*r*m+a*d*m,T=y*d*o-l*g*o-y*r*_+h*g*_+l*r*m-h*d*m,c=l*x*o-y*u*o+y*a*_-h*x*_-l*a*m+h*u*m,p=y*u*r-l*x*r-y*a*d+h*x*d+l*a*g-h*u*g,v=e*D+s*T+i*c+n*p;if(v===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/v;return t[0]=D*M,t[1]=(x*d*n-u*g*n-x*i*_+s*g*_+u*i*m-s*d*m)*M,t[2]=(a*g*n-x*r*n+x*i*o-s*g*o-a*i*m+s*r*m)*M,t[3]=(u*r*n-a*d*n-u*i*o+s*d*o+a*i*_-s*r*_)*M,t[4]=T*M,t[5]=(l*g*n-y*d*n+y*i*_-e*g*_-l*i*m+e*d*m)*M,t[6]=(y*r*n-h*g*n-y*i*o+e*g*o+h*i*m-e*r*m)*M,t[7]=(h*d*n-l*r*n+l*i*o-e*d*o-h*i*_+e*r*_)*M,t[8]=c*M,t[9]=(y*u*n-l*x*n-y*s*_+e*x*_+l*s*m-e*u*m)*M,t[10]=(h*x*n-y*a*n+y*s*o-e*x*o-h*s*m+e*a*m)*M,t[11]=(l*a*n-h*u*n-l*s*o+e*u*o+h*s*_-e*a*_)*M,t[12]=p*M,t[13]=(l*x*i-y*u*i+y*s*d-e*x*d-l*s*g+e*u*g)*M,t[14]=(y*a*i-h*x*i-y*s*r+e*x*r+h*s*g-e*a*g)*M,t[15]=(h*u*i-l*a*i+l*s*r-e*u*r-h*s*d+e*a*d)*M,this}scale(t){const e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=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(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),n=1-s,h=t.x,a=t.y,r=t.z,o=n*h,l=n*a;return this.set(o*h+s,o*a-i*r,o*r+i*a,0,o*a+i*r,l*a+s,l*r-i*h,0,o*r-i*a,l*r+i*h,n*r*r+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,h){return this.set(1,s,n,0,t,1,h,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,h=e._y,a=e._z,r=e._w,o=n+n,l=h+h,u=a+a,d=n*o,_=n*l,y=n*u,x=h*l,g=h*u,m=a*u,D=r*o,T=r*l,c=r*u,p=s.x,v=s.y,M=s.z;return i[0]=(1-(x+m))*p,i[1]=(_+c)*p,i[2]=(y-T)*p,i[3]=0,i[4]=(_-c)*v,i[5]=(1-(d+m))*v,i[6]=(g+D)*v,i[7]=0,i[8]=(y+T)*M,i[9]=(g-D)*M,i[10]=(1-(d+x))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let n=gt.set(i[0],i[1],i[2]).length();const h=gt.set(i[4],i[5],i[6]).length(),a=gt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],H.copy(this);const o=1/n,l=1/h,u=1/a;return H.elements[0]*=o,H.elements[1]*=o,H.elements[2]*=o,H.elements[4]*=l,H.elements[5]*=l,H.elements[6]*=l,H.elements[8]*=u,H.elements[9]*=u,H.elements[10]*=u,e.setFromRotationMatrix(H),s.x=n,s.y=h,s.z=a,this}makePerspective(t,e,s,i,n,h,a=Ot){const r=this.elements,o=2*n/(e-t),l=2*n/(s-i),u=(e+t)/(e-t),d=(s+i)/(s-i);let _,y;if(a===Ot)_=-(h+n)/(h-n),y=-2*h*n/(h-n);else if(a===ve)_=-h/(h-n),y=-h*n/(h-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return r[0]=o,r[4]=0,r[8]=u,r[12]=0,r[1]=0,r[5]=l,r[9]=d,r[13]=0,r[2]=0,r[6]=0,r[10]=_,r[14]=y,r[3]=0,r[7]=0,r[11]=-1,r[15]=0,this}makeOrthographic(t,e,s,i,n,h,a=Ot){const r=this.elements,o=1/(e-t),l=1/(s-i),u=1/(h-n),d=(e+t)*o,_=(s+i)*l;let y,x;if(a===Ot)y=(h+n)*u,x=-2*u;else if(a===ve)y=n*u,x=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return r[0]=2*o,r[4]=0,r[8]=0,r[12]=-d,r[1]=0,r[5]=2*l,r[9]=0,r[13]=-_,r[2]=0,r[6]=0,r[10]=x,r[14]=-y,r[3]=0,r[7]=0,r[11]=0,r[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const gt=new L,H=new Q,bs=new L(0,0,0),Es=new L(1,1,1),st=new L,kt=new L,O=new L,Ae=new Q,Se=new ct;class Lt{constructor(t=0,e=0,s=0,i=Lt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,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,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,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,e=this._order,s=!0){const i=t.elements,n=i[0],h=i[4],a=i[8],r=i[1],o=i[5],l=i[9],u=i[2],d=i[6],_=i[10];switch(e){case"XYZ":this._y=Math.asin($(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,_),this._z=Math.atan2(-h,n)):(this._x=Math.atan2(d,o),this._z=0);break;case"YXZ":this._x=Math.asin(-$(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,_),this._z=Math.atan2(r,o)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin($(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,_),this._z=Math.atan2(-h,o)):(this._y=0,this._z=Math.atan2(r,n));break;case"ZYX":this._y=Math.asin(-$(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,_),this._z=Math.atan2(r,n)):(this._x=0,this._z=Math.atan2(-h,o));break;case"YZX":this._z=Math.asin($(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(-l,o),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(a,_));break;case"XZY":this._z=Math.asin(-$(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,o),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-l,_),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return Ae.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ae,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Se.setFromEuler(this),this.setFromQuaternion(Se,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],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Lt.DEFAULT_ORDER="XYZ";class As{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let s=0;s0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function n(a,r){return a[r.uuid]===void 0&&(a[r.uuid]=r.toJSON(t)),r.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const r=a.shapes;if(Array.isArray(r))for(let o=0,l=r.length;o0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(s.geometries=a),r.length>0&&(s.materials=r),o.length>0&&(s.textures=o),l.length>0&&(s.images=l),u.length>0&&(s.shapes=u),d.length>0&&(s.skeletons=d),_.length>0&&(s.animations=_),y.length>0&&(s.nodes=y)}return s.object=i,s;function h(a){const r=[];for(const o in a){const l=a[o];delete l.metadata,r.push(l)}return r}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s({x:f.x*Zt,y:f.y*Zt,z:f.z*Zt}),wt=f=>{let t=Is(new Lt().setFromQuaternion(new ct(f.x,f.y,f.z,f.w)));return{x:t.x,y:t.y,z:t.z}},zt=(f,t,e)=>{let s=Math.cos(f*.5),i=Math.cos(t*.5),n=Math.cos(e*.5),h=Math.sin(f*.5),a=Math.sin(t*.5),r=Math.sin(e*.5),o=new ct;return o.w=n*s*i+r*h*a,o.x=n*h*i-r*s*a,o.y=n*s*a+r*h*i,o.z=r*s*i-n*h*a,o};function vt(f){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;f=f.replace(t,function(s,i,n,h){return i+i+n+n+h+h});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(f);return console.log(e),e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}const S=f=>{for(var t=new Date().getTime(),e=t;eObject.values(t).filter(p=>p.type===c)[0],r=c=>t[c],o=(c,p)=>{const v=r(c);if(x(v,v.type)){if(p){let M=r(p);for(x(M,M.type);M.next;)M=r(M.next),x(M,M.type)}}else return},l=c=>c==="TRUE";function u(c,p){return c=Math.ceil(c),p=Math.floor(p),Math.floor(Math.random()*(p-c+1))+c}function d(c,p){n&&h&&fetch(`http://${n}/api/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})}function _(c){if(c===2||c===3)return!0;if(c<=1||c%2===0||c%3===0)return!1;for(let p=5;p*p<=c;p+=6)if(c%p===0||c%(p+2)===0)return!1;return!0}function y(c){var p;if(typeof c!="string"&&typeof c!="object")return c.shadow.fields.NUM;{let v=(p=c==null?void 0:c.shadow)!=null&&p.id?r(c.shadow.id):r(c);return x(v,v.type)}}const x=(c,p)=>{var le,ce,ue;switch(console.log(c),!0){case p==="CustomIF":if(!c.inputs||!c.inputs.IF0)throw new Error(`err: controls_if do not have input value! id: ${c.id}`);o(c.inputs.IF0,c.inputs.DO0);break;case p==="logic_boolean":return l(c.fields.BOOL);case p==="logic_compare":if(!c.inputs||!c.inputs.A||!c.inputs.B)throw new Error(`err: logic_compare do not have input value! id: ${c.id}`);const yt=c.fields.OP,ke=c.inputs.A,Ue=c.inputs.B,U=r(ke),P=r(Ue);if(yt==="EQ")return x(U,U.type)==x(P,P.type);if(yt==="NEQ")return x(U,U.type)!==x(P,P.type);if(yt==="LT")return x(U,U.type)x(P,P.type);if(yt==="GTE")return x(U,U.type)>=x(P,P.type);case p==="logic_operation":if(!c.inputs||!c.inputs.A||!c.inputs.B)throw new Error(`err: logic_operation do not have input value! id: ${c.id}`);const Pe=c.fields.OP,je=c.inputs.A,Ne=c.inputs.B,Ct=r(je),Rt=r(Ne);return Pe==="OR"?x(Ct,Ct.type)||x(Rt,Rt.type):x(Ct,Ct.type)&&x(Rt,Rt.type);case p==="logic_negate":if(!c.inputs)throw new Error(`err: logic_negate do not have input value! id: ${c.id}`);const de=r(c.inputs.BOOL);return!x(de,de.type);case p==="logic_boolean":return!c.fields.BOOL!=="FALSE";case p==="logic_null":return null;case p==="logic_ternary":if(!c.inputs||!c.inputs.IF||!c.inputs.THEN||!c.inputs.ELSE)throw new Error(`err: logic_ternary do not have input value! id: ${c.id}`);const We=c.inputs.IF,Ve=c.inputs.THEN,He=c.inputs.ELSE,_e=r(We),ye=r(Ve),xe=r(He);return x(_e,_e.type)?x(ye,ye.type):x(xe,xe.type);case p==="controls_repeat_ext":const qe=y(c.inputs.TIMES);if(!c.inputs.DO)throw new Error(`err: controls_repeat_ext do not have input value! id: ${c.id}`);let Gt=r(c.inputs.DO);for(let pe=0;pe0;if(ht==="NEGATIVE")return at<0;if(ht==="DIVISIBLE_BY"){if(!c.inputs||!c.inputs.DIVISOR)throw new Error("err: DIVISOR is not filled!");if(c.inputs.DIVISOR===0)throw new Error("Note that divisor cannot be 0!");return at%c.inputs.DIVISOR===0}return;case p==="math_random_int":const Ye=y(c.inputs.FROM),Be=y(c.inputs.TO);return u(Ye,Be);case p==="colour_picker":return vt(c.fields.COLOUR);case p==="colour_random":let Ge=u(0,255),Je=u(0,255),Xe=u(0,255);return{r:Ge,g:Je,b:Xe};case p==="colour_rgb":const Ze=y(c.inputs.RED),$e=y(c.inputs.GREEN),Qe=y(c.inputs.BLUE);return{r:Ze,g:$e,b:Qe};case p==="colour_blend":const xt=y(c.inputs.RATIO),Jt=vt(c.inputs.COLOUR1.shadow.fields.COLOUR),Xt=vt(c.inputs.COLOUR2.shadow.fields.COLOUR),Ke=Jt.r*xt,ts=Jt.g*xt,es=Jt.b*xt,ss=Xt.r,is=Xt.g,ns=Xt.b,rs=(ss+Ke)/(xt+1),hs=(is+ts)/(xt+1),as=(ns+es)/(xt+1);return{r:rs,g:hs,b:as};case p==="ChangeLED":if(!c.inputs||!c.inputs.FIELD_ChangeLED)throw new Error(`err: ChangeLED do not have input value! id: ${c.id}`);var z="led",v=r(c.inputs.FIELD_ChangeLED),M=null;(le=v==null?void 0:v.fields)!=null&&le.COLOUR?M=vt(v.fields.COLOUR):M=x(v,v.type);var w={Red:M.r,Green:M.g,Blue:M.b};d(z,w),S(500);return;case p==="TransitionLED":if(!c.inputs||!c.inputs.COLOR1||!c.inputs.COLOR2)throw new Error(`err: TransitionLED do not have input value! id: ${c.id}`);var z="led/transition",N=r(c.inputs.COLOR1),W=r(c.inputs.COLOR2),q=null;(ce=N==null?void 0:N.fields)!=null&&ce.COLOUR?q=vt(N.fields.COLOUR):q=x(N,N.type);var Y=null;(ue=W==null?void 0:W.fields)!=null&&ue.COLOUR?Y=vt(W.fields.COLOUR):Y=x(W,W.type);var A=r(c.inputs.FIELD_Duration)*et,ut=c.fields.TRANSITION_TYPE,w={Red:q.r,Green:q.g,Blue:q.b,Red2:Y.r,Green2:Y.g,Blue2:Y.b,TransitionType:ut,TimeMS:A};d(z,w),S(A);return;case p==="DisplayImage":if(!c.inputs||!c.inputs.FIELD_DisplayImage_Filename)throw new Error(`err: DisplayImage do not have input value! id: ${c.id}`);var dt=1,B=r(c.inputs.FIELD_DisplayImage_Filename),G=us(B.type),z="images/display",w={FileName:G,Alpha:dt};d(z,w),S(500);return;case p==="PlayAudio":if(!c.inputs||!c.inputs.FIELD_PlayAudio_Filename)throw new Error(`err: PlayAudio do not have input value! id: ${c.id}`);var z="audio/play",B=r(c.inputs.FIELD_PlayAudio_Filename),G=fe(B.type),w={FileName:G};d(z,w),S(500);return;case p==="SetVolume":if(!c.inputs||!c.inputs.FIELD_Volume)throw new Error(`err: SetVolume do not have input value! id: ${c.id}`);var z="audio/volume",_t=r(c.inputs.FIELD_Volume),w={Volume:_t};d(z,w),S(500);return;case p==="DisplayAnimation":if(!c.inputs||!c.inputs.FIELD_DisplayAnimation_Filename)throw new Error(`err: DisplayAnimation do not have input value! id: ${c.id}`);var B=r(c.inputs.FIELD_DisplayAnimation_Filename),G=fe(B.type),w={FileName:G};readFile(w);return;case p==="DisplayText":var z="text/display",rt=c.fields.FIELD_DisplayText_Text,w={Text:rt};d(z,w),S(500);return;case p==="ClearText":var z="text/display",w={Text:""};d(z,w),S(500);return;case p==="TurnOnFlashlight":var z="flashlight",w={On:!0};d(z,w),S(500);return;case p==="TurnOffFlashlight":var z="flashlight",w={On:!1};d(z,w),S(500);return;case p==="WaitForSeconds":var A=y(c.fields.FIELD_Duration);S(A*et);return;case p==="MoveArm":var F=c.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",C=y(c.fields.FIELD_MoveArm_Position),k=y(c.fields.FIELD_MoveArm_Velocity),z="arms",w={Arm:F,Position:C,Velocity:k,Units:"Degrees"};d(z,w);var K=i[b(F)],tt=wt(K.rotation),V=2*j*ot*Math.abs(tt.y-C),A=V/(k/100*pt),E={x:0,y:C-mt,z:0},J=zt(E.x,E.y*j/180,E.z);i[b(F)].rotation.w=J._w,i[b(F)].rotation.x=J._x,i[b(F)].rotation.y=J._y,i[b(F)].rotation.z=J._z,S(A);return;case p==="MoveArm2":var C=y(c.fields.FIELD_MoveArm2_Position),k=y(c.fields.FIELD_MoveArm2_Velocity),z="arms",w={Arm:"both",Position:C,Velocity:k,Units:"Degrees"};d(z,w);var Nt=i[b("Left")],Wt=i[b("Right")],Vt=wt(Nt.rotation),V=2*j*ot*Math.abs(Vt.y-C),Ht=V/(k/100*pt),qt=wt(Wt.rotation);V=2*j*ot*Math.abs(qt.y-C);var Yt=V/(k/100*pt),E={x:0,y:C-mt,z:0},I=zt(E.x,E.y*j/180,E.z);E={x:0,y:C-mt,z:0};var X=zt(E.x,E.y*j/180,E.z);i[b("Left")].rotation.w=I._w,i[b("Left")].rotation.x=I._x,i[b("Left")].rotation.y=I._y,i[b("Left")].rotation.z=I._z,i[b("Right")].rotation.w=X._w,i[b("Right")].rotation.x=X._x,i[b("Right")].rotation.y=X._y,i[b("Right")].rotation.z=X._z,S(Math.max(Ht,Yt));return;case p==="MoveArm3":var F=c.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",C=y(c.inputs.FIELD_MoveArm_Position),k=y(c.inputs.FIELD_MoveArm_Velocity),z="arms",w={Arm:F,Position:C,Velocity:k,Units:"Degrees"};d(z,w);var K=i[b(F)],tt=wt(K.rotation),V=2*j*ot*Math.abs(tt.y-C),A=V/(k/100*pt),E={x:0,y:C-mt,z:0},I=zt(E.x,E.y*j/180,E.z);i[b(F)].rotation.w=I._w,i[b(F)].rotation.x=I._x,i[b(F)].rotation.y=I._y,i[b(F)].rotation.z=I._z,S(A);return;case p==="MoveArms2":var Pt=y(c.inputs.FIELD_MoveArm_LeftPosition),re=y(c.inputs.FIELD_MoveArm_LeftVelocity),jt=y(c.inputs.FIELD_MoveArm_RightPosition),he=y(c.inputs.FIELD_MoveArm_RightVelocity),w={LeftArmPosition:Pt,RightArmPosition:jt,LeftArmVelocity:re,RightArmVelocity:he,Units:"Degrees"},z="arms/set";d(z,w);var Nt=i[b("Left")],Wt=i[b("Right")],Vt=wt(Nt.rotation),V=2*j*ot*Math.abs(Vt.y-Pt),Ht=V/(re/100*pt),qt=wt(Wt.rotation);V=2*j*ot*Math.abs(qt.y-jt);var Yt=V/(he/100*pt),E={x:0,y:Pt-mt,z:0},I=zt(E.x,E.y*j/180,E.z);E={x:0,y:jt-mt,z:0};var X=zt(E.x,E.y*j/180,E.z);i[b("Left")].rotation.w=I._w,i[b("Left")].rotation.x=I._x,i[b("Left")].rotation.y=I._y,i[b("Left")].rotation.z=I._z,i[b("Right")].rotation.w=X._w,i[b("Right")].rotation.x=X._x,i[b("Right")].rotation.y=X._y,i[b("Right")].rotation.z=X._z,S(Math.max(Ht,Yt));return;case p==="MoveHead":var Ft=c.fields.FIELD_MoveHead_Pitch==="D"?25:-40,z="head",w={Pitch:Ft,Yaw:0,Roll:0,Duration:2,Units:"degrees"};d(z,w),S(2e3);return;case p==="MoveHead3":var Ft,ae,oe,z="head";Ft=y(c.inputs.FIELD_MoveHead_Pitch),ae=y(c.inputs.FIELD_MoveHead_Roll),oe=y(c.inputs.FIELD_MoveHead_Yaw),A=y(c.inputs.FIELD_MoveHead_Time);var w={Pitch:Ft,Yaw:oe,Roll:ae,Duration:A,Units:"degrees"};d(z,w),S(A);return;case p==="DriveTime":var bt=c.fields.FIELD_DriveTime_Direction,k=parseInt(c.fields.FIELD_DriveTime_Velocity),A=parseInt(c.fields.FIELD_DriveTime_TimeMs)*et,z="drive/time",nt=bt==="F"?k:-k,w={LinearVelocity:nt,AngularVelocity:0,TimeMs:A};d(z,w),S(A);return;case p==="DriveTime2":var z="drive/time",nt=y(c.inputs.FIELD_DriveTime_Velocity),Et=y(c.inputs.FIELD_DriveTime_Angular),A=y(c.inputs.FIELD_DriveTime_TimeMs)*et,w={LinearVelocity:nt,AngularVelocity:Et,TimeMs:A};d(z,w),S(A);return;case p==="Turn":var bt=c.fields.FIELD_Turn_Direction,A=parseInt(c.fields.FIELD_Turn_Duration)*et,Et=100,nt=0,Bt=bt==="L"?90:-90,z="drive/time",w={LinearVelocity:nt,AngularVelocity:Et,TimeMs:A,Degree:Bt};d(z,w),S(A);return;case p==="Turn2":var bt=c.fields.FIELD_Turn_Direction,A=parseInt(y(c.inputs.FIELD_Turn_Duration))*et,Et=100,nt=0,Bt=bt==="L"?90:-90,w={LinearVelocity:nt,AngularVelocity:Et,TimeMs:A,Degree:Bt},z="drive/time";d(z,w),S(A);return;case p=="Speak":var z="tts/speak",Oe=r(c.inputs.FIELD_Speak_Text),rt=Oe.fields.TEXT,w={Text:`${rt}`};d(z,w),S(me*rt.split(" ").length*et);return;case p=="SpeakDefault":var z="tts/speak",rt=c.fields.FIELD_SpeakDefault_Text,w={Text:`${rt}`};d(z,w),S(me*rt.split(" ").length*et);return;default:return"No case match"}};let m=a("Start"),D=1;for(;m&&m.next;)D+=1,m=r(m.next),x(m,m.type);var T=`${D} blocks compiled`;self.postMessage(T)}; + */const Ce="162",Re=300,ge=1e3,It=1001,Me=1002,we=1003,ds=1006,_s=1008,ys=1009,xs=1014,ps=1020,ms=1023,$t=1026,ze=1027,fs="",gs=515,Ot=2e3,ve=2001;class Ie{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const s=this._listeners[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let n=0,h=i.length;n>8&255]+R[f>>16&255]+R[f>>24&255]+"-"+R[t&255]+R[t>>8&255]+"-"+R[t>>16&15|64]+R[t>>24&255]+"-"+R[e&63|128]+R[e>>8&255]+"-"+R[e>>16&255]+R[e>>24&255]+R[s&255]+R[s>>8&255]+R[s>>16&255]+R[s>>24&255]).toLowerCase()}function $(f,t,e){return Math.max(t,Math.min(e,f))}class Dt{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;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;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos($(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,h=this.y-t.y;return this.x=n*s-h*i+t.x,this.y=n*i+h*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Tt{constructor(t,e,s,i,n,h,a,r,o){Tt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,h,a,r,o)}set(t,e,s,i,n,h,a,r,o){const l=this.elements;return l[0]=t,l[1]=i,l[2]=a,l[3]=e,l[4]=n,l[5]=r,l[6]=s,l[7]=h,l[8]=o,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,h=s[0],a=s[3],r=s[6],o=s[1],l=s[4],u=s[7],d=s[2],_=s[5],y=s[8],x=i[0],g=i[3],m=i[6],D=i[1],T=i[4],c=i[7],p=i[2],v=i[5],M=i[8];return n[0]=h*x+a*D+r*p,n[3]=h*g+a*T+r*v,n[6]=h*m+a*c+r*M,n[1]=o*x+l*D+u*p,n[4]=o*g+l*T+u*v,n[7]=o*m+l*c+u*M,n[2]=d*x+_*D+y*p,n[5]=d*g+_*T+y*v,n[8]=d*m+_*c+y*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],h=t[4],a=t[5],r=t[6],o=t[7],l=t[8];return e*h*l-e*a*o-s*n*l+s*a*r+i*n*o-i*h*r}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],h=t[4],a=t[5],r=t[6],o=t[7],l=t[8],u=l*h-a*o,d=a*r-l*n,_=o*n-h*r,y=e*u+s*d+i*_;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/y;return t[0]=u*x,t[1]=(i*o-l*s)*x,t[2]=(a*s-i*h)*x,t[3]=d*x,t[4]=(l*e-i*r)*x,t[5]=(i*n-a*e)*x,t[6]=_*x,t[7]=(s*r-o*e)*x,t[8]=(h*e-s*n)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,h,a){const r=Math.cos(n),o=Math.sin(n);return this.set(s*r,s*o,-s*(r*h+o*a)+h+t,-i*o,i*r,-i*(-o*h+r*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Qt.makeScale(t,e)),this}rotate(t){return this.premultiply(Qt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Qt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Qt=new Tt;function be(f){return document.createElementNS("http://www.w3.org/1999/xhtml",f)}function Kt(f){return f<.04045?f*.0773993808:Math.pow(f*.9478672986+.0521327014,2.4)}let ft;class Ms{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ft===void 0&&(ft=be("canvas")),ft.width=t.width,ft.height=t.height;const s=ft.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=ft}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=be("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let h=0;h0&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Re)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ge:t.x=t.x-Math.floor(t.x);break;case It:t.x=t.x<0?0:1;break;case Me:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ge:t.y=t.y-Math.floor(t.y);break;case It:t.y=t.y<0?0:1;break;case Me:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}}it.DEFAULT_IMAGE=null;it.DEFAULT_MAPPING=Re;it.DEFAULT_ANISOTROPY=1;class ct{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,h,a){let r=s[i+0],o=s[i+1],l=s[i+2],u=s[i+3];const d=n[h+0],_=n[h+1],y=n[h+2],x=n[h+3];if(a===0){t[e+0]=r,t[e+1]=o,t[e+2]=l,t[e+3]=u;return}if(a===1){t[e+0]=d,t[e+1]=_,t[e+2]=y,t[e+3]=x;return}if(u!==x||r!==d||o!==_||l!==y){let g=1-a;const m=r*d+o*_+l*y+u*x,D=m>=0?1:-1,T=1-m*m;if(T>Number.EPSILON){const p=Math.sqrt(T),v=Math.atan2(p,m*D);g=Math.sin(g*v)/p,a=Math.sin(a*v)/p}const c=a*D;if(r=r*g+d*c,o=o*g+_*c,l=l*g+y*c,u=u*g+x*c,g===1-a){const p=1/Math.sqrt(r*r+o*o+l*l+u*u);r*=p,o*=p,l*=p,u*=p}}t[e]=r,t[e+1]=o,t[e+2]=l,t[e+3]=u}static multiplyQuaternionsFlat(t,e,s,i,n,h){const a=s[i],r=s[i+1],o=s[i+2],l=s[i+3],u=n[h],d=n[h+1],_=n[h+2],y=n[h+3];return t[e]=a*y+l*u+r*_-o*d,t[e+1]=r*y+l*d+o*u-a*_,t[e+2]=o*y+l*_+a*d-r*u,t[e+3]=l*y-a*u-r*d-o*_,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,e,s,i){return this._x=t,this._y=e,this._z=s,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,e=!0){const s=t._x,i=t._y,n=t._z,h=t._order,a=Math.cos,r=Math.sin,o=a(s/2),l=a(i/2),u=a(n/2),d=r(s/2),_=r(i/2),y=r(n/2);switch(h){case"XYZ":this._x=d*l*u+o*_*y,this._y=o*_*u-d*l*y,this._z=o*l*y+d*_*u,this._w=o*l*u-d*_*y;break;case"YXZ":this._x=d*l*u+o*_*y,this._y=o*_*u-d*l*y,this._z=o*l*y-d*_*u,this._w=o*l*u+d*_*y;break;case"ZXY":this._x=d*l*u-o*_*y,this._y=o*_*u+d*l*y,this._z=o*l*y+d*_*u,this._w=o*l*u-d*_*y;break;case"ZYX":this._x=d*l*u-o*_*y,this._y=o*_*u+d*l*y,this._z=o*l*y-d*_*u,this._w=o*l*u+d*_*y;break;case"YZX":this._x=d*l*u+o*_*y,this._y=o*_*u+d*l*y,this._z=o*l*y-d*_*u,this._w=o*l*u-d*_*y;break;case"XZY":this._x=d*l*u-o*_*y,this._y=o*_*u-d*l*y,this._z=o*l*y+d*_*u,this._w=o*l*u+d*_*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+h)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],n=e[8],h=e[1],a=e[5],r=e[9],o=e[2],l=e[6],u=e[10],d=s+a+u;if(d>0){const _=.5/Math.sqrt(d+1);this._w=.25/_,this._x=(l-r)*_,this._y=(n-o)*_,this._z=(h-i)*_}else if(s>a&&s>u){const _=2*Math.sqrt(1+s-a-u);this._w=(l-r)/_,this._x=.25*_,this._y=(i+h)/_,this._z=(n+o)/_}else if(a>u){const _=2*Math.sqrt(1+a-s-u);this._w=(n-o)/_,this._x=(i+h)/_,this._y=.25*_,this._z=(r+l)/_}else{const _=2*Math.sqrt(1+u-s-a);this._w=(h-i)/_,this._x=(n+o)/_,this._y=(r+l)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return sMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs($(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){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 t===0?(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){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,n=t._z,h=t._w,a=e._x,r=e._y,o=e._z,l=e._w;return this._x=s*l+h*a+i*o-n*r,this._y=i*l+h*r+n*a-s*o,this._z=n*l+h*o+s*r-i*a,this._w=h*l-s*a-i*r-n*o,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,i=this._y,n=this._z,h=this._w;let a=h*t._w+s*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=h,this._x=s,this._y=i,this._z=n,this;const r=1-a*a;if(r<=Number.EPSILON){const _=1-e;return this._w=_*h+e*this._w,this._x=_*s+e*this._x,this._y=_*i+e*this._y,this._z=_*n+e*this._z,this.normalize(),this}const o=Math.sqrt(r),l=Math.atan2(o,a),u=Math.sin((1-e)*l)/o,d=Math.sin(e*l)/o;return this._w=h*u+this._w*d,this._x=s*u+this._x*d,this._y=i*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{constructor(t=0,e=0,s=0){L.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,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,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;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){return 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,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return 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,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return 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,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ee.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ee.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=t.elements,h=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*h,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*h,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*h,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,h=t.y,a=t.z,r=t.w,o=2*(h*i-a*s),l=2*(a*e-n*i),u=2*(n*s-h*e);return this.x=e+r*o+h*u-a*l,this.y=s+r*l+a*o-n*u,this.z=i+r*u+n*l-h*o,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[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,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(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,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,n=t.z,h=e.x,a=e.y,r=e.z;return this.x=i*r-n*a,this.y=n*h-s*r,this.z=s*a-i*h,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ee.copy(this).projectOnVector(t),this.sub(ee)}reflect(t){return this.sub(ee.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos($(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+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,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ee=new L,Ee=new ct;class Q{constructor(t,e,s,i,n,h,a,r,o,l,u,d,_,y,x,g){Q.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,h,a,r,o,l,u,d,_,y,x,g)}set(t,e,s,i,n,h,a,r,o,l,u,d,_,y,x,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=s,m[12]=i,m[1]=n,m[5]=h,m[9]=a,m[13]=r,m[2]=o,m[6]=l,m[10]=u,m[14]=d,m[3]=_,m[7]=y,m[11]=x,m[15]=g,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 Q().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/gt.setFromMatrixColumn(t,0).length(),n=1/gt.setFromMatrixColumn(t,1).length(),h=1/gt.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*h,e[9]=s[9]*h,e[10]=s[10]*h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,n=t.z,h=Math.cos(s),a=Math.sin(s),r=Math.cos(i),o=Math.sin(i),l=Math.cos(n),u=Math.sin(n);if(t.order==="XYZ"){const d=h*l,_=h*u,y=a*l,x=a*u;e[0]=r*l,e[4]=-r*u,e[8]=o,e[1]=_+y*o,e[5]=d-x*o,e[9]=-a*r,e[2]=x-d*o,e[6]=y+_*o,e[10]=h*r}else if(t.order==="YXZ"){const d=r*l,_=r*u,y=o*l,x=o*u;e[0]=d+x*a,e[4]=y*a-_,e[8]=h*o,e[1]=h*u,e[5]=h*l,e[9]=-a,e[2]=_*a-y,e[6]=x+d*a,e[10]=h*r}else if(t.order==="ZXY"){const d=r*l,_=r*u,y=o*l,x=o*u;e[0]=d-x*a,e[4]=-h*u,e[8]=y+_*a,e[1]=_+y*a,e[5]=h*l,e[9]=x-d*a,e[2]=-h*o,e[6]=a,e[10]=h*r}else if(t.order==="ZYX"){const d=h*l,_=h*u,y=a*l,x=a*u;e[0]=r*l,e[4]=y*o-_,e[8]=d*o+x,e[1]=r*u,e[5]=x*o+d,e[9]=_*o-y,e[2]=-o,e[6]=a*r,e[10]=h*r}else if(t.order==="YZX"){const d=h*r,_=h*o,y=a*r,x=a*o;e[0]=r*l,e[4]=x-d*u,e[8]=y*u+_,e[1]=u,e[5]=h*l,e[9]=-a*l,e[2]=-o*l,e[6]=_*u+y,e[10]=d-x*u}else if(t.order==="XZY"){const d=h*r,_=h*o,y=a*r,x=a*o;e[0]=r*l,e[4]=-u,e[8]=o*l,e[1]=d*u+x,e[5]=h*l,e[9]=_*u-y,e[2]=y*u-_,e[6]=a*l,e[10]=x*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bs,t,Es)}lookAt(t,e,s){const i=this.elements;return O.subVectors(t,e),O.lengthSq()===0&&(O.z=1),O.normalize(),st.crossVectors(s,O),st.lengthSq()===0&&(Math.abs(s.z)===1?O.x+=1e-4:O.z+=1e-4,O.normalize(),st.crossVectors(s,O)),st.normalize(),kt.crossVectors(O,st),i[0]=st.x,i[4]=kt.x,i[8]=O.x,i[1]=st.y,i[5]=kt.y,i[9]=O.y,i[2]=st.z,i[6]=kt.z,i[10]=O.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,h=s[0],a=s[4],r=s[8],o=s[12],l=s[1],u=s[5],d=s[9],_=s[13],y=s[2],x=s[6],g=s[10],m=s[14],D=s[3],T=s[7],c=s[11],p=s[15],v=i[0],M=i[4],N=i[8],W=i[12],q=i[1],Y=i[5],ut=i[9],dt=i[13],_t=i[2],B=i[6],G=i[10],J=i[14],F=i[3],C=i[7],K=i[11],tt=i[15];return n[0]=h*v+a*q+r*_t+o*F,n[4]=h*M+a*Y+r*B+o*C,n[8]=h*N+a*ut+r*G+o*K,n[12]=h*W+a*dt+r*J+o*tt,n[1]=l*v+u*q+d*_t+_*F,n[5]=l*M+u*Y+d*B+_*C,n[9]=l*N+u*ut+d*G+_*K,n[13]=l*W+u*dt+d*J+_*tt,n[2]=y*v+x*q+g*_t+m*F,n[6]=y*M+x*Y+g*B+m*C,n[10]=y*N+x*ut+g*G+m*K,n[14]=y*W+x*dt+g*J+m*tt,n[3]=D*v+T*q+c*_t+p*F,n[7]=D*M+T*Y+c*B+p*C,n[11]=D*N+T*ut+c*G+p*K,n[15]=D*W+T*dt+c*J+p*tt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],h=t[1],a=t[5],r=t[9],o=t[13],l=t[2],u=t[6],d=t[10],_=t[14],y=t[3],x=t[7],g=t[11],m=t[15];return y*(+n*r*u-i*o*u-n*a*d+s*o*d+i*a*_-s*r*_)+x*(+e*r*_-e*o*d+n*h*d-i*h*_+i*o*l-n*r*l)+g*(+e*o*u-e*a*_-n*h*u+s*h*_+n*a*l-s*o*l)+m*(-i*a*l-e*r*u+e*a*d+i*h*u-s*h*d+s*r*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],h=t[4],a=t[5],r=t[6],o=t[7],l=t[8],u=t[9],d=t[10],_=t[11],y=t[12],x=t[13],g=t[14],m=t[15],D=u*g*o-x*d*o+x*r*_-a*g*_-u*r*m+a*d*m,T=y*d*o-l*g*o-y*r*_+h*g*_+l*r*m-h*d*m,c=l*x*o-y*u*o+y*a*_-h*x*_-l*a*m+h*u*m,p=y*u*r-l*x*r-y*a*d+h*x*d+l*a*g-h*u*g,v=e*D+s*T+i*c+n*p;if(v===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/v;return t[0]=D*M,t[1]=(x*d*n-u*g*n-x*i*_+s*g*_+u*i*m-s*d*m)*M,t[2]=(a*g*n-x*r*n+x*i*o-s*g*o-a*i*m+s*r*m)*M,t[3]=(u*r*n-a*d*n-u*i*o+s*d*o+a*i*_-s*r*_)*M,t[4]=T*M,t[5]=(l*g*n-y*d*n+y*i*_-e*g*_-l*i*m+e*d*m)*M,t[6]=(y*r*n-h*g*n-y*i*o+e*g*o+h*i*m-e*r*m)*M,t[7]=(h*d*n-l*r*n+l*i*o-e*d*o-h*i*_+e*r*_)*M,t[8]=c*M,t[9]=(y*u*n-l*x*n-y*s*_+e*x*_+l*s*m-e*u*m)*M,t[10]=(h*x*n-y*a*n+y*s*o-e*x*o-h*s*m+e*a*m)*M,t[11]=(l*a*n-h*u*n-l*s*o+e*u*o+h*s*_-e*a*_)*M,t[12]=p*M,t[13]=(l*x*i-y*u*i+y*s*d-e*x*d-l*s*g+e*u*g)*M,t[14]=(y*a*i-h*x*i-y*s*r+e*x*r+h*s*g-e*a*g)*M,t[15]=(h*u*i-l*a*i+l*s*r-e*u*r-h*s*d+e*a*d)*M,this}scale(t){const e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=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(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),n=1-s,h=t.x,a=t.y,r=t.z,o=n*h,l=n*a;return this.set(o*h+s,o*a-i*r,o*r+i*a,0,o*a+i*r,l*a+s,l*r-i*h,0,o*r-i*a,l*r+i*h,n*r*r+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,h){return this.set(1,s,n,0,t,1,h,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,h=e._y,a=e._z,r=e._w,o=n+n,l=h+h,u=a+a,d=n*o,_=n*l,y=n*u,x=h*l,g=h*u,m=a*u,D=r*o,T=r*l,c=r*u,p=s.x,v=s.y,M=s.z;return i[0]=(1-(x+m))*p,i[1]=(_+c)*p,i[2]=(y-T)*p,i[3]=0,i[4]=(_-c)*v,i[5]=(1-(d+m))*v,i[6]=(g+D)*v,i[7]=0,i[8]=(y+T)*M,i[9]=(g-D)*M,i[10]=(1-(d+x))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let n=gt.set(i[0],i[1],i[2]).length();const h=gt.set(i[4],i[5],i[6]).length(),a=gt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],H.copy(this);const o=1/n,l=1/h,u=1/a;return H.elements[0]*=o,H.elements[1]*=o,H.elements[2]*=o,H.elements[4]*=l,H.elements[5]*=l,H.elements[6]*=l,H.elements[8]*=u,H.elements[9]*=u,H.elements[10]*=u,e.setFromRotationMatrix(H),s.x=n,s.y=h,s.z=a,this}makePerspective(t,e,s,i,n,h,a=Ot){const r=this.elements,o=2*n/(e-t),l=2*n/(s-i),u=(e+t)/(e-t),d=(s+i)/(s-i);let _,y;if(a===Ot)_=-(h+n)/(h-n),y=-2*h*n/(h-n);else if(a===ve)_=-h/(h-n),y=-h*n/(h-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return r[0]=o,r[4]=0,r[8]=u,r[12]=0,r[1]=0,r[5]=l,r[9]=d,r[13]=0,r[2]=0,r[6]=0,r[10]=_,r[14]=y,r[3]=0,r[7]=0,r[11]=-1,r[15]=0,this}makeOrthographic(t,e,s,i,n,h,a=Ot){const r=this.elements,o=1/(e-t),l=1/(s-i),u=1/(h-n),d=(e+t)*o,_=(s+i)*l;let y,x;if(a===Ot)y=(h+n)*u,x=-2*u;else if(a===ve)y=n*u,x=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return r[0]=2*o,r[4]=0,r[8]=0,r[12]=-d,r[1]=0,r[5]=2*l,r[9]=0,r[13]=-_,r[2]=0,r[6]=0,r[10]=x,r[14]=-y,r[3]=0,r[7]=0,r[11]=0,r[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const gt=new L,H=new Q,bs=new L(0,0,0),Es=new L(1,1,1),st=new L,kt=new L,O=new L,Ae=new Q,Se=new ct;class Lt{constructor(t=0,e=0,s=0,i=Lt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,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,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,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,e=this._order,s=!0){const i=t.elements,n=i[0],h=i[4],a=i[8],r=i[1],o=i[5],l=i[9],u=i[2],d=i[6],_=i[10];switch(e){case"XYZ":this._y=Math.asin($(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,_),this._z=Math.atan2(-h,n)):(this._x=Math.atan2(d,o),this._z=0);break;case"YXZ":this._x=Math.asin(-$(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,_),this._z=Math.atan2(r,o)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin($(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,_),this._z=Math.atan2(-h,o)):(this._y=0,this._z=Math.atan2(r,n));break;case"ZYX":this._y=Math.asin(-$(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,_),this._z=Math.atan2(r,n)):(this._x=0,this._z=Math.atan2(-h,o));break;case"YZX":this._z=Math.asin($(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(-l,o),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(a,_));break;case"XZY":this._z=Math.asin(-$(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,o),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-l,_),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return Ae.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ae,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Se.setFromEuler(this),this.setFromQuaternion(Se,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],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Lt.DEFAULT_ORDER="XYZ";class As{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let s=0;s0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function n(a,r){return a[r.uuid]===void 0&&(a[r.uuid]=r.toJSON(t)),r.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const r=a.shapes;if(Array.isArray(r))for(let o=0,l=r.length;o0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(s.geometries=a),r.length>0&&(s.materials=r),o.length>0&&(s.textures=o),l.length>0&&(s.images=l),u.length>0&&(s.shapes=u),d.length>0&&(s.skeletons=d),_.length>0&&(s.animations=_),y.length>0&&(s.nodes=y)}return s.object=i,s;function h(a){const r=[];for(const o in a){const l=a[o];delete l.metadata,r.push(l)}return r}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s({x:f.x*Zt,y:f.y*Zt,z:f.z*Zt}),wt=f=>{let t=Is(new Lt().setFromQuaternion(new ct(f.x,f.y,f.z,f.w)));return{x:t.x,y:t.y,z:t.z}},zt=(f,t,e)=>{let s=Math.cos(f*.5),i=Math.cos(t*.5),n=Math.cos(e*.5),h=Math.sin(f*.5),a=Math.sin(t*.5),r=Math.sin(e*.5),o=new ct;return o.w=n*s*i+r*h*a,o.x=n*h*i-r*s*a,o.y=n*s*a+r*h*i,o.z=r*s*i-n*h*a,o};function vt(f){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;f=f.replace(t,function(s,i,n,h){return i+i+n+n+h+h});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(f);return console.log(e),e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}const S=f=>{for(var t=new Date().getTime(),e=t;eObject.values(t).filter(p=>p.type===c)[0],r=c=>t[c],o=(c,p)=>{const v=r(c);if(x(v,v.type)){if(p){let M=r(p);for(x(M,M.type);M.next;)M=r(M.next),x(M,M.type)}}else return},l=c=>c==="TRUE";function u(c,p){return c=Math.ceil(c),p=Math.floor(p),Math.floor(Math.random()*(p-c+1))+c}function d(c,p){n&&h&&fetch(`http://${n}/api/${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})}function _(c){if(c===2||c===3)return!0;if(c<=1||c%2===0||c%3===0)return!1;for(let p=5;p*p<=c;p+=6)if(c%p===0||c%(p+2)===0)return!1;return!0}function y(c){var p;if(typeof c!="string"&&typeof c!="object")return c.shadow.fields.NUM;{let v=(p=c==null?void 0:c.shadow)!=null&&p.id?r(c.shadow.id):r(c);return x(v,v.type)}}const x=(c,p)=>{var le,ce,ue;switch(console.log(c),!0){case p==="CustomIF":if(!c.inputs||!c.inputs.IF0)throw new Error(`err: controls_if do not have input value! id: ${c.id}`);o(c.inputs.IF0,c.inputs.DO0);break;case p==="logic_boolean":return l(c.fields.BOOL);case p==="logic_compare":if(!c.inputs||!c.inputs.A||!c.inputs.B)throw new Error(`err: logic_compare do not have input value! id: ${c.id}`);const yt=c.fields.OP,ke=c.inputs.A,Ue=c.inputs.B,U=r(ke),P=r(Ue);if(yt==="EQ")return x(U,U.type)==x(P,P.type);if(yt==="NEQ")return x(U,U.type)!==x(P,P.type);if(yt==="LT")return x(U,U.type)x(P,P.type);if(yt==="GTE")return x(U,U.type)>=x(P,P.type);case p==="logic_operation":if(!c.inputs||!c.inputs.A||!c.inputs.B)throw new Error(`err: logic_operation do not have input value! id: ${c.id}`);const Pe=c.fields.OP,je=c.inputs.A,Ne=c.inputs.B,Ct=r(je),Rt=r(Ne);return Pe==="OR"?x(Ct,Ct.type)||x(Rt,Rt.type):x(Ct,Ct.type)&&x(Rt,Rt.type);case p==="logic_negate":if(!c.inputs)throw new Error(`err: logic_negate do not have input value! id: ${c.id}`);const de=r(c.inputs.BOOL);return!x(de,de.type);case p==="logic_boolean":return!c.fields.BOOL!=="FALSE";case p==="logic_null":return null;case p==="logic_ternary":if(!c.inputs||!c.inputs.IF||!c.inputs.THEN||!c.inputs.ELSE)throw new Error(`err: logic_ternary do not have input value! id: ${c.id}`);const We=c.inputs.IF,Ve=c.inputs.THEN,He=c.inputs.ELSE,_e=r(We),ye=r(Ve),xe=r(He);return x(_e,_e.type)?x(ye,ye.type):x(xe,xe.type);case p==="controls_repeat_ext":const qe=y(c.inputs.TIMES);if(!c.inputs.DO)throw new Error(`err: controls_repeat_ext do not have input value! id: ${c.id}`);let Gt=r(c.inputs.DO);for(let pe=0;pe0;if(ht==="NEGATIVE")return at<0;if(ht==="DIVISIBLE_BY"){if(!c.inputs||!c.inputs.DIVISOR)throw new Error("err: DIVISOR is not filled!");if(c.inputs.DIVISOR===0)throw new Error("Note that divisor cannot be 0!");return at%c.inputs.DIVISOR===0}return;case p==="math_random_int":const Ye=y(c.inputs.FROM),Be=y(c.inputs.TO);return u(Ye,Be);case p==="colour_picker":return vt(c.fields.COLOUR);case p==="colour_random":let Ge=u(0,255),Je=u(0,255),Xe=u(0,255);return{r:Ge,g:Je,b:Xe};case p==="colour_rgb":const Ze=y(c.inputs.RED),$e=y(c.inputs.GREEN),Qe=y(c.inputs.BLUE);return{r:Ze,g:$e,b:Qe};case p==="colour_blend":const xt=y(c.inputs.RATIO),Jt=vt(c.inputs.COLOUR1.shadow.fields.COLOUR),Xt=vt(c.inputs.COLOUR2.shadow.fields.COLOUR),Ke=Jt.r*xt,ts=Jt.g*xt,es=Jt.b*xt,ss=Xt.r,is=Xt.g,ns=Xt.b,rs=(ss+Ke)/(xt+1),hs=(is+ts)/(xt+1),as=(ns+es)/(xt+1);return{r:rs,g:hs,b:as};case p==="ChangeLED":if(!c.inputs||!c.inputs.FIELD_ChangeLED)throw new Error(`err: ChangeLED do not have input value! id: ${c.id}`);var z="led",v=r(c.inputs.FIELD_ChangeLED),M=null;(le=v==null?void 0:v.fields)!=null&&le.COLOUR?M=vt(v.fields.COLOUR):M=x(v,v.type);var w={Red:M.r,Green:M.g,Blue:M.b};d(z,w),S(500);return;case p==="TransitionLED":if(!c.inputs||!c.inputs.COLOR1||!c.inputs.COLOR2)throw new Error(`err: TransitionLED do not have input value! id: ${c.id}`);var z="led/transition",N=r(c.inputs.COLOR1),W=r(c.inputs.COLOR2),q=null;(ce=N==null?void 0:N.fields)!=null&&ce.COLOUR?q=vt(N.fields.COLOUR):q=x(N,N.type);var Y=null;(ue=W==null?void 0:W.fields)!=null&&ue.COLOUR?Y=vt(W.fields.COLOUR):Y=x(W,W.type);var A=r(c.inputs.FIELD_Duration)*et,ut=c.fields.TRANSITION_TYPE,w={Red:q.r,Green:q.g,Blue:q.b,Red2:Y.r,Green2:Y.g,Blue2:Y.b,TransitionType:ut,TimeMS:A};d(z,w),S(A);return;case p==="DisplayImage":if(!c.inputs||!c.inputs.FIELD_DisplayImage_Filename)throw new Error(`err: DisplayImage do not have input value! id: ${c.id}`);var dt=1,B=r(c.inputs.FIELD_DisplayImage_Filename),G=us(B.type),z="images/display",w={FileName:G,Alpha:dt};d(z,w),S(500);return;case p==="PlayAudio":if(!c.inputs||!c.inputs.FIELD_PlayAudio_Filename)throw new Error(`err: PlayAudio do not have input value! id: ${c.id}`);var z="audio/play",B=r(c.inputs.FIELD_PlayAudio_Filename),G=fe(B.type),w={FileName:G};d(z,w),S(500);return;case p==="SetVolume":if(!c.inputs||!c.inputs.FIELD_Volume)throw new Error(`err: SetVolume do not have input value! id: ${c.id}`);var z="audio/volume",_t=r(c.inputs.FIELD_Volume),w={Volume:_t};d(z,w),S(500);return;case p==="DisplayAnimation":if(!c.inputs||!c.inputs.FIELD_DisplayAnimation_Filename)throw new Error(`err: DisplayAnimation do not have input value! id: ${c.id}`);var B=r(c.inputs.FIELD_DisplayAnimation_Filename),G=fe(B.type),w={FileName:G};readFile(w);return;case p==="DisplayText":var z="text/display",rt=c.fields.FIELD_DisplayText_Text,w={Text:rt};d(z,w),S(500);return;case p==="ClearText":var z="text/display",w={Text:""};d(z,w),S(500);return;case p==="TurnOnFlashlight":var z="flashlight",w={On:!0};d(z,w),S(500);return;case p==="TurnOffFlashlight":var z="flashlight",w={On:!1};d(z,w),S(500);return;case p==="WaitForSeconds":var A=y(c.inputs.FIELD_Duration);S(A*et);return;case p==="MoveArm":var F=c.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",C=y(c.fields.FIELD_MoveArm_Position),k=y(c.fields.FIELD_MoveArm_Velocity),z="arms",w={Arm:F,Position:C,Velocity:k,Units:"Degrees"};d(z,w);var K=i[b(F)],tt=wt(K.rotation),V=2*j*ot*Math.abs(tt.y-C),A=V/(k/100*pt),E={x:0,y:C-mt,z:0},J=zt(E.x,E.y*j/180,E.z);i[b(F)].rotation.w=J._w,i[b(F)].rotation.x=J._x,i[b(F)].rotation.y=J._y,i[b(F)].rotation.z=J._z,S(A);return;case p==="MoveArm2":var C=y(c.fields.FIELD_MoveArm2_Position),k=y(c.fields.FIELD_MoveArm2_Velocity),z="arms",w={Arm:"both",Position:C,Velocity:k,Units:"Degrees"};d(z,w);var Nt=i[b("Left")],Wt=i[b("Right")],Vt=wt(Nt.rotation),V=2*j*ot*Math.abs(Vt.y-C),Ht=V/(k/100*pt),qt=wt(Wt.rotation);V=2*j*ot*Math.abs(qt.y-C);var Yt=V/(k/100*pt),E={x:0,y:C-mt,z:0},I=zt(E.x,E.y*j/180,E.z);E={x:0,y:C-mt,z:0};var X=zt(E.x,E.y*j/180,E.z);i[b("Left")].rotation.w=I._w,i[b("Left")].rotation.x=I._x,i[b("Left")].rotation.y=I._y,i[b("Left")].rotation.z=I._z,i[b("Right")].rotation.w=X._w,i[b("Right")].rotation.x=X._x,i[b("Right")].rotation.y=X._y,i[b("Right")].rotation.z=X._z,S(Math.max(Ht,Yt));return;case p==="MoveArm3":var F=c.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",C=y(c.inputs.FIELD_MoveArm_Position),k=y(c.inputs.FIELD_MoveArm_Velocity),z="arms",w={Arm:F,Position:C,Velocity:k,Units:"Degrees"};d(z,w);var K=i[b(F)],tt=wt(K.rotation),V=2*j*ot*Math.abs(tt.y-C),A=V/(k/100*pt),E={x:0,y:C-mt,z:0},I=zt(E.x,E.y*j/180,E.z);i[b(F)].rotation.w=I._w,i[b(F)].rotation.x=I._x,i[b(F)].rotation.y=I._y,i[b(F)].rotation.z=I._z,S(A);return;case p==="MoveArms2":var Pt=y(c.inputs.FIELD_MoveArm_LeftPosition),re=y(c.inputs.FIELD_MoveArm_LeftVelocity),jt=y(c.inputs.FIELD_MoveArm_RightPosition),he=y(c.inputs.FIELD_MoveArm_RightVelocity),w={LeftArmPosition:Pt,RightArmPosition:jt,LeftArmVelocity:re,RightArmVelocity:he,Units:"Degrees"},z="arms/set";d(z,w);var Nt=i[b("Left")],Wt=i[b("Right")],Vt=wt(Nt.rotation),V=2*j*ot*Math.abs(Vt.y-Pt),Ht=V/(re/100*pt),qt=wt(Wt.rotation);V=2*j*ot*Math.abs(qt.y-jt);var Yt=V/(he/100*pt),E={x:0,y:Pt-mt,z:0},I=zt(E.x,E.y*j/180,E.z);E={x:0,y:jt-mt,z:0};var X=zt(E.x,E.y*j/180,E.z);i[b("Left")].rotation.w=I._w,i[b("Left")].rotation.x=I._x,i[b("Left")].rotation.y=I._y,i[b("Left")].rotation.z=I._z,i[b("Right")].rotation.w=X._w,i[b("Right")].rotation.x=X._x,i[b("Right")].rotation.y=X._y,i[b("Right")].rotation.z=X._z,S(Math.max(Ht,Yt));return;case p==="MoveHead":var Ft=c.fields.FIELD_MoveHead_Pitch==="D"?25:-40,z="head",w={Pitch:Ft,Yaw:0,Roll:0,Duration:2,Units:"degrees"};d(z,w),S(2e3);return;case p==="MoveHead3":var Ft,ae,oe,z="head";Ft=y(c.inputs.FIELD_MoveHead_Pitch),ae=y(c.inputs.FIELD_MoveHead_Roll),oe=y(c.inputs.FIELD_MoveHead_Yaw),A=y(c.inputs.FIELD_MoveHead_Time);var w={Pitch:Ft,Yaw:oe,Roll:ae,Duration:A,Units:"degrees"};d(z,w),S(A);return;case p==="DriveTime":var bt=c.fields.FIELD_DriveTime_Direction,k=parseInt(c.fields.FIELD_DriveTime_Velocity),A=parseInt(c.fields.FIELD_DriveTime_TimeMs)*et,z="drive/time",nt=bt==="F"?k:-k,w={LinearVelocity:nt,AngularVelocity:0,TimeMs:A};d(z,w),S(A);return;case p==="DriveTime2":var z="drive/time",nt=y(c.inputs.FIELD_DriveTime_Velocity),Et=y(c.inputs.FIELD_DriveTime_Angular),A=y(c.inputs.FIELD_DriveTime_TimeMs)*et,w={LinearVelocity:nt,AngularVelocity:Et,TimeMs:A};d(z,w),S(A);return;case p==="Turn":var bt=c.fields.FIELD_Turn_Direction,A=parseInt(c.fields.FIELD_Turn_Duration)*et,Et=100,nt=0,Bt=bt==="L"?90:-90,z="drive/time",w={LinearVelocity:nt,AngularVelocity:Et,TimeMs:A,Degree:Bt};d(z,w),S(A);return;case p==="Turn2":var bt=c.fields.FIELD_Turn_Direction,A=parseInt(y(c.inputs.FIELD_Turn_Duration))*et,Et=100,nt=0,Bt=bt==="L"?90:-90,w={LinearVelocity:nt,AngularVelocity:Et,TimeMs:A,Degree:Bt},z="drive/time";d(z,w),S(A);return;case p=="Speak":var z="tts/speak",Oe=r(c.inputs.FIELD_Speak_Text),rt=Oe.fields.TEXT,w={Text:`${rt}`};d(z,w),S(me*rt.split(" ").length*et);return;case p=="SpeakDefault":var z="tts/speak",rt=c.fields.FIELD_SpeakDefault_Text,w={Text:`${rt}`};d(z,w),S(me*rt.split(" ").length*et);return;default:return"No case match"}};let m=a("Start"),D=1;for(;m&&m.next;)D+=1,m=r(m.next),x(m,m.type);var T=`${D} blocks compiled`;self.postMessage(T)}; diff --git a/assets/index-zfQAfM59.js b/assets/index-BC1ykvt1.js similarity index 99% rename from assets/index-zfQAfM59.js rename to assets/index-BC1ykvt1.js index 4bdafc6d..b3cd5cab 100644 --- a/assets/index-zfQAfM59.js +++ b/assets/index-BC1ykvt1.js @@ -5812,7 +5812,7 @@ outputColor=vec4(color,alpha); #else outputColor=vec4(color,max(alpha,inputColor.a)); #endif -}`,wOe="uniform float patternScale;varying vec2 vUvPattern;void mainSupport(const in vec2 uv){vUvPattern=uv*vec2(aspect,1.0)*patternScale;}",EOe=class extends TOe{constructor(n,e,{blendFunction:t=Is.SCREEN,patternTexture:r=null,patternScale:s=1,edgeStrength:o=1,pulseSpeed:l=0,visibleEdgeColor:u=16777215,hiddenEdgeColor:h=2230538,kernelSize:f=Q4.VERY_SMALL,blur:g=!1,xRay:y=!0,multisampling:b=0,resolutionScale:w=.5,width:C=cp.AUTO_SIZE,height:M=cp.AUTO_SIZE,resolutionX:A=C,resolutionY:k=M}={}){super("OutlineEffect",SOe,{uniforms:new Map([["maskTexture",new so(null)],["edgeTexture",new so(null)],["edgeStrength",new so(o)],["visibleEdgeColor",new so(new Fn(u))],["hiddenEdgeColor",new so(new Fn(h))],["pulse",new so(1)],["patternScale",new so(s)],["patternTexture",new so(null)]])}),this.blendMode.addEventListener("change",U=>{this.blendMode.getBlendFunction()===Is.ALPHA?this.defines.set("ALPHA","1"):this.defines.delete("ALPHA"),this.setChanged()}),this.blendMode.setBlendFunction(t),this.patternTexture=r,this.xRay=y,this.scene=n,this.camera=e,this.renderTargetMask=new Nc(1,1),this.renderTargetMask.samples=b,this.renderTargetMask.texture.name="Outline.Mask",this.uniforms.get("maskTexture").value=this.renderTargetMask.texture,this.renderTargetOutline=new Nc(1,1,{depthBuffer:!1}),this.renderTargetOutline.texture.name="Outline.Edges",this.uniforms.get("edgeTexture").value=this.renderTargetOutline.texture,this.clearPass=new Z4,this.clearPass.overrideClearColor=new Fn(0),this.clearPass.overrideClearAlpha=1,this.depthPass=new M2e(n,e),this.maskPass=new M2(n,e,new p2e(this.depthPass.texture,e));const O=this.maskPass.clearPass;O.overrideClearColor=new Fn(16777215),O.overrideClearAlpha=1,this.blurPass=new k2e({resolutionScale:w,resolutionX:A,resolutionY:k,kernelSize:f}),this.blurPass.enabled=g;const P=this.blurPass.resolution;P.addEventListener("change",U=>this.setSize(P.baseWidth,P.baseHeight)),this.outlinePass=new N2e(new w2e);const D=this.outlinePass.fullscreenMaterial;D.inputBuffer=this.renderTargetMask.texture,this.time=0,this.active=!1,this.selection=new z2e,this.selection.layer=10,this.pulseSpeed=l}set mainScene(n){this.scene=n,this.depthPass.mainScene=n,this.maskPass.mainScene=n}set mainCamera(n){this.camera=n,this.depthPass.mainCamera=n,this.maskPass.mainCamera=n,this.maskPass.overrideMaterial.copyCameraSettings(n)}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.getResolution()}get multisampling(){return this.renderTargetMask.samples}set multisampling(n){this.renderTargetMask.samples=n,this.renderTargetMask.dispose()}get patternScale(){return this.uniforms.get("patternScale").value}set patternScale(n){this.uniforms.get("patternScale").value=n}get edgeStrength(){return this.uniforms.get("edgeStrength").value}set edgeStrength(n){this.uniforms.get("edgeStrength").value=n}get visibleEdgeColor(){return this.uniforms.get("visibleEdgeColor").value}set visibleEdgeColor(n){this.uniforms.get("visibleEdgeColor").value=n}get hiddenEdgeColor(){return this.uniforms.get("hiddenEdgeColor").value}set hiddenEdgeColor(n){this.uniforms.get("hiddenEdgeColor").value=n}getBlurPass(){return this.blurPass}getSelection(){return this.selection}getPulseSpeed(){return this.pulseSpeed}setPulseSpeed(n){this.pulseSpeed=n}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get selectionLayer(){return this.selection.layer}set selectionLayer(n){this.selection.layer=n}get dithering(){return this.blurPass.dithering}set dithering(n){this.blurPass.dithering=n}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(n){this.blurPass.kernelSize=n}get blur(){return this.blurPass.enabled}set blur(n){this.blurPass.enabled=n}get xRay(){return this.defines.has("X_RAY")}set xRay(n){this.xRay!==n&&(n?this.defines.set("X_RAY","1"):this.defines.delete("X_RAY"),this.setChanged())}isXRayEnabled(){return this.xRay}setXRayEnabled(n){this.xRay=n}get patternTexture(){return this.uniforms.get("patternTexture").value}set patternTexture(n){if(n!==null?(n.wrapS=n.wrapT=Pw,this.defines.set("USE_PATTERN","1"),this.setVertexShader(wOe)):(this.defines.delete("USE_PATTERN"),this.setVertexShader(null)),this.renderer!==null){const e=E9(n,this.renderer.capabilities.isWebGL2);this.defines.set("texelToLinear(texel)",e)}this.uniforms.get("patternTexture").value=n,this.setChanged()}setPatternTexture(n){this.patternTexture=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}setSelection(n){return this.selection.set(n),this}clearSelection(){return this.selection.clear(),this}selectObject(n){return this.selection.add(n),this}deselectObject(n){return this.selection.delete(n),this}update(n,e,t){const r=this.scene,s=this.camera,o=this.selection,l=this.uniforms.get("pulse"),u=r.background,h=s.layers.mask;o.size>0?(r.background=null,l.value=1,this.pulseSpeed>0&&(l.value=Math.cos(this.time*this.pulseSpeed*10)*.375+.625),this.active=!0,this.time+=t,o.setVisible(!1),this.depthPass.render(n),o.setVisible(!0),s.layers.set(o.layer),this.maskPass.render(n,this.renderTargetMask),s.layers.mask=h,r.background=u,this.outlinePass.render(n,null,this.renderTargetOutline),this.blurPass.enabled&&this.blurPass.render(n,this.renderTargetOutline,this.renderTargetOutline)):this.active&&(this.clearPass.render(n,this.renderTargetOutline),this.active=!1)}setSize(n,e){this.blurPass.setSize(n,e),this.renderTargetMask.setSize(n,e);const t=this.resolution;t.setBaseSize(n,e);const r=t.width,s=t.height;this.depthPass.setSize(r,s),this.renderTargetOutline.setSize(r,s),this.outlinePass.fullscreenMaterial.setSize(r,s)}initialize(n,e,t){const r=this.patternTexture,s=E9(r,n.capabilities.isWebGL2);this.defines.set("texelToLinear(texel)",s),this.blurPass.initialize(n,e,af),t!==void 0&&(this.depthPass.initialize(n,e,t),this.maskPass.initialize(n,e,t),this.outlinePass.initialize(n,e,t))}};new Ae;new Ae;let $x;function xOe(){if($x!==void 0)return $x;try{var n;let e;const t=document.createElement("canvas");return $x=!!(window.WebGL2RenderingContext&&(e=t.getContext("webgl2"))),e&&((n=e.getExtension("WEBGL_lose_context"))===null||n===void 0||n.loseContext()),$x}catch{return $x=!1}}const $Oe=n=>!!n.current,M9=n=>$Oe(n)?n.current:n,Aee=de.createContext(null),COe=Tt.memo(de.forwardRef((n,e)=>{let{children:t,camera:r,scene:s,resolutionScale:o,enabled:l=!0,renderPriority:u=1,autoClear:h=!0,depthBuffer:f,disableNormalPass:g,stencilBuffer:y,multisampling:b=8,frameBufferType:w=tT}=n;const{gl:C,scene:M,camera:A,size:k}=nf();s=s||M,r=r||A;const[O,P,D]=de.useMemo(()=>{const V=xOe(),z=new B2e(C,{depthBuffer:f,stencilBuffer:y,multisampling:b>0&&V?b:0,frameBufferType:w});z.addPass(new M2(s,r));let Z=null,oe=null;return g||(oe=new L2e(s,r),oe.enabled=!1,z.addPass(oe),o!==void 0&&V&&(Z=new A2e({normalBuffer:oe.texture,resolutionScale:o}),Z.enabled=!1,z.addPass(Z))),[z,oe,Z]},[r,C,f,y,b,w,s,g,o]);de.useEffect(()=>O==null?void 0:O.setSize(k.width,k.height),[O,k]),Km((V,z)=>{l&&(C.autoClear=h,O.render(z))},l?u:0);const U=de.useRef(null);de.useLayoutEffect(()=>{let V;return U.current&&U.current.__r3f&&O&&(V=new R2e(r,...U.current.__r3f.objects),V.renderToScreen=!0,O.addPass(V),P&&(P.enabled=!0),D&&(D.enabled=!0)),()=>{V&&(O==null||O.removePass(V)),P&&(P.enabled=!1),D&&(D.enabled=!1)}},[O,t,r,P,D]);const H=de.useMemo(()=>({composer:O,normalPass:P,downSamplingPass:D,resolutionScale:o,camera:r,scene:s}),[O,P,D,o,r,s]);return de.useImperativeHandle(e,()=>O,[O]),un(Aee.Provider,{value:H,children:un("group",{ref:U,children:t})})})),ez=de.createContext(null);function MOe(n){let{children:e,enabled:t=!0}=n;const[r,s]=de.useState([]),o=de.useMemo(()=>({selected:r,select:s,enabled:t}),[r,s,t]);return Tt.createElement(ez.Provider,{value:o},e)}function Iee(n){let{enabled:e=!1,children:t,...r}=n;const s=de.useRef(null),o=de.useContext(ez);return de.useEffect(()=>{if(o&&e){let l=!1;const u=[];if(s.current.traverse(h=>{h.type==="Mesh"&&u.push(h),o.selected.indexOf(h)===-1&&(l=!0)}),l)return o.select(h=>[...h,...u]),()=>{o.select(h=>h.filter(f=>!u.includes(f)))}}},[e,t]),un("group",{ref:s,...r,children:t})}const AOe=de.forwardRef(function(n,e){let{selection:t=[],selectionLayer:r=10,blendFunction:s,patternTexture:o,edgeStrength:l,pulseSpeed:u,visibleEdgeColor:h,hiddenEdgeColor:f,width:g,height:y,kernelSize:b,blur:w,xRay:C,...M}=n;const A=nf(U=>U.invalidate),{scene:k,camera:O}=de.useContext(Aee),P=de.useMemo(()=>new EOe(k,O,{blendFunction:s,patternTexture:o,edgeStrength:l,pulseSpeed:u,visibleEdgeColor:h,hiddenEdgeColor:f,width:g,height:y,kernelSize:b,blur:w,xRay:C,...M}),[s,w,O,l,y,f,b,o,u,k,h,g,C]),D=de.useContext(ez);return de.useEffect(()=>{if(!D&&t)return P.selection.set(Array.isArray(t)?t.map(M9):[M9(t)]),A(),()=>{P.selection.clear(),A()}},[P,t,D]),de.useEffect(()=>{P.selectionLayer=r,A()},[P,r]),de.useRef(),de.useEffect(()=>{if(D&&D.enabled){var U;if((U=D.selected)!=null&&U.length)return P.selection.set(D.selected),A(),()=>{P.selection.clear(),A()}}},[D]),un("primitive",{ref:e,object:P})}),IOe=["cube","cylinder","sphere","capsule","arrow"],Ree=de.createContext(),ROe=n=>{const e=de.useContext(Ree)[n.shape];return IOe.includes(n.shape)?n2e(n):e&&typeof e=="function"?e():(console.warn(`Shape not loaded: ${n.shape} (reading property 'shape' of item)`,n),[])},kOe=({meshes:n,children:e})=>un(Ree.Provider,{value:n,children:e}),OOe=de.memo(de.forwardRef(({objectKey:n,highlightColor:e,position:t,rotation:r,scale:s,ghost:o},l)=>{const u=de.useRef(null),h=TE(l,u),f=Fo(M=>M.onClick,Nf),g=Fo(M=>M.onPointerOver,Nf),y=Fo(M=>M.onPointerOut,Nf),b=Fo(M=>M.clock),w=Fo(de.useCallback(M=>M.items[n],[n]),Nf),C=ROe(w);return Km(de.useCallback(()=>{const M=b.getElapsed()*1e3;h.current&&(h.current.position.set(t?t.x:typeof w.position.x=="function"?w.position.x(M):w.position.x,t?t.y:typeof w.position.y=="function"?w.position.y(M):w.position.y,t?t.z:typeof w.position.z=="function"?w.position.z(M):w.position.z),h.current.quaternion.set(r?r.x:typeof w.rotation.x=="function"?w.rotation.x(M):w.rotation.x,r?r.y:typeof w.rotation.y=="function"?w.rotation.y(M):w.rotation.y,r?r.z:typeof w.rotation.z=="function"?w.rotation.z(M):w.rotation.z,r?r.w:typeof w.rotation.w=="function"?w.rotation.w(M):w.rotation.w),h.current.scale.set(s?s.x:typeof w.scale.x=="function"?w.scale.x(M):w.scale.x,s?s.y:typeof w.scale.y=="function"?w.scale.y(M):w.scale.y,s?s.z:typeof w.scale.z=="function"?w.scale.z(M):w.scale.z),h.current.visible=typeof w.hidden=="function"?!w.hidden(M):!w.hidden)},[w,t,r,s,h,b])),un(Iee,{enabled:w.highlighted,children:Bh("group",{ref:h,up:[0,0,1],children:[un("group",{up:[0,0,1],rotation:[Math.PI/2,0,0],onPointerDown:M=>{f(n,!h.current.visible,{local:{position:h.current.position,rotation:h.current.quaternion},world:{position:h.current.getWorldPosition(new Ae),rotation:h.current.getWorldQuaternion(new Sl)}},M)},onPointerOver:M=>{g(n,!h.current.visible,M)},onPointerOut:M=>{y(n,!h.current.visible,M)},children:C.map((M,A)=>un(kee,{idx:A,groupOrPart:M,objectKey:n,ghost:o,highlightColor:e},A))}),w.showName&&un(ree,{distanceFactor:3,position:[0,0,.2],children:un("div",{style:{opacity:.75,borderRadius:2,backgroundColor:"lightgrey",padding:5,userSelect:"none"},children:w.name})})]})})})),LOe=de.memo(({part:n,objectKey:e,ghost:t,highlightColor:r})=>{const s=Fo(de.useCallback(g=>g.items[e].wireframe,[e])),o=Fo(de.useCallback(g=>g.items[e].color,[e])),l=o!==void 0,u=de.useRef(),h=de.useRef(),f=Fo(g=>g.clock);return Km(de.useCallback(()=>{const g=f.getElapsed()*1e3;t||(iC(h,o,g),iC(u,o,g))},[t,u,h,f,o])),t?un("mesh",{ref:h,geometry:n.geometry,material:RI(r),scale:n.scale,castShadow:!1,receiveShadow:!1},"B"):l?Bh("group",{up:[0,0,1],children:[un("mesh",{ref:h,geometry:n.geometry,scale:n.scale,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,wireframe:s,attach:"material",opacity:1,side:cd})},"B"),un("mesh",{ref:u,geometry:n.geometry,scale:n.scale,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,attach:"material",wireframe:s,opacity:1,side:_v})},"F")]}):un(FC,{children:un("mesh",{ref:u,geometry:n.geometry,material:n.material,scale:n.scale,castShadow:!0,receiveShadow:!0,wireframe:s},"I")})}),kee=de.memo(({idx:n,groupOrPart:e,ghost:t,objectKey:r,highlightColor:s})=>e.type==="group"?un("group",{up:[0,0,1],position:e.position,rotation:e.rotation,scale:e.scale,children:e.children.map((o,l)=>un(kee,{idx:l,groupOrPart:o,objectKey:r,ghost:t,highlightColor:s},l))},n):un(LOe,{part:e,objectKey:r,highlightColor:s,ghost:t},n)),NOe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),{vertices:s,width:o,hidden:l}=Fo(de.useCallback(u=>({vertices:u.lines[n].vertices,width:u.lines[n].width,hidden:u.lines[n].hidden}),[n]),Nf);return s.length<=1?null:un(MIe,{ref:r,visible:!l,points:s.map(u=>[u.position.x,u.position.y,u.position.z]),color:"white",vertexColors:s.map(u=>[u.color.r/255,u.color.g/255,u.color.b/255]),lineWidth:o})}),DOe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),s=Fo(C=>C.onClick,Nf),o=Fo(C=>C.onPointerOver,Nf),l=Fo(C=>C.onPointerOut,Nf),u=Fo(de.useCallback(C=>C.hulls[n],[n]),Nf),h=Fo(de.useCallback(C=>C.hulls[n].vertices,[n]),Nf),f=Fo(C=>C.clock),g=de.useRef(),y=de.useRef(),b=typeof h=="function"?h(0):h,w=new IW(b.map(C=>new Ae(C.x,C.y,C.z)));return Km(de.useCallback(()=>{const C=f.getElapsed()*1e3;iC(y,u.color,C),iC(g,u.color,C);const M=typeof h=="function"?h(C):h;if(M!==b){const k=new IW(M.map(O=>new Ae(O.x,O.y,O.z)));g.current.geometry=k,y.current.geometry=k}const A=typeof u.hidden=="function"?!u.hidden(C):!u.hidden;g.current.visible=A,y.current.visible=A},[g,y,b,u,f,h])),un(Iee,{enabled:u.highlighted,children:Bh("group",{ref:r,up:[0,0,1],children:[Bh("group",{up:[0,0,1],onPointerDown:C=>{s(n,g.current.visible,C)},onPointerOver:C=>{o(n,g.current.visible,C)},onPointerOut:C=>{l(n,g.current.visible,C)},children:[un("mesh",{ref:y,geometry:w,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,wireframe:u.wireframe,attach:"material",side:cd})},`${n}B`),un("mesh",{ref:g,geometry:w,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,attach:"material",wireframe:u.wireframe,side:_v})},`${n}F`)]}),u.showName&&un(ree,{distanceFactor:2,position:[0,0,.5],children:un("div",{style:{opacity:.75,borderRadius:2,backgroundColor:"lightgrey"},className:"disable-text-selection",children:u.name})})]})})}),POe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),s=de.useRef(),o=Fo(u=>u.clock),l=Fo(de.useCallback(u=>u.texts[n],[n]));return Km(de.useCallback(()=>{const u=o.getElapsed()*1e3;r.current&&(r.current.position.set(typeof l.position.x=="function"?l.position.x(u):l.position.x,typeof l.position.y=="function"?l.position.y(u):l.position.y,typeof l.position.z=="function"?l.position.z(u):l.position.z),r.current.visible=typeof l.hidden=="function"?!l.hidden(u):!l.hidden),s.current&&iC(s,l.color,u)},[l,r,o])),un("group",{ref:r,children:un(CIe,{follow:!0,children:un(SRe,{ref:s,depthOffset:2,scale:[.2,.2,.2],children:l.value})})})}),BOe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),s=Fo(g=>g.clock),{points:o,scale:l,hidden:u}=Fo(de.useCallback(g=>({points:g.points[n].points,scale:g.points[n].scale,hidden:g.points[n].hidden}),[n]),Nf),[{positions:h,colors:f}]=de.useState(()=>({positions:new Float32Array(o.length*3),colors:new Float32Array(o.length*3)}));return Km(()=>{const g=s.getElapsed()*1e3;if(r.current)for(let y=0;y{const A=n==="world"?i2e:n==="gizmo"?s2e:r2e,k=n===y?M:{},O=w?t.filter(D=>C.includes(D.key)):t,P=w&&n!==g;return Bh(A,{objectKey:n,displayTfs:e,ref:y===n?g:null,...k,ghost:f,highlightColor:h,children:[O.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>un(tz,{activeTf:D.key,displayTfs:e,allTfs:t,allItems:r,allLines:s,allHulls:o,allTexts:l,allPoints:u,highlightColor:h,ghosts:f,targetRef:g,targetSource:b,targetId:y,filterActive:P,tfFilter:C,customProps:M},D.key)),r.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="items"?M:{};return!w||D.key===y||n===y?un(OOe,{objectKey:D.key,highlightColor:h,ghost:f,ref:D.key===y?g:null,...U},D.key):null}),s.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="lines"?M:{};return!w||D.key===y||n===y?un(NOe,{objectKey:D.key,ref:D.lineKey===y?g:null,...U},D.key):null}),o.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="hulls"?M:{};return!w||D.key===y||n===y?un(DOe,{objectKey:D.key,highlightColor:h,ghost:f,ref:D.key===y?g:null,...U},D.key):null}),l.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="texts"?M:{};return!w||D.key===y||n===y?un(POe,{objectKey:D.key,highlightColor:h,ref:D.key===y?g:null,...U},D.key):null}),u.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="points"?M:{};return!w||D.key===y||n===y?un(BOe,{objectKey:D.key,highlightColor:h,ref:D.key===y?g:null,...U},D.key):null})]})}),FOe=["enabled","axis","translationSnap","rotationSnap","scaleSnap","space","size"],zOe=["displayTfs","allTfs","allItems","allLines","allHulls","allTexts","allPoints","highlightColor"],UOe=de.memo(({camera:n,objectInfo:e,highlightColor:t,translateSnap:r,rotateSnap:s,scaleSnap:o,onDragStart:l,onDragEnd:u,mode:h,...f})=>{const g=vN(f,FOe),y=vN(f,zOe),b=Fo(de.useCallback(q=>{let ae=[];e.source==="tfs"&&ae.push(e.key);let le=q[e.source][e.key].frame;for(;le&&le!=="world"&&le!=="gizmo";){let ce=q.tfs[le];ae.push(le),le=ce.frame}return ae},[e]),Nf),w=de.useRef(),C=de.useRef(),M=Fo(q=>vN(q[e.source][e.key],["position","rotation","scale"]),Nf),A=nf(({gl:q})=>q),k=nf(({camera:q})=>q),O=nf(({invalidate:q})=>q),P=n||k,[D]=de.useState(()=>new Fke(P,A.domElement));D.translationSnap=r,D.rotationSnap=s,D.scaleSnap=o,h!=null&&h.includes("translate")?D.mode="translate":h!=null&&h.includes("rotate")?D.mode="rotate":h!=null&&h.includes("scale")&&(D.mode="scale"),h!=null&&h.includes("-x")?(D.showY=!1,D.showZ=!1):h!=null&&h.includes("-y")?(D.showX=!1,D.showZ=!1):h!=null&&h.includes("-z")&&(D.showX=!1,D.showY=!1);const[U,H]=de.useState(!1),[V,z]=de.useState(M),[Z,oe]=de.useState(!1);de.useEffect(()=>{console.log("refreshing transform"),z(M)},[M,Z]);const ue=Fo(q=>q.onMove,Nf);return de.useEffect(()=>{const q=ae=>{var le,ce,ge;const $e=(le=C==null?void 0:C.current)==null?void 0:le.position,K=(ce=C==null?void 0:C.current)==null?void 0:ce.quaternion,ie=(ge=C==null?void 0:C.current)==null?void 0:ge.scale;ae.value&&!U?(console.log("starting transform"),H(!0),z({position:$e,rotation:K,scale:ie}),l&&l()):!ae.value&&U&&(console.log("stopping transform"),H(!1),u&&u(),ue(e.key,e.source,{position:D.worldPosition,quaternion:D.worldQuaternion,scale:D._worldScale},{position:$e?{x:$e.x,y:$e.y,z:$e.z}:null,quaternion:K?{x:K.x,y:K.y,z:K.z,w:K.w}:null,scale:ie?{x:ie.x,y:ie.y,z:ie.z}:null}),oe(!Z))};return D&&D.addEventListener("dragging-changed",q),()=>{D.removeEventListener("dragging-changed",q)}},[M,U,e]),de.useEffect(()=>void(D==null?void 0:D.attach(C.current)),[C,D]),de.useEffect(()=>(D&&D.addEventListener("change",O),()=>{var q;return(q=D==null?void 0:D.removeEventListener)==null?void 0:q.call(D,"change",O)}),[D,O]),D?Bh(FC,{children:[un("primitive",{ref:w,object:D,...g}),un(tz,{...y,activeTf:"world",tfFilter:b,ghosts:!0,targetRef:C,targetSource:e.source,targetId:e.key,filterActive:!0,customProps:{...V}})]}):null}),o1=(n,e)=>n.length!==e.length?!1:!n.some((t,r)=>!gg.exports.isEqual(e[r],t));function HOe({displayTfs:n=!1,displayGrid:e=!0,isPolar:t=!1,backgroundColor:r="#d0d0d0",planeColor:s="#a8a8a8",highlightColor:o="#00ffff",plane:l=0,translateSnap:u=0,rotateSnap:h=0,scaleSnap:f=0,debug:g=!1}){g&&console.log("content rerender");const y=nf(ue=>ue.camera),b=Fo(ue=>ue.clock,Nf);Km(()=>{b.update()});const w=Fo(ue=>gg.exports.sortBy(Object.entries(ue.tfs).map(([q,ae])=>({key:q,frame:ae.frame,transformMode:ae.transformMode,source:"tfs"})),q=>q.key),o1),C=Fo(ue=>gg.exports.sortBy(Object.entries(ue.items).map(([q,ae])=>({key:q,frame:ae.frame,transformMode:ae.transformMode,source:"items"})),q=>q.key),o1),M=Fo(ue=>gg.exports.sortBy(Object.entries(ue.lines).map(([q,ae])=>({key:q,frame:ae.frame,source:"lines"})),q=>q.key),o1),A=Fo(ue=>gg.exports.sortBy(Object.entries(ue.hulls).map(([q,ae])=>({key:q,frame:ae.frame,source:"hulls"})),q=>q.key),o1),k=Fo(ue=>gg.exports.sortBy(Object.entries(ue.texts).map(([q,ae])=>({key:q,frame:ae.frame,source:"texts"})),q=>q.key),o1),O=Fo(ue=>gg.exports.sortBy(Object.entries(ue.points).map(([q,ae])=>({key:q,frame:ae.frame,source:"points"})),q=>q.key),o1),P=Fo(ue=>gg.exports.sortBy(Object.entries(ue.widgets).map(([q,ae])=>({key:q,frame:ae.frame,source:"widgets"})),q=>q.key),o1),D=[...C,...w].filter(ue=>["translate","rotate","scale","translate-x","translate-y","translate-z","rotate-x","rotate-y","rotate-z","scale-x","scale-y","scale-z"].includes(ue.transformMode)),U=de.useRef(),H=de.useRef(),V=de.useRef(),z=de.useRef(),Z=Bke(s),oe=[Z.r,Z.g,Z.b,.5];return Bh(Tt.Fragment,{children:[un(qRe,{ref:z,makeDefault:!0,camera:y}),un("pointLight",{ref:H,intensity:.5,position:[-1,-3,3],color:"#FFFAEE"}),un(Dke,{ref:U,intensity:.7,color:"white"}),un(Pke,{ref:V,castShadow:!0,position:[5,15,15],intensity:.6,color:"#FFFAEE"}),un("spotLight",{penumbra:1,position:[-1,-1,4],intensity:.3,castShadow:!0,color:"#FFFAEE"}),un("color",{attach:"background",args:[r]}),un("fogExp2",{attach:"fog",args:[r,.01]}),un(tke,{receiveShadow:!0,scale:1e3,position:[0,0,l-.01],material:mv(...oe)}),Bh(MOe,{children:[un(COe,{autoClear:!1,children:un(AOe,{visibleEdgeColor:o,hiddenEdgeColor:o,blur:!0,kernelSize:1,edgeStrength:50,pulseSpeed:.25,xRay:!0})}),un(tz,{activeTf:"world",displayTfs:n,allTfs:w,allItems:C,allLines:M,allHulls:A,allTexts:k,allPoints:O,allWidgets:P,highlightColor:o})]}),un("group",{position:[0,0,l],rotation:[Math.PI/2,0,0],up:[0,0,1],children:e&&(t?un("polarGridHelper",{args:[10,16,8,64,"white","gray"]}):un("gridHelper",{args:[20,20,"white","gray"]}))}),D.map(ue=>un(UOe,{objectInfo:ue,mode:ue.transformMode,displayTfs:n,allTfs:w,allItems:C,allLines:M,allHulls:A,allTexts:k,allPoints:O,allWidgets:P,translateSnap:u,rotateSnap:h,scaleSnap:f,highlightColor:o,onDragEnd:()=>{z.current&&(z.current.enabled=!0)},onDragStart:()=>{z.current&&(z.current.enabled=!1)}},`movableObjectTransform-${ue.key}`))]})}oo.DefaultUp.set(0,0,1);function GOe({backgroundColor:n="#d0d0d0",store:e,fov:t=60,onPointerMissed:r=()=>{},meshLookup:s={},debug:o=!1,...l}){return o&&console.log("Scene rerender"),un(oIe,{camera:{up:[0,0,1],fov:t,position:[0,-3,3]},shadows:!0,style:{background:n||"#d0d0d0"},onPointerMissed:r||(()=>{}),children:un(Nke,{store:e,debug:o,children:un(kOe,{meshes:s,children:un(de.Suspense,{children:un(HOe,{...l,backgroundColor:n,debug:o})})})})})}var nz={},WOe=hE;Object.defineProperty(nz,"__esModule",{value:!0});var Oee=nz.default=void 0,VOe=WOe(n2()),jOe=Me;Oee=nz.default=(0,VOe.default)((0,jOe.jsx)("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}),"RestartAlt");var rz={},YOe=hE;Object.defineProperty(rz,"__esModule",{value:!0});var Lee=rz.default=void 0,XOe=YOe(n2()),KOe=Me;Lee=rz.default=(0,XOe.default)((0,KOe.jsx)("path",{d:"M8 5v14l11-7z"}),"PlayArrow");var iz={},JOe=hE;Object.defineProperty(iz,"__esModule",{value:!0});var Nee=iz.default=void 0,qOe=JOe(n2()),QOe=Me;Nee=iz.default=(0,qOe.default)((0,QOe.jsx)("path",{d:"M6 6h12v12H6z"}),"Stop");const ZOe="/gpu-programming/assets/compile-worker-dMA9xPCI.js",eLe={Left:"LEFT_ARM_CONNECTOR_1",Right:"RIGHT_ARM_CONNECTOR_1",Head:"HEAD_1",Neck:"NECK_GLOBE_BASE_1",Base:"base_link"},Vi=n=>eLe[n],tLe={s_Acceptance:"s_Acceptance.wav",s_Amazement:"s_Amazement.wav",s_Amazement2:"s_Amazement2.wav",s_Anger:"s_Anger.wav",s_Anger2:"s_Anger2.wav",s_Anger3:"s_Anger3.wav",s_Anger4:"s_Anger4.wav",s_Annoyance:"s_Annoyance.wav",s_Annoyance2:"s_Annoyance2.wav",s_Annoyance3:"s_Annoyance3.wav",s_Annoyance4:"s_Annoyance4.wav",s_Awe:"s_Awe.wav",s_Awe2:"s_Awe2.wav",s_Awe3:"s_Awe3.wav",s_Boredom:"s_Boredom.wav",s_Disapproval:"s_Disapproval.wav",s_Disgust:"s_Disgust.wav",s_Disgust2:"s_Disgust2.wav",s_Disgust3:"s_Disgust3.wav",s_DisorientedConfused:"s_DisorientedConfused.wav",s_DisorientedConfused2:"s_DisorientedConfused2.wav",s_DisorientedConfused3:"s_DisorientedConfused3.wav",s_DisorientedConfused4:"s_DisorientedConfused4.wav",s_DisorientedConfused5:"s_DisorientedConfused5.wav",s_DisorientedConfused6:"s_DisorientedConfused6.wav",s_Distraction:"s_Distraction.wav",s_Ecstacy:"s_Ecstacy.wav",s_Ecstacy2:"s_Ecstacy2.wav",s_Fear:"s_Fear.wav",s_Grief:"s_Grief.wav",s_Grief2:"s_Grief2.wav",s_Grief3:"s_Grief3.wav",s_Grief4:"s_Grief4.wav",s_Joy:"s_Joy.wav",s_Joy2:"s_Joy2.wav",s_Joy3:"s_Joy3.wav",s_Joy4:"s_Joy4.wav",s_Loathing:"s_Loathing.wav",s_Love:"s_Love.wav",s_PhraseByeBye:"s_PhraseByeBye.wav",s_PhraseEvilAhHa:"s_PhraseEvilAhHa.wav",s_PhraseHello:"s_PhraseHello.wav",s_PhraseNoNoNo:"s_PhraseNoNoNo.wav",s_PhraseOopsy:"s_PhraseOopsy.wav",s_PhraseOwOwOw:"s_PhraseOwOwOw.wav",s_PhraseOwwww:"s_PhraseOwwww.wav",s_PhraseUhOh:"s_PhraseUhOh.wav",s_Rage:"s_Rage.wav",s_Sadness:"s_Sadness.wav",s_Sadness2:"s_Sadness2.wav",s_Sadness3:"s_Sadness3.wav",s_Sadness4:"s_Sadness4.wav",s_Sadness5:"s_Sadness5.wav",s_Sadness6:"s_Sadness6.wav",s_Sadness7:"s_Sadness7.wav",s_Sleepy:"s_Sleepy.wav",s_Sleepy2:"s_Sleepy2.wav",s_Sleepy3:"s_Sleepy3.wav",s_Sleepy4:"s_Sleepy4.wav",s_SleepySnore:"s_SleepySnore.wav",s_SystemCameraShutter:"s_SystemCameraShutter.wav"},A9=n=>tLe[n],J0={e_Sleeping:"e_Sleeping.jpg",e_SleepingZZZ:"e_SleepingZZZ.jpg",e_Contempt:"e_Contempt.jpg",e_ContentLeft:"e_ContentLeft.jpg",e_ContentRight:"e_ContentRight.jpg",e_Disoriented:"e_Disoriented.jpg",e_EcstacyHilarious:"e_EcstacyHilarious.jpg",e_EcstacyStarryEyed:"e_EcstacyStarryEyed.jpg",e_JoyGoofy:"e_JoyGoofy.jpg",e_JoyGoofy2:"e_JoyGoofy2.jpg",e_JoyGoofy3:"e_JoyGoofy3.jpg",e_Love:"e_Love.jpg",e_Rage:"e_Rage.jpg",e_Rage2:"e_Rage2.jpg",e_Rage3:"e_Rage3.jpg",e_Rage4:"e_Rage4.jpg",e_RemorseShame:"e_RemorseShame.jpg",eyes_acceptance:"eyes_acceptance.jpg",eyes_admiration:"eyes_admiration.jpg",eyes_amazement:"eyes_amazement.jpg",eyes_anger:"eyes_anger.jpg",eyes_annoyed:"eyes_annoyed.jpg",eyes_anticipation:"eyes_anticipation.png",eyes_apprehension:"eyes_apprehension.jpg",eyes_apprehension_1:"eyes_apprehension_1.jpg",eyes_boredom:"eyes_boredom.jpg",eyes_default:"eyes_default.jpg",eyes_disgust:"eyes_disgust.jpg",eyes_distraction:"eyes_distraction.gif",eyes_ecstasy_frame_1:"eyes_ecstasy_frame_1.jpg",eyes_ecstasy_frame_2:"eyes_ecstasy_frame_2.jpg",eyes_fear:"eyes_fear.jpg",eyes_grief:"eyes_grief.jpg",eyes_interest:"eyes_interest.jpg",eyes_joy:"eyes_joy.jpg",eyes_loathing:"eyes_loathing.jpg",eyes_pensiveness:"eyes_pensiveness.jpg",eyes_rage:"eyes_rage.jpg",eyes_sad:"eyes_sad.jpg",eyes_serenity:"eyes_serenity.jpg",eyes_surprise:"eyes_surprise.png",eyes_terror:"eyes_terror.jpg",eyes_trust:"eyes_trust.jpg",eyes_vigilance:"eyes_vigilance.jpg"},nLe=n=>J0[n],rLe=({blocks:n,tfs:e,items:t})=>{var ue;var r=e[Vi("Left")],s=e[Vi("Right")],o=e[Vi("Head")],l=e[Vi("Base")];let u={Left:{x:[r.rotation.x],y:[r.rotation.y],z:[r.rotation.z],w:[r.rotation.w]},Right:{x:[s.rotation.x],y:[s.rotation.y],z:[s.rotation.z],w:[s.rotation.w]},Head:{x:[o.rotation.x],y:[o.rotation.y],z:[o.rotation.z],w:[o.rotation.w]},Base:{position:{x:[l.position.x],y:[l.position.y],z:[l.position.z],angle:[0],distance:[0]},rotation:{x:[l.rotation.x],y:[l.rotation.y],z:[l.rotation.z],w:[l.rotation.w]}},Speech:[],Time:[0]},h=Object.keys(J0);for(let q=0;q{if(q==="both")g(ae,le,ae,le);else if(le>0){var ce=q,ge=q==="Left"?"Right":"Left",$e={rotation:{x:u[ce].x[u[ce].x.length-1],y:u[ce].y[u[ce].y.length-1],z:u[ce].z[u[ce].z.length-1],w:u[ce].w[u[ce].w.length-1]}},K=cI($e.rotation),ie=2*ad*uI*Math.abs(K.y-ae),se=ie/(le/100*jO),fe={x:0,y:ae-YO,z:0},Se=1;if(fe.y<0&&K.y>0||fe.y>0&&K.y<0){let qe=(fe.y-K.y)/2,we=fe.y-qe;var Ue=sy(0,we*ad/180,0);u[ce].w.push(Ue._w),u[ce].x.push(Ue._x),u[ce].y.push(Ue._y),u[ce].z.push(Ue._z),u.Time.push(se/2),Se+=1}var ke=sy(fe.x,fe.y*ad/180,fe.z);u[ce].w.push(ke._w),u[ce].x.push(ke._x),u[ce].y.push(ke._y),u[ce].z.push(ke._z);for(let qe=0;qe1?u.Time.push(se/2):u.Time.push(se)}},g=(q,ae,le,ce)=>{if(ae>0||ce>0){var ge={rotation:{x:u.Left.x[u.Left.x.length-1],y:u.Left.y[u.Left.y.length-1],z:u.Left.z[u.Left.z.length-1],w:u.Left.w[u.Left.w.length-1]}},$e={rotation:{x:u.Right.x[u.Right.x.length-1],y:u.Right.y[u.Right.y.length-1],z:u.Right.z[u.Right.z.length-1],w:u.Right.w[u.Right.w.length-1]}},K=cI(ge.rotation),ie=2*ad*uI*Math.abs(K.y-q),se=ie/(ae/100*jO),fe=cI($e.rotation),Se=2*ad*uI*Math.abs(fe.y-le),Ue=Se/(ce/100*jO),ke=ae===0?Ue:ce===0?se:Math.max(se,Ue),qe={x:0,y:q-YO,z:0},we=sy(qe.x,qe.y*ad/180,qe.z),Ze={x:0,y:le-YO,z:0},et=sy(Ze.x,Ze.y*ad/180,Ze.z);let Ge=1;if(qe.y<0&&K.y>0||qe.y>0&&K.y<0||Ze.y<0&&fe.y>0||Ze.y>0&&fe.y<0){let Ie=(qe.y-K.y)/2,He=(qe.y-K.y)/2,it=qe.y-Ie,st=Ze.y-He;var ft=sy(0,it*ad/180,0),at=sy(0,st*ad/180,0);ae>0?(u.Left.w.push(ft._w),u.Left.x.push(ft._x),u.Left.y.push(ft._y),u.Left.z.push(ft._z)):(u.Left.w.push(u.Left.w[u.Left.w.length-1]),u.Left.x.push(u.Left.x[u.Left.x.length-1]),u.Left.y.push(u.Left.y[u.Left.y.length-1]),u.Left.z.push(u.Left.z[u.Left.z.length-1])),ce>0?(u.Right.w.push(at._w),u.Right.x.push(at._x),u.Right.y.push(at._y),u.Right.z.push(at._z)):(u.Right.w.push(u.Right.w[u.Right.w.length-1]),u.Right.x.push(u.Right.x[u.Right.x.length-1]),u.Right.y.push(u.Right.y[u.Right.y.length-1]),u.Right.z.push(u.Right.z[u.Right.z.length-1])),u.Time.push(ke/2),Ge+=1}ae>0?(u.Left.w.push(we._w),u.Left.x.push(we._x),u.Left.y.push(we._y),u.Left.z.push(we._z)):(u.Left.w.push(u.Left.w[u.Left.w.length-1]),u.Left.x.push(u.Left.x[u.Left.x.length-1]),u.Left.y.push(u.Left.y[u.Left.y.length-1]),u.Left.z.push(u.Left.z[u.Left.z.length-1])),ce>0?(u.Right.w.push(et._w),u.Right.x.push(et._x),u.Right.y.push(et._y),u.Right.z.push(et._z)):(u.Right.w.push(u.Right.w[u.Right.w.length-1]),u.Right.x.push(u.Right.x[u.Right.x.length-1]),u.Right.y.push(u.Right.y[u.Right.y.length-1]),u.Right.z.push(u.Right.z[u.Right.z.length-1]));for(let Ie=0;Ie1?u.Time.push(ke/2):u.Time.push(ke)}},y=(q,ae,le,ce)=>{if(ce>0){var ge=sy(ae*ad/180,q*ad/180,le*ad/180);u.Head.w.push(ge._w),u.Head.x.push(ge._x),u.Head.y.push(ge._y),u.Head.z.push(ge._z);let $e=u.Left.w.length-1;u.Speech.push(""),u.Left.w.push(u.Left.w[$e]),u.Left.x.push(u.Left.x[$e]),u.Left.y.push(u.Left.y[$e]),u.Left.z.push(u.Left.z[$e]),u.Right.w.push(u.Right.w[$e]),u.Right.x.push(u.Right.x[$e]),u.Right.y.push(u.Right.y[$e]),u.Right.z.push(u.Right.z[$e]),u.Base.position.x.push(u.Base.position.x[$e]),u.Base.position.y.push(u.Base.position.y[$e]),u.Base.position.z.push(u.Base.position.z[$e]),u.Base.position.distance.push(u.Base.position.distance[$e]),u.Base.position.angle.push(u.Base.position.angle[$e]),u.Base.rotation.w.push(u.Base.rotation.w[$e]),u.Base.rotation.x.push(u.Base.rotation.x[$e]),u.Base.rotation.y.push(u.Base.rotation.y[$e]),u.Base.rotation.z.push(u.Base.rotation.z[$e]);let K=Object.keys(J0);for(let ie=0;ie{if(le>0){var ce={position:{x:u.Base.position.x[u.Base.position.x.length-1],y:u.Base.position.y[u.Base.position.y.length-1],z:u.Base.position.z[u.Base.position.z.length-1]},rotation:{x:u.Base.rotation.x[u.Base.rotation.x.length-1],y:u.Base.rotation.y[u.Base.rotation.y.length-1],z:u.Base.rotation.z[u.Base.rotation.z.length-1],w:u.Base.rotation.w[u.Base.rotation.w.length-1]}},ge=ae/100*Ele*le/lg,$e=q/100*wle*le/lg,K=new Pu(ce.rotation.x,ce.rotation.y,ce.rotation.z,ce.rotation.w),ie=hH(K);if(ge!==0){var se={x:0,y:0,z:ge};K=sy(se.x,se.y,se.z),K.multiply(new Pu(ce.rotation.x,ce.rotation.y,ce.rotation.z,ce.rotation.w))}let fe=ce.position.x,Se=ce.position.y,Ue=null;Ue=new zt(fe+Math.sin(ie-ge)*$e,Se-Math.cos(ie-ge)*$e,ce.position.z),u.Base.position.x.push(Ue.x),u.Base.position.y.push(Ue.y),u.Base.position.z.push(Ue.z),u.Base.position.angle.push(ge),u.Base.position.distance.push($e),u.Base.rotation.w.push(K._w),u.Base.rotation.x.push(K._x),u.Base.rotation.y.push(K._y),u.Base.rotation.z.push(K._z),u.Speech.push(""),u.Head.x.push(u.Head.x[u.Head.x.length-1]),u.Head.y.push(u.Head.y[u.Head.y.length-1]),u.Head.z.push(u.Head.z[u.Head.z.length-1]),u.Head.w.push(u.Head.w[u.Head.w.length-1]),u.Left.w.push(u.Left.w[u.Left.w.length-1]),u.Left.x.push(u.Left.x[u.Left.x.length-1]),u.Left.y.push(u.Left.y[u.Left.y.length-1]),u.Left.z.push(u.Left.z[u.Left.z.length-1]),u.Right.w.push(u.Right.w[u.Right.w.length-1]),u.Right.x.push(u.Right.x[u.Right.x.length-1]),u.Right.y.push(u.Right.y[u.Right.y.length-1]),u.Right.z.push(u.Right.z[u.Right.z.length-1]);let ke=Object.keys(J0);for(let qe=0;qe{let le=Object.keys(J0);for(let ge=0;ge{let le=u.Head.x.length-1;u.Speech.push(q),u.Base.position.x.push(u.Base.position.x[le]),u.Base.position.y.push(u.Base.position.y[le]),u.Base.position.z.push(u.Base.position.z[le]),u.Base.position.distance.push(u.Base.position.distance[le]),u.Base.position.angle.push(u.Base.position.angle[le]),u.Base.rotation.w.push(u.Base.rotation.w[le]),u.Base.rotation.x.push(u.Base.rotation.x[le]),u.Base.rotation.y.push(u.Base.rotation.y[le]),u.Base.rotation.z.push(u.Base.rotation.z[le]),u.Head.x.push(u.Head.x[le]),u.Head.y.push(u.Head.y[le]),u.Head.z.push(u.Head.z[le]),u.Head.w.push(u.Head.w[le]),u.Left.w.push(u.Left.w[le]),u.Left.x.push(u.Left.x[le]),u.Left.y.push(u.Left.y[le]),u.Left.z.push(u.Left.z[le]),u.Right.w.push(u.Right.w[le]),u.Right.x.push(u.Right.x[le]),u.Right.y.push(u.Right.y[le]),u.Right.z.push(u.Right.z[le]);let ce=Object.keys(J0);for(let ge=0;ge{let ae=u.Head.x.length-1;u.Speech.push(""),u.Base.position.x.push(u.Base.position.x[ae]),u.Base.position.y.push(u.Base.position.y[ae]),u.Base.position.z.push(u.Base.position.z[ae]),u.Base.position.distance.push(u.Base.position.distance[ae]),u.Base.position.angle.push(u.Base.position.angle[ae]),u.Base.rotation.w.push(u.Base.rotation.w[ae]),u.Base.rotation.x.push(u.Base.rotation.x[ae]),u.Base.rotation.y.push(u.Base.rotation.y[ae]),u.Base.rotation.z.push(u.Base.rotation.z[ae]),u.Head.x.push(u.Head.x[ae]),u.Head.y.push(u.Head.y[ae]),u.Head.z.push(u.Head.z[ae]),u.Head.w.push(u.Head.w[ae]),u.Left.w.push(u.Left.w[ae]),u.Left.x.push(u.Left.x[ae]),u.Left.y.push(u.Left.y[ae]),u.Left.z.push(u.Left.z[ae]),u.Right.w.push(u.Right.w[ae]),u.Right.x.push(u.Right.x[ae]),u.Right.y.push(u.Right.y[ae]),u.Right.z.push(u.Right.z[ae]);let le=Object.keys(J0);for(let ce=0;ce{let q=JSON.parse(JSON.stringify(e)),ae=JSON.parse(JSON.stringify(e)),le=JSON.parse(JSON.stringify(t)),ce=JSON.parse(JSON.stringify(t)),ge=u.Time.length,$e=0,K=[],ie=[],se=[],fe=[],Se=[],Ue=[],ke=[],qe=[],we=[],Ze=[],et=[],ft=[],at=[],Ge=[],Ie=[],He=[],it=[],st=[],It=[],kt=[],vt=[],Mt=Object.keys(J0);for(let Ke=0;KeObject.values(n).filter(ae=>ae.type===q)[0],O=q=>n[q],P=(q,ae)=>{const le=O(q);let ce=O(ae);if(z(le,le.type))for(z(ce,ce.type);ce.next;)ce=O(ce.next),z(ce,ce.type)},D=q=>q==="TRUE";function U(q,ae){return q=Math.ceil(q),ae=Math.floor(ae),Math.floor(Math.random()*(ae-q+1))+q}function H(q){if(q===2||q===3)return!0;if(q<=1||q%2===0||q%3===0)return!1;for(let ae=5;ae*ae<=q;ae+=6)if(q%ae===0||q%(ae+2)===0)return!1;return!0}function V(q){var ae;if(typeof q!="string"&&typeof q!="object")return q.shadow.fields.NUM;{let le=(ae=q==null?void 0:q.shadow)!=null&&ae.id?O(q.shadow.id):O(q);return z(le,le.type)}}const z=(q,ae)=>{var Ct,gt,Ee;switch(!0){case ae==="CustomIF":if(!q.inputs||!q.inputs.IF0||!q.inputs.DO0)throw new Error("err: controls_if not complete!");P(q.inputs.IF0,q.inputs.DO0);break;case ae==="logic_boolean":return D(q.fields.BOOL);case ae==="logic_compare":if(!q.inputs||!q.inputs.A||!q.inputs.B)throw new Error("err: logic_compare is not complete!");const re=q.fields.OP,Be=q.inputs.A,mt=q.inputs.B,yt=O(Be),wt=O(mt);if(re==="EQ")return z(yt,yt.type)==z(wt,wt.type);if(re==="NEQ")return z(yt,yt.type)!==z(wt,wt.type);if(re==="LT")return z(yt,yt.type)z(wt,wt.type);if(re==="GTE")return z(yt,yt.type)>=z(wt,wt.type);case ae==="logic_operation":if(!q.inputs||!q.inputs.A||!q.inputs.B)throw new Error("err: logic_operation is not complete!");const Ke=q.fields.OP,Qe=q.inputs.A,Le=q.inputs.B,Q=O(Qe),te=O(Le);return Ke==="OR"?z(Q,Q.type)||z(te,te.type):z(Q,Q.type)&&z(te,te.type);case ae==="logic_negate":if(!q.inputs)throw new Error("err: logic_negate is not complete!");const me=O(q.inputs.BOOL);return!z(me,me.type);case ae==="logic_boolean":return!q.fields.BOOL!=="FALSE";case ae==="logic_null":return null;case ae==="logic_ternary":if(!q.inputs||!q.inputs.IF||!q.inputs.THEN||!q.inputs.ELSE)throw new Error("err: logic_ternary is not complete!");const Re=q.inputs.IF,Fe=q.inputs.THEN,bt=q.inputs.ELSE,ze=O(Re),Pt=O(Fe),lt=O(bt);return z(ze,ze.type)?z(Pt,Pt.type):z(lt,lt.type);case ae==="controls_repeat_ext":const Wt=V(q.inputs.TIMES);if(!q.inputs.DO)throw new Error("err: controls_repeat_ext is not complete!");let bn=O(q.inputs.DO);for(let Lr=0;Lr0;if(ar==="NEGATIVE")return cr<0;if(ar==="DIVISIBLE_BY"){if(!q.inputs||!q.inputs.DIVISOR)throw new Error("err: DIVISOR is not filled!");if(q.inputs.DIVISOR===0)throw new Error("Note that divisor cannot be 0!");return cr%q.inputs.DIVISOR===0}return;case ae==="math_random_int":const oi=V(q.inputs.FROM),Mr=V(q.inputs.TO);return U(oi,Mr);case ae==="colour_picker":return cS(q.fields.COLOUR);case ae==="colour_random":let _r=U(0,255),ne=U(0,255),Te=U(0,255);return{r:_r,g:ne,b:Te};case ae==="colour_rgb":const je=V(q.inputs.RED),ct=V(q.inputs.GREEN),Ht=V(q.inputs.BLUE);return{r:je,g:ct,b:Ht};case ae==="colour_blend":const nn=V(q.inputs.RATIO),kn=cS(q.inputs.COLOUR1.shadow.fields.COLOUR),De=cS(q.inputs.COLOUR2.shadow.fields.COLOUR),_t=kn.r*nn,Ot=kn.g*nn,St=kn.b*nn,Xt=De.r,Wn=De.g,ir=De.b,br=(Xt+_t)/(nn+1),Or=(Wn+Ot)/(nn+1),Ei=(ir+St)/(nn+1);return{r:br,g:Or,b:Ei};case ae==="ChangeLED":if(!q.inputs||!q.inputs.FIELD_ChangeLED)throw new Error("err: ChangeLED is not complete!");var le=O(q.inputs.FIELD_ChangeLED),ce=null;(Ct=le==null?void 0:le.fields)!=null&&Ct.COLOUR?ce=cS(le.fields.COLOUR):ce=z(le,le.type);var Ue={Red:ce.r,Green:ce.g,Blue:ce.b};return;case ae==="TransitionLED":if(!q.inputs||!q.inputs.COLOR1||!q.inputs.COLOR2)throw new Error("err: TransitionLED is not complete!");var ge=O(q.inputs.COLOR1),$e=O(q.inputs.COLOR2),K=null;(gt=ge==null?void 0:ge.fields)!=null&>.COLOUR?K=cS(ge.fields.COLOUR):K=z(ge,ge.type);var ie=null;(Ee=$e==null?void 0:$e.fields)!=null&&Ee.COLOUR?ie=cS($e.fields.COLOUR):ie=z($e,$e.type);var It=q.fields.FIELD_TransitionTime_TimeMs*lg,se=q.fields.TRANSITION_TYPE,Ue={Red:K.r,Green:K.g,Blue:K.b,Red2:ie.r,Green2:ie.g,Blue2:ie.b,TransitionType:se,TimeMS:It};return;case ae==="DisplayImage":if(!q.inputs||!q.inputs.FIELD_DisplayImage_Filename)throw new Error("err: DisplayImage is not complete!");var fe=O(q.inputs.FIELD_DisplayImage_Filename),Se=nLe(fe.type);w(fe.type,500);return;case ae==="PlayAudio":if(!q.inputs||!q.inputs.FIELD_PlayAudio_Filename)throw new Error("err: PlayAudio is not complete!");var fe=O(q.inputs.FIELD_PlayAudio_Filename),Se=A9(fe.type);return;case ae==="DisplayAnimation":if(!q.inputs||!q.inputs.FIELD_DisplayAnimation_Filename)throw new Error("err: DisplayAnimation is not complete!");var fe=O(q.inputs.FIELD_DisplayAnimation_Filename),Se=A9(fe.type),Ue={FileName:Se};readFile(Ue);return;case ae==="DisplayText":var Mt=q.fields.FIELD_DisplayText_Text;return;case ae==="TurnOnFlashlight":return;case ae==="TurnOffFlashlight":return;case ae==="WaitForSeconds":console.log(q),console.log("here");var It=V(q.inputs.FIELD_Duration)*lg;console.log(It),M(It);return;case ae==="MoveArm":var ke=q.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",qe=V(q.fields.FIELD_MoveArm_Position),He=V(q.fields.FIELD_MoveArm_Velocity);f(ke,qe,He);return;case ae==="MoveArm2":var qe=V(q.fields.FIELD_MoveArm2_Position),He=V(q.fields.FIELD_MoveArm2_Velocity),ke="both";f(ke,qe,He);return;case ae==="MoveArm3":var ke=q.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",qe=V(q.inputs.FIELD_MoveArm_Position),He=V(q.inputs.FIELD_MoveArm_Velocity);f(ke,qe,He);return;case ae==="MoveArms2":var we=V(q.inputs.FIELD_MoveArm_LeftPosition),Ze=V(q.inputs.FIELD_MoveArm_LeftVelocity),et=V(q.inputs.FIELD_MoveArm_RightPosition),ft=V(q.inputs.FIELD_MoveArm_RightVelocity);g(we,Ze,et,ft);return;case ae==="MoveHead":var at=q.fields.FIELD_MoveHead_Pitch==="D"?25:-40,It=2e3;y(at,0,0,It);return;case ae==="MoveHead3":var at,Ge,Ie;at=V(q.inputs.FIELD_MoveHead_Pitch),Ge=V(q.inputs.FIELD_MoveHead_Roll),Ie=V(q.inputs.FIELD_MoveHead_Yaw),It=V(q.inputs.FIELD_MoveHead_Time)*lg,y(at,Ge,Ie,It);return;case ae==="DriveTime":var st=q.fields.FIELD_DriveTime_Direction,He=parseInt(q.fields.FIELD_DriveTime_Velocity),It=parseInt(q.fields.FIELD_DriveTime_TimeMs)*lg,it=st==="F"?He:-He;b(it,0,It);return;case ae==="DriveTime2":var it=V(q.inputs.FIELD_DriveTime_Velocity),kt=V(q.inputs.FIELD_DriveTime_Angular),It=V(q.inputs.FIELD_DriveTime_TimeMs)*lg;b(it,kt,It);return;case ae==="Turn":var st=q.fields.FIELD_Turn_Direction,It=parseInt(q.fields.FIELD_Turn_Duration)*lg,kt=st==="L"?100:-100;b(0,kt,It);return;case ae==="Turn2":var st=q.fields.FIELD_Turn_Direction,It=parseInt(V(q.inputs.FIELD_Turn_Duration))*lg,kt=st==="L"?100:-100;b(0,kt,It);return;case ae=="Speak":var vt=O(q.inputs.FIELD_Speak_Text),Mt=vt.fields.TEXT;C(Mt,uH*Mt.split(" ").length*lg);return;case ae=="SpeakDefault":var Mt=q.fields.FIELD_SpeakDefault_Text;C(Mt,uH*Mt.split(" ").length*lg);return;default:return}};let oe=k("Start");for(;oe&&oe.next;)oe=O(oe.next),z(oe,oe.type);return A()};function iLe(n){const e=Bn(xi(H=>H.resetSim)),t=Bn(xi(H=>H.toggleSimOnly)),r=Bn(xi(H=>H.isConnected)),s=Bn(xi(H=>H.ip)),o=Bn(xi(H=>H.getBlocks)),l=Bn(xi(H=>H.getEndingItems)),u=Bn(xi(H=>H.clock)),h=Bn(xi(H=>H.mistyImageList)),f=Bn(xi(H=>H.mistyAudioList)),g=Bn(xi(H=>H.simOnly)),y=Bn(xi(H=>H.endingTfs)),b=Bn(xi(H=>H.setAnimationFrames)),w=Bn(xi(H=>H.setHighlightBlocks)),C=Bn(xi(H=>H.workerThread)),M=Bn(xi(H=>H.setWorkerThread)),A=Bn(xi(H=>H.llmMode));function k(H,V){s&&!g&&r&&fetch(`http://${s}/api/${H}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)})}const O=async()=>{ch("Click Run Code button"),u.reset_elapsed(),C&&(C.terminate(),M(null));const H=`import ${JSON.stringify(new URL(ZOe,import.meta.url))}`,V=new Blob([H],{type:"application/javascript"}),z=URL.createObjectURL(V);let Z=new Worker(z,{type:"module"});Z.onmessage=function(ce){console.log("Message received from worker "+ce.data),M(null)},Z.onerror=function(ce){console.log(ce);const $e=/id: (.+)/.exec(ce.message);if($e){w($e[1]),P();return}else console.log("ID not found in error message.");URL.revokeObjectURL(z)},Z.postMessage({blocks:o(),mistyAudioList:f,mistyImageList:h,tfs:y,ip:s,runOnRobot:!g}),M(Z);let{newTfs:oe,newEndingTfs:ue,newItems:q,newEndingItems:ae,speechObject:le}=rLe({blocks:o(),tfs:y,items:l()});b(oe,ue,q,ae,le)},P=()=>{C&&(C.terminate(),M(null),w(""),k("halt",{})),ch("Click Stop Code button")},D=()=>{k("arms/set",{LeftArmPosition:90,RightArmPosition:90,LeftArmVelocity:100,RightArmVelocity:100,Units:"Degrees"}),k("head",{Pitch:0,Yaw:0,Roll:0,Duration:1,Units:"Degrees"}),k("images/display",{FileName:"e_DefaultContent.jpg",Alpha:1}),k("text/display",{Text:""}),k("led",{Red:100,Green:70,Blue:160}),e()};let U=A?{top:"10px"}:{bottom:"0px"};return Me.jsxs(Nw,{style:{position:"absolute",padding:"0px",left:"10px",...U},children:[Me.jsxs(KH,{style:{paddingLeft:"0px",paddingRight:"0px"},children:[!C&&Me.jsx(_I,{variant:"contained","aria-label":"play",style:{backgroundColor:"#FAFAFA",marginBottom:"5px"},onClick:O,id:"runButton",children:Me.jsx(Lee,{})}),C&&Me.jsx(_I,{variant:"contained","aria-label":"play",style:{backgroundColor:"#FAFAFA",marginBottom:"5px"},onClick:P,id:"stopButton",children:Me.jsx(Nee,{})}),Me.jsx(_I,{variant:"contained","aria-label":"restart",style:{backgroundColor:"#FAFAFA",marginLeft:"5px",marginBottom:"5px"},onClick:D,children:Me.jsx(Oee,{})})]}),r&&Me.jsx(KH,{style:{backgroundColor:"#FAFAFA",borderRadius:"5px",marginBottom:"5px",paddingLeft:"10px",paddingRight:"0px"},children:Me.jsx(XK,{children:Me.jsx(YK,{control:Me.jsx(yge,{onChange:H=>t(H.target.checked)}),label:"Sim only"})})})]})}var li="cs",Dee={exports:{}};/*! +}`,wOe="uniform float patternScale;varying vec2 vUvPattern;void mainSupport(const in vec2 uv){vUvPattern=uv*vec2(aspect,1.0)*patternScale;}",EOe=class extends TOe{constructor(n,e,{blendFunction:t=Is.SCREEN,patternTexture:r=null,patternScale:s=1,edgeStrength:o=1,pulseSpeed:l=0,visibleEdgeColor:u=16777215,hiddenEdgeColor:h=2230538,kernelSize:f=Q4.VERY_SMALL,blur:g=!1,xRay:y=!0,multisampling:b=0,resolutionScale:w=.5,width:C=cp.AUTO_SIZE,height:M=cp.AUTO_SIZE,resolutionX:A=C,resolutionY:k=M}={}){super("OutlineEffect",SOe,{uniforms:new Map([["maskTexture",new so(null)],["edgeTexture",new so(null)],["edgeStrength",new so(o)],["visibleEdgeColor",new so(new Fn(u))],["hiddenEdgeColor",new so(new Fn(h))],["pulse",new so(1)],["patternScale",new so(s)],["patternTexture",new so(null)]])}),this.blendMode.addEventListener("change",U=>{this.blendMode.getBlendFunction()===Is.ALPHA?this.defines.set("ALPHA","1"):this.defines.delete("ALPHA"),this.setChanged()}),this.blendMode.setBlendFunction(t),this.patternTexture=r,this.xRay=y,this.scene=n,this.camera=e,this.renderTargetMask=new Nc(1,1),this.renderTargetMask.samples=b,this.renderTargetMask.texture.name="Outline.Mask",this.uniforms.get("maskTexture").value=this.renderTargetMask.texture,this.renderTargetOutline=new Nc(1,1,{depthBuffer:!1}),this.renderTargetOutline.texture.name="Outline.Edges",this.uniforms.get("edgeTexture").value=this.renderTargetOutline.texture,this.clearPass=new Z4,this.clearPass.overrideClearColor=new Fn(0),this.clearPass.overrideClearAlpha=1,this.depthPass=new M2e(n,e),this.maskPass=new M2(n,e,new p2e(this.depthPass.texture,e));const O=this.maskPass.clearPass;O.overrideClearColor=new Fn(16777215),O.overrideClearAlpha=1,this.blurPass=new k2e({resolutionScale:w,resolutionX:A,resolutionY:k,kernelSize:f}),this.blurPass.enabled=g;const P=this.blurPass.resolution;P.addEventListener("change",U=>this.setSize(P.baseWidth,P.baseHeight)),this.outlinePass=new N2e(new w2e);const D=this.outlinePass.fullscreenMaterial;D.inputBuffer=this.renderTargetMask.texture,this.time=0,this.active=!1,this.selection=new z2e,this.selection.layer=10,this.pulseSpeed=l}set mainScene(n){this.scene=n,this.depthPass.mainScene=n,this.maskPass.mainScene=n}set mainCamera(n){this.camera=n,this.depthPass.mainCamera=n,this.maskPass.mainCamera=n,this.maskPass.overrideMaterial.copyCameraSettings(n)}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.getResolution()}get multisampling(){return this.renderTargetMask.samples}set multisampling(n){this.renderTargetMask.samples=n,this.renderTargetMask.dispose()}get patternScale(){return this.uniforms.get("patternScale").value}set patternScale(n){this.uniforms.get("patternScale").value=n}get edgeStrength(){return this.uniforms.get("edgeStrength").value}set edgeStrength(n){this.uniforms.get("edgeStrength").value=n}get visibleEdgeColor(){return this.uniforms.get("visibleEdgeColor").value}set visibleEdgeColor(n){this.uniforms.get("visibleEdgeColor").value=n}get hiddenEdgeColor(){return this.uniforms.get("hiddenEdgeColor").value}set hiddenEdgeColor(n){this.uniforms.get("hiddenEdgeColor").value=n}getBlurPass(){return this.blurPass}getSelection(){return this.selection}getPulseSpeed(){return this.pulseSpeed}setPulseSpeed(n){this.pulseSpeed=n}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get selectionLayer(){return this.selection.layer}set selectionLayer(n){this.selection.layer=n}get dithering(){return this.blurPass.dithering}set dithering(n){this.blurPass.dithering=n}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(n){this.blurPass.kernelSize=n}get blur(){return this.blurPass.enabled}set blur(n){this.blurPass.enabled=n}get xRay(){return this.defines.has("X_RAY")}set xRay(n){this.xRay!==n&&(n?this.defines.set("X_RAY","1"):this.defines.delete("X_RAY"),this.setChanged())}isXRayEnabled(){return this.xRay}setXRayEnabled(n){this.xRay=n}get patternTexture(){return this.uniforms.get("patternTexture").value}set patternTexture(n){if(n!==null?(n.wrapS=n.wrapT=Pw,this.defines.set("USE_PATTERN","1"),this.setVertexShader(wOe)):(this.defines.delete("USE_PATTERN"),this.setVertexShader(null)),this.renderer!==null){const e=E9(n,this.renderer.capabilities.isWebGL2);this.defines.set("texelToLinear(texel)",e)}this.uniforms.get("patternTexture").value=n,this.setChanged()}setPatternTexture(n){this.patternTexture=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}setSelection(n){return this.selection.set(n),this}clearSelection(){return this.selection.clear(),this}selectObject(n){return this.selection.add(n),this}deselectObject(n){return this.selection.delete(n),this}update(n,e,t){const r=this.scene,s=this.camera,o=this.selection,l=this.uniforms.get("pulse"),u=r.background,h=s.layers.mask;o.size>0?(r.background=null,l.value=1,this.pulseSpeed>0&&(l.value=Math.cos(this.time*this.pulseSpeed*10)*.375+.625),this.active=!0,this.time+=t,o.setVisible(!1),this.depthPass.render(n),o.setVisible(!0),s.layers.set(o.layer),this.maskPass.render(n,this.renderTargetMask),s.layers.mask=h,r.background=u,this.outlinePass.render(n,null,this.renderTargetOutline),this.blurPass.enabled&&this.blurPass.render(n,this.renderTargetOutline,this.renderTargetOutline)):this.active&&(this.clearPass.render(n,this.renderTargetOutline),this.active=!1)}setSize(n,e){this.blurPass.setSize(n,e),this.renderTargetMask.setSize(n,e);const t=this.resolution;t.setBaseSize(n,e);const r=t.width,s=t.height;this.depthPass.setSize(r,s),this.renderTargetOutline.setSize(r,s),this.outlinePass.fullscreenMaterial.setSize(r,s)}initialize(n,e,t){const r=this.patternTexture,s=E9(r,n.capabilities.isWebGL2);this.defines.set("texelToLinear(texel)",s),this.blurPass.initialize(n,e,af),t!==void 0&&(this.depthPass.initialize(n,e,t),this.maskPass.initialize(n,e,t),this.outlinePass.initialize(n,e,t))}};new Ae;new Ae;let $x;function xOe(){if($x!==void 0)return $x;try{var n;let e;const t=document.createElement("canvas");return $x=!!(window.WebGL2RenderingContext&&(e=t.getContext("webgl2"))),e&&((n=e.getExtension("WEBGL_lose_context"))===null||n===void 0||n.loseContext()),$x}catch{return $x=!1}}const $Oe=n=>!!n.current,M9=n=>$Oe(n)?n.current:n,Aee=de.createContext(null),COe=Tt.memo(de.forwardRef((n,e)=>{let{children:t,camera:r,scene:s,resolutionScale:o,enabled:l=!0,renderPriority:u=1,autoClear:h=!0,depthBuffer:f,disableNormalPass:g,stencilBuffer:y,multisampling:b=8,frameBufferType:w=tT}=n;const{gl:C,scene:M,camera:A,size:k}=nf();s=s||M,r=r||A;const[O,P,D]=de.useMemo(()=>{const V=xOe(),z=new B2e(C,{depthBuffer:f,stencilBuffer:y,multisampling:b>0&&V?b:0,frameBufferType:w});z.addPass(new M2(s,r));let Z=null,oe=null;return g||(oe=new L2e(s,r),oe.enabled=!1,z.addPass(oe),o!==void 0&&V&&(Z=new A2e({normalBuffer:oe.texture,resolutionScale:o}),Z.enabled=!1,z.addPass(Z))),[z,oe,Z]},[r,C,f,y,b,w,s,g,o]);de.useEffect(()=>O==null?void 0:O.setSize(k.width,k.height),[O,k]),Km((V,z)=>{l&&(C.autoClear=h,O.render(z))},l?u:0);const U=de.useRef(null);de.useLayoutEffect(()=>{let V;return U.current&&U.current.__r3f&&O&&(V=new R2e(r,...U.current.__r3f.objects),V.renderToScreen=!0,O.addPass(V),P&&(P.enabled=!0),D&&(D.enabled=!0)),()=>{V&&(O==null||O.removePass(V)),P&&(P.enabled=!1),D&&(D.enabled=!1)}},[O,t,r,P,D]);const H=de.useMemo(()=>({composer:O,normalPass:P,downSamplingPass:D,resolutionScale:o,camera:r,scene:s}),[O,P,D,o,r,s]);return de.useImperativeHandle(e,()=>O,[O]),un(Aee.Provider,{value:H,children:un("group",{ref:U,children:t})})})),ez=de.createContext(null);function MOe(n){let{children:e,enabled:t=!0}=n;const[r,s]=de.useState([]),o=de.useMemo(()=>({selected:r,select:s,enabled:t}),[r,s,t]);return Tt.createElement(ez.Provider,{value:o},e)}function Iee(n){let{enabled:e=!1,children:t,...r}=n;const s=de.useRef(null),o=de.useContext(ez);return de.useEffect(()=>{if(o&&e){let l=!1;const u=[];if(s.current.traverse(h=>{h.type==="Mesh"&&u.push(h),o.selected.indexOf(h)===-1&&(l=!0)}),l)return o.select(h=>[...h,...u]),()=>{o.select(h=>h.filter(f=>!u.includes(f)))}}},[e,t]),un("group",{ref:s,...r,children:t})}const AOe=de.forwardRef(function(n,e){let{selection:t=[],selectionLayer:r=10,blendFunction:s,patternTexture:o,edgeStrength:l,pulseSpeed:u,visibleEdgeColor:h,hiddenEdgeColor:f,width:g,height:y,kernelSize:b,blur:w,xRay:C,...M}=n;const A=nf(U=>U.invalidate),{scene:k,camera:O}=de.useContext(Aee),P=de.useMemo(()=>new EOe(k,O,{blendFunction:s,patternTexture:o,edgeStrength:l,pulseSpeed:u,visibleEdgeColor:h,hiddenEdgeColor:f,width:g,height:y,kernelSize:b,blur:w,xRay:C,...M}),[s,w,O,l,y,f,b,o,u,k,h,g,C]),D=de.useContext(ez);return de.useEffect(()=>{if(!D&&t)return P.selection.set(Array.isArray(t)?t.map(M9):[M9(t)]),A(),()=>{P.selection.clear(),A()}},[P,t,D]),de.useEffect(()=>{P.selectionLayer=r,A()},[P,r]),de.useRef(),de.useEffect(()=>{if(D&&D.enabled){var U;if((U=D.selected)!=null&&U.length)return P.selection.set(D.selected),A(),()=>{P.selection.clear(),A()}}},[D]),un("primitive",{ref:e,object:P})}),IOe=["cube","cylinder","sphere","capsule","arrow"],Ree=de.createContext(),ROe=n=>{const e=de.useContext(Ree)[n.shape];return IOe.includes(n.shape)?n2e(n):e&&typeof e=="function"?e():(console.warn(`Shape not loaded: ${n.shape} (reading property 'shape' of item)`,n),[])},kOe=({meshes:n,children:e})=>un(Ree.Provider,{value:n,children:e}),OOe=de.memo(de.forwardRef(({objectKey:n,highlightColor:e,position:t,rotation:r,scale:s,ghost:o},l)=>{const u=de.useRef(null),h=TE(l,u),f=Fo(M=>M.onClick,Nf),g=Fo(M=>M.onPointerOver,Nf),y=Fo(M=>M.onPointerOut,Nf),b=Fo(M=>M.clock),w=Fo(de.useCallback(M=>M.items[n],[n]),Nf),C=ROe(w);return Km(de.useCallback(()=>{const M=b.getElapsed()*1e3;h.current&&(h.current.position.set(t?t.x:typeof w.position.x=="function"?w.position.x(M):w.position.x,t?t.y:typeof w.position.y=="function"?w.position.y(M):w.position.y,t?t.z:typeof w.position.z=="function"?w.position.z(M):w.position.z),h.current.quaternion.set(r?r.x:typeof w.rotation.x=="function"?w.rotation.x(M):w.rotation.x,r?r.y:typeof w.rotation.y=="function"?w.rotation.y(M):w.rotation.y,r?r.z:typeof w.rotation.z=="function"?w.rotation.z(M):w.rotation.z,r?r.w:typeof w.rotation.w=="function"?w.rotation.w(M):w.rotation.w),h.current.scale.set(s?s.x:typeof w.scale.x=="function"?w.scale.x(M):w.scale.x,s?s.y:typeof w.scale.y=="function"?w.scale.y(M):w.scale.y,s?s.z:typeof w.scale.z=="function"?w.scale.z(M):w.scale.z),h.current.visible=typeof w.hidden=="function"?!w.hidden(M):!w.hidden)},[w,t,r,s,h,b])),un(Iee,{enabled:w.highlighted,children:Bh("group",{ref:h,up:[0,0,1],children:[un("group",{up:[0,0,1],rotation:[Math.PI/2,0,0],onPointerDown:M=>{f(n,!h.current.visible,{local:{position:h.current.position,rotation:h.current.quaternion},world:{position:h.current.getWorldPosition(new Ae),rotation:h.current.getWorldQuaternion(new Sl)}},M)},onPointerOver:M=>{g(n,!h.current.visible,M)},onPointerOut:M=>{y(n,!h.current.visible,M)},children:C.map((M,A)=>un(kee,{idx:A,groupOrPart:M,objectKey:n,ghost:o,highlightColor:e},A))}),w.showName&&un(ree,{distanceFactor:3,position:[0,0,.2],children:un("div",{style:{opacity:.75,borderRadius:2,backgroundColor:"lightgrey",padding:5,userSelect:"none"},children:w.name})})]})})})),LOe=de.memo(({part:n,objectKey:e,ghost:t,highlightColor:r})=>{const s=Fo(de.useCallback(g=>g.items[e].wireframe,[e])),o=Fo(de.useCallback(g=>g.items[e].color,[e])),l=o!==void 0,u=de.useRef(),h=de.useRef(),f=Fo(g=>g.clock);return Km(de.useCallback(()=>{const g=f.getElapsed()*1e3;t||(iC(h,o,g),iC(u,o,g))},[t,u,h,f,o])),t?un("mesh",{ref:h,geometry:n.geometry,material:RI(r),scale:n.scale,castShadow:!1,receiveShadow:!1},"B"):l?Bh("group",{up:[0,0,1],children:[un("mesh",{ref:h,geometry:n.geometry,scale:n.scale,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,wireframe:s,attach:"material",opacity:1,side:cd})},"B"),un("mesh",{ref:u,geometry:n.geometry,scale:n.scale,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,attach:"material",wireframe:s,opacity:1,side:_v})},"F")]}):un(FC,{children:un("mesh",{ref:u,geometry:n.geometry,material:n.material,scale:n.scale,castShadow:!0,receiveShadow:!0,wireframe:s},"I")})}),kee=de.memo(({idx:n,groupOrPart:e,ghost:t,objectKey:r,highlightColor:s})=>e.type==="group"?un("group",{up:[0,0,1],position:e.position,rotation:e.rotation,scale:e.scale,children:e.children.map((o,l)=>un(kee,{idx:l,groupOrPart:o,objectKey:r,ghost:t,highlightColor:s},l))},n):un(LOe,{part:e,objectKey:r,highlightColor:s,ghost:t},n)),NOe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),{vertices:s,width:o,hidden:l}=Fo(de.useCallback(u=>({vertices:u.lines[n].vertices,width:u.lines[n].width,hidden:u.lines[n].hidden}),[n]),Nf);return s.length<=1?null:un(MIe,{ref:r,visible:!l,points:s.map(u=>[u.position.x,u.position.y,u.position.z]),color:"white",vertexColors:s.map(u=>[u.color.r/255,u.color.g/255,u.color.b/255]),lineWidth:o})}),DOe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),s=Fo(C=>C.onClick,Nf),o=Fo(C=>C.onPointerOver,Nf),l=Fo(C=>C.onPointerOut,Nf),u=Fo(de.useCallback(C=>C.hulls[n],[n]),Nf),h=Fo(de.useCallback(C=>C.hulls[n].vertices,[n]),Nf),f=Fo(C=>C.clock),g=de.useRef(),y=de.useRef(),b=typeof h=="function"?h(0):h,w=new IW(b.map(C=>new Ae(C.x,C.y,C.z)));return Km(de.useCallback(()=>{const C=f.getElapsed()*1e3;iC(y,u.color,C),iC(g,u.color,C);const M=typeof h=="function"?h(C):h;if(M!==b){const k=new IW(M.map(O=>new Ae(O.x,O.y,O.z)));g.current.geometry=k,y.current.geometry=k}const A=typeof u.hidden=="function"?!u.hidden(C):!u.hidden;g.current.visible=A,y.current.visible=A},[g,y,b,u,f,h])),un(Iee,{enabled:u.highlighted,children:Bh("group",{ref:r,up:[0,0,1],children:[Bh("group",{up:[0,0,1],onPointerDown:C=>{s(n,g.current.visible,C)},onPointerOver:C=>{o(n,g.current.visible,C)},onPointerOut:C=>{l(n,g.current.visible,C)},children:[un("mesh",{ref:y,geometry:w,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,wireframe:u.wireframe,attach:"material",side:cd})},`${n}B`),un("mesh",{ref:g,geometry:w,castShadow:!1,receiveShadow:!1,children:un("meshLambertMaterial",{transparent:!0,attach:"material",wireframe:u.wireframe,side:_v})},`${n}F`)]}),u.showName&&un(ree,{distanceFactor:2,position:[0,0,.5],children:un("div",{style:{opacity:.75,borderRadius:2,backgroundColor:"lightgrey"},className:"disable-text-selection",children:u.name})})]})})}),POe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),s=de.useRef(),o=Fo(u=>u.clock),l=Fo(de.useCallback(u=>u.texts[n],[n]));return Km(de.useCallback(()=>{const u=o.getElapsed()*1e3;r.current&&(r.current.position.set(typeof l.position.x=="function"?l.position.x(u):l.position.x,typeof l.position.y=="function"?l.position.y(u):l.position.y,typeof l.position.z=="function"?l.position.z(u):l.position.z),r.current.visible=typeof l.hidden=="function"?!l.hidden(u):!l.hidden),s.current&&iC(s,l.color,u)},[l,r,o])),un("group",{ref:r,children:un(CIe,{follow:!0,children:un(SRe,{ref:s,depthOffset:2,scale:[.2,.2,.2],children:l.value})})})}),BOe=de.forwardRef(({objectKey:n},e)=>{const t=de.useRef(null),r=TE(e,t),s=Fo(g=>g.clock),{points:o,scale:l,hidden:u}=Fo(de.useCallback(g=>({points:g.points[n].points,scale:g.points[n].scale,hidden:g.points[n].hidden}),[n]),Nf),[{positions:h,colors:f}]=de.useState(()=>({positions:new Float32Array(o.length*3),colors:new Float32Array(o.length*3)}));return Km(()=>{const g=s.getElapsed()*1e3;if(r.current)for(let y=0;y{const A=n==="world"?i2e:n==="gizmo"?s2e:r2e,k=n===y?M:{},O=w?t.filter(D=>C.includes(D.key)):t,P=w&&n!==g;return Bh(A,{objectKey:n,displayTfs:e,ref:y===n?g:null,...k,ghost:f,highlightColor:h,children:[O.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>un(tz,{activeTf:D.key,displayTfs:e,allTfs:t,allItems:r,allLines:s,allHulls:o,allTexts:l,allPoints:u,highlightColor:h,ghosts:f,targetRef:g,targetSource:b,targetId:y,filterActive:P,tfFilter:C,customProps:M},D.key)),r.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="items"?M:{};return!w||D.key===y||n===y?un(OOe,{objectKey:D.key,highlightColor:h,ghost:f,ref:D.key===y?g:null,...U},D.key):null}),s.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="lines"?M:{};return!w||D.key===y||n===y?un(NOe,{objectKey:D.key,ref:D.lineKey===y?g:null,...U},D.key):null}),o.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="hulls"?M:{};return!w||D.key===y||n===y?un(DOe,{objectKey:D.key,highlightColor:h,ghost:f,ref:D.key===y?g:null,...U},D.key):null}),l.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="texts"?M:{};return!w||D.key===y||n===y?un(POe,{objectKey:D.key,highlightColor:h,ref:D.key===y?g:null,...U},D.key):null}),u.filter(D=>D.frame===n||n==="world"&&!D.frame).map(D=>{const U=D.key===y&&b==="points"?M:{};return!w||D.key===y||n===y?un(BOe,{objectKey:D.key,highlightColor:h,ref:D.key===y?g:null,...U},D.key):null})]})}),FOe=["enabled","axis","translationSnap","rotationSnap","scaleSnap","space","size"],zOe=["displayTfs","allTfs","allItems","allLines","allHulls","allTexts","allPoints","highlightColor"],UOe=de.memo(({camera:n,objectInfo:e,highlightColor:t,translateSnap:r,rotateSnap:s,scaleSnap:o,onDragStart:l,onDragEnd:u,mode:h,...f})=>{const g=vN(f,FOe),y=vN(f,zOe),b=Fo(de.useCallback(q=>{let ae=[];e.source==="tfs"&&ae.push(e.key);let le=q[e.source][e.key].frame;for(;le&&le!=="world"&&le!=="gizmo";){let ce=q.tfs[le];ae.push(le),le=ce.frame}return ae},[e]),Nf),w=de.useRef(),C=de.useRef(),M=Fo(q=>vN(q[e.source][e.key],["position","rotation","scale"]),Nf),A=nf(({gl:q})=>q),k=nf(({camera:q})=>q),O=nf(({invalidate:q})=>q),P=n||k,[D]=de.useState(()=>new Fke(P,A.domElement));D.translationSnap=r,D.rotationSnap=s,D.scaleSnap=o,h!=null&&h.includes("translate")?D.mode="translate":h!=null&&h.includes("rotate")?D.mode="rotate":h!=null&&h.includes("scale")&&(D.mode="scale"),h!=null&&h.includes("-x")?(D.showY=!1,D.showZ=!1):h!=null&&h.includes("-y")?(D.showX=!1,D.showZ=!1):h!=null&&h.includes("-z")&&(D.showX=!1,D.showY=!1);const[U,H]=de.useState(!1),[V,z]=de.useState(M),[Z,oe]=de.useState(!1);de.useEffect(()=>{console.log("refreshing transform"),z(M)},[M,Z]);const ue=Fo(q=>q.onMove,Nf);return de.useEffect(()=>{const q=ae=>{var le,ce,ge;const $e=(le=C==null?void 0:C.current)==null?void 0:le.position,K=(ce=C==null?void 0:C.current)==null?void 0:ce.quaternion,ie=(ge=C==null?void 0:C.current)==null?void 0:ge.scale;ae.value&&!U?(console.log("starting transform"),H(!0),z({position:$e,rotation:K,scale:ie}),l&&l()):!ae.value&&U&&(console.log("stopping transform"),H(!1),u&&u(),ue(e.key,e.source,{position:D.worldPosition,quaternion:D.worldQuaternion,scale:D._worldScale},{position:$e?{x:$e.x,y:$e.y,z:$e.z}:null,quaternion:K?{x:K.x,y:K.y,z:K.z,w:K.w}:null,scale:ie?{x:ie.x,y:ie.y,z:ie.z}:null}),oe(!Z))};return D&&D.addEventListener("dragging-changed",q),()=>{D.removeEventListener("dragging-changed",q)}},[M,U,e]),de.useEffect(()=>void(D==null?void 0:D.attach(C.current)),[C,D]),de.useEffect(()=>(D&&D.addEventListener("change",O),()=>{var q;return(q=D==null?void 0:D.removeEventListener)==null?void 0:q.call(D,"change",O)}),[D,O]),D?Bh(FC,{children:[un("primitive",{ref:w,object:D,...g}),un(tz,{...y,activeTf:"world",tfFilter:b,ghosts:!0,targetRef:C,targetSource:e.source,targetId:e.key,filterActive:!0,customProps:{...V}})]}):null}),o1=(n,e)=>n.length!==e.length?!1:!n.some((t,r)=>!gg.exports.isEqual(e[r],t));function HOe({displayTfs:n=!1,displayGrid:e=!0,isPolar:t=!1,backgroundColor:r="#d0d0d0",planeColor:s="#a8a8a8",highlightColor:o="#00ffff",plane:l=0,translateSnap:u=0,rotateSnap:h=0,scaleSnap:f=0,debug:g=!1}){g&&console.log("content rerender");const y=nf(ue=>ue.camera),b=Fo(ue=>ue.clock,Nf);Km(()=>{b.update()});const w=Fo(ue=>gg.exports.sortBy(Object.entries(ue.tfs).map(([q,ae])=>({key:q,frame:ae.frame,transformMode:ae.transformMode,source:"tfs"})),q=>q.key),o1),C=Fo(ue=>gg.exports.sortBy(Object.entries(ue.items).map(([q,ae])=>({key:q,frame:ae.frame,transformMode:ae.transformMode,source:"items"})),q=>q.key),o1),M=Fo(ue=>gg.exports.sortBy(Object.entries(ue.lines).map(([q,ae])=>({key:q,frame:ae.frame,source:"lines"})),q=>q.key),o1),A=Fo(ue=>gg.exports.sortBy(Object.entries(ue.hulls).map(([q,ae])=>({key:q,frame:ae.frame,source:"hulls"})),q=>q.key),o1),k=Fo(ue=>gg.exports.sortBy(Object.entries(ue.texts).map(([q,ae])=>({key:q,frame:ae.frame,source:"texts"})),q=>q.key),o1),O=Fo(ue=>gg.exports.sortBy(Object.entries(ue.points).map(([q,ae])=>({key:q,frame:ae.frame,source:"points"})),q=>q.key),o1),P=Fo(ue=>gg.exports.sortBy(Object.entries(ue.widgets).map(([q,ae])=>({key:q,frame:ae.frame,source:"widgets"})),q=>q.key),o1),D=[...C,...w].filter(ue=>["translate","rotate","scale","translate-x","translate-y","translate-z","rotate-x","rotate-y","rotate-z","scale-x","scale-y","scale-z"].includes(ue.transformMode)),U=de.useRef(),H=de.useRef(),V=de.useRef(),z=de.useRef(),Z=Bke(s),oe=[Z.r,Z.g,Z.b,.5];return Bh(Tt.Fragment,{children:[un(qRe,{ref:z,makeDefault:!0,camera:y}),un("pointLight",{ref:H,intensity:.5,position:[-1,-3,3],color:"#FFFAEE"}),un(Dke,{ref:U,intensity:.7,color:"white"}),un(Pke,{ref:V,castShadow:!0,position:[5,15,15],intensity:.6,color:"#FFFAEE"}),un("spotLight",{penumbra:1,position:[-1,-1,4],intensity:.3,castShadow:!0,color:"#FFFAEE"}),un("color",{attach:"background",args:[r]}),un("fogExp2",{attach:"fog",args:[r,.01]}),un(tke,{receiveShadow:!0,scale:1e3,position:[0,0,l-.01],material:mv(...oe)}),Bh(MOe,{children:[un(COe,{autoClear:!1,children:un(AOe,{visibleEdgeColor:o,hiddenEdgeColor:o,blur:!0,kernelSize:1,edgeStrength:50,pulseSpeed:.25,xRay:!0})}),un(tz,{activeTf:"world",displayTfs:n,allTfs:w,allItems:C,allLines:M,allHulls:A,allTexts:k,allPoints:O,allWidgets:P,highlightColor:o})]}),un("group",{position:[0,0,l],rotation:[Math.PI/2,0,0],up:[0,0,1],children:e&&(t?un("polarGridHelper",{args:[10,16,8,64,"white","gray"]}):un("gridHelper",{args:[20,20,"white","gray"]}))}),D.map(ue=>un(UOe,{objectInfo:ue,mode:ue.transformMode,displayTfs:n,allTfs:w,allItems:C,allLines:M,allHulls:A,allTexts:k,allPoints:O,allWidgets:P,translateSnap:u,rotateSnap:h,scaleSnap:f,highlightColor:o,onDragEnd:()=>{z.current&&(z.current.enabled=!0)},onDragStart:()=>{z.current&&(z.current.enabled=!1)}},`movableObjectTransform-${ue.key}`))]})}oo.DefaultUp.set(0,0,1);function GOe({backgroundColor:n="#d0d0d0",store:e,fov:t=60,onPointerMissed:r=()=>{},meshLookup:s={},debug:o=!1,...l}){return o&&console.log("Scene rerender"),un(oIe,{camera:{up:[0,0,1],fov:t,position:[0,-3,3]},shadows:!0,style:{background:n||"#d0d0d0"},onPointerMissed:r||(()=>{}),children:un(Nke,{store:e,debug:o,children:un(kOe,{meshes:s,children:un(de.Suspense,{children:un(HOe,{...l,backgroundColor:n,debug:o})})})})})}var nz={},WOe=hE;Object.defineProperty(nz,"__esModule",{value:!0});var Oee=nz.default=void 0,VOe=WOe(n2()),jOe=Me;Oee=nz.default=(0,VOe.default)((0,jOe.jsx)("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}),"RestartAlt");var rz={},YOe=hE;Object.defineProperty(rz,"__esModule",{value:!0});var Lee=rz.default=void 0,XOe=YOe(n2()),KOe=Me;Lee=rz.default=(0,XOe.default)((0,KOe.jsx)("path",{d:"M8 5v14l11-7z"}),"PlayArrow");var iz={},JOe=hE;Object.defineProperty(iz,"__esModule",{value:!0});var Nee=iz.default=void 0,qOe=JOe(n2()),QOe=Me;Nee=iz.default=(0,qOe.default)((0,QOe.jsx)("path",{d:"M6 6h12v12H6z"}),"Stop");const ZOe="/gpu-programming/assets/compile-worker-CjCt9Tta.js",eLe={Left:"LEFT_ARM_CONNECTOR_1",Right:"RIGHT_ARM_CONNECTOR_1",Head:"HEAD_1",Neck:"NECK_GLOBE_BASE_1",Base:"base_link"},Vi=n=>eLe[n],tLe={s_Acceptance:"s_Acceptance.wav",s_Amazement:"s_Amazement.wav",s_Amazement2:"s_Amazement2.wav",s_Anger:"s_Anger.wav",s_Anger2:"s_Anger2.wav",s_Anger3:"s_Anger3.wav",s_Anger4:"s_Anger4.wav",s_Annoyance:"s_Annoyance.wav",s_Annoyance2:"s_Annoyance2.wav",s_Annoyance3:"s_Annoyance3.wav",s_Annoyance4:"s_Annoyance4.wav",s_Awe:"s_Awe.wav",s_Awe2:"s_Awe2.wav",s_Awe3:"s_Awe3.wav",s_Boredom:"s_Boredom.wav",s_Disapproval:"s_Disapproval.wav",s_Disgust:"s_Disgust.wav",s_Disgust2:"s_Disgust2.wav",s_Disgust3:"s_Disgust3.wav",s_DisorientedConfused:"s_DisorientedConfused.wav",s_DisorientedConfused2:"s_DisorientedConfused2.wav",s_DisorientedConfused3:"s_DisorientedConfused3.wav",s_DisorientedConfused4:"s_DisorientedConfused4.wav",s_DisorientedConfused5:"s_DisorientedConfused5.wav",s_DisorientedConfused6:"s_DisorientedConfused6.wav",s_Distraction:"s_Distraction.wav",s_Ecstacy:"s_Ecstacy.wav",s_Ecstacy2:"s_Ecstacy2.wav",s_Fear:"s_Fear.wav",s_Grief:"s_Grief.wav",s_Grief2:"s_Grief2.wav",s_Grief3:"s_Grief3.wav",s_Grief4:"s_Grief4.wav",s_Joy:"s_Joy.wav",s_Joy2:"s_Joy2.wav",s_Joy3:"s_Joy3.wav",s_Joy4:"s_Joy4.wav",s_Loathing:"s_Loathing.wav",s_Love:"s_Love.wav",s_PhraseByeBye:"s_PhraseByeBye.wav",s_PhraseEvilAhHa:"s_PhraseEvilAhHa.wav",s_PhraseHello:"s_PhraseHello.wav",s_PhraseNoNoNo:"s_PhraseNoNoNo.wav",s_PhraseOopsy:"s_PhraseOopsy.wav",s_PhraseOwOwOw:"s_PhraseOwOwOw.wav",s_PhraseOwwww:"s_PhraseOwwww.wav",s_PhraseUhOh:"s_PhraseUhOh.wav",s_Rage:"s_Rage.wav",s_Sadness:"s_Sadness.wav",s_Sadness2:"s_Sadness2.wav",s_Sadness3:"s_Sadness3.wav",s_Sadness4:"s_Sadness4.wav",s_Sadness5:"s_Sadness5.wav",s_Sadness6:"s_Sadness6.wav",s_Sadness7:"s_Sadness7.wav",s_Sleepy:"s_Sleepy.wav",s_Sleepy2:"s_Sleepy2.wav",s_Sleepy3:"s_Sleepy3.wav",s_Sleepy4:"s_Sleepy4.wav",s_SleepySnore:"s_SleepySnore.wav",s_SystemCameraShutter:"s_SystemCameraShutter.wav"},A9=n=>tLe[n],J0={e_Sleeping:"e_Sleeping.jpg",e_SleepingZZZ:"e_SleepingZZZ.jpg",e_Contempt:"e_Contempt.jpg",e_ContentLeft:"e_ContentLeft.jpg",e_ContentRight:"e_ContentRight.jpg",e_Disoriented:"e_Disoriented.jpg",e_EcstacyHilarious:"e_EcstacyHilarious.jpg",e_EcstacyStarryEyed:"e_EcstacyStarryEyed.jpg",e_JoyGoofy:"e_JoyGoofy.jpg",e_JoyGoofy2:"e_JoyGoofy2.jpg",e_JoyGoofy3:"e_JoyGoofy3.jpg",e_Love:"e_Love.jpg",e_Rage:"e_Rage.jpg",e_Rage2:"e_Rage2.jpg",e_Rage3:"e_Rage3.jpg",e_Rage4:"e_Rage4.jpg",e_RemorseShame:"e_RemorseShame.jpg",eyes_acceptance:"eyes_acceptance.jpg",eyes_admiration:"eyes_admiration.jpg",eyes_amazement:"eyes_amazement.jpg",eyes_anger:"eyes_anger.jpg",eyes_annoyed:"eyes_annoyed.jpg",eyes_anticipation:"eyes_anticipation.png",eyes_apprehension:"eyes_apprehension.jpg",eyes_apprehension_1:"eyes_apprehension_1.jpg",eyes_boredom:"eyes_boredom.jpg",eyes_default:"eyes_default.jpg",eyes_disgust:"eyes_disgust.jpg",eyes_distraction:"eyes_distraction.gif",eyes_ecstasy_frame_1:"eyes_ecstasy_frame_1.jpg",eyes_ecstasy_frame_2:"eyes_ecstasy_frame_2.jpg",eyes_fear:"eyes_fear.jpg",eyes_grief:"eyes_grief.jpg",eyes_interest:"eyes_interest.jpg",eyes_joy:"eyes_joy.jpg",eyes_loathing:"eyes_loathing.jpg",eyes_pensiveness:"eyes_pensiveness.jpg",eyes_rage:"eyes_rage.jpg",eyes_sad:"eyes_sad.jpg",eyes_serenity:"eyes_serenity.jpg",eyes_surprise:"eyes_surprise.png",eyes_terror:"eyes_terror.jpg",eyes_trust:"eyes_trust.jpg",eyes_vigilance:"eyes_vigilance.jpg"},nLe=n=>J0[n],rLe=({blocks:n,tfs:e,items:t})=>{var ue;var r=e[Vi("Left")],s=e[Vi("Right")],o=e[Vi("Head")],l=e[Vi("Base")];let u={Left:{x:[r.rotation.x],y:[r.rotation.y],z:[r.rotation.z],w:[r.rotation.w]},Right:{x:[s.rotation.x],y:[s.rotation.y],z:[s.rotation.z],w:[s.rotation.w]},Head:{x:[o.rotation.x],y:[o.rotation.y],z:[o.rotation.z],w:[o.rotation.w]},Base:{position:{x:[l.position.x],y:[l.position.y],z:[l.position.z],angle:[0],distance:[0]},rotation:{x:[l.rotation.x],y:[l.rotation.y],z:[l.rotation.z],w:[l.rotation.w]}},Speech:[],Time:[0]},h=Object.keys(J0);for(let q=0;q{if(q==="both")g(ae,le,ae,le);else if(le>0){var ce=q,ge=q==="Left"?"Right":"Left",$e={rotation:{x:u[ce].x[u[ce].x.length-1],y:u[ce].y[u[ce].y.length-1],z:u[ce].z[u[ce].z.length-1],w:u[ce].w[u[ce].w.length-1]}},K=cI($e.rotation),ie=2*ad*uI*Math.abs(K.y-ae),se=ie/(le/100*jO),fe={x:0,y:ae-YO,z:0},Se=1;if(fe.y<0&&K.y>0||fe.y>0&&K.y<0){let qe=(fe.y-K.y)/2,we=fe.y-qe;var Ue=sy(0,we*ad/180,0);u[ce].w.push(Ue._w),u[ce].x.push(Ue._x),u[ce].y.push(Ue._y),u[ce].z.push(Ue._z),u.Time.push(se/2),Se+=1}var ke=sy(fe.x,fe.y*ad/180,fe.z);u[ce].w.push(ke._w),u[ce].x.push(ke._x),u[ce].y.push(ke._y),u[ce].z.push(ke._z);for(let qe=0;qe1?u.Time.push(se/2):u.Time.push(se)}},g=(q,ae,le,ce)=>{if(ae>0||ce>0){var ge={rotation:{x:u.Left.x[u.Left.x.length-1],y:u.Left.y[u.Left.y.length-1],z:u.Left.z[u.Left.z.length-1],w:u.Left.w[u.Left.w.length-1]}},$e={rotation:{x:u.Right.x[u.Right.x.length-1],y:u.Right.y[u.Right.y.length-1],z:u.Right.z[u.Right.z.length-1],w:u.Right.w[u.Right.w.length-1]}},K=cI(ge.rotation),ie=2*ad*uI*Math.abs(K.y-q),se=ie/(ae/100*jO),fe=cI($e.rotation),Se=2*ad*uI*Math.abs(fe.y-le),Ue=Se/(ce/100*jO),ke=ae===0?Ue:ce===0?se:Math.max(se,Ue),qe={x:0,y:q-YO,z:0},we=sy(qe.x,qe.y*ad/180,qe.z),Ze={x:0,y:le-YO,z:0},et=sy(Ze.x,Ze.y*ad/180,Ze.z);let Ge=1;if(qe.y<0&&K.y>0||qe.y>0&&K.y<0||Ze.y<0&&fe.y>0||Ze.y>0&&fe.y<0){let Ie=(qe.y-K.y)/2,He=(qe.y-K.y)/2,it=qe.y-Ie,st=Ze.y-He;var ft=sy(0,it*ad/180,0),at=sy(0,st*ad/180,0);ae>0?(u.Left.w.push(ft._w),u.Left.x.push(ft._x),u.Left.y.push(ft._y),u.Left.z.push(ft._z)):(u.Left.w.push(u.Left.w[u.Left.w.length-1]),u.Left.x.push(u.Left.x[u.Left.x.length-1]),u.Left.y.push(u.Left.y[u.Left.y.length-1]),u.Left.z.push(u.Left.z[u.Left.z.length-1])),ce>0?(u.Right.w.push(at._w),u.Right.x.push(at._x),u.Right.y.push(at._y),u.Right.z.push(at._z)):(u.Right.w.push(u.Right.w[u.Right.w.length-1]),u.Right.x.push(u.Right.x[u.Right.x.length-1]),u.Right.y.push(u.Right.y[u.Right.y.length-1]),u.Right.z.push(u.Right.z[u.Right.z.length-1])),u.Time.push(ke/2),Ge+=1}ae>0?(u.Left.w.push(we._w),u.Left.x.push(we._x),u.Left.y.push(we._y),u.Left.z.push(we._z)):(u.Left.w.push(u.Left.w[u.Left.w.length-1]),u.Left.x.push(u.Left.x[u.Left.x.length-1]),u.Left.y.push(u.Left.y[u.Left.y.length-1]),u.Left.z.push(u.Left.z[u.Left.z.length-1])),ce>0?(u.Right.w.push(et._w),u.Right.x.push(et._x),u.Right.y.push(et._y),u.Right.z.push(et._z)):(u.Right.w.push(u.Right.w[u.Right.w.length-1]),u.Right.x.push(u.Right.x[u.Right.x.length-1]),u.Right.y.push(u.Right.y[u.Right.y.length-1]),u.Right.z.push(u.Right.z[u.Right.z.length-1]));for(let Ie=0;Ie1?u.Time.push(ke/2):u.Time.push(ke)}},y=(q,ae,le,ce)=>{if(ce>0){var ge=sy(ae*ad/180,q*ad/180,le*ad/180);u.Head.w.push(ge._w),u.Head.x.push(ge._x),u.Head.y.push(ge._y),u.Head.z.push(ge._z);let $e=u.Left.w.length-1;u.Speech.push(""),u.Left.w.push(u.Left.w[$e]),u.Left.x.push(u.Left.x[$e]),u.Left.y.push(u.Left.y[$e]),u.Left.z.push(u.Left.z[$e]),u.Right.w.push(u.Right.w[$e]),u.Right.x.push(u.Right.x[$e]),u.Right.y.push(u.Right.y[$e]),u.Right.z.push(u.Right.z[$e]),u.Base.position.x.push(u.Base.position.x[$e]),u.Base.position.y.push(u.Base.position.y[$e]),u.Base.position.z.push(u.Base.position.z[$e]),u.Base.position.distance.push(u.Base.position.distance[$e]),u.Base.position.angle.push(u.Base.position.angle[$e]),u.Base.rotation.w.push(u.Base.rotation.w[$e]),u.Base.rotation.x.push(u.Base.rotation.x[$e]),u.Base.rotation.y.push(u.Base.rotation.y[$e]),u.Base.rotation.z.push(u.Base.rotation.z[$e]);let K=Object.keys(J0);for(let ie=0;ie{if(le>0){var ce={position:{x:u.Base.position.x[u.Base.position.x.length-1],y:u.Base.position.y[u.Base.position.y.length-1],z:u.Base.position.z[u.Base.position.z.length-1]},rotation:{x:u.Base.rotation.x[u.Base.rotation.x.length-1],y:u.Base.rotation.y[u.Base.rotation.y.length-1],z:u.Base.rotation.z[u.Base.rotation.z.length-1],w:u.Base.rotation.w[u.Base.rotation.w.length-1]}},ge=ae/100*Ele*le/lg,$e=q/100*wle*le/lg,K=new Pu(ce.rotation.x,ce.rotation.y,ce.rotation.z,ce.rotation.w),ie=hH(K);if(ge!==0){var se={x:0,y:0,z:ge};K=sy(se.x,se.y,se.z),K.multiply(new Pu(ce.rotation.x,ce.rotation.y,ce.rotation.z,ce.rotation.w))}let fe=ce.position.x,Se=ce.position.y,Ue=null;Ue=new zt(fe+Math.sin(ie-ge)*$e,Se-Math.cos(ie-ge)*$e,ce.position.z),u.Base.position.x.push(Ue.x),u.Base.position.y.push(Ue.y),u.Base.position.z.push(Ue.z),u.Base.position.angle.push(ge),u.Base.position.distance.push($e),u.Base.rotation.w.push(K._w),u.Base.rotation.x.push(K._x),u.Base.rotation.y.push(K._y),u.Base.rotation.z.push(K._z),u.Speech.push(""),u.Head.x.push(u.Head.x[u.Head.x.length-1]),u.Head.y.push(u.Head.y[u.Head.y.length-1]),u.Head.z.push(u.Head.z[u.Head.z.length-1]),u.Head.w.push(u.Head.w[u.Head.w.length-1]),u.Left.w.push(u.Left.w[u.Left.w.length-1]),u.Left.x.push(u.Left.x[u.Left.x.length-1]),u.Left.y.push(u.Left.y[u.Left.y.length-1]),u.Left.z.push(u.Left.z[u.Left.z.length-1]),u.Right.w.push(u.Right.w[u.Right.w.length-1]),u.Right.x.push(u.Right.x[u.Right.x.length-1]),u.Right.y.push(u.Right.y[u.Right.y.length-1]),u.Right.z.push(u.Right.z[u.Right.z.length-1]);let ke=Object.keys(J0);for(let qe=0;qe{let le=Object.keys(J0);for(let ge=0;ge{let le=u.Head.x.length-1;u.Speech.push(q),u.Base.position.x.push(u.Base.position.x[le]),u.Base.position.y.push(u.Base.position.y[le]),u.Base.position.z.push(u.Base.position.z[le]),u.Base.position.distance.push(u.Base.position.distance[le]),u.Base.position.angle.push(u.Base.position.angle[le]),u.Base.rotation.w.push(u.Base.rotation.w[le]),u.Base.rotation.x.push(u.Base.rotation.x[le]),u.Base.rotation.y.push(u.Base.rotation.y[le]),u.Base.rotation.z.push(u.Base.rotation.z[le]),u.Head.x.push(u.Head.x[le]),u.Head.y.push(u.Head.y[le]),u.Head.z.push(u.Head.z[le]),u.Head.w.push(u.Head.w[le]),u.Left.w.push(u.Left.w[le]),u.Left.x.push(u.Left.x[le]),u.Left.y.push(u.Left.y[le]),u.Left.z.push(u.Left.z[le]),u.Right.w.push(u.Right.w[le]),u.Right.x.push(u.Right.x[le]),u.Right.y.push(u.Right.y[le]),u.Right.z.push(u.Right.z[le]);let ce=Object.keys(J0);for(let ge=0;ge{let ae=u.Head.x.length-1;u.Speech.push(""),u.Base.position.x.push(u.Base.position.x[ae]),u.Base.position.y.push(u.Base.position.y[ae]),u.Base.position.z.push(u.Base.position.z[ae]),u.Base.position.distance.push(u.Base.position.distance[ae]),u.Base.position.angle.push(u.Base.position.angle[ae]),u.Base.rotation.w.push(u.Base.rotation.w[ae]),u.Base.rotation.x.push(u.Base.rotation.x[ae]),u.Base.rotation.y.push(u.Base.rotation.y[ae]),u.Base.rotation.z.push(u.Base.rotation.z[ae]),u.Head.x.push(u.Head.x[ae]),u.Head.y.push(u.Head.y[ae]),u.Head.z.push(u.Head.z[ae]),u.Head.w.push(u.Head.w[ae]),u.Left.w.push(u.Left.w[ae]),u.Left.x.push(u.Left.x[ae]),u.Left.y.push(u.Left.y[ae]),u.Left.z.push(u.Left.z[ae]),u.Right.w.push(u.Right.w[ae]),u.Right.x.push(u.Right.x[ae]),u.Right.y.push(u.Right.y[ae]),u.Right.z.push(u.Right.z[ae]);let le=Object.keys(J0);for(let ce=0;ce{let q=JSON.parse(JSON.stringify(e)),ae=JSON.parse(JSON.stringify(e)),le=JSON.parse(JSON.stringify(t)),ce=JSON.parse(JSON.stringify(t)),ge=u.Time.length,$e=0,K=[],ie=[],se=[],fe=[],Se=[],Ue=[],ke=[],qe=[],we=[],Ze=[],et=[],ft=[],at=[],Ge=[],Ie=[],He=[],it=[],st=[],It=[],kt=[],vt=[],Mt=Object.keys(J0);for(let Ke=0;KeObject.values(n).filter(ae=>ae.type===q)[0],O=q=>n[q],P=(q,ae)=>{const le=O(q);let ce=O(ae);if(z(le,le.type))for(z(ce,ce.type);ce.next;)ce=O(ce.next),z(ce,ce.type)},D=q=>q==="TRUE";function U(q,ae){return q=Math.ceil(q),ae=Math.floor(ae),Math.floor(Math.random()*(ae-q+1))+q}function H(q){if(q===2||q===3)return!0;if(q<=1||q%2===0||q%3===0)return!1;for(let ae=5;ae*ae<=q;ae+=6)if(q%ae===0||q%(ae+2)===0)return!1;return!0}function V(q){var ae;if(typeof q!="string"&&typeof q!="object")return q.shadow.fields.NUM;{let le=(ae=q==null?void 0:q.shadow)!=null&&ae.id?O(q.shadow.id):O(q);return z(le,le.type)}}const z=(q,ae)=>{var Ct,gt,Ee;switch(!0){case ae==="CustomIF":if(!q.inputs||!q.inputs.IF0||!q.inputs.DO0)throw new Error("err: controls_if not complete!");P(q.inputs.IF0,q.inputs.DO0);break;case ae==="logic_boolean":return D(q.fields.BOOL);case ae==="logic_compare":if(!q.inputs||!q.inputs.A||!q.inputs.B)throw new Error("err: logic_compare is not complete!");const re=q.fields.OP,Be=q.inputs.A,mt=q.inputs.B,yt=O(Be),wt=O(mt);if(re==="EQ")return z(yt,yt.type)==z(wt,wt.type);if(re==="NEQ")return z(yt,yt.type)!==z(wt,wt.type);if(re==="LT")return z(yt,yt.type)z(wt,wt.type);if(re==="GTE")return z(yt,yt.type)>=z(wt,wt.type);case ae==="logic_operation":if(!q.inputs||!q.inputs.A||!q.inputs.B)throw new Error("err: logic_operation is not complete!");const Ke=q.fields.OP,Qe=q.inputs.A,Le=q.inputs.B,Q=O(Qe),te=O(Le);return Ke==="OR"?z(Q,Q.type)||z(te,te.type):z(Q,Q.type)&&z(te,te.type);case ae==="logic_negate":if(!q.inputs)throw new Error("err: logic_negate is not complete!");const me=O(q.inputs.BOOL);return!z(me,me.type);case ae==="logic_boolean":return!q.fields.BOOL!=="FALSE";case ae==="logic_null":return null;case ae==="logic_ternary":if(!q.inputs||!q.inputs.IF||!q.inputs.THEN||!q.inputs.ELSE)throw new Error("err: logic_ternary is not complete!");const Re=q.inputs.IF,Fe=q.inputs.THEN,bt=q.inputs.ELSE,ze=O(Re),Pt=O(Fe),lt=O(bt);return z(ze,ze.type)?z(Pt,Pt.type):z(lt,lt.type);case ae==="controls_repeat_ext":const Wt=V(q.inputs.TIMES);if(!q.inputs.DO)throw new Error("err: controls_repeat_ext is not complete!");let bn=O(q.inputs.DO);for(let Lr=0;Lr0;if(ar==="NEGATIVE")return cr<0;if(ar==="DIVISIBLE_BY"){if(!q.inputs||!q.inputs.DIVISOR)throw new Error("err: DIVISOR is not filled!");if(q.inputs.DIVISOR===0)throw new Error("Note that divisor cannot be 0!");return cr%q.inputs.DIVISOR===0}return;case ae==="math_random_int":const oi=V(q.inputs.FROM),Mr=V(q.inputs.TO);return U(oi,Mr);case ae==="colour_picker":return cS(q.fields.COLOUR);case ae==="colour_random":let _r=U(0,255),ne=U(0,255),Te=U(0,255);return{r:_r,g:ne,b:Te};case ae==="colour_rgb":const je=V(q.inputs.RED),ct=V(q.inputs.GREEN),Ht=V(q.inputs.BLUE);return{r:je,g:ct,b:Ht};case ae==="colour_blend":const nn=V(q.inputs.RATIO),kn=cS(q.inputs.COLOUR1.shadow.fields.COLOUR),De=cS(q.inputs.COLOUR2.shadow.fields.COLOUR),_t=kn.r*nn,Ot=kn.g*nn,St=kn.b*nn,Xt=De.r,Wn=De.g,ir=De.b,br=(Xt+_t)/(nn+1),Or=(Wn+Ot)/(nn+1),Ei=(ir+St)/(nn+1);return{r:br,g:Or,b:Ei};case ae==="ChangeLED":if(!q.inputs||!q.inputs.FIELD_ChangeLED)throw new Error("err: ChangeLED is not complete!");var le=O(q.inputs.FIELD_ChangeLED),ce=null;(Ct=le==null?void 0:le.fields)!=null&&Ct.COLOUR?ce=cS(le.fields.COLOUR):ce=z(le,le.type);var Ue={Red:ce.r,Green:ce.g,Blue:ce.b};return;case ae==="TransitionLED":if(!q.inputs||!q.inputs.COLOR1||!q.inputs.COLOR2)throw new Error("err: TransitionLED is not complete!");var ge=O(q.inputs.COLOR1),$e=O(q.inputs.COLOR2),K=null;(gt=ge==null?void 0:ge.fields)!=null&>.COLOUR?K=cS(ge.fields.COLOUR):K=z(ge,ge.type);var ie=null;(Ee=$e==null?void 0:$e.fields)!=null&&Ee.COLOUR?ie=cS($e.fields.COLOUR):ie=z($e,$e.type);var It=q.fields.FIELD_TransitionTime_TimeMs*lg,se=q.fields.TRANSITION_TYPE,Ue={Red:K.r,Green:K.g,Blue:K.b,Red2:ie.r,Green2:ie.g,Blue2:ie.b,TransitionType:se,TimeMS:It};return;case ae==="DisplayImage":if(!q.inputs||!q.inputs.FIELD_DisplayImage_Filename)throw new Error("err: DisplayImage is not complete!");var fe=O(q.inputs.FIELD_DisplayImage_Filename),Se=nLe(fe.type);w(fe.type,500);return;case ae==="PlayAudio":if(!q.inputs||!q.inputs.FIELD_PlayAudio_Filename)throw new Error("err: PlayAudio is not complete!");var fe=O(q.inputs.FIELD_PlayAudio_Filename),Se=A9(fe.type);return;case ae==="DisplayAnimation":if(!q.inputs||!q.inputs.FIELD_DisplayAnimation_Filename)throw new Error("err: DisplayAnimation is not complete!");var fe=O(q.inputs.FIELD_DisplayAnimation_Filename),Se=A9(fe.type),Ue={FileName:Se};readFile(Ue);return;case ae==="DisplayText":var Mt=q.fields.FIELD_DisplayText_Text;return;case ae==="TurnOnFlashlight":return;case ae==="TurnOffFlashlight":return;case ae==="WaitForSeconds":console.log(q),console.log("here");var It=V(q.inputs.FIELD_Duration)*lg;console.log(It),M(It);return;case ae==="MoveArm":var ke=q.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",qe=V(q.fields.FIELD_MoveArm_Position),He=V(q.fields.FIELD_MoveArm_Velocity);f(ke,qe,He);return;case ae==="MoveArm2":var qe=V(q.fields.FIELD_MoveArm2_Position),He=V(q.fields.FIELD_MoveArm2_Velocity),ke="both";f(ke,qe,He);return;case ae==="MoveArm3":var ke=q.fields.FIELD_MoveArm_Arm==="Right"?"Right":"Left",qe=V(q.inputs.FIELD_MoveArm_Position),He=V(q.inputs.FIELD_MoveArm_Velocity);f(ke,qe,He);return;case ae==="MoveArms2":var we=V(q.inputs.FIELD_MoveArm_LeftPosition),Ze=V(q.inputs.FIELD_MoveArm_LeftVelocity),et=V(q.inputs.FIELD_MoveArm_RightPosition),ft=V(q.inputs.FIELD_MoveArm_RightVelocity);g(we,Ze,et,ft);return;case ae==="MoveHead":var at=q.fields.FIELD_MoveHead_Pitch==="D"?25:-40,It=2e3;y(at,0,0,It);return;case ae==="MoveHead3":var at,Ge,Ie;at=V(q.inputs.FIELD_MoveHead_Pitch),Ge=V(q.inputs.FIELD_MoveHead_Roll),Ie=V(q.inputs.FIELD_MoveHead_Yaw),It=V(q.inputs.FIELD_MoveHead_Time)*lg,y(at,Ge,Ie,It);return;case ae==="DriveTime":var st=q.fields.FIELD_DriveTime_Direction,He=parseInt(q.fields.FIELD_DriveTime_Velocity),It=parseInt(q.fields.FIELD_DriveTime_TimeMs)*lg,it=st==="F"?He:-He;b(it,0,It);return;case ae==="DriveTime2":var it=V(q.inputs.FIELD_DriveTime_Velocity),kt=V(q.inputs.FIELD_DriveTime_Angular),It=V(q.inputs.FIELD_DriveTime_TimeMs)*lg;b(it,kt,It);return;case ae==="Turn":var st=q.fields.FIELD_Turn_Direction,It=parseInt(q.fields.FIELD_Turn_Duration)*lg,kt=st==="L"?100:-100;b(0,kt,It);return;case ae==="Turn2":var st=q.fields.FIELD_Turn_Direction,It=parseInt(V(q.inputs.FIELD_Turn_Duration))*lg,kt=st==="L"?100:-100;b(0,kt,It);return;case ae=="Speak":var vt=O(q.inputs.FIELD_Speak_Text),Mt=vt.fields.TEXT;C(Mt,uH*Mt.split(" ").length*lg);return;case ae=="SpeakDefault":var Mt=q.fields.FIELD_SpeakDefault_Text;C(Mt,uH*Mt.split(" ").length*lg);return;default:return}};let oe=k("Start");for(;oe&&oe.next;)oe=O(oe.next),z(oe,oe.type);return A()};function iLe(n){const e=Bn(xi(H=>H.resetSim)),t=Bn(xi(H=>H.toggleSimOnly)),r=Bn(xi(H=>H.isConnected)),s=Bn(xi(H=>H.ip)),o=Bn(xi(H=>H.getBlocks)),l=Bn(xi(H=>H.getEndingItems)),u=Bn(xi(H=>H.clock)),h=Bn(xi(H=>H.mistyImageList)),f=Bn(xi(H=>H.mistyAudioList)),g=Bn(xi(H=>H.simOnly)),y=Bn(xi(H=>H.endingTfs)),b=Bn(xi(H=>H.setAnimationFrames)),w=Bn(xi(H=>H.setHighlightBlocks)),C=Bn(xi(H=>H.workerThread)),M=Bn(xi(H=>H.setWorkerThread)),A=Bn(xi(H=>H.llmMode));function k(H,V){s&&!g&&r&&fetch(`http://${s}/api/${H}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)})}const O=async()=>{ch("Click Run Code button"),u.reset_elapsed(),C&&(C.terminate(),M(null));const H=`import ${JSON.stringify(new URL(ZOe,import.meta.url))}`,V=new Blob([H],{type:"application/javascript"}),z=URL.createObjectURL(V);let Z=new Worker(z,{type:"module"});Z.onmessage=function(ce){console.log("Message received from worker "+ce.data),M(null)},Z.onerror=function(ce){console.log(ce);const $e=/id: (.+)/.exec(ce.message);if($e){w($e[1]),P();return}else console.log("ID not found in error message.");URL.revokeObjectURL(z)},Z.postMessage({blocks:o(),mistyAudioList:f,mistyImageList:h,tfs:y,ip:s,runOnRobot:!g}),M(Z);let{newTfs:oe,newEndingTfs:ue,newItems:q,newEndingItems:ae,speechObject:le}=rLe({blocks:o(),tfs:y,items:l()});b(oe,ue,q,ae,le)},P=()=>{C&&(C.terminate(),M(null),w(""),k("halt",{})),ch("Click Stop Code button")},D=()=>{k("arms/set",{LeftArmPosition:90,RightArmPosition:90,LeftArmVelocity:100,RightArmVelocity:100,Units:"Degrees"}),k("head",{Pitch:0,Yaw:0,Roll:0,Duration:1,Units:"Degrees"}),k("images/display",{FileName:"e_DefaultContent.jpg",Alpha:1}),k("text/display",{Text:""}),k("led",{Red:100,Green:70,Blue:160}),e()};let U=A?{top:"10px"}:{bottom:"0px"};return Me.jsxs(Nw,{style:{position:"absolute",padding:"0px",left:"10px",...U},children:[Me.jsxs(KH,{style:{paddingLeft:"0px",paddingRight:"0px"},children:[!C&&Me.jsx(_I,{variant:"contained","aria-label":"play",style:{backgroundColor:"#FAFAFA",marginBottom:"5px"},onClick:O,id:"runButton",children:Me.jsx(Lee,{})}),C&&Me.jsx(_I,{variant:"contained","aria-label":"play",style:{backgroundColor:"#FAFAFA",marginBottom:"5px"},onClick:P,id:"stopButton",children:Me.jsx(Nee,{})}),Me.jsx(_I,{variant:"contained","aria-label":"restart",style:{backgroundColor:"#FAFAFA",marginLeft:"5px",marginBottom:"5px"},onClick:D,children:Me.jsx(Oee,{})})]}),r&&Me.jsx(KH,{style:{backgroundColor:"#FAFAFA",borderRadius:"5px",marginBottom:"5px",paddingLeft:"10px",paddingRight:"0px"},children:Me.jsx(XK,{children:Me.jsx(YK,{control:Me.jsx(yge,{onChange:H=>t(H.target.checked)}),label:"Sim only"})})})]})}var li="cs",Dee={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames diff --git a/index.html b/index.html index 83cb5816..ff4646ff 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@ Learn how to configure a non-root public URL by running `npm run build`. --> Misty Programming - +