soonspacejs-ustudio-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +8372 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# soonspacejs-ustudio-plugin
|
|
2
|
+
|
|
3
|
+
基于 [SoonSpaceJS](https://www.xwbuilders.com/soonspacejs/) 的 UStudio 插件 SDK。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add soonspacejs-ustudio-plugin soonspacejs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { SoonspaceUStudioPlugin } from 'soonspacejs-ustudio-plugin'
|
|
15
|
+
|
|
16
|
+
const plugin = new SoonspaceUStudioPlugin()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 开发
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 安装依赖
|
|
23
|
+
pnpm install
|
|
24
|
+
|
|
25
|
+
# 开发模式(watch)
|
|
26
|
+
pnpm dev
|
|
27
|
+
|
|
28
|
+
# 构建
|
|
29
|
+
pnpm build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var we=Object.defineProperty;var ze=(y,t,i)=>t in y?we(y,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):y[t]=i;var E=(y,t,i)=>ze(y,typeof t!="symbol"?t+"":t,i);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("soonspacejs");/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2010-2026 Three.js Authors
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/const ye="183",vi=0,Se=1,Wi=1,Vi=100,qi=204,Ui=205,Yi=3,Ae=0,xe=300,Xi=1e3,Zt=1001,Zi=1002,Fe=1006,Te=1008,Ce=1009,Be=1015,Ie=1023,ge="",j="srgb",Ji="srgb-linear",ji="linear",yi="srgb",gt=7680,$i=519,Hi=35044,Jt=2e3,Gi=2001;function ke(y){for(let t=y.length-1;t>=0;--t)if(y[t]>=65535)return!0;return!1}function Qi(y){return document.createElementNS("http://www.w3.org/1999/xhtml",y)}const Ki={};function be(y){const t=y[0];if(typeof t=="string"&&t.startsWith("TSL:")){const i=y[1];i&&i.isStackTrace?y[0]+=" "+i.getLocation():y[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return y}function N(...y){y=be(y);const t="THREE."+y.shift();{const i=y[0];i&&i.isStackTrace?console.warn(i.getError(t)):console.warn(t,...y)}}function yt(...y){y=be(y);const t="THREE."+y.shift();{const i=y[0];i&&i.isStackTrace?console.error(i.getError(t)):console.error(t,...y)}}function te(...y){const t=y.join(" ");t in Ki||(Ki[t]=!0,N(...y))}class pi{addEventListener(t,i){this._listeners===void 0&&(this._listeners={});const e=this._listeners;e[t]===void 0&&(e[t]=[]),e[t].indexOf(i)===-1&&e[t].push(i)}hasEventListener(t,i){const e=this._listeners;return e===void 0?!1:e[t]!==void 0&&e[t].indexOf(i)!==-1}removeEventListener(t,i){const e=this._listeners;if(e===void 0)return;const s=e[t];if(s!==void 0){const n=s.indexOf(i);n!==-1&&s.splice(n,1)}}dispatchEvent(t){const i=this._listeners;if(i===void 0)return;const e=i[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,t);t.target=null}}}const R=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function Pt(){const y=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(R[y&255]+R[y>>8&255]+R[y>>16&255]+R[y>>24&255]+"-"+R[t&255]+R[t>>8&255]+"-"+R[t>>16&15|64]+R[t>>24&255]+"-"+R[i&63|128]+R[i>>8&255]+"-"+R[i>>16&255]+R[i>>24&255]+R[e&255]+R[e>>8&255]+R[e>>16&255]+R[e>>24&255]).toLowerCase()}function A(y,t,i){return Math.max(t,Math.min(i,y))}function Ee(y,t){return(y%t+t)%t}function xi(y,t,i){return(1-i)*y+i*t}function kt(y,t){switch(t.constructor){case Float32Array:return y;case Uint32Array:return y/4294967295;case Uint16Array:return y/65535;case Uint8Array:return y/255;case Int32Array:return Math.max(y/2147483647,-1);case Int16Array:return Math.max(y/32767,-1);case Int8Array:return Math.max(y/127,-1);default:throw new Error("Invalid component type.")}}function L(y,t){switch(t.constructor){case Float32Array:return y;case Uint32Array:return Math.round(y*4294967295);case Uint16Array:return Math.round(y*65535);case Uint8Array:return Math.round(y*255);case Int32Array:return Math.round(y*2147483647);case Int16Array:return Math.round(y*32767);case Int8Array:return Math.round(y*127);default:throw new Error("Invalid component type.")}}class H{constructor(t=0,i=0){H.prototype.isVector2=!0,this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,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,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;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,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,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,i){return this.x=t.x-i.x,this.y=t.y-i.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 i=this.x,e=this.y,s=t.elements;return this.x=s[0]*i+s[3]*e+s[6],this.y=s[1]*i+s[4]*e+s[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,i){return this.x=A(this.x,t.x,i.x),this.y=A(this.y,t.y,i.y),this}clampScalar(t,i){return this.x=A(this.x,t,i),this.y=A(this.y,t,i),this}clampLength(t,i){const e=this.length();return this.divideScalar(e||1).multiplyScalar(A(e,t,i))}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 i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const e=this.dot(t)/i;return Math.acos(A(e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,e=this.y-t.y;return i*i+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,e){return this.x=t.x+(i.x-t.x)*e,this.y=t.y+(i.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){const e=Math.cos(i),s=Math.sin(i),n=this.x-t.x,r=this.y-t.y;return this.x=n*e-r*s+t.x,this.y=n*s+r*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Nt{constructor(t=0,i=0,e=0,s=1){this.isQuaternion=!0,this._x=t,this._y=i,this._z=e,this._w=s}static slerpFlat(t,i,e,s,n,r,h){let o=e[s+0],a=e[s+1],l=e[s+2],c=e[s+3],u=n[r+0],d=n[r+1],p=n[r+2],m=n[r+3];if(c!==m||o!==u||a!==d||l!==p){let g=o*u+a*d+l*p+c*m;g<0&&(u=-u,d=-d,p=-p,m=-m,g=-g);let f=1-h;if(g<.9995){const b=Math.acos(g),_=Math.sin(b);f=Math.sin(f*b)/_,h=Math.sin(h*b)/_,o=o*f+u*h,a=a*f+d*h,l=l*f+p*h,c=c*f+m*h}else{o=o*f+u*h,a=a*f+d*h,l=l*f+p*h,c=c*f+m*h;const b=1/Math.sqrt(o*o+a*a+l*l+c*c);o*=b,a*=b,l*=b,c*=b}}t[i]=o,t[i+1]=a,t[i+2]=l,t[i+3]=c}static multiplyQuaternionsFlat(t,i,e,s,n,r){const h=e[s],o=e[s+1],a=e[s+2],l=e[s+3],c=n[r],u=n[r+1],d=n[r+2],p=n[r+3];return t[i]=h*p+l*c+o*d-a*u,t[i+1]=o*p+l*u+a*c-h*d,t[i+2]=a*p+l*d+h*u-o*c,t[i+3]=l*p-h*c-o*u-a*d,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,i,e,s){return this._x=t,this._y=i,this._z=e,this._w=s,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,i=!0){const e=t._x,s=t._y,n=t._z,r=t._order,h=Math.cos,o=Math.sin,a=h(e/2),l=h(s/2),c=h(n/2),u=o(e/2),d=o(s/2),p=o(n/2);switch(r){case"XYZ":this._x=u*l*c+a*d*p,this._y=a*d*c-u*l*p,this._z=a*l*p+u*d*c,this._w=a*l*c-u*d*p;break;case"YXZ":this._x=u*l*c+a*d*p,this._y=a*d*c-u*l*p,this._z=a*l*p-u*d*c,this._w=a*l*c+u*d*p;break;case"ZXY":this._x=u*l*c-a*d*p,this._y=a*d*c+u*l*p,this._z=a*l*p+u*d*c,this._w=a*l*c-u*d*p;break;case"ZYX":this._x=u*l*c-a*d*p,this._y=a*d*c+u*l*p,this._z=a*l*p-u*d*c,this._w=a*l*c+u*d*p;break;case"YZX":this._x=u*l*c+a*d*p,this._y=a*d*c+u*l*p,this._z=a*l*p-u*d*c,this._w=a*l*c-u*d*p;break;case"XZY":this._x=u*l*c-a*d*p,this._y=a*d*c-u*l*p,this._z=a*l*p+u*d*c,this._w=a*l*c+u*d*p;break;default:N("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return i===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,i){const e=i/2,s=Math.sin(e);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const i=t.elements,e=i[0],s=i[4],n=i[8],r=i[1],h=i[5],o=i[9],a=i[2],l=i[6],c=i[10],u=e+h+c;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(l-o)*d,this._y=(n-a)*d,this._z=(r-s)*d}else if(e>h&&e>c){const d=2*Math.sqrt(1+e-h-c);this._w=(l-o)/d,this._x=.25*d,this._y=(s+r)/d,this._z=(n+a)/d}else if(h>c){const d=2*Math.sqrt(1+h-e-c);this._w=(n-a)/d,this._x=(s+r)/d,this._y=.25*d,this._z=(o+l)/d}else{const d=2*Math.sqrt(1+c-e-h);this._w=(r-s)/d,this._x=(n+a)/d,this._y=(o+l)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,i){let e=t.dot(i)+1;return e<1e-8?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(A(this.dot(t),-1,1)))}rotateTowards(t,i){const e=this.angleTo(t);if(e===0)return this;const s=Math.min(1,i/e);return this.slerp(t,s),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,i){const e=t._x,s=t._y,n=t._z,r=t._w,h=i._x,o=i._y,a=i._z,l=i._w;return this._x=e*l+r*h+s*a-n*o,this._y=s*l+r*o+n*h-e*a,this._z=n*l+r*a+e*o-s*h,this._w=r*l-e*h-s*o-n*a,this._onChangeCallback(),this}slerp(t,i){let e=t._x,s=t._y,n=t._z,r=t._w,h=this.dot(t);h<0&&(e=-e,s=-s,n=-n,r=-r,h=-h);let o=1-i;if(h<.9995){const a=Math.acos(h),l=Math.sin(a);o=Math.sin(o*a)/l,i=Math.sin(i*a)/l,this._x=this._x*o+e*i,this._y=this._y*o+s*i,this._z=this._z*o+n*i,this._w=this._w*o+r*i,this._onChangeCallback()}else this._x=this._x*o+e*i,this._y=this._y*o+s*i,this._z=this._z*o+n*i,this._w=this._w*o+r*i,this.normalize();return this}slerpQuaternions(t,i,e){return this.copy(t).slerp(i,e)}random(){const t=2*Math.PI*Math.random(),i=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),n=Math.sqrt(e);return this.set(s*Math.sin(t),s*Math.cos(t),n*Math.sin(i),n*Math.cos(i))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,i=0){return this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t}fromBufferAttribute(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),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 x{constructor(t=0,i=0,e=0){x.prototype.isVector3=!0,this.x=t,this.y=i,this.z=e}set(t,i,e){return e===void 0&&(e=this.z),this.x=t,this.y=i,this.z=e,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;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,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,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,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.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,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return this.applyQuaternion(ie.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(ie.setFromAxisAngle(t,i))}applyMatrix3(t){const i=this.x,e=this.y,s=this.z,n=t.elements;return this.x=n[0]*i+n[3]*e+n[6]*s,this.y=n[1]*i+n[4]*e+n[7]*s,this.z=n[2]*i+n[5]*e+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const i=this.x,e=this.y,s=this.z,n=t.elements,r=1/(n[3]*i+n[7]*e+n[11]*s+n[15]);return this.x=(n[0]*i+n[4]*e+n[8]*s+n[12])*r,this.y=(n[1]*i+n[5]*e+n[9]*s+n[13])*r,this.z=(n[2]*i+n[6]*e+n[10]*s+n[14])*r,this}applyQuaternion(t){const i=this.x,e=this.y,s=this.z,n=t.x,r=t.y,h=t.z,o=t.w,a=2*(r*s-h*e),l=2*(h*i-n*s),c=2*(n*e-r*i);return this.x=i+o*a+r*c-h*l,this.y=e+o*l+h*a-n*c,this.z=s+o*c+n*l-r*a,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const i=this.x,e=this.y,s=this.z,n=t.elements;return this.x=n[0]*i+n[4]*e+n[8]*s,this.y=n[1]*i+n[5]*e+n[9]*s,this.z=n[2]*i+n[6]*e+n[10]*s,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,i){return this.x=A(this.x,t.x,i.x),this.y=A(this.y,t.y,i.y),this.z=A(this.z,t.z,i.z),this}clampScalar(t,i){return this.x=A(this.x,t,i),this.y=A(this.y,t,i),this.z=A(this.z,t,i),this}clampLength(t,i){const e=this.length();return this.divideScalar(e||1).multiplyScalar(A(e,t,i))}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,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,e){return this.x=t.x+(i.x-t.x)*e,this.y=t.y+(i.y-t.y)*e,this.z=t.z+(i.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,i){const e=t.x,s=t.y,n=t.z,r=i.x,h=i.y,o=i.z;return this.x=s*o-n*h,this.y=n*r-e*o,this.z=e*h-s*r,this}projectOnVector(t){const i=t.lengthSq();if(i===0)return this.set(0,0,0);const e=t.dot(this)/i;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return gi.copy(this).projectOnVector(t),this.sub(gi)}reflect(t){return this.sub(gi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const e=this.dot(t)/i;return Math.acos(A(e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,e=this.y-t.y,s=this.z-t.z;return i*i+e*e+s*s}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,i,e){const s=Math.sin(i)*t;return this.x=s*Math.sin(e),this.y=Math.cos(i)*t,this.z=s*Math.cos(e),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,e){return this.x=t*Math.sin(i),this.y=e,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){const i=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=e,this.z=s,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*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,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,i=Math.random()*2-1,e=Math.sqrt(1-i*i);return this.x=e*Math.cos(t),this.y=i,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const gi=new x,ie=new Nt;class dt{constructor(t,i,e,s,n,r,h,o,a){dt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,i,e,s,n,r,h,o,a)}set(t,i,e,s,n,r,h,o,a){const l=this.elements;return l[0]=t,l[1]=s,l[2]=h,l[3]=i,l[4]=n,l[5]=o,l[6]=e,l[7]=r,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const i=this.elements,e=t.elements;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],this}extractBasis(t,i,e){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const e=t.elements,s=i.elements,n=this.elements,r=e[0],h=e[3],o=e[6],a=e[1],l=e[4],c=e[7],u=e[2],d=e[5],p=e[8],m=s[0],g=s[3],f=s[6],b=s[1],_=s[4],M=s[7],w=s[2],S=s[5],F=s[8];return n[0]=r*m+h*b+o*w,n[3]=r*g+h*_+o*S,n[6]=r*f+h*M+o*F,n[1]=a*m+l*b+c*w,n[4]=a*g+l*_+c*S,n[7]=a*f+l*M+c*F,n[2]=u*m+d*b+p*w,n[5]=u*g+d*_+p*S,n[8]=u*f+d*M+p*F,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){const t=this.elements,i=t[0],e=t[1],s=t[2],n=t[3],r=t[4],h=t[5],o=t[6],a=t[7],l=t[8];return i*r*l-i*h*a-e*n*l+e*h*o+s*n*a-s*r*o}invert(){const t=this.elements,i=t[0],e=t[1],s=t[2],n=t[3],r=t[4],h=t[5],o=t[6],a=t[7],l=t[8],c=l*r-h*a,u=h*o-l*n,d=a*n-r*o,p=i*c+e*u+s*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(s*a-l*e)*m,t[2]=(h*e-s*r)*m,t[3]=u*m,t[4]=(l*i-s*o)*m,t[5]=(s*n-h*i)*m,t[6]=d*m,t[7]=(e*o-a*i)*m,t[8]=(r*i-e*n)*m,this}transpose(){let t;const i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,e,s,n,r,h){const o=Math.cos(n),a=Math.sin(n);return this.set(e*o,e*a,-e*(o*r+a*h)+r+t,-s*a,s*o,-s*(-a*r+o*h)+h+i,0,0,1),this}scale(t,i){return this.premultiply(bi.makeScale(t,i)),this}rotate(t){return this.premultiply(bi.makeRotation(-t)),this}translate(t,i){return this.premultiply(bi.makeTranslation(t,i)),this}makeTranslation(t,i){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,i,0,0,1),this}makeRotation(t){const i=Math.cos(t),e=Math.sin(t);return this.set(i,-e,0,e,i,0,0,0,1),this}makeScale(t,i){return this.set(t,0,0,0,i,0,0,0,1),this}equals(t){const i=this.elements,e=t.elements;for(let s=0;s<9;s++)if(i[s]!==e[s])return!1;return!0}fromArray(t,i=0){for(let e=0;e<9;e++)this.elements[e]=t[e+i];return this}toArray(t=[],i=0){const e=this.elements;return t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],t[i+6]=e[6],t[i+7]=e[7],t[i+8]=e[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const bi=new dt,ee=new dt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),se=new dt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Oe(){const y={enabled:!0,workingColorSpace:Ji,spaces:{},convert:function(s,n,r){return this.enabled===!1||n===r||!n||!r||(this.spaces[n].transfer===yi&&(s.r=rt(s.r),s.g=rt(s.g),s.b=rt(s.b)),this.spaces[n].primaries!==this.spaces[r].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===yi&&(s.r=Bt(s.r),s.g=Bt(s.g),s.b=Bt(s.b))),s},workingToColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},colorSpaceToWorking:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===ge?ji:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,r){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,n){return te("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),y.workingToColorSpace(s,n)},toWorkingColorSpace:function(s,n){return te("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),y.colorSpaceToWorking(s,n)}},t=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],e=[.3127,.329];return y.define({[Ji]:{primaries:t,whitePoint:e,transfer:ji,toXYZ:ee,fromXYZ:se,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:j},outputColorSpaceConfig:{drawingBufferColorSpace:j}},[j]:{primaries:t,whitePoint:e,transfer:yi,toXYZ:ee,fromXYZ:se,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:j}}}),y}const Y=Oe();function rt(y){return y<.04045?y*.0773993808:Math.pow(y*.9478672986+.0521327014,2.4)}function Bt(y){return y<.0031308?y*12.92:1.055*Math.pow(y,.41666)-.055}let bt;class De{static getDataURL(t,i="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{bt===void 0&&(bt=Qi("canvas")),bt.width=t.width,bt.height=t.height;const s=bt.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=bt}return e.toDataURL(i)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const i=Qi("canvas");i.width=t.width,i.height=t.height;const e=i.getContext("2d");e.drawImage(t,0,0,t.width,t.height);const s=e.getImageData(0,0,t.width,t.height),n=s.data;for(let r=0;r<n.length;r++)n[r]=rt(n[r]/255)*255;return e.putImageData(s,0,0),i}else if(t.data){const i=t.data.slice(0);for(let e=0;e<i.length;e++)i instanceof Uint8Array||i instanceof Uint8ClampedArray?i[e]=Math.floor(rt(i[e]/255)*255):i[e]=rt(i[e]);return{data:i,width:t.width,height:t.height}}else return N("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Re=0;class Pe{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Re++}),this.uuid=Pt(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const i=this.data;return typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement?t.set(i.videoWidth,i.videoHeight,0):typeof VideoFrame<"u"&&i instanceof VideoFrame?t.set(i.displayHeight,i.displayWidth,0):i!==null?t.set(i.width,i.height,i.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const i=t===void 0||typeof t=="string";if(!i&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const e={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let r=0,h=s.length;r<h;r++)s[r].isDataTexture?n.push(Mi(s[r].image)):n.push(Mi(s[r]))}else n=Mi(s);e.url=n}return i||(t.images[this.uuid]=e),e}}function Mi(y){return typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&y instanceof ImageBitmap?De.getDataURL(y):y.data?{data:Array.from(y.data),width:y.width,height:y.height,type:y.data.constructor.name}:(N("Texture: Unable to serialize Texture."),{})}let Ne=0;const _i=new x;class xt extends pi{constructor(t=xt.DEFAULT_IMAGE,i=xt.DEFAULT_MAPPING,e=Zt,s=Zt,n=Fe,r=Te,h=Ie,o=Ce,a=xt.DEFAULT_ANISOTROPY,l=ge){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ne++}),this.uuid=Pt(),this.name="",this.source=new Pe(t),this.mipmaps=[],this.mapping=i,this.channel=0,this.wrapS=e,this.wrapT=s,this.magFilter=n,this.minFilter=r,this.anisotropy=a,this.format=h,this.internalFormat=null,this.type=o,this.offset=new H(0,0),this.repeat=new H(1,1),this.center=new H(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(_i).x}get height(){return this.source.getSize(_i).y}get depth(){return this.source.getSize(_i).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const i in t){const e=t[i];if(e===void 0){N(`Texture.setValues(): parameter '${i}' has value of undefined.`);continue}const s=this[i];if(s===void 0){N(`Texture.setValues(): property '${i}' does not exist.`);continue}s&&e&&s.isVector2&&e.isVector2||s&&e&&s.isVector3&&e.isVector3||s&&e&&s.isMatrix3&&e.isMatrix3?s.copy(e):this[i]=e}}toJSON(t){const i=t===void 0||typeof t=="string";if(!i&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const e={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(e.userData=this.userData),i||(t.textures[this.uuid]=e),e}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==xe)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Xi:t.x=t.x-Math.floor(t.x);break;case Zt:t.x=t.x<0?0:1;break;case Zi: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 Xi:t.y=t.y-Math.floor(t.y);break;case Zt:t.y=t.y<0?0:1;break;case Zi: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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}xt.DEFAULT_IMAGE=null;xt.DEFAULT_MAPPING=xe;xt.DEFAULT_ANISOTROPY=1;class vt{constructor(t=0,i=0,e=0,s=1){vt.prototype.isVector4=!0,this.x=t,this.y=i,this.z=e,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,i,e,s){return this.x=t,this.y=i,this.z=e,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;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;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}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!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const i=this.x,e=this.y,s=this.z,n=this.w,r=t.elements;return this.x=r[0]*i+r[4]*e+r[8]*s+r[12]*n,this.y=r[1]*i+r[5]*e+r[9]*s+r[13]*n,this.z=r[2]*i+r[6]*e+r[10]*s+r[14]*n,this.w=r[3]*i+r[7]*e+r[11]*s+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,e,s,n;const o=t.elements,a=o[0],l=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],g=o[6],f=o[10];if(Math.abs(l-u)<.01&&Math.abs(c-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(l+u)<.1&&Math.abs(c+m)<.1&&Math.abs(p+g)<.1&&Math.abs(a+d+f-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const _=(a+1)/2,M=(d+1)/2,w=(f+1)/2,S=(l+u)/4,F=(c+m)/4,z=(p+g)/4;return _>M&&_>w?_<.01?(e=0,s=.707106781,n=.707106781):(e=Math.sqrt(_),s=S/e,n=F/e):M>w?M<.01?(e=.707106781,s=0,n=.707106781):(s=Math.sqrt(M),e=S/s,n=z/s):w<.01?(e=.707106781,s=.707106781,n=0):(n=Math.sqrt(w),e=F/n,s=z/n),this.set(e,s,n,i),this}let b=Math.sqrt((g-p)*(g-p)+(c-m)*(c-m)+(u-l)*(u-l));return Math.abs(b)<.001&&(b=1),this.x=(g-p)/b,this.y=(c-m)/b,this.z=(u-l)/b,this.w=Math.acos((a+d+f-1)/2),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this.w=i[15],this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),this}clamp(t,i){return this.x=A(this.x,t.x,i.x),this.y=A(this.y,t.y,i.y),this.z=A(this.z,t.z,i.z),this.w=A(this.w,t.w,i.w),this}clampScalar(t,i){return this.x=A(this.x,t,i),this.y=A(this.y,t,i),this.z=A(this.z,t,i),this.w=A(this.w,t,i),this}clampLength(t,i){const e=this.length();return this.divideScalar(e||1).multiplyScalar(A(e,t,i))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,e){return this.x=t.x+(i.x-t.x)*e,this.y=t.y+(i.y-t.y)*e,this.z=t.z+(i.z-t.z)*e,this.w=t.w+(i.w-t.w)*e,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class G{constructor(t,i,e,s,n,r,h,o,a,l,c,u,d,p,m,g){G.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,i,e,s,n,r,h,o,a,l,c,u,d,p,m,g)}set(t,i,e,s,n,r,h,o,a,l,c,u,d,p,m,g){const f=this.elements;return f[0]=t,f[4]=i,f[8]=e,f[12]=s,f[1]=n,f[5]=r,f[9]=h,f[13]=o,f[2]=a,f[6]=l,f[10]=c,f[14]=u,f[3]=d,f[7]=p,f[11]=m,f[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 G().fromArray(this.elements)}copy(t){const i=this.elements,e=t.elements;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],this}copyPosition(t){const i=this.elements,e=t.elements;return i[12]=e[12],i[13]=e[13],i[14]=e[14],this}setFromMatrix3(t){const i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,e){return this.determinant()===0?(t.set(1,0,0),i.set(0,1,0),e.set(0,0,1),this):(t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this)}makeBasis(t,i,e){return this.set(t.x,i.x,e.x,0,t.y,i.y,e.y,0,t.z,i.z,e.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();const i=this.elements,e=t.elements,s=1/Mt.setFromMatrixColumn(t,0).length(),n=1/Mt.setFromMatrixColumn(t,1).length(),r=1/Mt.setFromMatrixColumn(t,2).length();return i[0]=e[0]*s,i[1]=e[1]*s,i[2]=e[2]*s,i[3]=0,i[4]=e[4]*n,i[5]=e[5]*n,i[6]=e[6]*n,i[7]=0,i[8]=e[8]*r,i[9]=e[9]*r,i[10]=e[10]*r,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){const i=this.elements,e=t.x,s=t.y,n=t.z,r=Math.cos(e),h=Math.sin(e),o=Math.cos(s),a=Math.sin(s),l=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){const u=r*l,d=r*c,p=h*l,m=h*c;i[0]=o*l,i[4]=-o*c,i[8]=a,i[1]=d+p*a,i[5]=u-m*a,i[9]=-h*o,i[2]=m-u*a,i[6]=p+d*a,i[10]=r*o}else if(t.order==="YXZ"){const u=o*l,d=o*c,p=a*l,m=a*c;i[0]=u+m*h,i[4]=p*h-d,i[8]=r*a,i[1]=r*c,i[5]=r*l,i[9]=-h,i[2]=d*h-p,i[6]=m+u*h,i[10]=r*o}else if(t.order==="ZXY"){const u=o*l,d=o*c,p=a*l,m=a*c;i[0]=u-m*h,i[4]=-r*c,i[8]=p+d*h,i[1]=d+p*h,i[5]=r*l,i[9]=m-u*h,i[2]=-r*a,i[6]=h,i[10]=r*o}else if(t.order==="ZYX"){const u=r*l,d=r*c,p=h*l,m=h*c;i[0]=o*l,i[4]=p*a-d,i[8]=u*a+m,i[1]=o*c,i[5]=m*a+u,i[9]=d*a-p,i[2]=-a,i[6]=h*o,i[10]=r*o}else if(t.order==="YZX"){const u=r*o,d=r*a,p=h*o,m=h*a;i[0]=o*l,i[4]=m-u*c,i[8]=p*c+d,i[1]=c,i[5]=r*l,i[9]=-h*l,i[2]=-a*l,i[6]=d*c+p,i[10]=u-m*c}else if(t.order==="XZY"){const u=r*o,d=r*a,p=h*o,m=h*a;i[0]=o*l,i[4]=-c,i[8]=a*l,i[1]=u*c+m,i[5]=r*l,i[9]=d*c-p,i[2]=p*c-d,i[6]=h*l,i[10]=m*c+u}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ve,t,Le)}lookAt(t,i,e){const s=this.elements;return W.subVectors(t,i),W.lengthSq()===0&&(W.z=1),W.normalize(),ht.crossVectors(e,W),ht.lengthSq()===0&&(Math.abs(e.z)===1?W.x+=1e-4:W.z+=1e-4,W.normalize(),ht.crossVectors(e,W)),ht.normalize(),jt.crossVectors(W,ht),s[0]=ht.x,s[4]=jt.x,s[8]=W.x,s[1]=ht.y,s[5]=jt.y,s[9]=W.y,s[2]=ht.z,s[6]=jt.z,s[10]=W.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const e=t.elements,s=i.elements,n=this.elements,r=e[0],h=e[4],o=e[8],a=e[12],l=e[1],c=e[5],u=e[9],d=e[13],p=e[2],m=e[6],g=e[10],f=e[14],b=e[3],_=e[7],M=e[11],w=e[15],S=s[0],F=s[4],z=s[8],T=s[12],C=s[1],B=s[5],v=s[9],I=s[13],U=s[2],k=s[6],Wt=s[10],Vt=s[14],qt=s[3],Ut=s[7],Yt=s[11],Xt=s[15];return n[0]=r*S+h*C+o*U+a*qt,n[4]=r*F+h*B+o*k+a*Ut,n[8]=r*z+h*v+o*Wt+a*Yt,n[12]=r*T+h*I+o*Vt+a*Xt,n[1]=l*S+c*C+u*U+d*qt,n[5]=l*F+c*B+u*k+d*Ut,n[9]=l*z+c*v+u*Wt+d*Yt,n[13]=l*T+c*I+u*Vt+d*Xt,n[2]=p*S+m*C+g*U+f*qt,n[6]=p*F+m*B+g*k+f*Ut,n[10]=p*z+m*v+g*Wt+f*Yt,n[14]=p*T+m*I+g*Vt+f*Xt,n[3]=b*S+_*C+M*U+w*qt,n[7]=b*F+_*B+M*k+w*Ut,n[11]=b*z+_*v+M*Wt+w*Yt,n[15]=b*T+_*I+M*Vt+w*Xt,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){const t=this.elements,i=t[0],e=t[4],s=t[8],n=t[12],r=t[1],h=t[5],o=t[9],a=t[13],l=t[2],c=t[6],u=t[10],d=t[14],p=t[3],m=t[7],g=t[11],f=t[15],b=o*d-a*u,_=h*d-a*c,M=h*u-o*c,w=r*d-a*l,S=r*u-o*l,F=r*c-h*l;return i*(m*b-g*_+f*M)-e*(p*b-g*w+f*S)+s*(p*_-m*w+f*F)-n*(p*M-m*S+g*F)}transpose(){const t=this.elements;let i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,e){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=i,s[14]=e),this}invert(){const t=this.elements,i=t[0],e=t[1],s=t[2],n=t[3],r=t[4],h=t[5],o=t[6],a=t[7],l=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=t[15],b=i*h-e*r,_=i*o-s*r,M=i*a-n*r,w=e*o-s*h,S=e*a-n*h,F=s*a-n*o,z=l*m-c*p,T=l*g-u*p,C=l*f-d*p,B=c*g-u*m,v=c*f-d*m,I=u*f-d*g,U=b*I-_*v+M*B+w*C-S*T+F*z;if(U===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/U;return t[0]=(h*I-o*v+a*B)*k,t[1]=(s*v-e*I-n*B)*k,t[2]=(m*F-g*S+f*w)*k,t[3]=(u*S-c*F-d*w)*k,t[4]=(o*C-r*I-a*T)*k,t[5]=(i*I-s*C+n*T)*k,t[6]=(g*M-p*F-f*_)*k,t[7]=(l*F-u*M+d*_)*k,t[8]=(r*v-h*C+a*z)*k,t[9]=(e*C-i*v-n*z)*k,t[10]=(p*S-m*M+f*b)*k,t[11]=(c*M-l*S-d*b)*k,t[12]=(h*T-r*B-o*z)*k,t[13]=(i*B-e*T+s*z)*k,t[14]=(m*_-p*w-g*b)*k,t[15]=(l*w-c*_+u*b)*k,this}scale(t){const i=this.elements,e=t.x,s=t.y,n=t.z;return i[0]*=e,i[4]*=s,i[8]*=n,i[1]*=e,i[5]*=s,i[9]*=n,i[2]*=e,i[6]*=s,i[10]*=n,i[3]*=e,i[7]*=s,i[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,e,s))}makeTranslation(t,i,e){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,i,0,0,1,e,0,0,0,1),this}makeRotationX(t){const i=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,i,-e,0,0,e,i,0,0,0,0,1),this}makeRotationY(t){const i=Math.cos(t),e=Math.sin(t);return this.set(i,0,e,0,0,1,0,0,-e,0,i,0,0,0,0,1),this}makeRotationZ(t){const i=Math.cos(t),e=Math.sin(t);return this.set(i,-e,0,0,e,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){const e=Math.cos(i),s=Math.sin(i),n=1-e,r=t.x,h=t.y,o=t.z,a=n*r,l=n*h;return this.set(a*r+e,a*h-s*o,a*o+s*h,0,a*h+s*o,l*h+e,l*o-s*r,0,a*o-s*h,l*o+s*r,n*o*o+e,0,0,0,0,1),this}makeScale(t,i,e){return this.set(t,0,0,0,0,i,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,i,e,s,n,r){return this.set(1,e,n,0,t,1,r,0,i,s,1,0,0,0,0,1),this}compose(t,i,e){const s=this.elements,n=i._x,r=i._y,h=i._z,o=i._w,a=n+n,l=r+r,c=h+h,u=n*a,d=n*l,p=n*c,m=r*l,g=r*c,f=h*c,b=o*a,_=o*l,M=o*c,w=e.x,S=e.y,F=e.z;return s[0]=(1-(m+f))*w,s[1]=(d+M)*w,s[2]=(p-_)*w,s[3]=0,s[4]=(d-M)*S,s[5]=(1-(u+f))*S,s[6]=(g+b)*S,s[7]=0,s[8]=(p+_)*F,s[9]=(g-b)*F,s[10]=(1-(u+m))*F,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,i,e){const s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];const n=this.determinant();if(n===0)return e.set(1,1,1),i.identity(),this;let r=Mt.set(s[0],s[1],s[2]).length();const h=Mt.set(s[4],s[5],s[6]).length(),o=Mt.set(s[8],s[9],s[10]).length();n<0&&(r=-r),X.copy(this);const a=1/r,l=1/h,c=1/o;return X.elements[0]*=a,X.elements[1]*=a,X.elements[2]*=a,X.elements[4]*=l,X.elements[5]*=l,X.elements[6]*=l,X.elements[8]*=c,X.elements[9]*=c,X.elements[10]*=c,i.setFromRotationMatrix(X),e.x=r,e.y=h,e.z=o,this}makePerspective(t,i,e,s,n,r,h=Jt,o=!1){const a=this.elements,l=2*n/(i-t),c=2*n/(e-s),u=(i+t)/(i-t),d=(e+s)/(e-s);let p,m;if(o)p=n/(r-n),m=r*n/(r-n);else if(h===Jt)p=-(r+n)/(r-n),m=-2*r*n/(r-n);else if(h===Gi)p=-r/(r-n),m=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+h);return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=d,a[13]=0,a[2]=0,a[6]=0,a[10]=p,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,i,e,s,n,r,h=Jt,o=!1){const a=this.elements,l=2/(i-t),c=2/(e-s),u=-(i+t)/(i-t),d=-(e+s)/(e-s);let p,m;if(o)p=1/(r-n),m=r/(r-n);else if(h===Jt)p=-2/(r-n),m=-(r+n)/(r-n);else if(h===Gi)p=-1/(r-n),m=-n/(r-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+h);return a[0]=l,a[4]=0,a[8]=0,a[12]=u,a[1]=0,a[5]=c,a[9]=0,a[13]=d,a[2]=0,a[6]=0,a[10]=p,a[14]=m,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const i=this.elements,e=t.elements;for(let s=0;s<16;s++)if(i[s]!==e[s])return!1;return!0}fromArray(t,i=0){for(let e=0;e<16;e++)this.elements[e]=t[e+i];return this}toArray(t=[],i=0){const e=this.elements;return t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],t[i+6]=e[6],t[i+7]=e[7],t[i+8]=e[8],t[i+9]=e[9],t[i+10]=e[10],t[i+11]=e[11],t[i+12]=e[12],t[i+13]=e[13],t[i+14]=e[14],t[i+15]=e[15],t}}const Mt=new x,X=new G,ve=new x(0,0,0),Le=new x(1,1,1),ht=new x,jt=new x,W=new x,ne=new G,re=new Nt;class Lt{constructor(t=0,i=0,e=0,s=Lt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=i,this._z=e,this._order=s}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,i,e,s=this._order){return this._x=t,this._y=i,this._z=e,this._order=s,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,i=this._order,e=!0){const s=t.elements,n=s[0],r=s[4],h=s[8],o=s[1],a=s[5],l=s[9],c=s[2],u=s[6],d=s[10];switch(i){case"XYZ":this._y=Math.asin(A(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(u,a),this._z=0);break;case"YXZ":this._x=Math.asin(-A(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(h,d),this._z=Math.atan2(o,a)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(A(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-r,a)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-A(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-r,a));break;case"YZX":this._z=Math.asin(A(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,a),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(h,d));break;case"XZY":this._z=Math.asin(-A(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,a),this._y=Math.atan2(h,n)):(this._x=Math.atan2(-l,d),this._y=0);break;default:N("Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,i,e){return ne.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ne,i,e)}setFromVector3(t,i=this._order){return this.set(t.x,t.y,t.z,i)}reorder(t){return re.setFromEuler(this),this.setFromQuaternion(re,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=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+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 We{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Ve=0;const oe=new x,_t=new Nt,K=new G,$t=new x,Et=new x,qe=new x,Ue=new Nt,he=new x(1,0,0),ae=new x(0,1,0),le=new x(0,0,1),ce={type:"added"},Ye={type:"removed"},wt={type:"childadded",child:null},wi={type:"childremoved",child:null};class ot extends pi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ve++}),this.uuid=Pt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ot.DEFAULT_UP.clone();const t=new x,i=new Lt,e=new Nt,s=new x(1,1,1);function n(){e.setFromEuler(i,!1)}function r(){i.setFromQuaternion(e,void 0,!1)}i._onChange(n),e._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:i},quaternion:{configurable:!0,enumerable:!0,value:e},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new G},normalMatrix:{value:new dt}}),this.matrix=new G,this.matrixWorld=new G,this.matrixAutoUpdate=ot.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new We,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,i){this.quaternion.setFromAxisAngle(t,i)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,i){return _t.setFromAxisAngle(t,i),this.quaternion.multiply(_t),this}rotateOnWorldAxis(t,i){return _t.setFromAxisAngle(t,i),this.quaternion.premultiply(_t),this}rotateX(t){return this.rotateOnAxis(he,t)}rotateY(t){return this.rotateOnAxis(ae,t)}rotateZ(t){return this.rotateOnAxis(le,t)}translateOnAxis(t,i){return oe.copy(t).applyQuaternion(this.quaternion),this.position.add(oe.multiplyScalar(i)),this}translateX(t){return this.translateOnAxis(he,t)}translateY(t){return this.translateOnAxis(ae,t)}translateZ(t){return this.translateOnAxis(le,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(K.copy(this.matrixWorld).invert())}lookAt(t,i,e){t.isVector3?$t.copy(t):$t.set(t,i,e);const s=this.parent;this.updateWorldMatrix(!0,!1),Et.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?K.lookAt(Et,$t,this.up):K.lookAt($t,Et,this.up),this.quaternion.setFromRotationMatrix(K),s&&(K.extractRotation(s.matrixWorld),_t.setFromRotationMatrix(K),this.quaternion.premultiply(_t.invert()))}add(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.add(arguments[i]);return this}return t===this?(yt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(ce),wt.child=t,this.dispatchEvent(wt),wt.child=null):yt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const i=this.children.indexOf(t);return i!==-1&&(t.parent=null,this.children.splice(i,1),t.dispatchEvent(Ye),wi.child=t,this.dispatchEvent(wi),wi.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),K.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),K.multiply(t.parent.matrixWorld)),t.applyMatrix4(K),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(ce),wt.child=t,this.dispatchEvent(wt),wt.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,i){if(this[t]===i)return this;for(let e=0,s=this.children.length;e<s;e++){const r=this.children[e].getObjectByProperty(t,i);if(r!==void 0)return r}}getObjectsByProperty(t,i,e=[]){this[t]===i&&e.push(this);const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].getObjectsByProperty(t,i,e);return e}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Et,t,qe),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Et,Ue,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const i=this.matrixWorld.elements;return t.set(i[8],i[9],i[10]).normalize()}raycast(){}traverse(t){t(this);const i=this.children;for(let e=0,s=i.length;e<s;e++)i[e].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const i=this.children;for(let e=0,s=i.length;e<s;e++)i[e].traverseVisible(t)}traverseAncestors(t){const i=this.parent;i!==null&&(t(i),i.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const i=t.x,e=t.y,s=t.z,n=this.matrix.elements;n[12]+=i-n[0]*i-n[4]*e-n[8]*s,n[13]+=e-n[1]*i-n[5]*e-n[9]*s,n[14]+=s-n[2]*i-n[6]*e-n[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const i=this.children;for(let e=0,s=i.length;e<s;e++)i[e].updateMatrixWorld(t)}updateWorldMatrix(t,i){const e=this.parent;if(t===!0&&e!==null&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),i===!0){const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){const i=t===void 0||typeof t=="string",e={};i&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},e.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(h=>({...h,boundingBox:h.boundingBox?h.boundingBox.toJSON():void 0,boundingSphere:h.boundingSphere?h.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(h=>({...h})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function n(h,o){return h[o.uuid]===void 0&&(h[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const h=this.geometry.parameters;if(h!==void 0&&h.shapes!==void 0){const o=h.shapes;if(Array.isArray(o))for(let a=0,l=o.length;a<l;a++){const c=o[a];n(t.shapes,c)}else n(t.shapes,o)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const h=[];for(let o=0,a=this.material.length;o<a;o++)h.push(n(t.materials,this.material[o]));s.material=h}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let h=0;h<this.children.length;h++)s.children.push(this.children[h].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let h=0;h<this.animations.length;h++){const o=this.animations[h];s.animations.push(n(t.animations,o))}}if(i){const h=r(t.geometries),o=r(t.materials),a=r(t.textures),l=r(t.images),c=r(t.shapes),u=r(t.skeletons),d=r(t.animations),p=r(t.nodes);h.length>0&&(e.geometries=h),o.length>0&&(e.materials=o),a.length>0&&(e.textures=a),l.length>0&&(e.images=l),c.length>0&&(e.shapes=c),u.length>0&&(e.skeletons=u),d.length>0&&(e.animations=d),p.length>0&&(e.nodes=p)}return e.object=s,e;function r(h){const o=[];for(const a in h){const l=h[a];delete l.metadata,o.push(l)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,i=!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),t.pivot!==null&&(this.pivot=t.pivot.clone()),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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),i===!0)for(let e=0;e<t.children.length;e++){const s=t.children[e];this.add(s.clone())}return this}}ot.DEFAULT_UP=new x(0,1,0);ot.DEFAULT_MATRIX_AUTO_UPDATE=!0;ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Me={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},at={h:0,s:0,l:0},Ht={h:0,s:0,l:0};function zi(y,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?y+(t-y)*6*i:i<1/2?t:i<2/3?y+(t-y)*6*(2/3-i):y}class fi{constructor(t,i,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,i,e)}set(t,i,e){if(i===void 0&&e===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,i,e);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,i=j){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Y.colorSpaceToWorking(this,i),this}setRGB(t,i,e,s=Y.workingColorSpace){return this.r=t,this.g=i,this.b=e,Y.colorSpaceToWorking(this,s),this}setHSL(t,i,e,s=Y.workingColorSpace){if(t=Ee(t,1),i=A(i,0,1),e=A(e,0,1),i===0)this.r=this.g=this.b=e;else{const n=e<=.5?e*(1+i):e+i-e*i,r=2*e-n;this.r=zi(r,n,t+1/3),this.g=zi(r,n,t),this.b=zi(r,n,t-1/3)}return Y.colorSpaceToWorking(this,s),this}setStyle(t,i=j){function e(n){n!==void 0&&parseFloat(n)<1&&N("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const r=s[1],h=s[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return e(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,i);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return e(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,i);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return e(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,i);break;default:N("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,i);if(r===6)return this.setHex(parseInt(n,16),i);N("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,i);return this}setColorName(t,i=j){const e=Me[t.toLowerCase()];return e!==void 0?this.setHex(e,i):N("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=rt(t.r),this.g=rt(t.g),this.b=rt(t.b),this}copyLinearToSRGB(t){return this.r=Bt(t.r),this.g=Bt(t.g),this.b=Bt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=j){return Y.workingToColorSpace(P.copy(this),t),Math.round(A(P.r*255,0,255))*65536+Math.round(A(P.g*255,0,255))*256+Math.round(A(P.b*255,0,255))}getHexString(t=j){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,i=Y.workingColorSpace){Y.workingToColorSpace(P.copy(this),i);const e=P.r,s=P.g,n=P.b,r=Math.max(e,s,n),h=Math.min(e,s,n);let o,a;const l=(h+r)/2;if(h===r)o=0,a=0;else{const c=r-h;switch(a=l<=.5?c/(r+h):c/(2-r-h),r){case e:o=(s-n)/c+(s<n?6:0);break;case s:o=(n-e)/c+2;break;case n:o=(e-s)/c+4;break}o/=6}return t.h=o,t.s=a,t.l=l,t}getRGB(t,i=Y.workingColorSpace){return Y.workingToColorSpace(P.copy(this),i),t.r=P.r,t.g=P.g,t.b=P.b,t}getStyle(t=j){Y.workingToColorSpace(P.copy(this),t);const i=P.r,e=P.g,s=P.b;return t!==j?`color(${t} ${i.toFixed(3)} ${e.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(i*255)},${Math.round(e*255)},${Math.round(s*255)})`}offsetHSL(t,i,e){return this.getHSL(at),this.setHSL(at.h+t,at.s+i,at.l+e)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,i){return this.r=t.r+i.r,this.g=t.g+i.g,this.b=t.b+i.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,i){return this.r+=(t.r-this.r)*i,this.g+=(t.g-this.g)*i,this.b+=(t.b-this.b)*i,this}lerpColors(t,i,e){return this.r=t.r+(i.r-t.r)*e,this.g=t.g+(i.g-t.g)*e,this.b=t.b+(i.b-t.b)*e,this}lerpHSL(t,i){this.getHSL(at),t.getHSL(Ht);const e=xi(at.h,Ht.h,i),s=xi(at.s,Ht.s,i),n=xi(at.l,Ht.l,i);return this.setHSL(e,s,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const i=this.r,e=this.g,s=this.b,n=t.elements;return this.r=n[0]*i+n[3]*e+n[6]*s,this.g=n[1]*i+n[4]*e+n[7]*s,this.b=n[2]*i+n[5]*e+n[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,i=0){return this.r=t[i],this.g=t[i+1],this.b=t[i+2],this}toArray(t=[],i=0){return t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,t}fromBufferAttribute(t,i){return this.r=t.getX(i),this.g=t.getY(i),this.b=t.getZ(i),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const P=new fi;fi.NAMES=Me;const Z=new x,tt=new x,Si=new x,it=new x,zt=new x,St=new x,ue=new x,Ai=new x,Fi=new x,Ti=new x,Ci=new vt,Bi=new vt,Ii=new vt;class ${constructor(t=new x,i=new x,e=new x){this.a=t,this.b=i,this.c=e}static getNormal(t,i,e,s){s.subVectors(e,i),Z.subVectors(t,i),s.cross(Z);const n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,i,e,s,n){Z.subVectors(s,i),tt.subVectors(e,i),Si.subVectors(t,i);const r=Z.dot(Z),h=Z.dot(tt),o=Z.dot(Si),a=tt.dot(tt),l=tt.dot(Si),c=r*a-h*h;if(c===0)return n.set(0,0,0),null;const u=1/c,d=(a*o-h*l)*u,p=(r*l-h*o)*u;return n.set(1-d-p,p,d)}static containsPoint(t,i,e,s){return this.getBarycoord(t,i,e,s,it)===null?!1:it.x>=0&&it.y>=0&&it.x+it.y<=1}static getInterpolation(t,i,e,s,n,r,h,o){return this.getBarycoord(t,i,e,s,it)===null?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(n,it.x),o.addScaledVector(r,it.y),o.addScaledVector(h,it.z),o)}static getInterpolatedAttribute(t,i,e,s,n,r){return Ci.setScalar(0),Bi.setScalar(0),Ii.setScalar(0),Ci.fromBufferAttribute(t,i),Bi.fromBufferAttribute(t,e),Ii.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(Ci,n.x),r.addScaledVector(Bi,n.y),r.addScaledVector(Ii,n.z),r}static isFrontFacing(t,i,e,s){return Z.subVectors(e,i),tt.subVectors(t,i),Z.cross(tt).dot(s)<0}set(t,i,e){return this.a.copy(t),this.b.copy(i),this.c.copy(e),this}setFromPointsAndIndices(t,i,e,s){return this.a.copy(t[i]),this.b.copy(t[e]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,i,e,s){return this.a.fromBufferAttribute(t,i),this.b.fromBufferAttribute(t,e),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Z.subVectors(this.c,this.b),tt.subVectors(this.a,this.b),Z.cross(tt).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return $.getBarycoord(t,this.a,this.b,this.c,i)}getInterpolation(t,i,e,s,n){return $.getInterpolation(t,this.a,this.b,this.c,i,e,s,n)}containsPoint(t){return $.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){const e=this.a,s=this.b,n=this.c;let r,h;zt.subVectors(s,e),St.subVectors(n,e),Ai.subVectors(t,e);const o=zt.dot(Ai),a=St.dot(Ai);if(o<=0&&a<=0)return i.copy(e);Fi.subVectors(t,s);const l=zt.dot(Fi),c=St.dot(Fi);if(l>=0&&c<=l)return i.copy(s);const u=o*c-l*a;if(u<=0&&o>=0&&l<=0)return r=o/(o-l),i.copy(e).addScaledVector(zt,r);Ti.subVectors(t,n);const d=zt.dot(Ti),p=St.dot(Ti);if(p>=0&&d<=p)return i.copy(n);const m=d*a-o*p;if(m<=0&&a>=0&&p<=0)return h=a/(a-p),i.copy(e).addScaledVector(St,h);const g=l*p-d*c;if(g<=0&&c-l>=0&&d-p>=0)return ue.subVectors(n,s),h=(c-l)/(c-l+(d-p)),i.copy(s).addScaledVector(ue,h);const f=1/(g+m+u);return r=m*f,h=u*f,i.copy(e).addScaledVector(zt,r).addScaledVector(St,h)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Q{constructor(t=new x(1/0,1/0,1/0),i=new x(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=i}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromArray(t){this.makeEmpty();for(let i=0,e=t.length;i<e;i+=3)this.expandByPoint(J.fromArray(t,i));return this}setFromBufferAttribute(t){this.makeEmpty();for(let i=0,e=t.count;i<e;i++)this.expandByPoint(J.fromBufferAttribute(t,i));return this}setFromPoints(t){this.makeEmpty();for(let i=0,e=t.length;i<e;i++)this.expandByPoint(t[i]);return this}setFromCenterAndSize(t,i){const e=J.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}setFromObject(t,i=!1){return this.makeEmpty(),this.expandByObject(t,i)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,i=!1){t.updateWorldMatrix(!1,!1);const e=t.geometry;if(e!==void 0){const n=e.getAttribute("position");if(i===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,h=n.count;r<h;r++)t.isMesh===!0?t.getVertexPosition(r,J):J.fromBufferAttribute(n,r),J.applyMatrix4(t.matrixWorld),this.expandByPoint(J);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Gt.copy(t.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),Gt.copy(e.boundingBox)),Gt.applyMatrix4(t.matrixWorld),this.union(Gt)}const s=t.children;for(let n=0,r=s.length;n<r;n++)this.expandByObject(s[n],i);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,i){return i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,J),J.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let i,e;return t.normal.x>0?(i=t.normal.x*this.min.x,e=t.normal.x*this.max.x):(i=t.normal.x*this.max.x,e=t.normal.x*this.min.x),t.normal.y>0?(i+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(i+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),t.normal.z>0?(i+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(i+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),i<=-t.constant&&e>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ot),Qt.subVectors(this.max,Ot),At.subVectors(t.a,Ot),Ft.subVectors(t.b,Ot),Tt.subVectors(t.c,Ot),lt.subVectors(Ft,At),ct.subVectors(Tt,Ft),pt.subVectors(At,Tt);let i=[0,-lt.z,lt.y,0,-ct.z,ct.y,0,-pt.z,pt.y,lt.z,0,-lt.x,ct.z,0,-ct.x,pt.z,0,-pt.x,-lt.y,lt.x,0,-ct.y,ct.x,0,-pt.y,pt.x,0];return!ki(i,At,Ft,Tt,Qt)||(i=[1,0,0,0,1,0,0,0,1],!ki(i,At,Ft,Tt,Qt))?!1:(Kt.crossVectors(lt,ct),i=[Kt.x,Kt.y,Kt.z],ki(i,At,Ft,Tt,Qt))}clampPoint(t,i){return i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,J).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(J).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(et[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),et[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),et[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),et[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),et[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),et[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),et[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),et[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(et),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const et=[new x,new x,new x,new x,new x,new x,new x,new x],J=new x,Gt=new Q,At=new x,Ft=new x,Tt=new x,lt=new x,ct=new x,pt=new x,Ot=new x,Qt=new x,Kt=new x,ft=new x;function ki(y,t,i,e,s){for(let n=0,r=y.length-3;n<=r;n+=3){ft.fromArray(y,n);const h=s.x*Math.abs(ft.x)+s.y*Math.abs(ft.y)+s.z*Math.abs(ft.z),o=t.dot(ft),a=i.dot(ft),l=e.dot(ft);if(Math.max(-Math.max(o,a,l),Math.min(o,a,l))>h)return!1}return!0}const O=new x,ti=new H;let Xe=0;class It{constructor(t,i,e=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xe++}),this.name="",this.array=t,this.itemSize=i,this.count=t!==void 0?t.length/i:0,this.normalized=e,this.usage=Hi,this.updateRanges=[],this.gpuType=Be,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,i,e){t*=this.itemSize,e*=i.itemSize;for(let s=0,n=this.itemSize;s<n;s++)this.array[t+s]=i.array[e+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let i=0,e=this.count;i<e;i++)ti.fromBufferAttribute(this,i),ti.applyMatrix3(t),this.setXY(i,ti.x,ti.y);else if(this.itemSize===3)for(let i=0,e=this.count;i<e;i++)O.fromBufferAttribute(this,i),O.applyMatrix3(t),this.setXYZ(i,O.x,O.y,O.z);return this}applyMatrix4(t){for(let i=0,e=this.count;i<e;i++)O.fromBufferAttribute(this,i),O.applyMatrix4(t),this.setXYZ(i,O.x,O.y,O.z);return this}applyNormalMatrix(t){for(let i=0,e=this.count;i<e;i++)O.fromBufferAttribute(this,i),O.applyNormalMatrix(t),this.setXYZ(i,O.x,O.y,O.z);return this}transformDirection(t){for(let i=0,e=this.count;i<e;i++)O.fromBufferAttribute(this,i),O.transformDirection(t),this.setXYZ(i,O.x,O.y,O.z);return this}set(t,i=0){return this.array.set(t,i),this}getComponent(t,i){let e=this.array[t*this.itemSize+i];return this.normalized&&(e=kt(e,this.array)),e}setComponent(t,i,e){return this.normalized&&(e=L(e,this.array)),this.array[t*this.itemSize+i]=e,this}getX(t){let i=this.array[t*this.itemSize];return this.normalized&&(i=kt(i,this.array)),i}setX(t,i){return this.normalized&&(i=L(i,this.array)),this.array[t*this.itemSize]=i,this}getY(t){let i=this.array[t*this.itemSize+1];return this.normalized&&(i=kt(i,this.array)),i}setY(t,i){return this.normalized&&(i=L(i,this.array)),this.array[t*this.itemSize+1]=i,this}getZ(t){let i=this.array[t*this.itemSize+2];return this.normalized&&(i=kt(i,this.array)),i}setZ(t,i){return this.normalized&&(i=L(i,this.array)),this.array[t*this.itemSize+2]=i,this}getW(t){let i=this.array[t*this.itemSize+3];return this.normalized&&(i=kt(i,this.array)),i}setW(t,i){return this.normalized&&(i=L(i,this.array)),this.array[t*this.itemSize+3]=i,this}setXY(t,i,e){return t*=this.itemSize,this.normalized&&(i=L(i,this.array),e=L(e,this.array)),this.array[t+0]=i,this.array[t+1]=e,this}setXYZ(t,i,e,s){return t*=this.itemSize,this.normalized&&(i=L(i,this.array),e=L(e,this.array),s=L(s,this.array)),this.array[t+0]=i,this.array[t+1]=e,this.array[t+2]=s,this}setXYZW(t,i,e,s,n){return t*=this.itemSize,this.normalized&&(i=L(i,this.array),e=L(e,this.array),s=L(s,this.array),n=L(n,this.array)),this.array[t+0]=i,this.array[t+1]=e,this.array[t+2]=s,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Hi&&(t.usage=this.usage),t}}class Ze extends It{constructor(t,i,e){super(new Uint16Array(t),i,e)}}class Je extends It{constructor(t,i,e){super(new Uint32Array(t),i,e)}}class ci extends It{constructor(t,i,e){super(new Float32Array(t),i,e)}}const je=new Q,Dt=new x,Ei=new x;class _e{constructor(t=new x,i=-1){this.isSphere=!0,this.center=t,this.radius=i}set(t,i){return this.center.copy(t),this.radius=i,this}setFromPoints(t,i){const e=this.center;i!==void 0?e.copy(i):je.setFromPoints(t).getCenter(e);let s=0;for(let n=0,r=t.length;n<r;n++)s=Math.max(s,e.distanceToSquared(t[n]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const i=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=i*i}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,i){const e=this.center.distanceToSquared(t);return i.copy(t),e>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Dt.subVectors(t,this.center);const i=Dt.lengthSq();if(i>this.radius*this.radius){const e=Math.sqrt(i),s=(e-this.radius)*.5;this.center.addScaledVector(Dt,s/e),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Ei.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Dt.copy(t.center).add(Ei)),this.expandByPoint(Dt.copy(t.center).sub(Ei))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let $e=0;const q=new G,Oi=new ot,Ct=new x,V=new Q,Rt=new Q,D=new x;class mi extends pi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$e++}),this.uuid=Pt(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(ke(t)?Je:Ze)(t,1):this.index=t,this}setIndirect(t,i=0){return this.indirect=t,this.indirectOffset=i,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,i){return this.attributes[t]=i,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,i,e=0){this.groups.push({start:t,count:i,materialIndex:e})}clearGroups(){this.groups=[]}setDrawRange(t,i){this.drawRange.start=t,this.drawRange.count=i}applyMatrix4(t){const i=this.attributes.position;i!==void 0&&(i.applyMatrix4(t),i.needsUpdate=!0);const e=this.attributes.normal;if(e!==void 0){const n=new dt().getNormalMatrix(t);e.applyNormalMatrix(n),e.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return q.makeRotationFromQuaternion(t),this.applyMatrix4(q),this}rotateX(t){return q.makeRotationX(t),this.applyMatrix4(q),this}rotateY(t){return q.makeRotationY(t),this.applyMatrix4(q),this}rotateZ(t){return q.makeRotationZ(t),this.applyMatrix4(q),this}translate(t,i,e){return q.makeTranslation(t,i,e),this.applyMatrix4(q),this}scale(t,i,e){return q.makeScale(t,i,e),this.applyMatrix4(q),this}lookAt(t){return Oi.lookAt(t),Oi.updateMatrix(),this.applyMatrix4(Oi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ct).negate(),this.translate(Ct.x,Ct.y,Ct.z),this}setFromPoints(t){const i=this.getAttribute("position");if(i===void 0){const e=[];for(let s=0,n=t.length;s<n;s++){const r=t[s];e.push(r.x,r.y,r.z||0)}this.setAttribute("position",new ci(e,3))}else{const e=Math.min(t.length,i.count);for(let s=0;s<e;s++){const n=t[s];i.setXYZ(s,n.x,n.y,n.z||0)}t.length>i.count&&N("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),i.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Q);const t=this.attributes.position,i=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){yt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new x(-1/0,-1/0,-1/0),new x(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),i)for(let e=0,s=i.length;e<s;e++){const n=i[e];V.setFromBufferAttribute(n),this.morphTargetsRelative?(D.addVectors(this.boundingBox.min,V.min),this.boundingBox.expandByPoint(D),D.addVectors(this.boundingBox.max,V.max),this.boundingBox.expandByPoint(D)):(this.boundingBox.expandByPoint(V.min),this.boundingBox.expandByPoint(V.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&yt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _e);const t=this.attributes.position,i=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){yt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new x,1/0);return}if(t){const e=this.boundingSphere.center;if(V.setFromBufferAttribute(t),i)for(let n=0,r=i.length;n<r;n++){const h=i[n];Rt.setFromBufferAttribute(h),this.morphTargetsRelative?(D.addVectors(V.min,Rt.min),V.expandByPoint(D),D.addVectors(V.max,Rt.max),V.expandByPoint(D)):(V.expandByPoint(Rt.min),V.expandByPoint(Rt.max))}V.getCenter(e);let s=0;for(let n=0,r=t.count;n<r;n++)D.fromBufferAttribute(t,n),s=Math.max(s,e.distanceToSquared(D));if(i)for(let n=0,r=i.length;n<r;n++){const h=i[n],o=this.morphTargetsRelative;for(let a=0,l=h.count;a<l;a++)D.fromBufferAttribute(h,a),o&&(Ct.fromBufferAttribute(t,a),D.add(Ct)),s=Math.max(s,e.distanceToSquared(D))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&yt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,i=this.attributes;if(t===null||i.position===void 0||i.normal===void 0||i.uv===void 0){yt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const e=i.position,s=i.normal,n=i.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new It(new Float32Array(4*e.count),4));const r=this.getAttribute("tangent"),h=[],o=[];for(let z=0;z<e.count;z++)h[z]=new x,o[z]=new x;const a=new x,l=new x,c=new x,u=new H,d=new H,p=new H,m=new x,g=new x;function f(z,T,C){a.fromBufferAttribute(e,z),l.fromBufferAttribute(e,T),c.fromBufferAttribute(e,C),u.fromBufferAttribute(n,z),d.fromBufferAttribute(n,T),p.fromBufferAttribute(n,C),l.sub(a),c.sub(a),d.sub(u),p.sub(u);const B=1/(d.x*p.y-p.x*d.y);isFinite(B)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(B),g.copy(c).multiplyScalar(d.x).addScaledVector(l,-p.x).multiplyScalar(B),h[z].add(m),h[T].add(m),h[C].add(m),o[z].add(g),o[T].add(g),o[C].add(g))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let z=0,T=b.length;z<T;++z){const C=b[z],B=C.start,v=C.count;for(let I=B,U=B+v;I<U;I+=3)f(t.getX(I+0),t.getX(I+1),t.getX(I+2))}const _=new x,M=new x,w=new x,S=new x;function F(z){w.fromBufferAttribute(s,z),S.copy(w);const T=h[z];_.copy(T),_.sub(w.multiplyScalar(w.dot(T))).normalize(),M.crossVectors(S,T);const B=M.dot(o[z])<0?-1:1;r.setXYZW(z,_.x,_.y,_.z,B)}for(let z=0,T=b.length;z<T;++z){const C=b[z],B=C.start,v=C.count;for(let I=B,U=B+v;I<U;I+=3)F(t.getX(I+0)),F(t.getX(I+1)),F(t.getX(I+2))}}computeVertexNormals(){const t=this.index,i=this.getAttribute("position");if(i!==void 0){let e=this.getAttribute("normal");if(e===void 0)e=new It(new Float32Array(i.count*3),3),this.setAttribute("normal",e);else for(let u=0,d=e.count;u<d;u++)e.setXYZ(u,0,0,0);const s=new x,n=new x,r=new x,h=new x,o=new x,a=new x,l=new x,c=new x;if(t)for(let u=0,d=t.count;u<d;u+=3){const p=t.getX(u+0),m=t.getX(u+1),g=t.getX(u+2);s.fromBufferAttribute(i,p),n.fromBufferAttribute(i,m),r.fromBufferAttribute(i,g),l.subVectors(r,n),c.subVectors(s,n),l.cross(c),h.fromBufferAttribute(e,p),o.fromBufferAttribute(e,m),a.fromBufferAttribute(e,g),h.add(l),o.add(l),a.add(l),e.setXYZ(p,h.x,h.y,h.z),e.setXYZ(m,o.x,o.y,o.z),e.setXYZ(g,a.x,a.y,a.z)}else for(let u=0,d=i.count;u<d;u+=3)s.fromBufferAttribute(i,u+0),n.fromBufferAttribute(i,u+1),r.fromBufferAttribute(i,u+2),l.subVectors(r,n),c.subVectors(s,n),l.cross(c),e.setXYZ(u+0,l.x,l.y,l.z),e.setXYZ(u+1,l.x,l.y,l.z),e.setXYZ(u+2,l.x,l.y,l.z);this.normalizeNormals(),e.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let i=0,e=t.count;i<e;i++)D.fromBufferAttribute(t,i),D.normalize(),t.setXYZ(i,D.x,D.y,D.z)}toNonIndexed(){function t(h,o){const a=h.array,l=h.itemSize,c=h.normalized,u=new a.constructor(o.length*l);let d=0,p=0;for(let m=0,g=o.length;m<g;m++){h.isInterleavedBufferAttribute?d=o[m]*h.data.stride+h.offset:d=o[m]*l;for(let f=0;f<l;f++)u[p++]=a[d++]}return new It(u,l,c)}if(this.index===null)return N("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const i=new mi,e=this.index.array,s=this.attributes;for(const h in s){const o=s[h],a=t(o,e);i.setAttribute(h,a)}const n=this.morphAttributes;for(const h in n){const o=[],a=n[h];for(let l=0,c=a.length;l<c;l++){const u=a[l],d=t(u,e);o.push(d)}i.morphAttributes[h]=o}i.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let h=0,o=r.length;h<o;h++){const a=r[h];i.addGroup(a.start,a.count,a.materialIndex)}return i}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const a in o)o[a]!==void 0&&(t[a]=o[a]);return t}t.data={attributes:{}};const i=this.index;i!==null&&(t.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});const e=this.attributes;for(const o in e){const a=e[o];t.data.attributes[o]=a.toJSON(t.data)}const s={};let n=!1;for(const o in this.morphAttributes){const a=this.morphAttributes[o],l=[];for(let c=0,u=a.length;c<u;c++){const d=a[c];l.push(d.toJSON(t.data))}l.length>0&&(s[o]=l,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const h=this.boundingSphere;return h!==null&&(t.data.boundingSphere=h.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const i={};this.name=t.name;const e=t.index;e!==null&&this.setIndex(e.clone());const s=t.attributes;for(const a in s){const l=s[a];this.setAttribute(a,l.clone(i))}const n=t.morphAttributes;for(const a in n){const l=[],c=n[a];for(let u=0,d=c.length;u<d;u++)l.push(c[u].clone(i));this.morphAttributes[a]=l}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let a=0,l=r.length;a<l;a++){const c=r[a];this.addGroup(c.start,c.count,c.materialIndex)}const h=t.boundingBox;h!==null&&(this.boundingBox=h.clone());const o=t.boundingSphere;return o!==null&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let He=0;class Ge extends pi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:He++}),this.uuid=Pt(),this.name="",this.type="Material",this.blending=Wi,this.side=vi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=qi,this.blendDst=Ui,this.blendEquation=Vi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new fi(0,0,0),this.blendAlpha=0,this.depthFunc=Yi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=$i,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gt,this.stencilZFail=gt,this.stencilZPass=gt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const i in t){const e=t[i];if(e===void 0){N(`Material: parameter '${i}' has value of undefined.`);continue}const s=this[i];if(s===void 0){N(`Material: '${i}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(e):s&&s.isVector3&&e&&e.isVector3?s.copy(e):this[i]=e}}toJSON(t){const i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{}});const e={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.color&&this.color.isColor&&(e.color=this.color.getHex()),this.roughness!==void 0&&(e.roughness=this.roughness),this.metalness!==void 0&&(e.metalness=this.metalness),this.sheen!==void 0&&(e.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(e.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(e.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(e.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(e.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(e.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(e.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(e.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(e.shininess=this.shininess),this.clearcoat!==void 0&&(e.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(e.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(e.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(e.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(e.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,e.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(e.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(e.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(e.dispersion=this.dispersion),this.iridescence!==void 0&&(e.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(e.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(e.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(e.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(e.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(e.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(e.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(e.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(e.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(e.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(e.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(e.lightMap=this.lightMap.toJSON(t).uuid,e.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(e.aoMap=this.aoMap.toJSON(t).uuid,e.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(e.bumpMap=this.bumpMap.toJSON(t).uuid,e.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(e.normalMap=this.normalMap.toJSON(t).uuid,e.normalMapType=this.normalMapType,e.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(e.displacementMap=this.displacementMap.toJSON(t).uuid,e.displacementScale=this.displacementScale,e.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(e.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(e.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(e.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(e.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(e.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(e.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(e.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(e.combine=this.combine)),this.envMapRotation!==void 0&&(e.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(e.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(e.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(e.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(e.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(e.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(e.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(e.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(e.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(e.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(e.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(e.size=this.size),this.shadowSide!==null&&(e.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(e.sizeAttenuation=this.sizeAttenuation),this.blending!==Wi&&(e.blending=this.blending),this.side!==vi&&(e.side=this.side),this.vertexColors===!0&&(e.vertexColors=!0),this.opacity<1&&(e.opacity=this.opacity),this.transparent===!0&&(e.transparent=!0),this.blendSrc!==qi&&(e.blendSrc=this.blendSrc),this.blendDst!==Ui&&(e.blendDst=this.blendDst),this.blendEquation!==Vi&&(e.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(e.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(e.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(e.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(e.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(e.blendAlpha=this.blendAlpha),this.depthFunc!==Yi&&(e.depthFunc=this.depthFunc),this.depthTest===!1&&(e.depthTest=this.depthTest),this.depthWrite===!1&&(e.depthWrite=this.depthWrite),this.colorWrite===!1&&(e.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(e.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==$i&&(e.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(e.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(e.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gt&&(e.stencilFail=this.stencilFail),this.stencilZFail!==gt&&(e.stencilZFail=this.stencilZFail),this.stencilZPass!==gt&&(e.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(e.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(e.rotation=this.rotation),this.polygonOffset===!0&&(e.polygonOffset=!0),this.polygonOffsetFactor!==0&&(e.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(e.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(e.linewidth=this.linewidth),this.dashSize!==void 0&&(e.dashSize=this.dashSize),this.gapSize!==void 0&&(e.gapSize=this.gapSize),this.scale!==void 0&&(e.scale=this.scale),this.dithering===!0&&(e.dithering=!0),this.alphaTest>0&&(e.alphaTest=this.alphaTest),this.alphaHash===!0&&(e.alphaHash=!0),this.alphaToCoverage===!0&&(e.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(e.premultipliedAlpha=!0),this.forceSinglePass===!0&&(e.forceSinglePass=!0),this.allowOverride===!1&&(e.allowOverride=!1),this.wireframe===!0&&(e.wireframe=!0),this.wireframeLinewidth>1&&(e.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(e.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(e.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(e.flatShading=!0),this.visible===!1&&(e.visible=!1),this.toneMapped===!1&&(e.toneMapped=!1),this.fog===!1&&(e.fog=!1),Object.keys(this.userData).length>0&&(e.userData=this.userData);function s(n){const r=[];for(const h in n){const o=n[h];delete o.metadata,r.push(o)}return r}if(i){const n=s(t.textures),r=s(t.images);n.length>0&&(e.textures=n),r.length>0&&(e.images=r)}return e}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const i=t.clippingPlanes;let e=null;if(i!==null){const s=i.length;e=new Array(s);for(let n=0;n!==s;++n)e[n]=i[n].clone()}return this.clippingPlanes=e,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}const st=new x,Di=new x,ii=new x,ut=new x,Ri=new x,ei=new x,Pi=new x;class Qe{constructor(t=new x,i=new x(0,0,-1)){this.origin=t,this.direction=i}set(t,i){return this.origin.copy(t),this.direction.copy(i),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,i){return i.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,st)),this}closestPointToPoint(t,i){i.subVectors(t,this.origin);const e=i.dot(this.direction);return e<0?i.copy(this.origin):i.copy(this.origin).addScaledVector(this.direction,e)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const i=st.subVectors(t,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(t):(st.copy(this.origin).addScaledVector(this.direction,i),st.distanceToSquared(t))}distanceSqToSegment(t,i,e,s){Di.copy(t).add(i).multiplyScalar(.5),ii.copy(i).sub(t).normalize(),ut.copy(this.origin).sub(Di);const n=t.distanceTo(i)*.5,r=-this.direction.dot(ii),h=ut.dot(this.direction),o=-ut.dot(ii),a=ut.lengthSq(),l=Math.abs(1-r*r);let c,u,d,p;if(l>0)if(c=r*o-h,u=r*h-o,p=n*l,c>=0)if(u>=-p)if(u<=p){const m=1/l;c*=m,u*=m,d=c*(c+r*u+2*h)+u*(r*c+u+2*o)+a}else u=n,c=Math.max(0,-(r*u+h)),d=-c*c+u*(u+2*o)+a;else u=-n,c=Math.max(0,-(r*u+h)),d=-c*c+u*(u+2*o)+a;else u<=-p?(c=Math.max(0,-(-r*n+h)),u=c>0?-n:Math.min(Math.max(-n,-o),n),d=-c*c+u*(u+2*o)+a):u<=p?(c=0,u=Math.min(Math.max(-n,-o),n),d=u*(u+2*o)+a):(c=Math.max(0,-(r*n+h)),u=c>0?n:Math.min(Math.max(-n,-o),n),d=-c*c+u*(u+2*o)+a);else u=r>0?-n:n,c=Math.max(0,-(r*u+h)),d=-c*c+u*(u+2*o)+a;return e&&e.copy(this.origin).addScaledVector(this.direction,c),s&&s.copy(Di).addScaledVector(ii,u),d}intersectSphere(t,i){st.subVectors(t.center,this.origin);const e=st.dot(this.direction),s=st.dot(st)-e*e,n=t.radius*t.radius;if(s>n)return null;const r=Math.sqrt(n-s),h=e-r,o=e+r;return o<0?null:h<0?this.at(o,i):this.at(h,i)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const i=t.normal.dot(this.direction);if(i===0)return t.distanceToPoint(this.origin)===0?0:null;const e=-(this.origin.dot(t.normal)+t.constant)/i;return e>=0?e:null}intersectPlane(t,i){const e=this.distanceToPlane(t);return e===null?null:this.at(e,i)}intersectsPlane(t){const i=t.distanceToPoint(this.origin);return i===0||t.normal.dot(this.direction)*i<0}intersectBox(t,i){let e,s,n,r,h,o;const a=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,u=this.origin;return a>=0?(e=(t.min.x-u.x)*a,s=(t.max.x-u.x)*a):(e=(t.max.x-u.x)*a,s=(t.min.x-u.x)*a),l>=0?(n=(t.min.y-u.y)*l,r=(t.max.y-u.y)*l):(n=(t.max.y-u.y)*l,r=(t.min.y-u.y)*l),e>r||n>s||((n>e||isNaN(e))&&(e=n),(r<s||isNaN(s))&&(s=r),c>=0?(h=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(h=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),e>o||h>s)||((h>e||e!==e)&&(e=h),(o<s||s!==s)&&(s=o),s<0)?null:this.at(e>=0?e:s,i)}intersectsBox(t){return this.intersectBox(t,st)!==null}intersectTriangle(t,i,e,s,n){Ri.subVectors(i,t),ei.subVectors(e,t),Pi.crossVectors(Ri,ei);let r=this.direction.dot(Pi),h;if(r>0){if(s)return null;h=1}else if(r<0)h=-1,r=-r;else return null;ut.subVectors(this.origin,t);const o=h*this.direction.dot(ei.crossVectors(ut,ei));if(o<0)return null;const a=h*this.direction.dot(Ri.cross(ut));if(a<0||o+a>r)return null;const l=-h*ut.dot(Pi);return l<0?null:this.at(l/r,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ui extends Ge{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new fi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Lt,this.combine=Ae,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const de=new G,mt=new Qe,si=new _e,pe=new x,ni=new x,ri=new x,oi=new x,Ni=new x,hi=new x,fe=new x,ai=new x;class me extends ot{constructor(t=new mi,i=new ui){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=i,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,i){return super.copy(t,i),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const i=this.geometry.morphAttributes,e=Object.keys(i);if(e.length>0){const s=i[e[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const h=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[h]=n}}}}getVertexPosition(t,i){const e=this.geometry,s=e.attributes.position,n=e.morphAttributes.position,r=e.morphTargetsRelative;i.fromBufferAttribute(s,t);const h=this.morphTargetInfluences;if(n&&h){hi.set(0,0,0);for(let o=0,a=n.length;o<a;o++){const l=h[o],c=n[o];l!==0&&(Ni.fromBufferAttribute(c,t),r?hi.addScaledVector(Ni,l):hi.addScaledVector(Ni.sub(i),l))}i.add(hi)}return i}raycast(t,i){const e=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(e.boundingSphere===null&&e.computeBoundingSphere(),si.copy(e.boundingSphere),si.applyMatrix4(n),mt.copy(t.ray).recast(t.near),!(si.containsPoint(mt.origin)===!1&&(mt.intersectSphere(si,pe)===null||mt.origin.distanceToSquared(pe)>(t.far-t.near)**2))&&(de.copy(n).invert(),mt.copy(t.ray).applyMatrix4(de),!(e.boundingBox!==null&&mt.intersectsBox(e.boundingBox)===!1)&&this._computeIntersections(t,i,mt)))}_computeIntersections(t,i,e){let s;const n=this.geometry,r=this.material,h=n.index,o=n.attributes.position,a=n.attributes.uv,l=n.attributes.uv1,c=n.attributes.normal,u=n.groups,d=n.drawRange;if(h!==null)if(Array.isArray(r))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=r[g.materialIndex],b=Math.max(g.start,d.start),_=Math.min(h.count,Math.min(g.start+g.count,d.start+d.count));for(let M=b,w=_;M<w;M+=3){const S=h.getX(M),F=h.getX(M+1),z=h.getX(M+2);s=li(this,f,t,e,a,l,c,S,F,z),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=g.materialIndex,i.push(s))}}else{const p=Math.max(0,d.start),m=Math.min(h.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=h.getX(g),_=h.getX(g+1),M=h.getX(g+2);s=li(this,r,t,e,a,l,c,b,_,M),s&&(s.faceIndex=Math.floor(g/3),i.push(s))}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,m=u.length;p<m;p++){const g=u[p],f=r[g.materialIndex],b=Math.max(g.start,d.start),_=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let M=b,w=_;M<w;M+=3){const S=M,F=M+1,z=M+2;s=li(this,f,t,e,a,l,c,S,F,z),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=g.materialIndex,i.push(s))}}else{const p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let g=p,f=m;g<f;g+=3){const b=g,_=g+1,M=g+2;s=li(this,r,t,e,a,l,c,b,_,M),s&&(s.faceIndex=Math.floor(g/3),i.push(s))}}}}function Ke(y,t,i,e,s,n,r,h){let o;if(t.side===Se?o=e.intersectTriangle(r,n,s,!0,h):o=e.intersectTriangle(s,n,r,t.side===vi,h),o===null)return null;ai.copy(h),ai.applyMatrix4(y.matrixWorld);const a=i.ray.origin.distanceTo(ai);return a<i.near||a>i.far?null:{distance:a,point:ai.clone(),object:y}}function li(y,t,i,e,s,n,r,h,o,a){y.getVertexPosition(h,ni),y.getVertexPosition(o,ri),y.getVertexPosition(a,oi);const l=Ke(y,t,i,e,ni,ri,oi,fe);if(l){const c=new x;$.getBarycoord(fe,ni,ri,oi,c),s&&(l.uv=$.getInterpolatedAttribute(s,h,o,a,c,new H)),n&&(l.uv1=$.getInterpolatedAttribute(n,h,o,a,c,new H)),r&&(l.normal=$.getInterpolatedAttribute(r,h,o,a,c,new x),l.normal.dot(e.direction)>0&&l.normal.multiplyScalar(-1));const u={a:h,b:o,c:a,normal:new x,materialIndex:0};$.getNormal(ni,ri,oi,u.normal),l.face=u,l.barycoord=c}return l}class Li extends mi{constructor(t=1,i=32,e=16,s=0,n=Math.PI*2,r=0,h=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:i,heightSegments:e,phiStart:s,phiLength:n,thetaStart:r,thetaLength:h},i=Math.max(3,Math.floor(i)),e=Math.max(2,Math.floor(e));const o=Math.min(r+h,Math.PI);let a=0;const l=[],c=new x,u=new x,d=[],p=[],m=[],g=[];for(let f=0;f<=e;f++){const b=[],_=f/e;let M=0;f===0&&r===0?M=.5/i:f===e&&o===Math.PI&&(M=-.5/i);for(let w=0;w<=i;w++){const S=w/i;c.x=-t*Math.cos(s+S*n)*Math.sin(r+_*h),c.y=t*Math.cos(r+_*h),c.z=t*Math.sin(s+S*n)*Math.sin(r+_*h),p.push(c.x,c.y,c.z),u.copy(c).normalize(),m.push(u.x,u.y,u.z),g.push(S+M,1-_),b.push(a++)}l.push(b)}for(let f=0;f<e;f++)for(let b=0;b<i;b++){const _=l[f][b+1],M=l[f][b],w=l[f+1][b],S=l[f+1][b+1];(f!==0||r>0)&&d.push(_,M,S),(f!==e-1||o<Math.PI)&&d.push(M,w,S)}this.setIndex(d),this.setAttribute("position",new ci(p,3)),this.setAttribute("normal",new ci(m,3)),this.setAttribute("uv",new ci(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Li(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ye}}));typeof window<"u"&&(window.__THREE__?N("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ye);const ts="__ustudio_label__",nt=class nt{constructor(t,i={}){E(this,"ssp");E(this,"yExtendSpacing");E(this,"originalScales",new Map);E(this,"originalPositionsY",new Map);E(this,"opacityTargets",[]);E(this,"hiddenTargets",[]);E(this,"hiddenStoryTargets",[]);E(this,"hiddenStoryLabelTargets",[]);E(this,"labelPoiIds",new Map);E(this,"originalWindowDoorPosY",new Map);E(this,"originalWindowDoorMaterials",new Map);E(this,"outlineTopologyIds",new Map);E(this,"reachableTopologyId",null);E(this,"reachableAnimFrameId",null);E(this,"reachableAnimDots",[]);E(this,"_reachableEdges",null);E(this,"_reachableTreeData",null);this.ssp=t,this.yExtendSpacing=i.yExtendSpacing??5}async setViewMode(t,i){var h;const e=Array.isArray(t)?t:[t],s=e.find(o=>o.type==="2D"),n=e.find(o=>o.type==="3D");if(s&&n){const o=s.ids??[],a=n.ids??[];if(o.length===0&&a.length===0)throw new Error("2D 和 3D 模式同时存在时,ids 不能同时为空");const l=o.filter(c=>a.includes(c));if(l.length>0)throw new Error(`2D 和 3D 模式的 ids 存在重复:${l.join(", ")}`)}await this.resetAll(i);for(const o of e)await this.applyMode(o,i);if(e.some(o=>o.hideWalls)){const o=this.collectByIdentifiers(i,["Story"]);for(const a of o){if(!a.out_instance_id)continue;const l=this.ssp.getObjectById(a.out_instance_id);if(!((h=l==null?void 0:l.parent)!=null&&h.children[0]))continue;const c=l.parent.children[0];c.visible=!1,this.hiddenTargets.push(c)}}if(e.some(o=>o.hideWindowAndDoor)){const o=this.collectByIdentifiers(i,["Window","Door"]);for(const a of o){if(!a.out_instance_id)continue;const l=this.ssp.getObjectById(a.out_instance_id);l&&(l.visible=!1,this.hiddenTargets.push(l))}}const r=e.some(o=>o.type==="YExtend");this._reachableEdges&&this._reachableTreeData&&this.drawReachableRoutes(this._reachableEdges,this._reachableTreeData,r),this.ssp.render()}async applyMode(t,i){const{type:e,ids:s=[]}=t;if(e!=="3D"){if(e==="2D"){const n=this.collectByIdentifiers(i,["Story"]);for(const r of n){if(!r.out_instance_id||s.length>0&&!s.includes(r.out_instance_id))continue;const h=this.ssp.getObjectById(r.out_instance_id);if(!(h!=null&&h.parent))continue;const o=h.parent,l=new Q().setFromObject(o).min.y;this.originalScales.has(r.out_instance_id)||(this.originalScales.set(r.out_instance_id,o.scale.y),this.originalPositionsY.set(r.out_instance_id,o.position.y)),o.scale.set(o.scale.x,.01,o.scale.z),o.position.y=l,o.updateMatrix(),o.updateMatrixWorld(!0);const c={Window:2201331,Door:16757504},u=this.collectByIdentifiers(r.children??[],["Window","Door"]);for(const d of u){if(!d.out_instance_id||!d.twins_identifier)continue;const p=this.ssp.getObjectById(d.out_instance_id);if(!(p!=null&&p.parent))continue;this.originalWindowDoorPosY.has(d.out_instance_id)||this.originalWindowDoorPosY.set(d.out_instance_id,p.position.y);const m=new x;if(p.getWorldPosition(m),m.y=l+.02,p.parent.worldToLocal(m),p.position.y=m.y,p.updateMatrix(),p.updateMatrixWorld(!0),!this.originalWindowDoorMaterials.has(d.out_instance_id)){const g=[];p.traverse(f=>{f instanceof me&&(g.push({mesh:f,mat:f.material}),f.material=new ui({color:c[d.twins_identifier]}))}),this.originalWindowDoorMaterials.set(d.out_instance_id,g)}}}return}e==="YExtend"&&this.collectByIdentifiers(i,["Story"]).forEach((r,h)=>{if(!r.out_instance_id)return;const o=h*this.yExtendSpacing;if(o===0)return;const a=this.ssp.getObjectById(r.out_instance_id);if(!(a!=null&&a.parent))return;const l=a.parent;this.originalPositionsY.has(r.out_instance_id)||this.originalPositionsY.set(r.out_instance_id,l.position.y),console.log(l.position),l.position.y+=o,l.updateMatrix(),l.updateMatrixWorld(!0)})}}async resetAll(t){this.opacityTargets.length>0&&(await this.ssp.unOpacityShow(this.opacityTargets),this.opacityTargets=[]);for(const e of this.hiddenTargets)e.visible=!0;this.hiddenTargets=[];const i=[...this.collectByIdentifiers(t,["Story"]),...this.collectStoryChildren(t)];for(const e of i){if(!e.out_instance_id)continue;const s=this.ssp.getObjectById(e.out_instance_id);if(!(s!=null&&s.parent))continue;const n=s.parent;let r=!1;this.originalScales.has(e.out_instance_id)&&(n.scale.y=this.originalScales.get(e.out_instance_id),r=!0),this.originalPositionsY.has(e.out_instance_id)&&(n.position.y=this.originalPositionsY.get(e.out_instance_id),r=!0),r&&(n.updateMatrix(),n.updateMatrixWorld(!0))}this.originalScales.clear(),this.originalPositionsY.clear();for(const[e,s]of this.originalWindowDoorPosY){const n=this.ssp.getObjectById(e);n&&(n.position.y=s,n.updateMatrix(),n.updateMatrixWorld(!0))}this.originalWindowDoorPosY.clear();for(const e of this.originalWindowDoorMaterials.values())for(const{mesh:s,mat:n}of e)s.material=n;this.originalWindowDoorMaterials.clear()}showTwinsNameLabels(t,i=["Building","Story"],e){this.hideTwinsNameLabels(i,e);const s=this.collectByIdentifiers(t,i),n=e&&e.length>0?s.filter(r=>{if(!r.out_instance_id)return!1;if(r.twins_identifier==="Story")return e.includes(r.out_instance_id);const h=this.findAncestorStoryId(t,r.out_instance_id);return h?e.includes(h):!1}):s;for(const r of n){if(!r.out_instance_id||!r.twins_name||!r.twins_identifier)continue;const h=this.ssp.getObjectById(r.out_instance_id);if(!h)continue;const o=r.twins_identifier==="Building"||r.twins_identifier==="Story",a=o?h.parent??h:h,l=o?new Q().setFromObject(a).getCenter(new x):this.ssp.getObjectLabelPos(a),c=`${ts}${r.out_instance_id}`,u=document.createElement("div");u.textContent=r.twins_name,u.style.cssText="color:#fff;background:rgba(0,0,0,.6);padding:2px 8px;border-radius:4px;font:14px sans-serif;white-space:nowrap;pointer-events:none;",this.ssp.createPoiNode({id:c,name:r.twins_name,position:{x:l.x,y:l.y,z:l.z},type:"2D",element:u});const d=r.twins_identifier==="Story"?r.out_instance_id:this.findAncestorStoryId(t,r.out_instance_id)??"",p=this.labelPoiIds.get(r.twins_identifier)??new Map,m=p.get(d)??[];m.push(c),p.set(d,m),this.labelPoiIds.set(r.twins_identifier,p)}}hideStories(t,i){this.showStories();const e=this.collectByIdentifiers(t,["Story"]),s=i&&i.length>0?e.filter(n=>n.out_instance_id&&i.includes(n.out_instance_id)):e;for(const n of s){if(!n.out_instance_id)continue;const r=this.ssp.getObjectById(n.out_instance_id);if(r!=null&&r.parent){r.parent.visible=!1,this.hiddenStoryTargets.push(r.parent);for(const h of this.labelPoiIds.values()){const o=h.get(n.out_instance_id)??[];for(const a of o){const l=this.ssp.getObjectById(a);l&&(l.visible=!1,this.hiddenStoryLabelTargets.push(l))}}}}this.ssp.render()}getVisibleStoryIds(t){return this.collectByIdentifiers(t,["Story"]).filter(e=>{var n;if(!e.out_instance_id)return!1;const s=this.ssp.getObjectById(e.out_instance_id);return((n=s==null?void 0:s.parent)==null?void 0:n.visible)!==!1}).map(e=>e.out_instance_id)}showStories(){for(const t of this.hiddenStoryTargets)t.visible=!0;this.hiddenStoryTargets=[];for(const t of this.hiddenStoryLabelTargets)t.visible=!0;this.hiddenStoryLabelTargets=[],this.ssp.render()}hideTwinsNameLabels(t,i){const e=t??[...this.labelPoiIds.keys()];for(const s of e){const n=this.labelPoiIds.get(s);if(n)if(i&&i.length>0){for(const r of i){const h=n.get(r)??[];for(const o of h)this.ssp.removePoiById(o);n.delete(r)}n.size===0&&this.labelPoiIds.delete(s)}else{for(const r of n.values())for(const h of r)this.ssp.removePoiById(h);this.labelPoiIds.delete(s)}}}drawOutlineLines(t,i){this.clearOutlineLines(i);const e=this.collectByIdentifiers(t,[i]),s=[],n=nt.OUTLINE_LINE_COLORS[i];for(const r of e){if(!r.out_instance_id)continue;const h=this.ssp.getObjectById(r.out_instance_id);if(!h)continue;const o=new Q().setFromObject(h);if(o.isEmpty())continue;const a=(o.min.y+o.max.y)/2,l=`__ustudio_outline_${i}_${r.out_instance_id}`,c=`${l}_0`,u=`${l}_1`,d=`${l}_2`,p=`${l}_3`;this.ssp.createTopology({id:l,name:l,type:"line",renderNode:!1,linkColor:n,linkWidth:2,nodes:[{id:c,position:{x:o.min.x,y:a,z:o.min.z},graphs:[{targetNodeId:u,linkInfo:{id:`${l}_l01`},passable:1}]},{id:u,position:{x:o.max.x,y:a,z:o.min.z},graphs:[{targetNodeId:d,linkInfo:{id:`${l}_l12`},passable:1}]},{id:d,position:{x:o.max.x,y:a,z:o.max.z},graphs:[{targetNodeId:p,linkInfo:{id:`${l}_l23`},passable:1}]},{id:p,position:{x:o.min.x,y:a,z:o.max.z},graphs:[{targetNodeId:c,linkInfo:{id:`${l}_l30`},passable:1}]}]}),s.push(l)}this.outlineTopologyIds.set(i,s),this.ssp.render()}clearOutlineLines(t){const i=t?[t]:Object.keys(nt.OUTLINE_LINE_COLORS);for(const e of i){const s=this.outlineTopologyIds.get(e)??[];for(const n of s)this.ssp.removeTopologyById(n);this.outlineTopologyIds.delete(e)}this.ssp.render()}drawReachableRoutes(t,i,e=!1){this._clearReachableVisuals(),this._reachableEdges=t,this._reachableTreeData=i;const s=new Map;for(const f of this.collectByIdentifiers(i,["Story"])){if(!f.out_instance_id)continue;const b=this.ssp.getObjectById(f.out_instance_id);if(!(b!=null&&b.parent))continue;const _=new Q().setFromObject(b.parent).min.y;for(const M of this.collectStoryChildren([f]))M.out_instance_id&&s.set(M.out_instance_id,_)}const n="__reachable_node__",r=.3,h=new Map;for(const f of t)for(const b of[f.start_out_instance_id,f.end_out_instance_id]){if(!b||h.has(b))continue;const _=this.ssp.getObjectById(b);if(!_)continue;const M=new Q().setFromObject(_).getCenter(new x),w=s.get(b)??M.y;h.set(b,{x:M.x,y:w+r,z:M.z})}if(h.size===0)return;const o=new Map;for(const f of t){const{start_out_instance_id:b,end_out_instance_id:_}=f;if(!h.has(b)||!h.has(_))continue;const M=o.get(b)??[],w=`${n}${b}__${_}`;M.push({targetNodeId:n+_,linkInfo:{id:w},passable:1}),o.set(b,M)}const a=[...h.entries()].map(([f,b])=>({id:n+f,position:b,graphs:o.get(f)??[]})),l=this.ssp.createTopology({id:nt.REACHABLE_TOPOLOGY_ID,name:nt.REACHABLE_TOPOLOGY_ID,type:"network",renderNode:!0,nodeColor:6746256,nodeRadius:r,linkColor:6746256,linkWidth:.15,nodes:a}),c=new ui({color:6746256});l.nodes.forEach(f=>{f.material=c,f.mesh.material=c}),this.reachableTopologyId=nt.REACHABLE_TOPOLOGY_ID;const u=new Li(.15,8,8),d=new ui({color:16777215}),p=[];for(const f of t){const b=h.get(f.start_out_instance_id),_=h.get(f.end_out_instance_id);if(!b||!_)continue;const M=new me(u,d);M.position.set(b.x,b.y,b.z),this.ssp.addObject(M),this.reachableAnimDots.push(M),p.push({mesh:M,start:new x(b.x,b.y,b.z),end:new x(_.x,_.y,_.z),t:0,dir:1})}const m=.008,g=()=>{for(const f of p)f.t+=m*f.dir,f.t>=1?(f.t=1,f.dir=-1):f.t<=0&&(f.t=0,f.dir=1),f.mesh.position.lerpVectors(f.start,f.end,f.t);this.ssp.render(),this.reachableAnimFrameId=requestAnimationFrame(g)};this.reachableAnimFrameId=requestAnimationFrame(g)}clearReachableRoutes(){this._clearReachableVisuals(),this._reachableEdges=null,this._reachableTreeData=null,this.ssp.render()}_clearReachableVisuals(){this.reachableAnimFrameId!==null&&(cancelAnimationFrame(this.reachableAnimFrameId),this.reachableAnimFrameId=null);for(const t of this.reachableAnimDots)t.removeFromParent();this.reachableAnimDots=[],this.reachableTopologyId&&(this.ssp.removeTopologyById(this.reachableTopologyId),this.reachableTopologyId=null)}findAncestorStoryId(t,i){for(const e of t)if(e.twins_identifier==="Story"&&e.children){if(this.hasDescendant(e.children,i))return e.out_instance_id}else if(e.children){const s=this.findAncestorStoryId(e.children,i);if(s)return s}return null}hasDescendant(t,i){for(const e of t)if(e.out_instance_id===i||e.children&&this.hasDescendant(e.children,i))return!0;return!1}collectByIdentifiers(t,i){const e=[];for(const s of t)s.twins_identifier&&i.includes(s.twins_identifier)&&e.push(s),s.children&&e.push(...this.collectByIdentifiers(s.children,i));return e}collectStoryChildren(t){const i=[];for(const e of t)e.twins_identifier==="Story"?e.children&&i.push(...e.children):e.children&&i.push(...this.collectStoryChildren(e.children));return i}};E(nt,"OUTLINE_LINE_COLORS",{Wall:8947848,Window:48340,Door:16747520}),E(nt,"REACHABLE_TOPOLOGY_ID","__ustudio_reachable__");let di=nt;exports.SoonspaceUStudioPlugin=di;exports.default=di;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { default as default_2 } from 'soonspacejs';
|
|
2
|
+
|
|
3
|
+
declare type OutlineLineType = 'Wall' | 'Window' | 'Door';
|
|
4
|
+
|
|
5
|
+
export declare interface PluginOptions {
|
|
6
|
+
/** YExtend 模式下楼层之间的 Y 轴间距,默认 200 */
|
|
7
|
+
yExtendSpacing?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare interface ReachableEdge {
|
|
11
|
+
edge_id: string;
|
|
12
|
+
start_out_instance_id: string;
|
|
13
|
+
end_out_instance_id: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class SoonspaceUStudioPlugin {
|
|
18
|
+
private ssp;
|
|
19
|
+
private yExtendSpacing;
|
|
20
|
+
private originalScales;
|
|
21
|
+
private originalPositionsY;
|
|
22
|
+
private opacityTargets;
|
|
23
|
+
private hiddenTargets;
|
|
24
|
+
private hiddenStoryTargets;
|
|
25
|
+
private hiddenStoryLabelTargets;
|
|
26
|
+
/** identifier → storyId → poiId[],storyId 为空字符串表示节点不属于任何楼层 */
|
|
27
|
+
private labelPoiIds;
|
|
28
|
+
private originalWindowDoorPosY;
|
|
29
|
+
private originalWindowDoorMaterials;
|
|
30
|
+
private outlineTopologyIds;
|
|
31
|
+
private reachableTopologyId;
|
|
32
|
+
private reachableAnimFrameId;
|
|
33
|
+
private reachableAnimDots;
|
|
34
|
+
private _reachableEdges;
|
|
35
|
+
private _reachableTreeData;
|
|
36
|
+
constructor(ssp: default_2, options?: PluginOptions);
|
|
37
|
+
/**
|
|
38
|
+
* 切换模型展示模式,支持单个或多个模式同时生效
|
|
39
|
+
* - 2D + 3D 同时传入时:ids 不能同时为空,且 ids 不能有交集
|
|
40
|
+
* @param params 单个或多个模式参数
|
|
41
|
+
* @param treeData CPS 平台 Digital Twin 树形数据
|
|
42
|
+
*/
|
|
43
|
+
setViewMode(params: ViewModeParams | ViewModeParams[], treeData: TreeNode[]): Promise<void>;
|
|
44
|
+
private applyMode;
|
|
45
|
+
private resetAll;
|
|
46
|
+
/**
|
|
47
|
+
* 在指定类型节点的中心点显示 twins_name 文字标签
|
|
48
|
+
* @param treeData CPS 平台 Digital Twin 树形数据
|
|
49
|
+
* @param identifiers 要展示标签的 twins_identifier 类型列表,默认 ['Building', 'Story']
|
|
50
|
+
* @param storyIds 指定楼层 out_instance_id 列表,不传则展示全部楼层下的标签
|
|
51
|
+
*/
|
|
52
|
+
showTwinsNameLabels(treeData: TreeNode[], identifiers?: string[], storyIds?: string[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* 隐藏指定楼层(Story)
|
|
55
|
+
* @param treeData CPS 平台 Digital Twin 树形数据
|
|
56
|
+
* @param ids 要隐藏的 Story out_instance_id 列表,不传则隐藏全部楼层
|
|
57
|
+
*/
|
|
58
|
+
hideStories(treeData: TreeNode[], ids?: string[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* 获取当前可见楼层的 out_instance_id 列表
|
|
61
|
+
* @param treeData CPS 平台 Digital Twin 树形数据
|
|
62
|
+
*/
|
|
63
|
+
getVisibleStoryIds(treeData: TreeNode[]): string[];
|
|
64
|
+
/** 恢复所有通过 hideStories 隐藏的楼层 */
|
|
65
|
+
showStories(): void;
|
|
66
|
+
/**
|
|
67
|
+
* 移除通过 showTwinsNameLabels 创建的文字标签
|
|
68
|
+
* @param identifiers 要隐藏标签的 twins_identifier 类型列表,不传则移除全部类型
|
|
69
|
+
* @param storyIds 指定楼层 out_instance_id 列表,不传则移除全部楼层
|
|
70
|
+
*/
|
|
71
|
+
hideTwinsNameLabels(identifiers?: string[], storyIds?: string[]): void;
|
|
72
|
+
private static readonly OUTLINE_LINE_COLORS;
|
|
73
|
+
/**
|
|
74
|
+
* 在 2D 模式下为指定类型对象绘制包围盒轮廓线
|
|
75
|
+
* @param treeData CPS 平台 Digital Twin 树形数据
|
|
76
|
+
* @param lineType 线型类型:Wall 墙线 | Window 窗线 | Door 门线
|
|
77
|
+
*/
|
|
78
|
+
drawOutlineLines(treeData: TreeNode[], lineType: OutlineLineType): void;
|
|
79
|
+
/**
|
|
80
|
+
* 清除轮廓线
|
|
81
|
+
* @param lineType 不传则清除全部类型
|
|
82
|
+
*/
|
|
83
|
+
clearOutlineLines(lineType?: OutlineLineType): void;
|
|
84
|
+
private static readonly REACHABLE_TOPOLOGY_ID;
|
|
85
|
+
/**
|
|
86
|
+
* 绘制可达性路线,在每条边的起止对象中心点之间绘制带流动动画的连线
|
|
87
|
+
* @param edges 可达性边数据列表
|
|
88
|
+
* @param treeData CPS 平台 Digital Twin 树形数据,用于确定节点所属楼层地面 Y
|
|
89
|
+
* @param yExtend 当前是否处于楼层展开状态,影响节点 Y 坐标取值时机
|
|
90
|
+
*/
|
|
91
|
+
drawReachableRoutes(edges: ReachableEdge[], treeData: TreeNode[], yExtend?: boolean): void;
|
|
92
|
+
/** 清除可达性路线(视觉 + 保存的参数) */
|
|
93
|
+
clearReachableRoutes(): void;
|
|
94
|
+
/** 仅清除可达性路线的视觉对象,保留保存的参数供重绘使用 */
|
|
95
|
+
private _clearReachableVisuals;
|
|
96
|
+
private findAncestorStoryId;
|
|
97
|
+
private hasDescendant;
|
|
98
|
+
private collectByIdentifiers;
|
|
99
|
+
private collectStoryChildren;
|
|
100
|
+
}
|
|
101
|
+
export { SoonspaceUStudioPlugin }
|
|
102
|
+
export default SoonspaceUStudioPlugin;
|
|
103
|
+
|
|
104
|
+
export declare interface TreeNode {
|
|
105
|
+
sid: string | null;
|
|
106
|
+
source: string | null;
|
|
107
|
+
children: TreeNode[] | null;
|
|
108
|
+
twins_instance_id: string | null;
|
|
109
|
+
twins_instance_name: string | null;
|
|
110
|
+
twins_id: string | null;
|
|
111
|
+
twins_name: string | null;
|
|
112
|
+
twins_type: string | null;
|
|
113
|
+
twins_identifier: string | null;
|
|
114
|
+
out_instance_id: string | null;
|
|
115
|
+
parent_id: string | null;
|
|
116
|
+
node_type: string | null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare interface ViewModeParams {
|
|
120
|
+
type: ViewModeType;
|
|
121
|
+
/** Story 的 out_instance_id 列表。2D/3D 模式下为空则作用于全部楼层,有值则只作用于指定楼层 */
|
|
122
|
+
ids?: string[];
|
|
123
|
+
/** 仅 3D 模式有效:是否隐藏墙体。ids 为空隐藏全部楼层墙体,有值则仅隐藏指定楼层墙体 */
|
|
124
|
+
hideWalls?: boolean;
|
|
125
|
+
/** 仅 3D 模式有效:是否隐藏所有门窗(twins_identifier 为 Window 或 Door 的对象) */
|
|
126
|
+
hideWindowAndDoor?: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export declare type ViewModeType = '2D' | '3D' | 'YExtend';
|
|
130
|
+
|
|
131
|
+
export { }
|