UNPKG

@inweb/viewer-three

Version:

JavaScript library for rendering CAD and BIM files in a browser using Three.js

29 lines (28 loc) 1.22 MB
/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a // license agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Three=t.ODA.Three||{}))}(this,function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,n){this._commands.set(t,{id:t,handler:e,thisArg:n,description:i})}registerCommandAlias(t,e){this.registerCommand(e,(e,...i)=>this.executeCommand(t,e,...i))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach((e,i)=>t.set(i,e)),t}executeCommand(t,e,...i){const n=this._commands.get(t);if(!n){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:r,thisArg:s}=n,a=r.apply(s,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),a}}const i=new Map;function n(t=""){let n=i.get(t);return n||(n=new e,i.set(t,n)),n}class r{constructor(){this._providers=new Map}registerDragger(t,e){this._providers.set(t,e)}registerDraggerAlias(t,e){const i=this._providers.get(t);i&&this.registerDragger(e,t=>i(t))}getDraggers(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createDragger(t,e){const i=this._providers.get(t);if(!i)return null;const n=i(e);return n.name=t,n}}const s=new Map;function a(t=""){let e=s.get(t);return e||(e=new r,s.set(t,e)),e}class o{constructor(){this._providers=new Map}registerComponent(t,e){this._providers.set(t,e)}registerComponentAlias(t,e){const i=this._providers.get(t);i&&this.registerComponent(e,t=>i(t))}getComponents(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createComponent(t,e){const i=this._providers.get(t);if(!i)return null;const n=i(e);return n.name=t,n}}const h=new Map;function l(t=""){let e=h.get(t);return e||(e=new o,h.set(t,e)),e}let c=class{constructor(){this.name="",this.abortController=new AbortController}dispose(){this.abortController.abort(),this.abortController=void 0}isSupport(t,e){return!1}load(t,e,i){return Promise.resolve(this)}cancel(){this.abortController.abort()}extractFileName(t){const e=/[^/\\?#:]+(?=\?|#|$)/;return"string"==typeof t?(t.match(e)||[])[0]:t instanceof globalThis.File?(t.name.match(e)||[])[0]:void 0}};class d{constructor(){this._providers=new Map}registerLoader(t,e){this._providers.set(t,e)}getLoader(t){return this._providers.get(t)}getLoaders(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createLoader(t,e,i){let n=null;return this._providers.forEach((r,s)=>{const a=r(t);a.isSupport(e,i)&&(n=a,n.name=s)}),n}}const u=new Map;function p(t=""){let e=u.get(t);return e||(e=new d,u.set(t,e)),e}function m(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective"}}class f{constructor(t){this._emitter=t,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective"},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=f.defaults(),i=t.reduce((t,i)=>(t[i]=e[i],t),{});this.data={...this.data,...i}}else this.data={...this.data,...f.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...f.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(t){this._data.rulerUnit=t,this.change()}get rulerPrecision(){return this._data.rulerPrecision}set rulerPrecision(t){this._data.rulerPrecision=t,this.change()}get cameraMode(){return this._data.cameraMode||"perspective"}set cameraMode(t){this._data.cameraMode=t,this.change()}}const g=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],v=g;class y{constructor(){this.performance={fps:0,frameTime:0,timeToFirstRender:0,loadTime:0},this.render={viewport:{width:0,height:0},antialiasing:"",drawCalls:0,triangles:0,points:0,lines:0},this.scene={objects:0,triangles:0,points:0,lines:0,edges:0},this.optimizedScene={objects:0,triangles:0,points:0,lines:0,edges:0},this.memory={geometries:0,geometryBytes:0,textures:0,textureBytes:0,materials:0,totalEstimatedGpuBytes:0,usedJSHeapSize:0},this.system={webglRenderer:"",webglVendor:""}}} /** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */const _="180",x={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},w={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},b=0,S=1,M=2,E=100,T=101,A=102,C=200,R=201,P=202,L=203,I=204,D=205,O=206,N=207,U=208,F=209,z=210,k=211,B=212,G=213,H=214,V=0,W=1,j=2,X=3,Y=4,q=5,Z=6,K=7,J="attached",Q="detached",$=300,tt=301,et=302,it=303,nt=304,rt=306,st=1e3,at=1001,ot=1002,ht=1003,lt=1004,ct=1005,dt=1006,ut=1007,pt=1008,mt=1009,ft=1010,gt=1011,vt=1012,yt=1013,_t=1014,xt=1015,wt=1016,bt=1017,St=1018,Mt=1020,Et=35902,Tt=35899,At=1021,Ct=1022,Rt=1023,Pt=1026,Lt=1027,It=1028,Dt=1029,Ot=1030,Nt=1031,Ut=1033,Ft=33776,zt=33777,kt=33778,Bt=33779,Gt=35840,Ht=35841,Vt=35842,Wt=35843,jt=36196,Xt=37492,Yt=37496,qt=37808,Zt=37809,Kt=37810,Jt=37811,Qt=37812,$t=37813,te=37814,ee=37815,ie=37816,ne=37817,re=37818,se=37819,ae=37820,oe=37821,he=36492,le=36494,ce=36495,de=36283,ue=36284,pe=36285,me=36286,fe=2300,ge=2301,ve=2302,ye=2400,_e=2401,xe=2402,we=2500,be=2501,Se="",Me="srgb",Ee="srgb-linear",Te="linear",Ae="srgb",Ce=7680,Re=512,Pe=513,Le=514,Ie=515,De=516,Oe=517,Ne=518,Ue=519,Fe=35044,ze="300 es",ke=2e3,Be=2001;class Ge{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i&&(void 0!==i[t]&&-1!==i[t].indexOf(e))}removeEventListener(t,e){const i=this._listeners;if(void 0===i)return;const n=i[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const i=e[t.type];if(void 0!==i){t.target=this;const e=i.slice(0);for(let i=0,n=e.length;i<n;i++)e[i].call(this,t);t.target=null}}}const He=["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"];let Ve=1234567;const We=Math.PI/180,je=180/Math.PI;function Xe(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(He[255&t]+He[t>>8&255]+He[t>>16&255]+He[t>>24&255]+"-"+He[255&e]+He[e>>8&255]+"-"+He[e>>16&15|64]+He[e>>24&255]+"-"+He[63&i|128]+He[i>>8&255]+"-"+He[i>>16&255]+He[i>>24&255]+He[255&n]+He[n>>8&255]+He[n>>16&255]+He[n>>24&255]).toLowerCase()}function Ye(t,e,i){return Math.max(e,Math.min(i,t))}function qe(t,e){return(t%e+e)%e}function Ze(t,e,i){return(1-i)*t+i*e}function Ke(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Je(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Qe={DEG2RAD:We,RAD2DEG:je,generateUUID:Xe,clamp:Ye,euclideanModulo:qe,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:Ze,damp:function(t,e,i,n){return Ze(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(qe(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Ve=t);let e=Ve+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*We},radToDeg:function(t){return t*je},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),h=a(i/2),l=s((e+n)/2),c=a((e+n)/2),d=s((e-n)/2),u=a((e-n)/2),p=s((n-e)/2),m=a((n-e)/2);switch(r){case"XYX":t.set(o*c,h*d,h*u,o*l);break;case"YZY":t.set(h*u,o*c,h*d,o*l);break;case"ZXZ":t.set(h*d,h*u,o*c,o*l);break;case"XZX":t.set(o*c,h*m,h*p,o*l);break;case"YXY":t.set(h*p,o*c,h*m,o*l);break;case"ZYZ":t.set(h*m,h*p,o*c,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Je,denormalize:Ke};class $e{constructor(t=0,e=0){$e.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Ye(this.x,t.x,e.x),this.y=Ye(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Ye(this.x,t,e),this.y=Ye(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ye(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ye(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ti{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,r,s,a){let o=i[n+0],h=i[n+1],l=i[n+2],c=i[n+3];const d=r[s+0],u=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===a)return t[e+0]=d,t[e+1]=u,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==d||h!==u||l!==p){let t=1-a;const e=o*d+h*u+l*p+c*m,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,e*i);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*i;if(o=o*t+d*r,h=h*t+u*r,l=l*t+p*r,c=c*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+h*h+l*l+c*c);o*=t,h*=t,l*=t,c*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,r,s){const a=i[n],o=i[n+1],h=i[n+2],l=i[n+3],c=r[s],d=r[s+1],u=r[s+2],p=r[s+3];return t[e]=a*p+l*c+o*u-h*d,t[e+1]=o*p+l*d+h*c-a*u,t[e+2]=h*p+l*u+a*d-o*c,t[e+3]=l*p-a*c-o*d-h*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,n=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,h=a(i/2),l=a(n/2),c=a(r/2),d=o(i/2),u=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=d*l*c+h*u*p,this._y=h*u*c-d*l*p,this._z=h*l*p+d*u*c,this._w=h*l*c-d*u*p;break;case"YXZ":this._x=d*l*c+h*u*p,this._y=h*u*c-d*l*p,this._z=h*l*p-d*u*c,this._w=h*l*c+d*u*p;break;case"ZXY":this._x=d*l*c-h*u*p,this._y=h*u*c+d*l*p,this._z=h*l*p+d*u*c,this._w=h*l*c-d*u*p;break;case"ZYX":this._x=d*l*c-h*u*p,this._y=h*u*c+d*l*p,this._z=h*l*p-d*u*c,this._w=h*l*c+d*u*p;break;case"YZX":this._x=d*l*c+h*u*p,this._y=h*u*c+d*l*p,this._z=h*l*p-d*u*c,this._w=h*l*c-d*u*p;break;case"XZY":this._x=d*l*c-h*u*p,this._y=h*u*c-d*l*p,this._z=h*l*p+d*u*c,this._w=h*l*c+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],h=e[2],l=e[6],c=e[10],d=i+a+c;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(s-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(l-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+h)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-h)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+l)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(s-n)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ye(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,h=e._z,l=e._w;return this._x=i*l+s*a+n*h-r*o,this._y=n*l+s*o+r*a-i*h,this._z=r*l+s*h+i*o-n*a,this._w=s*l-i*a-n*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,s=this._w;let a=s*t._w+i*t._x+n*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const h=Math.sqrt(o),l=Math.atan2(h,a),c=Math.sin((1-e)*l)/h,d=Math.sin(e*l)/h;return this._w=s*c+this._w*d,this._x=i*c+this._x*d,this._y=n*c+this._y*d,this._z=r*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ei{constructor(t=0,e=0,i=0){ei.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ni.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ni.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,h=2*(s*n-a*i),l=2*(a*e-r*n),c=2*(r*i-s*e);return this.x=e+o*h+s*c-a*l,this.y=i+o*l+a*h-r*c,this.z=n+o*c+r*l-s*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Ye(this.x,t.x,e.x),this.y=Ye(this.y,t.y,e.y),this.z=Ye(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Ye(this.x,t,e),this.y=Ye(this.y,t,e),this.z=Ye(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ye(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ii.copy(this).projectOnVector(t),this.sub(ii)}reflect(t){return this.sub(ii.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ye(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ii=new ei,ni=new ti;class ri{constructor(t,e,i,n,r,s,a,o,h){ri.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,h)}set(t,e,i,n,r,s,a,o,h){const l=this.elements;return l[0]=t,l[1]=n,l[2]=a,l[3]=e,l[4]=r,l[5]=o,l[6]=i,l[7]=s,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[3],o=i[6],h=i[1],l=i[4],c=i[7],d=i[2],u=i[5],p=i[8],m=n[0],f=n[3],g=n[6],v=n[1],y=n[4],_=n[7],x=n[2],w=n[5],b=n[8];return r[0]=s*m+a*v+o*x,r[3]=s*f+a*y+o*w,r[6]=s*g+a*_+o*b,r[1]=h*m+l*v+c*x,r[4]=h*f+l*y+c*w,r[7]=h*g+l*_+c*b,r[2]=d*m+u*v+p*x,r[5]=d*f+u*y+p*w,r[8]=d*g+u*_+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7],l=t[8];return e*s*l-e*a*h-i*r*l+i*a*o+n*r*h-n*s*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=l*s-a*h,d=a*o-l*r,u=h*r-s*o,p=e*c+i*d+n*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(n*h-l*i)*m,t[2]=(a*i-n*s)*m,t[3]=d*m,t[4]=(l*e-n*o)*m,t[5]=(n*r-a*e)*m,t[6]=u*m,t[7]=(i*o-h*e)*m,t[8]=(s*e-i*r)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,a){const o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*s+h*a)+s+t,-n*h,n*o,-n*(-h*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(si.makeScale(t,e)),this}rotate(t){return this.premultiply(si.makeRotation(-t)),this}translate(t,e){return this.premultiply(si.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const si=new ri;function ai(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const oi={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function hi(t,e){return new oi[t](e)}function li(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function ci(){const t=li("canvas");return t.style.display="block",t}const di={};function ui(t){t in di||(di[t]=!0,console.warn(t))}const pi=(new ri).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mi=(new ri).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);const fi=function(){const t={enabled:!0,workingColorSpace:Ee,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i?(this.spaces[e].transfer===Ae&&(t.r=gi(t.r),t.g=gi(t.g),t.b=gi(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===Ae&&(t.r=vi(t.r),t.g=vi(t.g),t.b=vi(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===Se?Te:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,i){return ui("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,i)},toWorkingColorSpace:function(e,i){return ui("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,i)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],n=[.3127,.329];return t.define({[Ee]:{primaries:e,whitePoint:n,transfer:Te,toXYZ:pi,fromXYZ:mi,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:Me},outputColorSpaceConfig:{drawingBufferColorSpace:Me}},[Me]:{primaries:e,whitePoint:n,transfer:Ae,toXYZ:pi,fromXYZ:mi,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:Me}}}),t}();function gi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function vi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let yi;class _i{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{void 0===yi&&(yi=li("canvas")),yi.width=t.width,yi.height=t.height;const e=yi.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),i=yi}return i.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=li("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t<r.length;t++)r[t]=255*gi(r[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*gi(e[t]/255)):e[t]=gi(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let xi=0;class wi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:xi++}),this.uuid=Xe(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(bi(n[e].image)):t.push(bi(n[e]))}else t=bi(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function bi(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_i.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Si=0;const Mi=new ei;class Ei extends Ge{constructor(t=Ei.DEFAULT_IMAGE,e=Ei.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,a=1023,o=1009,h=Ei.DEFAULT_ANISOTROPY,l=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Si++}),this.uuid=Xe(),this.name="",this.source=new wi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new $e(0,0),this.repeat=new $e(1,1),this.center=new $e(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ri,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(Mi).x}get height(){return this.source.getSize(Mi).y}get depth(){return this.source.getSize(Mi).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,e){this.updateRanges.push({start:t,count:e})}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 e in t){const i=t[e];if(void 0===i){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i:console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==$)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case st:t.x=t.x-Math.floor(t.x);break;case at:t.x=t.x<0?0:1;break;case ot:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case st:t.y=t.y-Math.floor(t.y);break;case at:t.y=t.y<0?0:1;break;case ot:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Ei.DEFAULT_IMAGE=null,Ei.DEFAULT_MAPPING=$,Ei.DEFAULT_ANISOTROPY=1;class Ti{constructor(t=0,e=0,i=0,n=1){Ti.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,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,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;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=void 0!==t.w?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,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,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,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.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 e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,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 e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,a=.1,o=t.elements,h=o[0],l=o[4],c=o[8],d=o[1],u=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(l-d)<s&&Math.abs(c-m)<s&&Math.abs(p-f)<s){if(Math.abs(l+d)<a&&Math.abs(c+m)<a&&Math.abs(p+f)<a&&Math.abs(h+u+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(h+1)/2,o=(u+1)/2,v=(g+1)/2,y=(l+d)/4,_=(c+m)/4,x=(p+f)/4;return t>o&&t>v?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=y/i,r=_/i):o>v?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=y/n,r=x/n):v<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(v),i=_/r,n=x/r),this.set(i,n,r,e),this}let v=Math.sqrt((f-p)*(f-p)+(c-m)*(c-m)+(d-l)*(d-l));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(c-m)/v,this.z=(d-l)/v,this.w=Math.acos((h+u+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[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,e){return this.x=Ye(this.x,t.x,e.x),this.y=Ye(this.y,t.y,e.y),this.z=Ye(this.z,t.z,e.z),this.w=Ye(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Ye(this.x,t,e),this.y=Ye(this.y,t,e),this.z=Ye(this.z,t,e),this.w=Ye(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ye(i,t,e))}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,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)