@needle-tools/engine 4.14.0-next.31f837e → 4.14.0-next.52fdb13

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/components.needle.json +1 -1
  3. package/dist/{generateMeshBVH.worker-DFcS3P04.js → generateMeshBVH.worker-DiCnZlf3.js} +1 -1
  4. package/dist/{gltf-progressive-8voIgNp_.js → gltf-progressive-Bm_6aEi4.js} +4 -4
  5. package/dist/{gltf-progressive-BRRBj-nY.umd.cjs → gltf-progressive-BttGBXw6.umd.cjs} +3 -3
  6. package/dist/{gltf-progressive-Dkh3tG4-.min.js → gltf-progressive-T5WKTux5.min.js} +1 -1
  7. package/dist/{loader.worker-C6cXDgR1.js → loader.worker-BqODMeeW.js} +1 -1
  8. package/dist/{materialx-Dx8st96L.min.js → materialx-CJyQZtjt.min.js} +1 -1
  9. package/dist/{materialx-D66rYPqe.js → materialx-DMs1E08Z.js} +2 -2
  10. package/dist/{materialx-CxlgposR.umd.cjs → materialx-DaKKOoVk.umd.cjs} +1 -1
  11. package/dist/{needle-engine.bundle-D7w0XD7M.min.js → needle-engine.bundle-BwfaInTa.min.js} +156 -148
  12. package/dist/{needle-engine.bundle-BQXG5qbQ.umd.cjs → needle-engine.bundle-DJE-Bjpa.umd.cjs} +141 -133
  13. package/dist/{needle-engine.bundle-Byl5i6zJ.js → needle-engine.bundle-TmE5-_na.js} +6741 -6449
  14. package/dist/needle-engine.d.ts +896 -51
  15. package/dist/needle-engine.js +571 -570
  16. package/dist/needle-engine.min.js +1 -1
  17. package/dist/needle-engine.umd.cjs +1 -1
  18. package/dist/{postprocessing-Ce5-UWiA.min.js → postprocessing-06AXuvdv.min.js} +2 -2
  19. package/dist/{postprocessing-BkSpxpYB.js → postprocessing-CI2x8Cln.js} +4 -4
  20. package/dist/{postprocessing-DFVElmAh.umd.cjs → postprocessing-CPDcA21P.umd.cjs} +2 -2
  21. package/dist/{three-Bad8p1pf.umd.cjs → three-BjYim-vL.umd.cjs} +47 -47
  22. package/dist/{three-DFV1-P9z.js → three-Bvk2VKbF.js} +2 -2
  23. package/dist/{three-CWn13_u1.min.js → three-IG2qPafA.min.js} +2 -2
  24. package/dist/{three-examples-CO-tx3Sp.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +1 -1
  25. package/dist/{three-examples-43yqn3mL.js → three-examples-CMYCd5nH.js} +1 -1
  26. package/dist/{three-examples-DKuJVGT4.min.js → three-examples-CQl1fFZp.min.js} +1 -1
  27. package/dist/{three-mesh-ui-DyEA5HQF.min.js → three-mesh-ui-5HVE2RV-.min.js} +1 -1
  28. package/dist/{three-mesh-ui-fSAQJxdI.js → three-mesh-ui-BlakAItG.js} +1 -1
  29. package/dist/{three-mesh-ui-ChzVOraf.umd.cjs → three-mesh-ui-D828VbQp.umd.cjs} +1 -1
  30. package/dist/{vendor-pe19S9r5.min.js → vendor-BxK0WKmT.min.js} +1 -1
  31. package/dist/{vendor-B51YffMU.umd.cjs → vendor-CIDkyBaO.umd.cjs} +1 -1
  32. package/dist/{vendor-CgpZ5ivC.js → vendor-ixwD-vv2.js} +1 -1
  33. package/lib/engine/api.d.ts +203 -18
  34. package/lib/engine/api.js +271 -18
  35. package/lib/engine/api.js.map +1 -1
  36. package/lib/engine/engine_accessibility.d.ts +58 -0
  37. package/lib/engine/engine_accessibility.js +143 -0
  38. package/lib/engine/engine_accessibility.js.map +1 -0
  39. package/lib/engine/engine_context.d.ts +2 -0
  40. package/lib/engine/engine_context.js +7 -0
  41. package/lib/engine/engine_context.js.map +1 -1
  42. package/lib/engine/engine_materialpropertyblock.d.ts +309 -11
  43. package/lib/engine/engine_materialpropertyblock.js +396 -36
  44. package/lib/engine/engine_materialpropertyblock.js.map +1 -1
  45. package/lib/engine/engine_math.d.ts +34 -1
  46. package/lib/engine/engine_math.js +34 -1
  47. package/lib/engine/engine_math.js.map +1 -1
  48. package/lib/engine/engine_networking.js +1 -1
  49. package/lib/engine/engine_networking.js.map +1 -1
  50. package/lib/engine/engine_types.d.ts +2 -0
  51. package/lib/engine/engine_types.js +2 -0
  52. package/lib/engine/engine_types.js.map +1 -1
  53. package/lib/engine/webcomponents/icons.js +3 -0
  54. package/lib/engine/webcomponents/icons.js.map +1 -1
  55. package/lib/engine/webcomponents/logo-element.d.ts +1 -0
  56. package/lib/engine/webcomponents/logo-element.js +3 -1
  57. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  58. package/lib/engine/webcomponents/needle-button.d.ts +37 -11
  59. package/lib/engine/webcomponents/needle-button.js +42 -11
  60. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  61. package/lib/engine/webcomponents/needle-engine.d.ts +10 -2
  62. package/lib/engine/webcomponents/needle-engine.js +13 -3
  63. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  64. package/lib/engine-components/Camera.js.map +1 -1
  65. package/lib/engine-components/Component.d.ts +1 -2
  66. package/lib/engine-components/Component.js +1 -2
  67. package/lib/engine-components/Component.js.map +1 -1
  68. package/lib/engine-components/DragControls.d.ts +1 -0
  69. package/lib/engine-components/DragControls.js +21 -0
  70. package/lib/engine-components/DragControls.js.map +1 -1
  71. package/lib/engine-components/DropListener.js.map +1 -1
  72. package/lib/engine-components/Duplicatable.js.map +1 -1
  73. package/lib/engine-components/GroundProjection.js.map +1 -1
  74. package/lib/engine-components/NeedleMenu.d.ts +2 -0
  75. package/lib/engine-components/NeedleMenu.js +2 -0
  76. package/lib/engine-components/NeedleMenu.js.map +1 -1
  77. package/lib/engine-components/NestedGltf.js.map +1 -1
  78. package/lib/engine-components/Networking.d.ts +28 -3
  79. package/lib/engine-components/Networking.js +28 -3
  80. package/lib/engine-components/Networking.js.map +1 -1
  81. package/lib/engine-components/ReflectionProbe.d.ts +33 -3
  82. package/lib/engine-components/ReflectionProbe.js +76 -27
  83. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  84. package/lib/engine-components/Renderer.d.ts +2 -0
  85. package/lib/engine-components/Renderer.js +30 -6
  86. package/lib/engine-components/Renderer.js.map +1 -1
  87. package/lib/engine-components/RendererLightmap.js +2 -3
  88. package/lib/engine-components/RendererLightmap.js.map +1 -1
  89. package/lib/engine-components/SeeThrough.d.ts +0 -2
  90. package/lib/engine-components/SeeThrough.js +114 -88
  91. package/lib/engine-components/SeeThrough.js.map +1 -1
  92. package/lib/engine-components/SmoothFollow.js.map +1 -1
  93. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +107 -13
  94. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +167 -30
  95. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
  96. package/lib/engine-components/ui/Button.d.ts +1 -0
  97. package/lib/engine-components/ui/Button.js +11 -0
  98. package/lib/engine-components/ui/Button.js.map +1 -1
  99. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  100. package/lib/engine-components/ui/Text.d.ts +1 -0
  101. package/lib/engine-components/ui/Text.js +11 -0
  102. package/lib/engine-components/ui/Text.js.map +1 -1
  103. package/lib/engine-components/web/ViewBox.d.ts +2 -2
  104. package/lib/engine-components/web/ViewBox.js +2 -2
  105. package/lib/engine-components/web/ViewBox.js.map +1 -1
  106. package/lib/engine-components/webxr/WebXRPlaneTracking.js.map +1 -1
  107. package/lib/engine-components/webxr/controllers/XRControllerFollow.js.map +1 -1
  108. package/lib/engine-components/webxr/controllers/XRControllerMovement.js.map +1 -1
  109. package/package.json +4 -4
  110. package/src/engine/api.ts +371 -19
  111. package/src/engine/engine_accessibility.ts +178 -0
  112. package/src/engine/engine_context.ts +9 -0
  113. package/src/engine/engine_materialpropertyblock.ts +499 -42
  114. package/src/engine/engine_math.ts +34 -1
  115. package/src/engine/engine_networking.ts +1 -1
  116. package/src/engine/engine_types.ts +5 -0
  117. package/src/engine/webcomponents/icons.ts +3 -0
  118. package/src/engine/webcomponents/logo-element.ts +4 -1
  119. package/src/engine/webcomponents/needle-button.ts +44 -13
  120. package/src/engine/webcomponents/needle-engine.ts +18 -7
  121. package/src/engine-components/Camera.ts +2 -2
  122. package/src/engine-components/Component.ts +1 -3
  123. package/src/engine-components/DragControls.ts +29 -4
  124. package/src/engine-components/DropListener.ts +1 -1
  125. package/src/engine-components/Duplicatable.ts +1 -1
  126. package/src/engine-components/GroundProjection.ts +3 -0
  127. package/src/engine-components/NeedleMenu.ts +8 -3
  128. package/src/engine-components/NestedGltf.ts +1 -1
  129. package/src/engine-components/Networking.ts +29 -4
  130. package/src/engine-components/ReflectionProbe.ts +81 -31
  131. package/src/engine-components/Renderer.ts +34 -6
  132. package/src/engine-components/RendererLightmap.ts +2 -3
  133. package/src/engine-components/SeeThrough.ts +122 -107
  134. package/src/engine-components/SmoothFollow.ts +2 -2
  135. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +198 -65
  136. package/src/engine-components/ui/Button.ts +13 -1
  137. package/src/engine-components/ui/Raycaster.ts +1 -1
  138. package/src/engine-components/ui/Text.ts +13 -0
  139. package/src/engine-components/web/ViewBox.ts +9 -2
  140. package/src/engine-components/webxr/WebXRPlaneTracking.ts +3 -3
  141. package/src/engine-components/webxr/controllers/XRControllerFollow.ts +1 -1
  142. package/src/engine-components/webxr/controllers/XRControllerMovement.ts +4 -4
@@ -1,4 +1,4 @@
1
- (function(){"use strict";const ze="169.17",Wt="srgb",Rs="srgb-linear",Io="display-p3",Yi="display-p3-linear",bn="linear",Zi="srgb",Ji="rec709";class ns{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const n=this._listeners[t];if(n!==void 0){const i=n.indexOf(e);i!==-1&&n.splice(i,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const s=this._listeners[t.type];if(s!==void 0){t.target=this;const n=s.slice(0);for(let i=0,o=n.length;i<o;i++)n[i].call(this,t);t.target=null}}}const ut=["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 Qi=1234567;const ji=Math.PI/180,Ki=180/Math.PI;function se(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ut[r&255]+ut[r>>8&255]+ut[r>>16&255]+ut[r>>24&255]+"-"+ut[t&255]+ut[t>>8&255]+"-"+ut[t>>16&15|64]+ut[t>>24&255]+"-"+ut[e&63|128]+ut[e>>8&255]+"-"+ut[e>>16&255]+ut[e>>24&255]+ut[s&255]+ut[s>>8&255]+ut[s>>16&255]+ut[s>>24&255]).toLowerCase()}function lt(r,t,e){return Math.max(t,Math.min(e,r))}function En(r,t){return(r%t+t)%t}function Po(r,t,e,s,n){return s+(r-t)*(n-s)/(e-t)}function vo(r,t,e){return r!==t?(e-r)/(t-r):0}function is(r,t,e){return(1-e)*r+e*t}function Lo(r,t,e,s){return is(r,t,1-Math.exp(-e*s))}function Oo(r,t=1){return t-Math.abs(En(r,t*2)-t)}function Do(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Vo(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Uo(r,t){return r+Math.floor(Math.random()*(t-r+1))}function ko(r,t){return r+Math.random()*(t-r)}function qo(r){return r*(.5-Math.random())}function Ho(r){r!==void 0&&(Qi=r);let t=Qi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Wo(r){return r*ji}function $o(r){return r*Ki}function Go(r){return(r&r-1)===0&&r!==0}function Xo(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Yo(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Zo(r,t,e,s,n){const i=Math.cos,o=Math.sin,a=i(e/2),c=o(e/2),u=i((t+s)/2),h=o((t+s)/2),l=i((t-s)/2),d=o((t-s)/2),f=i((s-t)/2),p=o((s-t)/2);switch(n){case"XYX":r.set(a*h,c*l,c*d,a*u);break;case"YZY":r.set(c*d,a*h,c*l,a*u);break;case"ZXZ":r.set(c*l,c*d,a*h,a*u);break;case"XZX":r.set(a*h,c*p,c*f,a*u);break;case"YXY":r.set(c*f,a*h,c*p,a*u);break;case"ZYZ":r.set(c*p,c*f,a*h,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Ft(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function W(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Jo={DEG2RAD:ji,RAD2DEG:Ki,generateUUID:se,clamp:lt,euclideanModulo:En,mapLinear:Po,inverseLerp:vo,lerp:is,damp:Lo,pingpong:Oo,smoothstep:Do,smootherstep:Vo,randInt:Uo,randFloat:ko,randFloatSpread:qo,seededRandom:Ho,degToRad:Wo,radToDeg:$o,isPowerOfTwo:Go,ceilPowerOfTwo:Xo,floorPowerOfTwo:Yo,setQuaternionFromProperEuler:Zo,normalize:W,denormalize:Ft};class Z{constructor(t=0,e=0){Z.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6],this.y=n[1]*e+n[4]*s+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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(lt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*s-o*n+t.x,this.y=i*n+o*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,e,s,n,i,o,a,c,u){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,n,i,o,a,c,u)}set(t,e,s,n,i,o,a,c,u){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=i,h[5]=c,h[6]=s,h[7]=o,h[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,n=e.elements,i=this.elements,o=s[0],a=s[3],c=s[6],u=s[1],h=s[4],l=s[7],d=s[2],f=s[5],p=s[8],m=n[0],x=n[3],g=n[6],y=n[1],N=n[4],w=n[7],T=n[2],_=n[5],S=n[8];return i[0]=o*m+a*y+c*T,i[3]=o*x+a*N+c*_,i[6]=o*g+a*w+c*S,i[1]=u*m+h*y+l*T,i[4]=u*x+h*N+l*_,i[7]=u*g+h*w+l*S,i[2]=d*m+f*y+p*T,i[5]=d*x+f*N+p*_,i[8]=d*g+f*w+p*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8];return e*o*h-e*a*u-s*i*h+s*a*c+n*i*u-n*o*c}invert(){const t=this.elements,e=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=h*o-a*u,d=a*c-h*i,f=u*i-o*c,p=e*l+s*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=l*m,t[1]=(n*u-h*s)*m,t[2]=(a*s-n*o)*m,t[3]=d*m,t[4]=(h*e-n*c)*m,t[5]=(n*i-a*e)*m,t[6]=f*m,t[7]=(s*c-u*e)*m,t[8]=(o*e-s*i)*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,s,n,i,o,a){const c=Math.cos(i),u=Math.sin(i);return this.set(s*c,s*u,-s*(c*o+u*a)+o+t,-n*u,n*c,-n*(-u*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Cn.makeScale(t,e)),this}rotate(t){return this.premultiply(Cn.makeRotation(-t)),this}translate(t,e){return this.premultiply(Cn.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let n=0;n<9;n++)if(e[n]!==s[n])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Cn=new Bt;function Qo(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function tr(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const er=new Bt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),sr=new Bt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),rs={[Rs]:{transfer:bn,primaries:Ji,luminanceCoefficients:[.2126,.7152,.0722],toReference:r=>r,fromReference:r=>r},[Wt]:{transfer:Zi,primaries:Ji,luminanceCoefficients:[.2126,.7152,.0722],toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[Yi]:{transfer:bn,primaries:"p3",luminanceCoefficients:[.2289,.6917,.0793],toReference:r=>r.applyMatrix3(sr),fromReference:r=>r.applyMatrix3(er)},[Io]:{transfer:Zi,primaries:"p3",luminanceCoefficients:[.2289,.6917,.0793],toReference:r=>r.convertSRGBToLinear().applyMatrix3(sr),fromReference:r=>r.applyMatrix3(er).convertLinearToSRGB()}},jo=new Set([Rs,Yi]),wt={enabled:!0,_workingColorSpace:Rs,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!jo.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,t,e){if(this.enabled===!1||t===e||!t||!e)return r;const s=rs[t].toReference,n=rs[e].fromReference;return n(s(r))},fromWorkingColorSpace:function(r,t){return this.convert(r,this._workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this._workingColorSpace)},getPrimaries:function(r){return rs[r].primaries},getTransfer:function(r){return r===""?bn:rs[r].transfer},getLuminanceCoefficients:function(r,t=this._workingColorSpace){return r.fromArray(rs[t].luminanceCoefficients)}};function be(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Fn(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Ee;class Ko{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Ee===void 0&&(Ee=tr("canvas")),Ee.width=t.width,Ee.height=t.height;const s=Ee.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=Ee}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=tr("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const n=s.getImageData(0,0,t.width,t.height),i=n.data;for(let o=0;o<i.length;o++)i[o]=be(i[o]/255)*255;return s.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(be(e[s]/255)*255):e[s]=be(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ta=0;class nr{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ta++}),this.uuid=se(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},n=this.data;if(n!==null){let i;if(Array.isArray(n)){i=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?i.push(Bn(n[o].image)):i.push(Bn(n[o]))}else i=Bn(n);s.url=i}return e||(t.images[this.uuid]=s),s}}function Bn(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Ko.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ea=0;class Ut extends ns{constructor(t=Ut.DEFAULT_IMAGE,e=Ut.DEFAULT_MAPPING,s=1001,n=1001,i=1006,o=1008,a=1023,c=1009,u=Ut.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ea++}),this.uuid=se(),this.name="",this.source=new nr(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=n,this.magFilter=i,this.minFilter=o,this.anisotropy=u,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Z(0,0),this.repeat=new Z(1,1),this.center=new Z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}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.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.6,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&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002: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 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002: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++}}Ut.DEFAULT_IMAGE=null,Ut.DEFAULT_MAPPING=300,Ut.DEFAULT_ANISOTROPY=4;class Rt{constructor(t=0,e=0,s=0,n=1){Rt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,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,s,n){return this.x=t,this.y=e,this.z=s,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=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,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,s=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*s+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*s+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*s+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*s+o[11]*n+o[15]*i,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,s,n,i;const c=t.elements,u=c[0],h=c[4],l=c[8],d=c[1],f=c[5],p=c[9],m=c[2],x=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(l-m)<.01&&Math.abs(p-x)<.01){if(Math.abs(h+d)<.1&&Math.abs(l+m)<.1&&Math.abs(p+x)<.1&&Math.abs(u+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const N=(u+1)/2,w=(f+1)/2,T=(g+1)/2,_=(h+d)/4,S=(l+m)/4,z=(p+x)/4;return N>w&&N>T?N<.01?(s=0,n=.707106781,i=.707106781):(s=Math.sqrt(N),n=_/s,i=S/s):w>T?w<.01?(s=.707106781,n=0,i=.707106781):(n=Math.sqrt(w),s=_/n,i=z/n):T<.01?(s=.707106781,n=.707106781,i=0):(i=Math.sqrt(T),s=S/i,n=z/i),this.set(s,n,i,e),this}let y=Math.sqrt((x-p)*(x-p)+(l-m)*(l-m)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(x-p)/y,this.y=(l-m)/y,this.z=(d-h)/y,this.w=Math.acos((u+f+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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.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)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}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}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}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 ir extends ns{constructor(t=1,e=1,s={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Rt(0,0,t,e),this.scissorTest=!1,this.viewport=new Rt(0,0,t,e);const n={width:t,height:e,depth:1};s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},s);const i=new Ut(n,s.mapping,s.wrapS,s.wrapT,s.magFilter,s.minFilter,s.format,s.type,s.anisotropy,s.colorSpace);i.flipY=!1,i.generateMipmaps=s.generateMipmaps,i.internalFormat=s.internalFormat,this.textures=[];const o=s.count;for(let a=0;a<o;a++)this.textures[a]=i.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this.depthTexture=s.depthTexture,this.samples=s.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,s=1){if(this.width!==t||this.height!==e||this.depth!==s){this.width=t,this.height=e,this.depth=s;for(let n=0,i=this.textures.length;n<i;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=s;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let s=0,n=t.textures.length;s<n;s++)this.textures[s]=t.textures[s].clone(),this.textures[s].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new nr(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class os{constructor(t=0,e=0,s=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=n}static slerpFlat(t,e,s,n,i,o,a){let c=s[n+0],u=s[n+1],h=s[n+2],l=s[n+3];const d=i[o+0],f=i[o+1],p=i[o+2],m=i[o+3];if(a===0){t[e+0]=c,t[e+1]=u,t[e+2]=h,t[e+3]=l;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=m;return}if(l!==m||c!==d||u!==f||h!==p){let x=1-a;const g=c*d+u*f+h*p+l*m,y=g>=0?1:-1,N=1-g*g;if(N>Number.EPSILON){const T=Math.sqrt(N),_=Math.atan2(T,g*y);x=Math.sin(x*_)/T,a=Math.sin(a*_)/T}const w=a*y;if(c=c*x+d*w,u=u*x+f*w,h=h*x+p*w,l=l*x+m*w,x===1-a){const T=1/Math.sqrt(c*c+u*u+h*h+l*l);c*=T,u*=T,h*=T,l*=T}}t[e]=c,t[e+1]=u,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,s,n,i,o){const a=s[n],c=s[n+1],u=s[n+2],h=s[n+3],l=i[o],d=i[o+1],f=i[o+2],p=i[o+3];return t[e]=a*p+h*l+c*f-u*d,t[e+1]=c*p+h*d+u*l-a*f,t[e+2]=u*p+h*f+a*d-c*l,t[e+3]=h*p-a*l-c*d-u*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,n){return this._x=t,this._y=e,this._z=s,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 s=t._x,n=t._y,i=t._z,o=t._order,a=Math.cos,c=Math.sin,u=a(s/2),h=a(n/2),l=a(i/2),d=c(s/2),f=c(n/2),p=c(i/2);switch(o){case"XYZ":this._x=d*h*l+u*f*p,this._y=u*f*l-d*h*p,this._z=u*h*p+d*f*l,this._w=u*h*l-d*f*p;break;case"YXZ":this._x=d*h*l+u*f*p,this._y=u*f*l-d*h*p,this._z=u*h*p-d*f*l,this._w=u*h*l+d*f*p;break;case"ZXY":this._x=d*h*l-u*f*p,this._y=u*f*l+d*h*p,this._z=u*h*p+d*f*l,this._w=u*h*l-d*f*p;break;case"ZYX":this._x=d*h*l-u*f*p,this._y=u*f*l+d*h*p,this._z=u*h*p-d*f*l,this._w=u*h*l+d*f*p;break;case"YZX":this._x=d*h*l+u*f*p,this._y=u*f*l+d*h*p,this._z=u*h*p-d*f*l,this._w=u*h*l-d*f*p;break;case"XZY":this._x=d*h*l-u*f*p,this._y=u*f*l-d*h*p,this._z=u*h*p+d*f*l,this._w=u*h*l+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,n=Math.sin(s);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],n=e[4],i=e[8],o=e[1],a=e[5],c=e[9],u=e[2],h=e[6],l=e[10],d=s+a+l;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(i-u)*f,this._z=(o-n)*f}else if(s>a&&s>l){const f=2*Math.sqrt(1+s-a-l);this._w=(h-c)/f,this._x=.25*f,this._y=(n+o)/f,this._z=(i+u)/f}else if(a>l){const f=2*Math.sqrt(1+a-s-l);this._w=(i-u)/f,this._x=(n+o)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+l-s-a);this._w=(o-n)/f,this._x=(i+u)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(lt(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const n=Math.min(1,e/s);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 t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,n=t._y,i=t._z,o=t._w,a=e._x,c=e._y,u=e._z,h=e._w;return this._x=s*h+o*a+n*u-i*c,this._y=n*h+o*c+i*a-s*u,this._z=i*h+o*u+s*c-n*a,this._w=o*h-s*a-n*c-i*u,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,n=this._y,i=this._z,o=this._w;let a=o*t._w+s*t._x+n*t._y+i*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=o,this._x=s,this._y=n,this._z=i,this;const c=1-a*a;if(c<=Number.EPSILON){const f=1-e;return this._w=f*o+e*this._w,this._x=f*s+e*this._x,this._y=f*n+e*this._y,this._z=f*i+e*this._z,this.normalize(),this}const u=Math.sqrt(c),h=Math.atan2(u,a),l=Math.sin((1-e)*h)/u,d=Math.sin(e*h)/u;return this._w=o*l+this._w*d,this._x=s*l+this._x*d,this._y=n*l+this._y*d,this._z=i*l+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),n=Math.sqrt(1-s),i=Math.sqrt(s);return this.set(n*Math.sin(t),n*Math.cos(t),i*Math.sin(e),i*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 M{constructor(t=0,e=0,s=0){M.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(rr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(rr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6]*n,this.y=i[1]*e+i[4]*s+i[7]*n,this.z=i[2]*e+i[5]*s+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*s+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*s+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*s+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*s+i[10]*n+i[14])*o,this}applyQuaternion(t){const e=this.x,s=this.y,n=this.z,i=t.x,o=t.y,a=t.z,c=t.w,u=2*(o*n-a*s),h=2*(a*e-i*n),l=2*(i*s-o*e);return this.x=e+c*u+o*l-a*h,this.y=s+c*h+a*u-i*l,this.z=n+c*l+i*h-o*u,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*s+i[8]*n,this.y=i[1]*e+i[5]*s+i[9]*n,this.z=i[2]*e+i[6]*s+i[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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,n=t.y,i=t.z,o=e.x,a=e.y,c=e.z;return this.x=n*c-i*a,this.y=i*o-s*c,this.z=s*a-n*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Rn.copy(this).projectOnVector(t),this.sub(Rn)}reflect(t){return this.sub(Rn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(lt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,n=this.z-t.z;return e*e+s*s+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,s){const n=Math.sin(e)*t;return this.x=n*Math.sin(s),this.y=Math.cos(e)*t,this.z=n*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Rn=new M,rr=new os;class mt{constructor(t=new M(1/0,1/0,1/0),e=new M(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(It.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(It.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=It.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}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,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const i=s.getAttribute("position");if(e===!0&&i!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=i.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,It):It.fromBufferAttribute(i,o),It.applyMatrix4(t.matrixWorld),this.expandByPoint(It);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Is.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Is.copy(s.boundingBox)),Is.applyMatrix4(t.matrixWorld),this.union(Is)}const n=t.children;for(let i=0,o=n.length;i<o;i++)this.expandByObject(n[i],e);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,e){return e.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,It),It.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(as),Ps.subVectors(this.max,as),Ce.subVectors(t.a,as),Fe.subVectors(t.b,as),Be.subVectors(t.c,as),ne.subVectors(Fe,Ce),ie.subVectors(Be,Fe),ye.subVectors(Ce,Be);let e=[0,-ne.z,ne.y,0,-ie.z,ie.y,0,-ye.z,ye.y,ne.z,0,-ne.x,ie.z,0,-ie.x,ye.z,0,-ye.x,-ne.y,ne.x,0,-ie.y,ie.x,0,-ye.y,ye.x,0];return!In(e,Ce,Fe,Be,Ps)||(e=[1,0,0,0,1,0,0,0,1],!In(e,Ce,Fe,Be,Ps))?!1:(vs.crossVectors(ne,ie),e=[vs.x,vs.y,vs.z],In(e,Ce,Fe,Be,Ps))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,It).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(It).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:($t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),$t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),$t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),$t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),$t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),$t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),$t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),$t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints($t),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)}}const $t=[new M,new M,new M,new M,new M,new M,new M,new M],It=new M,Is=new mt,Ce=new M,Fe=new M,Be=new M,ne=new M,ie=new M,ye=new M,as=new M,Ps=new M,vs=new M,ge=new M;function In(r,t,e,s,n){for(let i=0,o=r.length-3;i<=o;i+=3){ge.fromArray(r,i);const a=n.x*Math.abs(ge.x)+n.y*Math.abs(ge.y)+n.z*Math.abs(ge.z),c=t.dot(ge),u=e.dot(ge),h=s.dot(ge);if(Math.max(-Math.max(c,u,h),Math.min(c,u,h))>a)return!1}return!0}const sa=new mt,cs=new M,Pn=new M;class na{constructor(t=new M,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):sa.setFromPoints(t).getCenter(s);let n=0;for(let i=0,o=t.length;i<o;i++)n=Math.max(n,s.distanceToSquared(t[i]));return this.radius=Math.sqrt(n),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 e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}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;cs.subVectors(t,this.center);const e=cs.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),n=(s-this.radius)*.5;this.center.addScaledVector(cs,n/s),this.radius+=n}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):(Pn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(cs.copy(t.center).add(Pn)),this.expandByPoint(cs.copy(t.center).sub(Pn))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Gt=new M,vn=new M,Ls=new M,re=new M,Ln=new M,Os=new M,On=new M;class ia{constructor(t=new M,e=new M(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.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,Gt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Gt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Gt.copy(this.origin).addScaledVector(this.direction,e),Gt.distanceToSquared(t))}distanceSqToSegment(t,e,s,n){vn.copy(t).add(e).multiplyScalar(.5),Ls.copy(e).sub(t).normalize(),re.copy(this.origin).sub(vn);const i=t.distanceTo(e)*.5,o=-this.direction.dot(Ls),a=re.dot(this.direction),c=-re.dot(Ls),u=re.lengthSq(),h=Math.abs(1-o*o);let l,d,f,p;if(h>0)if(l=o*c-a,d=o*a-c,p=i*h,l>=0)if(d>=-p)if(d<=p){const m=1/h;l*=m,d*=m,f=l*(l+o*d+2*a)+d*(o*l+d+2*c)+u}else d=i,l=Math.max(0,-(o*d+a)),f=-l*l+d*(d+2*c)+u;else d=-i,l=Math.max(0,-(o*d+a)),f=-l*l+d*(d+2*c)+u;else d<=-p?(l=Math.max(0,-(-o*i+a)),d=l>0?-i:Math.min(Math.max(-i,-c),i),f=-l*l+d*(d+2*c)+u):d<=p?(l=0,d=Math.min(Math.max(-i,-c),i),f=d*(d+2*c)+u):(l=Math.max(0,-(o*i+a)),d=l>0?i:Math.min(Math.max(-i,-c),i),f=-l*l+d*(d+2*c)+u);else d=o>0?-i:i,l=Math.max(0,-(o*d+a)),f=-l*l+d*(d+2*c)+u;return s&&s.copy(this.origin).addScaledVector(this.direction,l),n&&n.copy(vn).addScaledVector(Ls,d),f}intersectSphere(t,e){Gt.subVectors(t.center,this.origin);const s=Gt.dot(this.direction),n=Gt.dot(Gt)-s*s,i=t.radius*t.radius;if(n>i)return null;const o=Math.sqrt(i-n),a=s-o,c=s+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){const s=this.distanceToPlane(t);return s===null?null:this.at(s,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let s,n,i,o,a,c;const u=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,d=this.origin;return u>=0?(s=(t.min.x-d.x)*u,n=(t.max.x-d.x)*u):(s=(t.max.x-d.x)*u,n=(t.min.x-d.x)*u),h>=0?(i=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(i=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),s>o||i>n||((i>s||isNaN(s))&&(s=i),(o<n||isNaN(n))&&(n=o),l>=0?(a=(t.min.z-d.z)*l,c=(t.max.z-d.z)*l):(a=(t.max.z-d.z)*l,c=(t.min.z-d.z)*l),s>c||a>n)||((a>s||s!==s)&&(s=a),(c<n||n!==n)&&(n=c),n<0)?null:this.at(s>=0?s:n,e)}intersectsBox(t){return this.intersectBox(t,Gt)!==null}intersectTriangle(t,e,s,n,i){Ln.subVectors(e,t),Os.subVectors(s,t),On.crossVectors(Ln,Os);let o=this.direction.dot(On),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;re.subVectors(this.origin,t);const c=a*this.direction.dot(Os.crossVectors(re,Os));if(c<0)return null;const u=a*this.direction.dot(Ln.cross(re));if(u<0||c+u>o)return null;const h=-a*re.dot(On);return h<0?null:this.at(h/o,i)}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 Q{constructor(t,e,s,n,i,o,a,c,u,h,l,d,f,p,m,x){Q.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,n,i,o,a,c,u,h,l,d,f,p,m,x)}set(t,e,s,n,i,o,a,c,u,h,l,d,f,p,m,x){const g=this.elements;return g[0]=t,g[4]=e,g[8]=s,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=c,g[2]=u,g[6]=h,g[10]=l,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Q().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,n=1/Re.setFromMatrixColumn(t,0).length(),i=1/Re.setFromMatrixColumn(t,1).length(),o=1/Re.setFromMatrixColumn(t,2).length();return e[0]=s[0]*n,e[1]=s[1]*n,e[2]=s[2]*n,e[3]=0,e[4]=s[4]*i,e[5]=s[5]*i,e[6]=s[6]*i,e[7]=0,e[8]=s[8]*o,e[9]=s[9]*o,e[10]=s[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,n=t.y,i=t.z,o=Math.cos(s),a=Math.sin(s),c=Math.cos(n),u=Math.sin(n),h=Math.cos(i),l=Math.sin(i);if(t.order==="XYZ"){const d=o*h,f=o*l,p=a*h,m=a*l;e[0]=c*h,e[4]=-c*l,e[8]=u,e[1]=f+p*u,e[5]=d-m*u,e[9]=-a*c,e[2]=m-d*u,e[6]=p+f*u,e[10]=o*c}else if(t.order==="YXZ"){const d=c*h,f=c*l,p=u*h,m=u*l;e[0]=d+m*a,e[4]=p*a-f,e[8]=o*u,e[1]=o*l,e[5]=o*h,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=o*c}else if(t.order==="ZXY"){const d=c*h,f=c*l,p=u*h,m=u*l;e[0]=d-m*a,e[4]=-o*l,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*h,e[9]=m-d*a,e[2]=-o*u,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const d=o*h,f=o*l,p=a*h,m=a*l;e[0]=c*h,e[4]=p*u-f,e[8]=d*u+m,e[1]=c*l,e[5]=m*u+d,e[9]=f*u-p,e[2]=-u,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const d=o*c,f=o*u,p=a*c,m=a*u;e[0]=c*h,e[4]=m-d*l,e[8]=p*l+f,e[1]=l,e[5]=o*h,e[9]=-a*h,e[2]=-u*h,e[6]=f*l+p,e[10]=d-m*l}else if(t.order==="XZY"){const d=o*c,f=o*u,p=a*c,m=a*u;e[0]=c*h,e[4]=-l,e[8]=u*h,e[1]=d*l+m,e[5]=o*h,e[9]=f*l-p,e[2]=p*l-f,e[6]=a*h,e[10]=m*l+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ra,t,oa)}lookAt(t,e,s){const n=this.elements;return At.subVectors(t,e),At.lengthSq()===0&&(At.z=1),At.normalize(),oe.crossVectors(s,At),oe.lengthSq()===0&&(Math.abs(s.z)===1?At.x+=1e-4:At.z+=1e-4,At.normalize(),oe.crossVectors(s,At)),oe.normalize(),Ds.crossVectors(At,oe),n[0]=oe.x,n[4]=Ds.x,n[8]=At.x,n[1]=oe.y,n[5]=Ds.y,n[9]=At.y,n[2]=oe.z,n[6]=Ds.z,n[10]=At.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,n=e.elements,i=this.elements,o=s[0],a=s[4],c=s[8],u=s[12],h=s[1],l=s[5],d=s[9],f=s[13],p=s[2],m=s[6],x=s[10],g=s[14],y=s[3],N=s[7],w=s[11],T=s[15],_=n[0],S=n[4],z=n[8],B=n[12],b=n[1],I=n[5],C=n[9],P=n[13],L=n[2],D=n[6],X=n[10],ee=n[14],Me=n[3],_e=n[7],pe=n[11],me=n[15];return i[0]=o*_+a*b+c*L+u*Me,i[4]=o*S+a*I+c*D+u*_e,i[8]=o*z+a*C+c*X+u*pe,i[12]=o*B+a*P+c*ee+u*me,i[1]=h*_+l*b+d*L+f*Me,i[5]=h*S+l*I+d*D+f*_e,i[9]=h*z+l*C+d*X+f*pe,i[13]=h*B+l*P+d*ee+f*me,i[2]=p*_+m*b+x*L+g*Me,i[6]=p*S+m*I+x*D+g*_e,i[10]=p*z+m*C+x*X+g*pe,i[14]=p*B+m*P+x*ee+g*me,i[3]=y*_+N*b+w*L+T*Me,i[7]=y*S+N*I+w*D+T*_e,i[11]=y*z+N*C+w*X+T*pe,i[15]=y*B+N*P+w*ee+T*me,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],n=t[8],i=t[12],o=t[1],a=t[5],c=t[9],u=t[13],h=t[2],l=t[6],d=t[10],f=t[14],p=t[3],m=t[7],x=t[11],g=t[15];return p*(+i*c*l-n*u*l-i*a*d+s*u*d+n*a*f-s*c*f)+m*(+e*c*f-e*u*d+i*o*d-n*o*f+n*u*h-i*c*h)+x*(+e*u*l-e*a*f-i*o*l+s*o*f+i*a*h-s*u*h)+g*(-n*a*h-e*c*l+e*a*d+n*o*l-s*o*d+s*c*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=t[9],d=t[10],f=t[11],p=t[12],m=t[13],x=t[14],g=t[15],y=l*x*u-m*d*u+m*c*f-a*x*f-l*c*g+a*d*g,N=p*d*u-h*x*u-p*c*f+o*x*f+h*c*g-o*d*g,w=h*m*u-p*l*u+p*a*f-o*m*f-h*a*g+o*l*g,T=p*l*c-h*m*c-p*a*d+o*m*d+h*a*x-o*l*x,_=e*y+s*N+n*w+i*T;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/_;return t[0]=y*S,t[1]=(m*d*i-l*x*i-m*n*f+s*x*f+l*n*g-s*d*g)*S,t[2]=(a*x*i-m*c*i+m*n*u-s*x*u-a*n*g+s*c*g)*S,t[3]=(l*c*i-a*d*i-l*n*u+s*d*u+a*n*f-s*c*f)*S,t[4]=N*S,t[5]=(h*x*i-p*d*i+p*n*f-e*x*f-h*n*g+e*d*g)*S,t[6]=(p*c*i-o*x*i-p*n*u+e*x*u+o*n*g-e*c*g)*S,t[7]=(o*d*i-h*c*i+h*n*u-e*d*u-o*n*f+e*c*f)*S,t[8]=w*S,t[9]=(p*l*i-h*m*i-p*s*f+e*m*f+h*s*g-e*l*g)*S,t[10]=(o*m*i-p*a*i+p*s*u-e*m*u-o*s*g+e*a*g)*S,t[11]=(h*a*i-o*l*i-h*s*u+e*l*u+o*s*f-e*a*f)*S,t[12]=T*S,t[13]=(h*m*n-p*l*n+p*s*d-e*m*d-h*s*x+e*l*x)*S,t[14]=(p*a*n-o*m*n-p*s*c+e*m*c+o*s*x-e*a*x)*S,t[15]=(o*l*n-h*a*n+h*s*c-e*l*c-o*s*d+e*a*d)*S,this}scale(t){const e=this.elements,s=t.x,n=t.y,i=t.z;return e[0]*=s,e[4]*=n,e[8]*=i,e[1]*=s,e[5]*=n,e[9]*=i,e[2]*=s,e[6]*=n,e[10]*=i,e[3]*=s,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,n))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),n=Math.sin(e),i=1-s,o=t.x,a=t.y,c=t.z,u=i*o,h=i*a;return this.set(u*o+s,u*a-n*c,u*c+n*a,0,u*a+n*c,h*a+s,h*c-n*o,0,u*c-n*a,h*c+n*o,i*c*c+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,n,i,o){return this.set(1,s,i,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,s){const n=this.elements,i=e._x,o=e._y,a=e._z,c=e._w,u=i+i,h=o+o,l=a+a,d=i*u,f=i*h,p=i*l,m=o*h,x=o*l,g=a*l,y=c*u,N=c*h,w=c*l,T=s.x,_=s.y,S=s.z;return n[0]=(1-(m+g))*T,n[1]=(f+w)*T,n[2]=(p-N)*T,n[3]=0,n[4]=(f-w)*_,n[5]=(1-(d+g))*_,n[6]=(x+y)*_,n[7]=0,n[8]=(p+N)*S,n[9]=(x-y)*S,n[10]=(1-(d+m))*S,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,s){const n=this.elements;let i=Re.set(n[0],n[1],n[2]).length();const o=Re.set(n[4],n[5],n[6]).length(),a=Re.set(n[8],n[9],n[10]).length();this.determinant()<0&&(i=-i),t.x=n[12],t.y=n[13],t.z=n[14],Pt.copy(this);const u=1/i,h=1/o,l=1/a;return Pt.elements[0]*=u,Pt.elements[1]*=u,Pt.elements[2]*=u,Pt.elements[4]*=h,Pt.elements[5]*=h,Pt.elements[6]*=h,Pt.elements[8]*=l,Pt.elements[9]*=l,Pt.elements[10]*=l,e.setFromRotationMatrix(Pt),s.x=i,s.y=o,s.z=a,this}makePerspective(t,e,s,n,i,o,a=2e3){const c=this.elements,u=2*i/(e-t),h=2*i/(s-n),l=(e+t)/(e-t),d=(s+n)/(s-n);let f,p;if(a===2e3)f=-(o+i)/(o-i),p=-2*o*i/(o-i);else if(a===2001)f=-o/(o-i),p=-o*i/(o-i);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,s,n,i,o,a=2e3){const c=this.elements,u=1/(e-t),h=1/(s-n),l=1/(o-i),d=(e+t)*u,f=(s+n)*h;let p,m;if(a===2e3)p=(o+i)*l,m=-2*l;else if(a===2001)p=i*l,m=-1*l;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=m,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let n=0;n<16;n++)if(e[n]!==s[n])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const Re=new M,Pt=new Q,ra=new M(0,0,0),oa=new M(1,1,1),oe=new M,Ds=new M,At=new M,or=new Q,ar=new os;class Vs{constructor(t=0,e=0,s=0,n=Vs.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,n=this._order){return this._x=t,this._y=e,this._z=s,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const n=t.elements,i=n[0],o=n[4],a=n[8],c=n[1],u=n[5],h=n[9],l=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(lt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-lt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-l,i),this._z=0);break;case"ZXY":this._x=Math.asin(lt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-l,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,i));break;case"ZYX":this._y=Math.asin(-lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,i)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(lt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-l,i)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return or.makeRotationFromQuaternion(t),this.setFromRotationMatrix(or,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ar.setFromEuler(this),this.setFromQuaternion(ar,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Vs.DEFAULT_ORDER="XYZ";class aa{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 ca=0;const cr=new M,Ie=new os,Xt=new Q,Us=new M,hs=new M,ha=new M,ua=new os,hr=new M(1,0,0),ur=new M(0,1,0),lr=new M(0,0,1),dr={type:"added"},la={type:"removed"},Pe={type:"childadded",child:null},Dn={type:"childremoved",child:null};class ae extends ns{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ca++}),this.uuid=se(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ae.DEFAULT_UP.clone();const t=new M,e=new Vs,s=new os,n=new M(1,1,1);function i(){s.setFromEuler(e,!1)}function o(){e.setFromQuaternion(s,void 0,!1)}e._onChange(i),s._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Q},normalMatrix:{value:new Bt}}),this.matrix=new Q,this.matrixWorld=new Q,this.matrixAutoUpdate=ae.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ae.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ie.setFromAxisAngle(t,e),this.quaternion.multiply(Ie),this}rotateOnWorldAxis(t,e){return Ie.setFromAxisAngle(t,e),this.quaternion.premultiply(Ie),this}rotateX(t){return this.rotateOnAxis(hr,t)}rotateY(t){return this.rotateOnAxis(ur,t)}rotateZ(t){return this.rotateOnAxis(lr,t)}translateOnAxis(t,e){return cr.copy(t).applyQuaternion(this.quaternion),this.position.add(cr.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(hr,t)}translateY(t){return this.translateOnAxis(ur,t)}translateZ(t){return this.translateOnAxis(lr,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Xt.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?Us.copy(t):Us.set(t,e,s);const n=this.parent;this.updateWorldMatrix(!0,!1),hs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xt.lookAt(hs,Us,this.up):Xt.lookAt(Us,hs,this.up),this.quaternion.setFromRotationMatrix(Xt),n&&(Xt.extractRotation(n.matrixWorld),Ie.setFromRotationMatrix(Xt),this.quaternion.premultiply(Ie.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(dr),Pe.child=t,this.dispatchEvent(Pe),Pe.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(la),Dn.child=t,this.dispatchEvent(Dn),Dn.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),Xt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Xt.multiply(t.parent.matrixWorld)),t.applyMatrix4(Xt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(dr),Pe.child=t,this.dispatchEvent(Pe),Pe.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,n=this.children.length;s<n;s++){const o=this.children[s].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const n=this.children;for(let i=0,o=n.length;i<o;i++)n[i].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,t,ha),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,ua,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,n=e.length;s<n;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,n=e.length;s<n;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),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 e=this.children;for(let s=0,n=e.length;s<n;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.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)),e===!0){const n=this.children;for(let i=0,o=n.length;i<o;i++)n[i].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),this.boundingBox!==null&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()}));function i(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=i(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let u=0,h=c.length;u<h;u++){const l=c[u];i(t.shapes,l)}else i(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,u=this.material.length;c<u;c++)a.push(i(t.materials,this.material[c]));n.material=a}else n.material=i(t.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];n.animations.push(i(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),u=o(t.textures),h=o(t.images),l=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(s.geometries=a),c.length>0&&(s.materials=c),u.length>0&&(s.textures=u),h.length>0&&(s.images=h),l.length>0&&(s.shapes=l),d.length>0&&(s.skeletons=d),f.length>0&&(s.animations=f),p.length>0&&(s.nodes=p)}return s.object=n,s;function o(a){const c=[];for(const u in a){const h=a[u];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const n=t.children[s];this.add(n.clone())}return this}}ae.DEFAULT_UP=new M(0,1,0),ae.DEFAULT_MATRIX_AUTO_UPDATE=!0,ae.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const vt=new M,Yt=new M,Vn=new M,Zt=new M,ve=new M,Le=new M,fr=new M,Un=new M,kn=new M,qn=new M,Hn=new Rt,Wn=new Rt,$n=new Rt;class _t{constructor(t=new M,e=new M,s=new M){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,n){n.subVectors(s,e),vt.subVectors(t,e),n.cross(vt);const i=n.lengthSq();return i>0?n.multiplyScalar(1/Math.sqrt(i)):n.set(0,0,0)}static getBarycoord(t,e,s,n,i){vt.subVectors(n,e),Yt.subVectors(s,e),Vn.subVectors(t,e);const o=vt.dot(vt),a=vt.dot(Yt),c=vt.dot(Vn),u=Yt.dot(Yt),h=Yt.dot(Vn),l=o*u-a*a;if(l===0)return i.set(0,0,0),null;const d=1/l,f=(u*c-a*h)*d,p=(o*h-a*c)*d;return i.set(1-f-p,p,f)}static containsPoint(t,e,s,n){return this.getBarycoord(t,e,s,n,Zt)===null?!1:Zt.x>=0&&Zt.y>=0&&Zt.x+Zt.y<=1}static getInterpolation(t,e,s,n,i,o,a,c){return this.getBarycoord(t,e,s,n,Zt)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(i,Zt.x),c.addScaledVector(o,Zt.y),c.addScaledVector(a,Zt.z),c)}static getInterpolatedAttribute(t,e,s,n,i,o){return Hn.setScalar(0),Wn.setScalar(0),$n.setScalar(0),Hn.fromBufferAttribute(t,e),Wn.fromBufferAttribute(t,s),$n.fromBufferAttribute(t,n),o.setScalar(0),o.addScaledVector(Hn,i.x),o.addScaledVector(Wn,i.y),o.addScaledVector($n,i.z),o}static isFrontFacing(t,e,s,n){return vt.subVectors(s,e),Yt.subVectors(t,e),vt.cross(Yt).dot(n)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,n){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,s,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,n),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 vt.subVectors(this.c,this.b),Yt.subVectors(this.a,this.b),vt.cross(Yt).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return _t.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return _t.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,n,i){return _t.getInterpolation(t,this.a,this.b,this.c,e,s,n,i)}containsPoint(t){return _t.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return _t.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,n=this.b,i=this.c;let o,a;ve.subVectors(n,s),Le.subVectors(i,s),Un.subVectors(t,s);const c=ve.dot(Un),u=Le.dot(Un);if(c<=0&&u<=0)return e.copy(s);kn.subVectors(t,n);const h=ve.dot(kn),l=Le.dot(kn);if(h>=0&&l<=h)return e.copy(n);const d=c*l-h*u;if(d<=0&&c>=0&&h<=0)return o=c/(c-h),e.copy(s).addScaledVector(ve,o);qn.subVectors(t,i);const f=ve.dot(qn),p=Le.dot(qn);if(p>=0&&f<=p)return e.copy(i);const m=f*u-c*p;if(m<=0&&u>=0&&p<=0)return a=u/(u-p),e.copy(s).addScaledVector(Le,a);const x=h*p-f*l;if(x<=0&&l-h>=0&&f-p>=0)return fr.subVectors(i,n),a=(l-h)/(l-h+(f-p)),e.copy(n).addScaledVector(fr,a);const g=1/(x+m+d);return o=m*g,a=d*g,e.copy(s).addScaledVector(ve,o).addScaledVector(Le,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const pr={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},ce={h:0,s:0,l:0},ks={h:0,s:0,l:0};function Gn(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class Xn{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Wt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,wt.toWorkingColorSpace(this,e),this}setRGB(t,e,s,n=wt.workingColorSpace){return this.r=t,this.g=e,this.b=s,wt.toWorkingColorSpace(this,n),this}setHSL(t,e,s,n=wt.workingColorSpace){if(t=En(t,1),e=lt(e,0,1),s=lt(s,0,1),e===0)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+e):s+e-s*e,o=2*s-i;this.r=Gn(o,i,t+1/3),this.g=Gn(o,i,t),this.b=Gn(o,i,t-1/3)}return wt.toWorkingColorSpace(this,n),this}setStyle(t,e=Wt){function s(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let i;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],o=i.length;if(o===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(i,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Wt){const s=pr[t.toLowerCase()];return s!==void 0?this.setHex(s,e):console.warn("THREE.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=be(t.r),this.g=be(t.g),this.b=be(t.b),this}copyLinearToSRGB(t){return this.r=Fn(t.r),this.g=Fn(t.g),this.b=Fn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Wt){return wt.fromWorkingColorSpace(dt.copy(this),t),Math.round(lt(dt.r*255,0,255))*65536+Math.round(lt(dt.g*255,0,255))*256+Math.round(lt(dt.b*255,0,255))}getHexString(t=Wt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=wt.workingColorSpace){wt.fromWorkingColorSpace(dt.copy(this),e);const s=dt.r,n=dt.g,i=dt.b,o=Math.max(s,n,i),a=Math.min(s,n,i);let c,u;const h=(a+o)/2;if(a===o)c=0,u=0;else{const l=o-a;switch(u=h<=.5?l/(o+a):l/(2-o-a),o){case s:c=(n-i)/l+(n<i?6:0);break;case n:c=(i-s)/l+2;break;case i:c=(s-n)/l+4;break}c/=6}return t.h=c,t.s=u,t.l=h,t}getRGB(t,e=wt.workingColorSpace){return wt.fromWorkingColorSpace(dt.copy(this),e),t.r=dt.r,t.g=dt.g,t.b=dt.b,t}getStyle(t=Wt){wt.fromWorkingColorSpace(dt.copy(this),t);const e=dt.r,s=dt.g,n=dt.b;return t!==Wt?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(n*255)})`}offsetHSL(t,e,s){return this.getHSL(ce),this.setHSL(ce.h+t,ce.s+e,ce.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.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,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(ce),t.getHSL(ks);const s=is(ce.h,ks.h,e),n=is(ce.s,ks.s,e),i=is(ce.l,ks.l,e);return this.setHSL(s,n,i),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,n=this.b,i=t.elements;return this.r=i[0]*e+i[3]*s+i[6]*n,this.g=i[1]*e+i[4]*s+i[7]*n,this.b=i[2]*e+i[5]*s+i[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const dt=new Xn;Xn.NAMES=pr;const j=new M,qs=new Z;class Lt{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}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,e,s){t*=this.itemSize,s*=e.itemSize;for(let n=0,i=this.itemSize;n<i;n++)this.array[t+n]=e.array[s+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)qs.fromBufferAttribute(this,e),qs.applyMatrix3(t),this.setXY(e,qs.x,qs.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix3(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix4(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyNormalMatrix(t),this.setXYZ(e,j.x,j.y,j.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.transformDirection(t),this.setXYZ(e,j.x,j.y,j.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Ft(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=W(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ft(e,this.array)),e}setX(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ft(e,this.array)),e}setY(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ft(e,this.array)),e}setZ(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ft(e,this.array)),e}setW(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=W(e,this.array),s=W(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,n){return t*=this.itemSize,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=n,this}setXYZW(t,e,s,n,i){return t*=this.itemSize,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array),i=W(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=n,this.array[t+3]=i,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!==35044&&(t.usage=this.usage),t}}class da extends Lt{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class fa extends Lt{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class pa extends Lt{constructor(t,e,s){super(new Float32Array(t),e,s)}}let ma=0;const zt=new Q,Yn=new ae,Oe=new M,St=new mt,us=new mt,ot=new M;class Zn extends ns{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ma++}),this.uuid=se(),this.name="",this.type="BufferGeometry",this.index=null,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(Qo(t)?fa:da)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const i=new Bt().getNormalMatrix(t);s.applyNormalMatrix(i),s.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return zt.makeRotationFromQuaternion(t),this.applyMatrix4(zt),this}rotateX(t){return zt.makeRotationX(t),this.applyMatrix4(zt),this}rotateY(t){return zt.makeRotationY(t),this.applyMatrix4(zt),this}rotateZ(t){return zt.makeRotationZ(t),this.applyMatrix4(zt),this}translate(t,e,s){return zt.makeTranslation(t,e,s),this.applyMatrix4(zt),this}scale(t,e,s){return zt.makeScale(t,e,s),this.applyMatrix4(zt),this}lookAt(t){return Yn.lookAt(t),Yn.updateMatrix(),this.applyMatrix4(Yn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Oe).negate(),this.translate(Oe.x,Oe.y,Oe.z),this}setFromPoints(t){const e=[];for(let s=0,n=t.length;s<n;s++){const i=t[s];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new pa(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,n=e.length;s<n;s++){const i=e[s];St.setFromBufferAttribute(i),this.morphTargetsRelative?(ot.addVectors(this.boundingBox.min,St.min),this.boundingBox.expandByPoint(ot),ot.addVectors(this.boundingBox.max,St.max),this.boundingBox.expandByPoint(ot)):(this.boundingBox.expandByPoint(St.min),this.boundingBox.expandByPoint(St.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 na);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new M,1/0);return}if(t){const s=this.boundingSphere.center;if(St.setFromBufferAttribute(t),e)for(let i=0,o=e.length;i<o;i++){const a=e[i];us.setFromBufferAttribute(a),this.morphTargetsRelative?(ot.addVectors(St.min,us.min),St.expandByPoint(ot),ot.addVectors(St.max,us.max),St.expandByPoint(ot)):(St.expandByPoint(us.min),St.expandByPoint(us.max))}St.getCenter(s);let n=0;for(let i=0,o=t.count;i<o;i++)ot.fromBufferAttribute(t,i),n=Math.max(n,s.distanceToSquared(ot));if(e)for(let i=0,o=e.length;i<o;i++){const a=e[i],c=this.morphTargetsRelative;for(let u=0,h=a.count;u<h;u++)ot.fromBufferAttribute(a,u),c&&(Oe.fromBufferAttribute(t,u),ot.add(Oe)),n=Math.max(n,s.distanceToSquared(ot))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=e.position,n=e.normal,i=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Lt(new Float32Array(4*s.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let z=0;z<s.count;z++)a[z]=new M,c[z]=new M;const u=new M,h=new M,l=new M,d=new Z,f=new Z,p=new Z,m=new M,x=new M;function g(z,B,b){u.fromBufferAttribute(s,z),h.fromBufferAttribute(s,B),l.fromBufferAttribute(s,b),d.fromBufferAttribute(i,z),f.fromBufferAttribute(i,B),p.fromBufferAttribute(i,b),h.sub(u),l.sub(u),f.sub(d),p.sub(d);const I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(l,-f.y).multiplyScalar(I),x.copy(l).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),a[z].add(m),a[B].add(m),a[b].add(m),c[z].add(x),c[B].add(x),c[b].add(x))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let z=0,B=y.length;z<B;++z){const b=y[z],I=b.start,C=b.count;for(let P=I,L=I+C;P<L;P+=3)g(t.getX(P+0),t.getX(P+1),t.getX(P+2))}const N=new M,w=new M,T=new M,_=new M;function S(z){T.fromBufferAttribute(n,z),_.copy(T);const B=a[z];N.copy(B),N.sub(T.multiplyScalar(T.dot(B))).normalize(),w.crossVectors(_,B);const I=w.dot(c[z])<0?-1:1;o.setXYZW(z,N.x,N.y,N.z,I)}for(let z=0,B=y.length;z<B;++z){const b=y[z],I=b.start,C=b.count;for(let P=I,L=I+C;P<L;P+=3)S(t.getX(P+0)),S(t.getX(P+1)),S(t.getX(P+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new Lt(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let d=0,f=s.count;d<f;d++)s.setXYZ(d,0,0,0);const n=new M,i=new M,o=new M,a=new M,c=new M,u=new M,h=new M,l=new M;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),m=t.getX(d+1),x=t.getX(d+2);n.fromBufferAttribute(e,p),i.fromBufferAttribute(e,m),o.fromBufferAttribute(e,x),h.subVectors(o,i),l.subVectors(n,i),h.cross(l),a.fromBufferAttribute(s,p),c.fromBufferAttribute(s,m),u.fromBufferAttribute(s,x),a.add(h),c.add(h),u.add(h),s.setXYZ(p,a.x,a.y,a.z),s.setXYZ(m,c.x,c.y,c.z),s.setXYZ(x,u.x,u.y,u.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),i.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,i),l.subVectors(n,i),h.cross(l),s.setXYZ(d+0,h.x,h.y,h.z),s.setXYZ(d+1,h.x,h.y,h.z),s.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)ot.fromBufferAttribute(t,e),ot.normalize(),t.setXYZ(e,ot.x,ot.y,ot.z)}toNonIndexed(){function t(a,c){const u=a.array,h=a.itemSize,l=a.normalized,d=new u.constructor(c.length*h);let f=0,p=0;for(let m=0,x=c.length;m<x;m++){a.isInterleavedBufferAttribute?f=c[m]*a.data.stride+a.offset:f=c[m]*h;for(let g=0;g<h;g++)d[p++]=u[f++]}return new Lt(d,h,l)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Zn,s=this.index.array,n=this.attributes;for(const a in n){const c=n[a],u=t(c,s);e.setAttribute(a,u)}const i=this.morphAttributes;for(const a in i){const c=[],u=i[a];for(let h=0,l=u.length;h<l;h++){const d=u[h],f=t(d,s);c.push(f)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const u=o[a];e.addGroup(u.start,u.count,u.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,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 c=this.parameters;for(const u in c)c[u]!==void 0&&(t[u]=c[u]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const c in s){const u=s[c];t.data.attributes[c]=u.toJSON(t.data)}const n={};let i=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],h=[];for(let l=0,d=u.length;l<d;l++){const f=u[l];h.push(f.toJSON(t.data))}h.length>0&&(n[c]=h,i=!0)}i&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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 e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone(e));const n=t.attributes;for(const u in n){const h=n[u];this.setAttribute(u,h.clone(e))}const i=t.morphAttributes;for(const u in i){const h=[],l=i[u];for(let d=0,f=l.length;d<f;d++)h.push(l[d].clone(e));this.morphAttributes[u]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let u=0,h=o.length;u<h;u++){const l=o[u];this.addGroup(l.start,l.count,l.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Jn=new M,ya=new M,ga=new Bt;class Qn{constructor(t=new M(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,n){return this.normal.set(t,e,s),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const n=Jn.subVectors(s,e).cross(ya.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(Jn),n=this.normal.dot(s);if(n===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/n;return i<0||i>1?null:e.copy(t.start).addScaledVector(s,i)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||ga.getNormalMatrix(t),n=this.coplanarPoint(Jn).applyMatrix4(t),i=this.normal.applyMatrix3(s).normalize();return this.constant=-n.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}class mr extends Ut{constructor(t,e,s,n,i,o,a,c,u,h=1026){if(h!==1026&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");s===void 0&&h===1026&&(s=1014),s===void 0&&h===1027&&(s=1020),super(null,n,i,o,a,c,h,s,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:1003,this.minFilter=c!==void 0?c:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class xa{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=se()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,s){t*=this.stride,s*=e.stride;for(let n=0,i=this.stride;n<i;n++)this.array[t+n]=e.array[s+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=se()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(e,this.stride);return s.setUsage(this.usage),s}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=se()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const yt=new M;class jn{constructor(t,e,s,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)yt.fromBufferAttribute(this,e),yt.applyMatrix4(t),this.setXYZ(e,yt.x,yt.y,yt.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)yt.fromBufferAttribute(this,e),yt.applyNormalMatrix(t),this.setXYZ(e,yt.x,yt.y,yt.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)yt.fromBufferAttribute(this,e),yt.transformDirection(t),this.setXYZ(e,yt.x,yt.y,yt.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Ft(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=W(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ft(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ft(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ft(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ft(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=W(e,this.array),s=W(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=n,this}setXYZW(t,e,s,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array),i=W(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=n,this.data.array[t+3]=i,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const n=s*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)e.push(this.data.array[n+i])}return new Lt(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new jn(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const n=s*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)e.push(this.data.array[n+i])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ta extends Ut{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}const yr=new M,Hs=new M;class Jt{constructor(t=new M,e=new M){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){yr.subVectors(t,this.start),Hs.subVectors(this.end,this.start);const s=Hs.dot(Hs);let i=Hs.dot(yr)/s;return e&&(i=lt(i,0,1)),i}closestPointToPoint(t,e,s){const n=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}function Kn(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let n=0,i;n<r.length;n++)i=r[n],e=Math.imul(e^i,2654435761),s=Math.imul(s^i,1597334677);else for(let n=0,i;n<r.length;n++)i=r.charCodeAt(n),e=Math.imul(e^i,2654435761),s=Math.imul(s^i,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const Na=(...r)=>Kn(r);function wa(r,t=!1){const e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(const{property:s,childNode:n}of ti(r))e.push(e,Kn(s.slice(0,-4)),n.getCacheKey(t));return Kn(e)}function*ti(r,t=!1){for(const e in r){if(e.startsWith("_")===!0)continue;const s=r[e];if(Array.isArray(s)===!0)for(let n=0;n<s.length;n++){const i=s[n];i&&(i.isNode===!0||t&&typeof i.toJSON=="function")&&(yield{property:e,index:n,childNode:i})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(const n in s){const i=s[n];i&&(i.isNode===!0||t&&typeof i.toJSON=="function")&&(yield{property:e,index:n,childNode:i})}}}function Ws(r){if(r==null)return null;const t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function gr(r,...t){const e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new Xn(...t):e==="vec2"?new Z(...t):e==="vec3"?new M(...t):e==="vec4"?new Rt(...t):e==="mat3"?new Bt(...t):e==="mat4"?new Q(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Sa(t[0]):null}function Aa(r){let t="";const e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Sa(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}const xr={VERTEX:"vertex"},K={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ls=["x","y","z","w"];let Ma=0;class U extends ns{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=K.NONE,this.updateBeforeType=K.NONE,this.updateAfterType=K.NONE,this.uuid=Jo.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Ma++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,K.FRAME)}onRenderUpdate(t){return this.onUpdate(t,K.RENDER)}onObjectUpdate(t){return this.onUpdate(t,K.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of ti(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t=t||this.version!==this._cacheKeyVersion,(t===!0||this._cacheKey===null)&&(this._cacheKey=wa(this,t),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){const e=t.getNodeProperties(this);let s=0;for(const n of this.getChildren())e["node"+s++]=n;return null}analyze(t){if(t.increaseUsage(this)===1){const s=t.getNodeProperties(this);for(const n of Object.values(s))n&&n.isNode===!0&&n.build(t)}}generate(t,e){const{outputNode:s}=t.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){const s=this.getShared(t);if(this!==s)return s.build(t,e);t.addNode(this),t.addChain(this);let n=null;const i=t.getBuildStage();if(i==="setup"){this.updateReference(t);const o=t.getNodeProperties(this);if(o.initialized!==!0){const a=t.stack.nodes.length;o.initialized=!0,o.outputNode=this.setup(t),o.outputNode!==null&&t.stack.nodes.length;for(const c of Object.values(o))c&&c.isNode===!0&&c.build(t)}}else if(i==="analyze")this.analyze(t);else if(i==="generate")if(this.generate.length===1){const a=this.getNodeType(t),c=t.getDataFromNode(this);n=c.snippet,n===void 0?(n=this.generate(t)||"",c.snippet=n):c.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,a,e)}else n=this.generate(t,e)||"";return t.removeChain(this),n}getSerializeChildren(){return ti(this)}serialize(t){const e=this.getSerializeChildren(),s={};for(const{property:n,index:i,childNode:o}of e)i!==void 0?(s[n]===void 0&&(s[n]=Number.isInteger(i)?[]:{}),s[n][i]=o.toJSON(t.meta).uuid):s[n]=o.toJSON(t.meta).uuid;Object.keys(s).length>0&&(t.inputNodes=s)}deserialize(t){if(t.inputNodes!==void 0){const e=t.meta.nodes;for(const s in t.inputNodes)if(Array.isArray(t.inputNodes[s])){const n=[];for(const i of t.inputNodes[s])n.push(e[i]);this[s]=n}else if(typeof t.inputNodes[s]=="object"){const n={};for(const i in t.inputNodes[s]){const o=t.inputNodes[s][i];n[i]=e[o]}this[s]=n}else{const n=t.inputNodes[s];this[s]=e[n]}}}toJSON(t){const{uuid:e,type:s}=this,n=t===void 0||typeof t=="string";n&&(t={textures:{},images:{},nodes:{}});let i=t.nodes[e];i===void 0&&(i={uuid:e,type:s,meta:t,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},n!==!0&&(t.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function o(a){const c=[];for(const u in a){const h=a[u];delete h.metadata,c.push(h)}return c}if(n){const a=o(t.textures),c=o(t.images),u=o(t.nodes);a.length>0&&(i.textures=a),c.length>0&&(i.images=c),u.length>0&&(i.nodes=u)}return i}}class ds extends U{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){const e=this.node.build(t),s=this.indexNode.build(t,"uint");return`${e}[ ${s} ]`}}class Tr extends U{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let s=null;for(const n of this.convertTo.split("|"))(s===null||t.getTypeLength(e)===t.getTypeLength(n))&&(s=n);return s}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const s=this.node,n=this.getNodeType(t),i=s.build(t,n);return t.format(i,n,e)}}class Tt extends U{static get type(){return"TempNode"}constructor(t){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){const n=t.getVectorType(this.getNodeType(t,e)),i=t.getDataFromNode(this);if(i.propertyName!==void 0)return t.format(i.propertyName,n,e);if(n!=="void"&&e!=="void"&&this.hasDependencies(t)){const o=super.build(t,n),a=t.getVarFromNode(this,null,n),c=t.getPropertyName(a);return t.addLineFlowCode(`${c} = ${o}`,this),i.snippet=o,i.propertyName=c,t.format(i.propertyName,n,e)}}return super.build(t,e)}}class _a extends Tt{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,s)=>e+t.getTypeLength(s.getNodeType(t)),0))}generate(t,e){const s=this.getNodeType(t),n=this.nodes,i=t.getComponentType(s),o=[];for(const c of n){let u=c.build(t);const h=t.getComponentType(c.getNodeType(t));h!==i&&(u=t.format(u,h,i)),o.push(u)}const a=`${t.getType(s)}( ${o.join(", ")} )`;return t.format(a,s,e)}}const za=ls.join("");class Nr extends U{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(ls.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){const s=this.node,n=t.getTypeLength(s.getNodeType(t));let i=null;if(n>1){let o=null;this.getVectorLength()>=n&&(o=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const c=s.build(t,o);this.components.length===n&&this.components===za.slice(0,this.components.length)?i=t.format(c,o,e):i=t.format(`${c}.${this.components}`,this.getNodeType(t),e)}else i=s.build(t,e);return i}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class ba extends Tt{static get type(){return"SetNode"}constructor(t,e,s){super(),this.sourceNode=t,this.components=e,this.targetNode=s}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:s,targetNode:n}=this,i=this.getNodeType(t),o=t.getTypeFromLength(s.length,n.getNodeType(t)),a=n.build(t,o),c=e.build(t,i),u=t.getTypeLength(i),h=[];for(let l=0;l<u;l++){const d=ls[l];d===s[0]?(h.push(a),l+=s.length-1):h.push(c+"."+d)}return`${t.getType(i)}( ${h.join(", ")} )`}}class Ea extends Tt{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:s}=this,n=this.getNodeType(t),i=s.build(t),o=t.getVarFromNode(this),a=t.getPropertyName(o);t.addLineFlowCode(a+" = "+i,this);const c=t.getTypeLength(n),u=[];let h=0;for(let l=0;l<c;l++){const d=ls[l];d===e[h]?(u.push("1.0 - "+(a+"."+d)),h++):u.push(a+"."+d)}return`${t.getType(n)}( ${u.join(", ")} )`}}class ei extends U{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Ws(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Ws(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=Aa(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?gr(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}}class Qt extends ei{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const s=this.getNodeType(t);return t.format(this.generateConst(t),s,e)}}let wr=null;const De=new Map;function F(r,t){if(De.has(r)){console.warn(`Redefinition of method chaining ${r}`);return}if(typeof t!="function")throw new Error(`Node element ${r} is not a function`);De.set(r,t)}const Ar=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Sr=r=>Ar(r).split("").sort().join(""),Mr={setup(r,t){const e=t.shift();return r(Xs(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(wr.assign(e,...s),e);if(De.has(t)){const s=De.get(t);return r.isStackNode?(...n)=>e.add(s(...n)):(...n)=>s(e,...n)}else{if(t==="self")return r;if(t.endsWith("Assign")&&De.has(t.slice(0,t.length-6))){const s=De.get(t.slice(0,t.length-6));return r.isStackNode?(...n)=>e.assign(n[0],s(...n)):(...n)=>e.assign(s(e,...n))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=Ar(t),v(new Nr(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Sr(t.slice(3).toLowerCase()),s=>v(new ba(r,t,s));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Sr(t.slice(4).toLowerCase()),()=>v(new Ea(v(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),v(new Nr(r,t));if(/^\d+$/.test(t)===!0)return v(new ds(e,new Qt(Number(t),"uint")))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},si=new WeakMap,_r=new WeakMap,Ca=function(r,t=null){const e=Ws(r);if(e==="node"){let s=si.get(r);return s===void 0&&(s=new Proxy(r,Mr),si.set(r,s),si.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return v(oi(r,t));if(e==="shader")return et(r)}return r},Fa=function(r,t=null){for(const e in r)r[e]=v(r[e],t);return r},Ba=function(r,t=null){const e=r.length;for(let s=0;s<e;s++)r[s]=v(r[s],t);return r},Ra=function(r,t=null,e=null,s=null){const n=i=>v(s!==null?Object.assign(i,s):i);return t===null?(...i)=>n(new r(...Ve(i))):e!==null?(e=v(e),(...i)=>n(new r(t,...Ve(i),e))):(...i)=>n(new r(t,...Ve(i)))},Ia=function(r,...t){return v(new r(...Ve(t)))};class Pa extends U{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}call(t){const{shaderNode:e,inputNodes:s}=this,n=t.getNodeProperties(e);if(n.onceOutput)return n.onceOutput;let i=null;if(e.layout){let o=_r.get(t.constructor);o===void 0&&(o=new WeakMap,_r.set(t.constructor,o));let a=o.get(e);a===void 0&&(a=v(t.buildFunctionNode(e)),o.set(e,a)),t.currentFunctionNode!==null&&t.currentFunctionNode.includes.push(a),i=v(a.call(s))}else{const o=e.jsFunc,a=s!==null?o(s,t):o(t);i=v(a)}return e.once&&(n.onceOutput=i),i}getOutputNode(t){const e=t.getNodeProperties(this);return e.outputNode===null&&(e.outputNode=this.setupOutput(t)),e.outputNode}setup(t){return this.getOutputNode(t)}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}generate(t,e){return this.getOutputNode(t).build(t,e)}}class va extends U{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}call(t=null){return Xs(t),v(new Pa(this,t))}setup(){return this.call()}}const La=[!1,!0],Oa=[0,1,2,3],Da=[-1,-2],zr=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],ni=new Map;for(const r of La)ni.set(r,new Qt(r));const ii=new Map;for(const r of Oa)ii.set(r,new Qt(r,"uint"));const ri=new Map([...ii].map(r=>new Qt(r.value,"int")));for(const r of Da)ri.set(r,new Qt(r,"int"));const $s=new Map([...ri].map(r=>new Qt(r.value)));for(const r of zr)$s.set(r,new Qt(r));for(const r of zr)$s.set(-r,new Qt(-r));const Gs={bool:ni,uint:ii,ints:ri,float:$s},br=new Map([...ni,...$s]),oi=(r,t)=>br.has(r)?br.get(r):r.isNode===!0?r:new Qt(r,t),Va=r=>{try{return r.getNodeType()}catch{return}},tt=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(n=>typeof n!="object"))&&(e=[gr(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return v(t.get(e[0]));if(e.length===1){const n=oi(e[0],r);return Va(n)===r?v(n):v(new Tr(n,r))}const s=e.map(n=>oi(n));return v(new _a(s,r))}},Ua=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function ka(r,t){return new Proxy(new va(r,t),Mr)}const v=(r,t=null)=>Ca(r,t),Xs=(r,t=null)=>new Fa(r,t),Ve=(r,t=null)=>new Ba(r,t),R=(...r)=>new Ra(...r),O=(...r)=>new Ia(...r),et=(r,t)=>{const e=new ka(r,t),s=(...n)=>{let i;return Xs(n),n[0]&&n[0].isNode?i=[...n]:i=n[0],e.call(i)};return s.shaderNode=e,s.setLayout=n=>(e.setLayout(n),s),s.once=()=>(e.once=!0,s),s};F("toGlobal",r=>(r.global=!0,r));const ai=(...r)=>wr.If(...r);function qa(r){return r}F("append",qa);const Ha=new tt("color"),H=new tt("float",Gs.float),Ue=new tt("int",Gs.ints),Wa=new tt("uint",Gs.uint),$a=new tt("bool",Gs.bool),V=new tt("vec2"),Ga=new tt("ivec2"),Xa=new tt("uvec2"),Ya=new tt("bvec2"),k=new tt("vec3"),Za=new tt("ivec3"),Ja=new tt("uvec3"),Qa=new tt("bvec3"),ke=new tt("vec4"),ja=new tt("ivec4"),Ka=new tt("uvec4"),tc=new tt("bvec4"),Er=new tt("mat2"),Ys=new tt("mat3"),ec=new tt("mat4");F("toColor",Ha),F("toFloat",H),F("toInt",Ue),F("toUint",Wa),F("toBool",$a),F("toVec2",V),F("toIVec2",Ga),F("toUVec2",Xa),F("toBVec2",Ya),F("toVec3",k),F("toIVec3",Za),F("toUVec3",Ja),F("toBVec3",Qa),F("toVec4",ke),F("toIVec4",ja),F("toUVec4",Ka),F("toBVec4",tc),F("toMat2",Er),F("toMat3",Ys),F("toMat4",ec);const sc=R(ds),nc=(r,t)=>v(new Tr(v(r),t));F("element",sc),F("convert",nc);class Cr extends U{static get type(){return"UniformGroupNode"}constructor(t,e=!1,s=1){super("string"),this.name=t,this.version=0,this.shared=e,this.order=s,this.isUniformGroup=!0}set needsUpdate(t){t===!0&&this.version++}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const ic=r=>new Cr(r),xe=((r,t=0)=>new Cr(r,!0,t))("render"),rc=ic("object");class qe extends ei{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=rc}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){const s=this.getSelf();return t=t.bind(s),super.onUpdate(n=>{const i=t(n,s);i!==void 0&&(this.value=i)},e)}generate(t,e){const s=this.getNodeType(t),n=this.getUniformHash(t);let i=t.getNodeFromHash(n);i===void 0&&(t.setHashNode(this,n),i=this);const o=i.getInputType(t),a=t.getUniformFromNode(i,o,t.shaderStage,this.name||t.context.label),c=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(c,s,e)}}const Mt=(r,t)=>{const e=Ua(t||r),s=r&&r.isNode===!0?r.node&&r.node.value||r.value:r;return v(new qe(s,e))};class Fr extends U{static get type(){return"PropertyNode"}constructor(t,e=null,s=!1){super(t),this.name=e,this.varying=s,this.isPropertyNode=!0}getHash(t){return this.name||super.getHash(t)}isGlobal(){return!0}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const He=(r,t)=>v(new Fr(r,t)),Br=O(Fr,"vec4","DiffuseColor");class oc extends Tt{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e}hasDependencies(){return!1}getNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){const s=t.getTypeLength(e.node.getNodeType(t));return ls.join("").slice(0,s)!==e.components}return!1}generate(t,e){const{targetNode:s,sourceNode:n}=this,i=this.needsSplitAssign(t),o=s.getNodeType(t),a=s.context({assign:!0}).build(t),c=n.build(t,o),u=n.getNodeType(t),h=t.getDataFromNode(this);let l;if(h.initialized===!0)e!=="void"&&(l=a);else if(i){const d=t.getVarFromNode(this,null,o),f=t.getPropertyName(d);t.addLineFlowCode(`${f} = ${c}`,this);const p=s.node.context({assign:!0}).build(t);for(let m=0;m<s.components.length;m++){const x=s.components[m];t.addLineFlowCode(`${p}.${x} = ${f}[ ${m} ]`,this)}e!=="void"&&(l=a)}else l=`${a} = ${c}`,(e==="void"||u==="void")&&(t.addLineFlowCode(l,this),e!=="void"&&(l=a));return h.initialized=!0,t.format(l,o,e)}}F("assign",R(oc));class ac extends Tt{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){const e=[],s=this.functionNode,n=s.getInputs(t),i=this.parameters;if(Array.isArray(i))for(let a=0;a<i.length;a++){const c=n[a],u=i[a];e.push(u.build(t,c.type))}else for(const a of n){const c=i[a.name];if(c!==void 0)e.push(c.build(t,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${s.build(t,"property")}( ${e.join(", ")} )`}}F("call",(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Ve(t):Xs(t[0]),v(new ac(v(r),t))));class Y extends Tt{static get type(){return"OperatorNode"}constructor(t,e,s,...n){if(super(),n.length>0){let i=new Y(t,e,s);for(let o=0;o<n.length-1;o++)i=new Y(t,i,n[o]);e=i,s=n[n.length-1]}this.op=t,this.aNode=e,this.bNode=s}getNodeType(t,e){const s=this.op,n=this.aNode,i=this.bNode,o=n.getNodeType(t),a=typeof i<"u"?i.getNodeType(t):null;if(o==="void"||a==="void")return"void";if(s==="%")return o;if(s==="~"||s==="&"||s==="|"||s==="^"||s===">>"||s==="<<")return t.getIntegerType(o);if(s==="!"||s==="=="||s==="&&"||s==="||"||s==="^^")return"bool";if(s==="<"||s===">"||s==="<="||s===">="){const c=e?t.getTypeLength(e):Math.max(t.getTypeLength(o),t.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else return o==="float"&&t.isMatrix(a)?a:t.isMatrix(o)&&t.isVector(a)?t.getVectorFromMatrix(o):t.isVector(o)&&t.isMatrix(a)?t.getVectorFromMatrix(a):t.getTypeLength(a)>t.getTypeLength(o)?a:o}generate(t,e){const s=this.op,n=this.aNode,i=this.bNode,o=this.getNodeType(t,e);let a=null,c=null;o!=="void"?(a=n.getNodeType(t),c=typeof i<"u"?i.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="?t.isVector(a)?c=a:a!==c&&(a=c="float"):s===">>"||s==="<<"?(a=o,c=t.changeComponentType(c,"uint")):t.isMatrix(a)&&t.isVector(c)?c=t.getVectorFromMatrix(a):t.isVector(a)&&t.isMatrix(c)?a=t.getVectorFromMatrix(c):a=c=o):a=c=o;const u=n.build(t,a),h=typeof i<"u"?i.build(t,c):null,l=t.getTypeLength(e),d=t.getFunctionOperator(s);if(e!=="void")return s==="<"&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThan",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} < ${h} )`,o,e):s==="<="&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThanEqual",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} <= ${h} )`,o,e):s===">"&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThan",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} > ${h} )`,o,e):s===">="&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThanEqual",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} >= ${h} )`,o,e):s==="!"||s==="~"?t.format(`(${s}${u})`,a,e):d?t.format(`${d}( ${u}, ${h} )`,o,e):t.format(`( ${u} ${s} ${h} )`,o,e);if(a!=="void")return d?t.format(`${d}( ${u}, ${h} )`,o,e):t.format(`${u} ${s} ${h}`,o,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const Te=R(Y,"+"),Zs=R(Y,"-"),Js=R(Y,"*"),Rr=R(Y,"/"),Ir=R(Y,"%"),cc=R(Y,"=="),hc=R(Y,"!="),uc=R(Y,"<"),lc=R(Y,">"),dc=R(Y,"<="),fc=R(Y,">="),pc=R(Y,"&&"),mc=R(Y,"||"),yc=R(Y,"!"),gc=R(Y,"^^"),xc=R(Y,"&"),Tc=R(Y,"~"),Nc=R(Y,"|"),wc=R(Y,"^"),Ac=R(Y,"<<"),Sc=R(Y,">>");F("add",Te),F("sub",Zs),F("mul",Js),F("div",Rr),F("modInt",Ir),F("equal",cc),F("notEqual",hc),F("lessThan",uc),F("greaterThan",lc),F("lessThanEqual",dc),F("greaterThanEqual",fc),F("and",pc),F("or",mc),F("not",yc),F("xor",gc),F("bitAnd",xc),F("bitNot",Tc),F("bitOr",Nc),F("bitXor",wc),F("shiftLeft",Ac),F("shiftRight",Sc),F("remainder",(...r)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Ir(...r)));class A extends Tt{static get type(){return"MathNode"}constructor(t,e,s=null,n=null){super(),this.method=t,this.aNode=e,this.bNode=s,this.cNode=n}getInputType(t){const e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,n=this.cNode?this.cNode.getNodeType(t):null,i=t.isMatrix(e)?0:t.getTypeLength(e),o=t.isMatrix(s)?0:t.getTypeLength(s),a=t.isMatrix(n)?0:t.getTypeLength(n);return i>o&&i>a?e:o>a?s:a>i?n:e}getNodeType(t){const e=this.method;return e===A.LENGTH||e===A.DISTANCE||e===A.DOT?"float":e===A.CROSS?"vec3":e===A.ALL?"bool":e===A.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):e===A.MOD?this.aNode.getNodeType(t):this.getInputType(t)}generate(t,e){const s=this.method,n=this.getNodeType(t),i=this.getInputType(t),o=this.aNode,a=this.bNode,c=this.cNode,u=t.renderer.isWebGLRenderer===!0;if(s===A.TRANSFORM_DIRECTION){let h=o,l=a;t.isMatrix(h.getNodeType(t))?l=ke(k(l),0):h=ke(k(h),0);const d=Js(h,l).xyz;return Pr(d).build(t,e)}else{if(s===A.NEGATE)return t.format("( - "+o.build(t,i)+" )",n,e);if(s===A.ONE_MINUS)return Zs(1,o).build(t,e);if(s===A.RECIPROCAL)return Rr(1,o).build(t,e);if(s===A.DIFFERENCE)return ui(Zs(o,a)).build(t,e);{const h=[];return s===A.CROSS||s===A.MOD?h.push(o.build(t,n),a.build(t,n)):u&&s===A.STEP?h.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":i),a.build(t,i)):u&&(s===A.MIN||s===A.MAX)||s===A.MOD?h.push(o.build(t,i),a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":i)):s===A.REFRACT?h.push(o.build(t,i),a.build(t,i),c.build(t,"float")):s===A.MIX?h.push(o.build(t,i),a.build(t,i),c.build(t,t.getTypeLength(c.getNodeType(t))===1?"float":i)):(h.push(o.build(t,i)),a!==null&&h.push(a.build(t,i)),c!==null&&h.push(c.build(t,i))),t.format(`${t.getMethod(s,n)}( ${h.join(", ")} )`,n,e)}}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}A.ALL="all",A.ANY="any",A.EQUALS="equals",A.RADIANS="radians",A.DEGREES="degrees",A.EXP="exp",A.EXP2="exp2",A.LOG="log",A.LOG2="log2",A.SQRT="sqrt",A.INVERSE_SQRT="inversesqrt",A.FLOOR="floor",A.CEIL="ceil",A.NORMALIZE="normalize",A.FRACT="fract",A.SIN="sin",A.COS="cos",A.TAN="tan",A.ASIN="asin",A.ACOS="acos",A.ATAN="atan",A.ABS="abs",A.SIGN="sign",A.LENGTH="length",A.NEGATE="negate",A.ONE_MINUS="oneMinus",A.DFDX="dFdx",A.DFDY="dFdy",A.ROUND="round",A.RECIPROCAL="reciprocal",A.TRUNC="trunc",A.FWIDTH="fwidth",A.BITCAST="bitcast",A.TRANSPOSE="transpose",A.ATAN2="atan2",A.MIN="min",A.MAX="max",A.MOD="mod",A.STEP="step",A.REFLECT="reflect",A.DISTANCE="distance",A.DIFFERENCE="difference",A.DOT="dot",A.CROSS="cross",A.POW="pow",A.TRANSFORM_DIRECTION="transformDirection",A.MIX="mix",A.CLAMP="clamp",A.REFRACT="refract",A.SMOOTHSTEP="smoothstep",A.FACEFORWARD="faceforward";const Mc=H(Math.PI),_c=R(A,A.ALL),zc=R(A,A.ANY),bc=R(A,A.EQUALS),Ec=R(A,A.RADIANS),Cc=R(A,A.DEGREES),Fc=R(A,A.EXP),Bc=R(A,A.EXP2),Rc=R(A,A.LOG),Ic=R(A,A.LOG2),ci=R(A,A.SQRT),Pc=R(A,A.INVERSE_SQRT),vc=R(A,A.FLOOR),Lc=R(A,A.CEIL),Pr=R(A,A.NORMALIZE),hi=R(A,A.FRACT),vr=R(A,A.SIN),Oc=R(A,A.COS),Dc=R(A,A.TAN),Vc=R(A,A.ASIN),Uc=R(A,A.ACOS),kc=R(A,A.ATAN),ui=R(A,A.ABS),Lr=R(A,A.SIGN),qc=R(A,A.LENGTH),Hc=R(A,A.NEGATE),Wc=R(A,A.ONE_MINUS),$c=R(A,A.DFDX),Gc=R(A,A.DFDY),Xc=R(A,A.ROUND),Yc=R(A,A.RECIPROCAL),Zc=R(A,A.TRUNC),Jc=R(A,A.FWIDTH);A.BITCAST;const Qc=R(A,A.TRANSPOSE),jc=R(A,A.ATAN2),Kc=R(A,A.MIN),li=R(A,A.MAX),Or=R(A,A.MOD),Dr=R(A,A.STEP),th=R(A,A.REFLECT),eh=R(A,A.DISTANCE),sh=R(A,A.DIFFERENCE),di=R(A,A.DOT),nh=R(A,A.CROSS),Vr=R(A,A.POW),ih=R(A,A.POW,2),rh=R(A,A.POW,3),oh=R(A,A.POW,4),ah=R(A,A.TRANSFORM_DIRECTION),ch=r=>Js(Lr(r),Vr(ui(r),1/3)),hh=r=>di(r,r),he=R(A,A.MIX),Qs=(r,t=0,e=1)=>v(new A(A.CLAMP,v(r),v(t),v(e))),uh=r=>Qs(r),lh=R(A,A.REFRACT),fi=R(A,A.SMOOTHSTEP),dh=R(A,A.FACEFORWARD),fh=et(([r])=>{const s=43758.5453,n=di(r.xy,V(12.9898,78.233)),i=Or(n,Mc);return hi(vr(i).mul(s))}),ph=(r,t,e)=>he(t,e,r),mh=(r,t,e)=>fi(t,e,r);F("all",_c),F("any",zc),F("equals",bc),F("radians",Ec),F("degrees",Cc),F("exp",Fc),F("exp2",Bc),F("log",Rc),F("log2",Ic),F("sqrt",ci),F("inverseSqrt",Pc),F("floor",vc),F("ceil",Lc),F("normalize",Pr),F("fract",hi),F("sin",vr),F("cos",Oc),F("tan",Dc),F("asin",Vc),F("acos",Uc),F("atan",kc),F("abs",ui),F("sign",Lr),F("length",qc),F("lengthSq",hh),F("negate",Hc),F("oneMinus",Wc),F("dFdx",$c),F("dFdy",Gc),F("round",Xc),F("reciprocal",Yc),F("trunc",Zc),F("fwidth",Jc),F("atan2",jc),F("min",Kc),F("max",li),F("mod",Or),F("step",Dr),F("reflect",th),F("distance",eh),F("dot",di),F("cross",nh),F("pow",Vr),F("pow2",ih),F("pow3",rh),F("pow4",oh),F("transformDirection",ah),F("mix",ph),F("clamp",Qs),F("refract",lh),F("smoothstep",mh),F("faceForward",dh),F("difference",sh),F("saturate",uh),F("cbrt",ch),F("transpose",Qc),F("rand",fh);class yh extends U{static get type(){return"ConditionalNode"}constructor(t,e,s=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=s}getNodeType(t){const e=this.ifNode.getNodeType(t);if(this.elseNode!==null){const s=this.elseNode.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(e))return s}return e}setup(t){const e=this.condNode.cache(),s=this.ifNode.cache(),n=this.elseNode?this.elseNode.cache():null,i=t.context.nodeBlock;t.getDataFromNode(s).parentNodeBlock=i,n!==null&&(t.getDataFromNode(n).parentNodeBlock=i);const o=t.getNodeProperties(this);o.condNode=e,o.ifNode=s.context({nodeBlock:s}),o.elseNode=n?n.context({nodeBlock:n}):null}generate(t,e){const s=this.getNodeType(t),n=t.getDataFromNode(this);if(n.nodeProperty!==void 0)return n.nodeProperty;const{condNode:i,ifNode:o,elseNode:a}=t.getNodeProperties(this),c=e!=="void",u=c?He(s).build(t):"";n.nodeProperty=u;const h=i.build(t,"bool");t.addFlowCode(`
1
+ (function(){"use strict";const ze="169.19",Wt="srgb",Rs="srgb-linear",Io="display-p3",Yi="display-p3-linear",bn="linear",Zi="srgb",Ji="rec709";class ns{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const n=this._listeners[t];if(n!==void 0){const i=n.indexOf(e);i!==-1&&n.splice(i,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const s=this._listeners[t.type];if(s!==void 0){t.target=this;const n=s.slice(0);for(let i=0,o=n.length;i<o;i++)n[i].call(this,t);t.target=null}}}const ut=["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 Qi=1234567;const ji=Math.PI/180,Ki=180/Math.PI;function se(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ut[r&255]+ut[r>>8&255]+ut[r>>16&255]+ut[r>>24&255]+"-"+ut[t&255]+ut[t>>8&255]+"-"+ut[t>>16&15|64]+ut[t>>24&255]+"-"+ut[e&63|128]+ut[e>>8&255]+"-"+ut[e>>16&255]+ut[e>>24&255]+ut[s&255]+ut[s>>8&255]+ut[s>>16&255]+ut[s>>24&255]).toLowerCase()}function lt(r,t,e){return Math.max(t,Math.min(e,r))}function En(r,t){return(r%t+t)%t}function Po(r,t,e,s,n){return s+(r-t)*(n-s)/(e-t)}function vo(r,t,e){return r!==t?(e-r)/(t-r):0}function is(r,t,e){return(1-e)*r+e*t}function Lo(r,t,e,s){return is(r,t,1-Math.exp(-e*s))}function Oo(r,t=1){return t-Math.abs(En(r,t*2)-t)}function Do(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Vo(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Uo(r,t){return r+Math.floor(Math.random()*(t-r+1))}function ko(r,t){return r+Math.random()*(t-r)}function qo(r){return r*(.5-Math.random())}function Ho(r){r!==void 0&&(Qi=r);let t=Qi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Wo(r){return r*ji}function $o(r){return r*Ki}function Go(r){return(r&r-1)===0&&r!==0}function Xo(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Yo(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Zo(r,t,e,s,n){const i=Math.cos,o=Math.sin,a=i(e/2),c=o(e/2),u=i((t+s)/2),h=o((t+s)/2),l=i((t-s)/2),d=o((t-s)/2),f=i((s-t)/2),p=o((s-t)/2);switch(n){case"XYX":r.set(a*h,c*l,c*d,a*u);break;case"YZY":r.set(c*d,a*h,c*l,a*u);break;case"ZXZ":r.set(c*l,c*d,a*h,a*u);break;case"XZX":r.set(a*h,c*p,c*f,a*u);break;case"YXY":r.set(c*f,a*h,c*p,a*u);break;case"ZYZ":r.set(c*p,c*f,a*h,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Ft(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function W(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Jo={DEG2RAD:ji,RAD2DEG:Ki,generateUUID:se,clamp:lt,euclideanModulo:En,mapLinear:Po,inverseLerp:vo,lerp:is,damp:Lo,pingpong:Oo,smoothstep:Do,smootherstep:Vo,randInt:Uo,randFloat:ko,randFloatSpread:qo,seededRandom:Ho,degToRad:Wo,radToDeg:$o,isPowerOfTwo:Go,ceilPowerOfTwo:Xo,floorPowerOfTwo:Yo,setQuaternionFromProperEuler:Zo,normalize:W,denormalize:Ft};class Z{constructor(t=0,e=0){Z.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6],this.y=n[1]*e+n[4]*s+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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(lt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*s-o*n+t.x,this.y=i*n+o*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,e,s,n,i,o,a,c,u){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,n,i,o,a,c,u)}set(t,e,s,n,i,o,a,c,u){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=i,h[5]=c,h[6]=s,h[7]=o,h[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,n=e.elements,i=this.elements,o=s[0],a=s[3],c=s[6],u=s[1],h=s[4],l=s[7],d=s[2],f=s[5],p=s[8],m=n[0],x=n[3],g=n[6],y=n[1],N=n[4],w=n[7],T=n[2],_=n[5],S=n[8];return i[0]=o*m+a*y+c*T,i[3]=o*x+a*N+c*_,i[6]=o*g+a*w+c*S,i[1]=u*m+h*y+l*T,i[4]=u*x+h*N+l*_,i[7]=u*g+h*w+l*S,i[2]=d*m+f*y+p*T,i[5]=d*x+f*N+p*_,i[8]=d*g+f*w+p*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8];return e*o*h-e*a*u-s*i*h+s*a*c+n*i*u-n*o*c}invert(){const t=this.elements,e=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=h*o-a*u,d=a*c-h*i,f=u*i-o*c,p=e*l+s*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=l*m,t[1]=(n*u-h*s)*m,t[2]=(a*s-n*o)*m,t[3]=d*m,t[4]=(h*e-n*c)*m,t[5]=(n*i-a*e)*m,t[6]=f*m,t[7]=(s*c-u*e)*m,t[8]=(o*e-s*i)*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,s,n,i,o,a){const c=Math.cos(i),u=Math.sin(i);return this.set(s*c,s*u,-s*(c*o+u*a)+o+t,-n*u,n*c,-n*(-u*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Cn.makeScale(t,e)),this}rotate(t){return this.premultiply(Cn.makeRotation(-t)),this}translate(t,e){return this.premultiply(Cn.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let n=0;n<9;n++)if(e[n]!==s[n])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Cn=new Bt;function Qo(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function tr(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const er=new Bt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),sr=new Bt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),rs={[Rs]:{transfer:bn,primaries:Ji,luminanceCoefficients:[.2126,.7152,.0722],toReference:r=>r,fromReference:r=>r},[Wt]:{transfer:Zi,primaries:Ji,luminanceCoefficients:[.2126,.7152,.0722],toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[Yi]:{transfer:bn,primaries:"p3",luminanceCoefficients:[.2289,.6917,.0793],toReference:r=>r.applyMatrix3(sr),fromReference:r=>r.applyMatrix3(er)},[Io]:{transfer:Zi,primaries:"p3",luminanceCoefficients:[.2289,.6917,.0793],toReference:r=>r.convertSRGBToLinear().applyMatrix3(sr),fromReference:r=>r.applyMatrix3(er).convertLinearToSRGB()}},jo=new Set([Rs,Yi]),wt={enabled:!0,_workingColorSpace:Rs,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!jo.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,t,e){if(this.enabled===!1||t===e||!t||!e)return r;const s=rs[t].toReference,n=rs[e].fromReference;return n(s(r))},fromWorkingColorSpace:function(r,t){return this.convert(r,this._workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this._workingColorSpace)},getPrimaries:function(r){return rs[r].primaries},getTransfer:function(r){return r===""?bn:rs[r].transfer},getLuminanceCoefficients:function(r,t=this._workingColorSpace){return r.fromArray(rs[t].luminanceCoefficients)}};function be(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Fn(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Ee;class Ko{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Ee===void 0&&(Ee=tr("canvas")),Ee.width=t.width,Ee.height=t.height;const s=Ee.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=Ee}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=tr("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const n=s.getImageData(0,0,t.width,t.height),i=n.data;for(let o=0;o<i.length;o++)i[o]=be(i[o]/255)*255;return s.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(be(e[s]/255)*255):e[s]=be(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ta=0;class nr{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ta++}),this.uuid=se(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},n=this.data;if(n!==null){let i;if(Array.isArray(n)){i=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?i.push(Bn(n[o].image)):i.push(Bn(n[o]))}else i=Bn(n);s.url=i}return e||(t.images[this.uuid]=s),s}}function Bn(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Ko.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ea=0;class Ut extends ns{constructor(t=Ut.DEFAULT_IMAGE,e=Ut.DEFAULT_MAPPING,s=1001,n=1001,i=1006,o=1008,a=1023,c=1009,u=Ut.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ea++}),this.uuid=se(),this.name="",this.source=new nr(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=n,this.magFilter=i,this.minFilter=o,this.anisotropy=u,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Z(0,0),this.repeat=new Z(1,1),this.center=new Z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}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.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.6,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&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002: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 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002: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++}}Ut.DEFAULT_IMAGE=null,Ut.DEFAULT_MAPPING=300,Ut.DEFAULT_ANISOTROPY=4;class Rt{constructor(t=0,e=0,s=0,n=1){Rt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,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,s,n){return this.x=t,this.y=e,this.z=s,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=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,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,s=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*s+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*s+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*s+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*s+o[11]*n+o[15]*i,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,s,n,i;const c=t.elements,u=c[0],h=c[4],l=c[8],d=c[1],f=c[5],p=c[9],m=c[2],x=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(l-m)<.01&&Math.abs(p-x)<.01){if(Math.abs(h+d)<.1&&Math.abs(l+m)<.1&&Math.abs(p+x)<.1&&Math.abs(u+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const N=(u+1)/2,w=(f+1)/2,T=(g+1)/2,_=(h+d)/4,S=(l+m)/4,z=(p+x)/4;return N>w&&N>T?N<.01?(s=0,n=.707106781,i=.707106781):(s=Math.sqrt(N),n=_/s,i=S/s):w>T?w<.01?(s=.707106781,n=0,i=.707106781):(n=Math.sqrt(w),s=_/n,i=z/n):T<.01?(s=.707106781,n=.707106781,i=0):(i=Math.sqrt(T),s=S/i,n=z/i),this.set(s,n,i,e),this}let y=Math.sqrt((x-p)*(x-p)+(l-m)*(l-m)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(x-p)/y,this.y=(l-m)/y,this.z=(d-h)/y,this.w=Math.acos((u+f+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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.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)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}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}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}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 ir extends ns{constructor(t=1,e=1,s={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Rt(0,0,t,e),this.scissorTest=!1,this.viewport=new Rt(0,0,t,e);const n={width:t,height:e,depth:1};s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},s);const i=new Ut(n,s.mapping,s.wrapS,s.wrapT,s.magFilter,s.minFilter,s.format,s.type,s.anisotropy,s.colorSpace);i.flipY=!1,i.generateMipmaps=s.generateMipmaps,i.internalFormat=s.internalFormat,this.textures=[];const o=s.count;for(let a=0;a<o;a++)this.textures[a]=i.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this.depthTexture=s.depthTexture,this.samples=s.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,s=1){if(this.width!==t||this.height!==e||this.depth!==s){this.width=t,this.height=e,this.depth=s;for(let n=0,i=this.textures.length;n<i;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=s;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let s=0,n=t.textures.length;s<n;s++)this.textures[s]=t.textures[s].clone(),this.textures[s].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new nr(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class os{constructor(t=0,e=0,s=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=n}static slerpFlat(t,e,s,n,i,o,a){let c=s[n+0],u=s[n+1],h=s[n+2],l=s[n+3];const d=i[o+0],f=i[o+1],p=i[o+2],m=i[o+3];if(a===0){t[e+0]=c,t[e+1]=u,t[e+2]=h,t[e+3]=l;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=m;return}if(l!==m||c!==d||u!==f||h!==p){let x=1-a;const g=c*d+u*f+h*p+l*m,y=g>=0?1:-1,N=1-g*g;if(N>Number.EPSILON){const T=Math.sqrt(N),_=Math.atan2(T,g*y);x=Math.sin(x*_)/T,a=Math.sin(a*_)/T}const w=a*y;if(c=c*x+d*w,u=u*x+f*w,h=h*x+p*w,l=l*x+m*w,x===1-a){const T=1/Math.sqrt(c*c+u*u+h*h+l*l);c*=T,u*=T,h*=T,l*=T}}t[e]=c,t[e+1]=u,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,s,n,i,o){const a=s[n],c=s[n+1],u=s[n+2],h=s[n+3],l=i[o],d=i[o+1],f=i[o+2],p=i[o+3];return t[e]=a*p+h*l+c*f-u*d,t[e+1]=c*p+h*d+u*l-a*f,t[e+2]=u*p+h*f+a*d-c*l,t[e+3]=h*p-a*l-c*d-u*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,n){return this._x=t,this._y=e,this._z=s,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 s=t._x,n=t._y,i=t._z,o=t._order,a=Math.cos,c=Math.sin,u=a(s/2),h=a(n/2),l=a(i/2),d=c(s/2),f=c(n/2),p=c(i/2);switch(o){case"XYZ":this._x=d*h*l+u*f*p,this._y=u*f*l-d*h*p,this._z=u*h*p+d*f*l,this._w=u*h*l-d*f*p;break;case"YXZ":this._x=d*h*l+u*f*p,this._y=u*f*l-d*h*p,this._z=u*h*p-d*f*l,this._w=u*h*l+d*f*p;break;case"ZXY":this._x=d*h*l-u*f*p,this._y=u*f*l+d*h*p,this._z=u*h*p+d*f*l,this._w=u*h*l-d*f*p;break;case"ZYX":this._x=d*h*l-u*f*p,this._y=u*f*l+d*h*p,this._z=u*h*p-d*f*l,this._w=u*h*l+d*f*p;break;case"YZX":this._x=d*h*l+u*f*p,this._y=u*f*l+d*h*p,this._z=u*h*p-d*f*l,this._w=u*h*l-d*f*p;break;case"XZY":this._x=d*h*l-u*f*p,this._y=u*f*l-d*h*p,this._z=u*h*p+d*f*l,this._w=u*h*l+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,n=Math.sin(s);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],n=e[4],i=e[8],o=e[1],a=e[5],c=e[9],u=e[2],h=e[6],l=e[10],d=s+a+l;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(i-u)*f,this._z=(o-n)*f}else if(s>a&&s>l){const f=2*Math.sqrt(1+s-a-l);this._w=(h-c)/f,this._x=.25*f,this._y=(n+o)/f,this._z=(i+u)/f}else if(a>l){const f=2*Math.sqrt(1+a-s-l);this._w=(i-u)/f,this._x=(n+o)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+l-s-a);this._w=(o-n)/f,this._x=(i+u)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(lt(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const n=Math.min(1,e/s);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 t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,n=t._y,i=t._z,o=t._w,a=e._x,c=e._y,u=e._z,h=e._w;return this._x=s*h+o*a+n*u-i*c,this._y=n*h+o*c+i*a-s*u,this._z=i*h+o*u+s*c-n*a,this._w=o*h-s*a-n*c-i*u,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,n=this._y,i=this._z,o=this._w;let a=o*t._w+s*t._x+n*t._y+i*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=o,this._x=s,this._y=n,this._z=i,this;const c=1-a*a;if(c<=Number.EPSILON){const f=1-e;return this._w=f*o+e*this._w,this._x=f*s+e*this._x,this._y=f*n+e*this._y,this._z=f*i+e*this._z,this.normalize(),this}const u=Math.sqrt(c),h=Math.atan2(u,a),l=Math.sin((1-e)*h)/u,d=Math.sin(e*h)/u;return this._w=o*l+this._w*d,this._x=s*l+this._x*d,this._y=n*l+this._y*d,this._z=i*l+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),n=Math.sqrt(1-s),i=Math.sqrt(s);return this.set(n*Math.sin(t),n*Math.cos(t),i*Math.sin(e),i*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 M{constructor(t=0,e=0,s=0){M.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(rr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(rr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6]*n,this.y=i[1]*e+i[4]*s+i[7]*n,this.z=i[2]*e+i[5]*s+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*s+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*s+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*s+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*s+i[10]*n+i[14])*o,this}applyQuaternion(t){const e=this.x,s=this.y,n=this.z,i=t.x,o=t.y,a=t.z,c=t.w,u=2*(o*n-a*s),h=2*(a*e-i*n),l=2*(i*s-o*e);return this.x=e+c*u+o*l-a*h,this.y=s+c*h+a*u-i*l,this.z=n+c*l+i*h-o*u,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*s+i[8]*n,this.y=i[1]*e+i[5]*s+i[9]*n,this.z=i[2]*e+i[6]*s+i[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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,n=t.y,i=t.z,o=e.x,a=e.y,c=e.z;return this.x=n*c-i*a,this.y=i*o-s*c,this.z=s*a-n*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Rn.copy(this).projectOnVector(t),this.sub(Rn)}reflect(t){return this.sub(Rn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(lt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,n=this.z-t.z;return e*e+s*s+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,s){const n=Math.sin(e)*t;return this.x=n*Math.sin(s),this.y=Math.cos(e)*t,this.z=n*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Rn=new M,rr=new os;class mt{constructor(t=new M(1/0,1/0,1/0),e=new M(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(It.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(It.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=It.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}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,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const i=s.getAttribute("position");if(e===!0&&i!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=i.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,It):It.fromBufferAttribute(i,o),It.applyMatrix4(t.matrixWorld),this.expandByPoint(It);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Is.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Is.copy(s.boundingBox)),Is.applyMatrix4(t.matrixWorld),this.union(Is)}const n=t.children;for(let i=0,o=n.length;i<o;i++)this.expandByObject(n[i],e);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,e){return e.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,It),It.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(as),Ps.subVectors(this.max,as),Ce.subVectors(t.a,as),Fe.subVectors(t.b,as),Be.subVectors(t.c,as),ne.subVectors(Fe,Ce),ie.subVectors(Be,Fe),ye.subVectors(Ce,Be);let e=[0,-ne.z,ne.y,0,-ie.z,ie.y,0,-ye.z,ye.y,ne.z,0,-ne.x,ie.z,0,-ie.x,ye.z,0,-ye.x,-ne.y,ne.x,0,-ie.y,ie.x,0,-ye.y,ye.x,0];return!In(e,Ce,Fe,Be,Ps)||(e=[1,0,0,0,1,0,0,0,1],!In(e,Ce,Fe,Be,Ps))?!1:(vs.crossVectors(ne,ie),e=[vs.x,vs.y,vs.z],In(e,Ce,Fe,Be,Ps))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,It).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(It).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:($t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),$t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),$t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),$t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),$t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),$t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),$t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),$t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints($t),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)}}const $t=[new M,new M,new M,new M,new M,new M,new M,new M],It=new M,Is=new mt,Ce=new M,Fe=new M,Be=new M,ne=new M,ie=new M,ye=new M,as=new M,Ps=new M,vs=new M,ge=new M;function In(r,t,e,s,n){for(let i=0,o=r.length-3;i<=o;i+=3){ge.fromArray(r,i);const a=n.x*Math.abs(ge.x)+n.y*Math.abs(ge.y)+n.z*Math.abs(ge.z),c=t.dot(ge),u=e.dot(ge),h=s.dot(ge);if(Math.max(-Math.max(c,u,h),Math.min(c,u,h))>a)return!1}return!0}const sa=new mt,cs=new M,Pn=new M;class na{constructor(t=new M,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):sa.setFromPoints(t).getCenter(s);let n=0;for(let i=0,o=t.length;i<o;i++)n=Math.max(n,s.distanceToSquared(t[i]));return this.radius=Math.sqrt(n),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 e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}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;cs.subVectors(t,this.center);const e=cs.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),n=(s-this.radius)*.5;this.center.addScaledVector(cs,n/s),this.radius+=n}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):(Pn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(cs.copy(t.center).add(Pn)),this.expandByPoint(cs.copy(t.center).sub(Pn))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Gt=new M,vn=new M,Ls=new M,re=new M,Ln=new M,Os=new M,On=new M;class ia{constructor(t=new M,e=new M(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.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,Gt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Gt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Gt.copy(this.origin).addScaledVector(this.direction,e),Gt.distanceToSquared(t))}distanceSqToSegment(t,e,s,n){vn.copy(t).add(e).multiplyScalar(.5),Ls.copy(e).sub(t).normalize(),re.copy(this.origin).sub(vn);const i=t.distanceTo(e)*.5,o=-this.direction.dot(Ls),a=re.dot(this.direction),c=-re.dot(Ls),u=re.lengthSq(),h=Math.abs(1-o*o);let l,d,f,p;if(h>0)if(l=o*c-a,d=o*a-c,p=i*h,l>=0)if(d>=-p)if(d<=p){const m=1/h;l*=m,d*=m,f=l*(l+o*d+2*a)+d*(o*l+d+2*c)+u}else d=i,l=Math.max(0,-(o*d+a)),f=-l*l+d*(d+2*c)+u;else d=-i,l=Math.max(0,-(o*d+a)),f=-l*l+d*(d+2*c)+u;else d<=-p?(l=Math.max(0,-(-o*i+a)),d=l>0?-i:Math.min(Math.max(-i,-c),i),f=-l*l+d*(d+2*c)+u):d<=p?(l=0,d=Math.min(Math.max(-i,-c),i),f=d*(d+2*c)+u):(l=Math.max(0,-(o*i+a)),d=l>0?i:Math.min(Math.max(-i,-c),i),f=-l*l+d*(d+2*c)+u);else d=o>0?-i:i,l=Math.max(0,-(o*d+a)),f=-l*l+d*(d+2*c)+u;return s&&s.copy(this.origin).addScaledVector(this.direction,l),n&&n.copy(vn).addScaledVector(Ls,d),f}intersectSphere(t,e){Gt.subVectors(t.center,this.origin);const s=Gt.dot(this.direction),n=Gt.dot(Gt)-s*s,i=t.radius*t.radius;if(n>i)return null;const o=Math.sqrt(i-n),a=s-o,c=s+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){const s=this.distanceToPlane(t);return s===null?null:this.at(s,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let s,n,i,o,a,c;const u=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,d=this.origin;return u>=0?(s=(t.min.x-d.x)*u,n=(t.max.x-d.x)*u):(s=(t.max.x-d.x)*u,n=(t.min.x-d.x)*u),h>=0?(i=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(i=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),s>o||i>n||((i>s||isNaN(s))&&(s=i),(o<n||isNaN(n))&&(n=o),l>=0?(a=(t.min.z-d.z)*l,c=(t.max.z-d.z)*l):(a=(t.max.z-d.z)*l,c=(t.min.z-d.z)*l),s>c||a>n)||((a>s||s!==s)&&(s=a),(c<n||n!==n)&&(n=c),n<0)?null:this.at(s>=0?s:n,e)}intersectsBox(t){return this.intersectBox(t,Gt)!==null}intersectTriangle(t,e,s,n,i){Ln.subVectors(e,t),Os.subVectors(s,t),On.crossVectors(Ln,Os);let o=this.direction.dot(On),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;re.subVectors(this.origin,t);const c=a*this.direction.dot(Os.crossVectors(re,Os));if(c<0)return null;const u=a*this.direction.dot(Ln.cross(re));if(u<0||c+u>o)return null;const h=-a*re.dot(On);return h<0?null:this.at(h/o,i)}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 Q{constructor(t,e,s,n,i,o,a,c,u,h,l,d,f,p,m,x){Q.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,n,i,o,a,c,u,h,l,d,f,p,m,x)}set(t,e,s,n,i,o,a,c,u,h,l,d,f,p,m,x){const g=this.elements;return g[0]=t,g[4]=e,g[8]=s,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=c,g[2]=u,g[6]=h,g[10]=l,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Q().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,n=1/Re.setFromMatrixColumn(t,0).length(),i=1/Re.setFromMatrixColumn(t,1).length(),o=1/Re.setFromMatrixColumn(t,2).length();return e[0]=s[0]*n,e[1]=s[1]*n,e[2]=s[2]*n,e[3]=0,e[4]=s[4]*i,e[5]=s[5]*i,e[6]=s[6]*i,e[7]=0,e[8]=s[8]*o,e[9]=s[9]*o,e[10]=s[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,n=t.y,i=t.z,o=Math.cos(s),a=Math.sin(s),c=Math.cos(n),u=Math.sin(n),h=Math.cos(i),l=Math.sin(i);if(t.order==="XYZ"){const d=o*h,f=o*l,p=a*h,m=a*l;e[0]=c*h,e[4]=-c*l,e[8]=u,e[1]=f+p*u,e[5]=d-m*u,e[9]=-a*c,e[2]=m-d*u,e[6]=p+f*u,e[10]=o*c}else if(t.order==="YXZ"){const d=c*h,f=c*l,p=u*h,m=u*l;e[0]=d+m*a,e[4]=p*a-f,e[8]=o*u,e[1]=o*l,e[5]=o*h,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=o*c}else if(t.order==="ZXY"){const d=c*h,f=c*l,p=u*h,m=u*l;e[0]=d-m*a,e[4]=-o*l,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*h,e[9]=m-d*a,e[2]=-o*u,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const d=o*h,f=o*l,p=a*h,m=a*l;e[0]=c*h,e[4]=p*u-f,e[8]=d*u+m,e[1]=c*l,e[5]=m*u+d,e[9]=f*u-p,e[2]=-u,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const d=o*c,f=o*u,p=a*c,m=a*u;e[0]=c*h,e[4]=m-d*l,e[8]=p*l+f,e[1]=l,e[5]=o*h,e[9]=-a*h,e[2]=-u*h,e[6]=f*l+p,e[10]=d-m*l}else if(t.order==="XZY"){const d=o*c,f=o*u,p=a*c,m=a*u;e[0]=c*h,e[4]=-l,e[8]=u*h,e[1]=d*l+m,e[5]=o*h,e[9]=f*l-p,e[2]=p*l-f,e[6]=a*h,e[10]=m*l+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ra,t,oa)}lookAt(t,e,s){const n=this.elements;return At.subVectors(t,e),At.lengthSq()===0&&(At.z=1),At.normalize(),oe.crossVectors(s,At),oe.lengthSq()===0&&(Math.abs(s.z)===1?At.x+=1e-4:At.z+=1e-4,At.normalize(),oe.crossVectors(s,At)),oe.normalize(),Ds.crossVectors(At,oe),n[0]=oe.x,n[4]=Ds.x,n[8]=At.x,n[1]=oe.y,n[5]=Ds.y,n[9]=At.y,n[2]=oe.z,n[6]=Ds.z,n[10]=At.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,n=e.elements,i=this.elements,o=s[0],a=s[4],c=s[8],u=s[12],h=s[1],l=s[5],d=s[9],f=s[13],p=s[2],m=s[6],x=s[10],g=s[14],y=s[3],N=s[7],w=s[11],T=s[15],_=n[0],S=n[4],z=n[8],B=n[12],b=n[1],I=n[5],C=n[9],P=n[13],L=n[2],D=n[6],X=n[10],ee=n[14],Me=n[3],_e=n[7],pe=n[11],me=n[15];return i[0]=o*_+a*b+c*L+u*Me,i[4]=o*S+a*I+c*D+u*_e,i[8]=o*z+a*C+c*X+u*pe,i[12]=o*B+a*P+c*ee+u*me,i[1]=h*_+l*b+d*L+f*Me,i[5]=h*S+l*I+d*D+f*_e,i[9]=h*z+l*C+d*X+f*pe,i[13]=h*B+l*P+d*ee+f*me,i[2]=p*_+m*b+x*L+g*Me,i[6]=p*S+m*I+x*D+g*_e,i[10]=p*z+m*C+x*X+g*pe,i[14]=p*B+m*P+x*ee+g*me,i[3]=y*_+N*b+w*L+T*Me,i[7]=y*S+N*I+w*D+T*_e,i[11]=y*z+N*C+w*X+T*pe,i[15]=y*B+N*P+w*ee+T*me,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],n=t[8],i=t[12],o=t[1],a=t[5],c=t[9],u=t[13],h=t[2],l=t[6],d=t[10],f=t[14],p=t[3],m=t[7],x=t[11],g=t[15];return p*(+i*c*l-n*u*l-i*a*d+s*u*d+n*a*f-s*c*f)+m*(+e*c*f-e*u*d+i*o*d-n*o*f+n*u*h-i*c*h)+x*(+e*u*l-e*a*f-i*o*l+s*o*f+i*a*h-s*u*h)+g*(-n*a*h-e*c*l+e*a*d+n*o*l-s*o*d+s*c*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=t[9],d=t[10],f=t[11],p=t[12],m=t[13],x=t[14],g=t[15],y=l*x*u-m*d*u+m*c*f-a*x*f-l*c*g+a*d*g,N=p*d*u-h*x*u-p*c*f+o*x*f+h*c*g-o*d*g,w=h*m*u-p*l*u+p*a*f-o*m*f-h*a*g+o*l*g,T=p*l*c-h*m*c-p*a*d+o*m*d+h*a*x-o*l*x,_=e*y+s*N+n*w+i*T;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/_;return t[0]=y*S,t[1]=(m*d*i-l*x*i-m*n*f+s*x*f+l*n*g-s*d*g)*S,t[2]=(a*x*i-m*c*i+m*n*u-s*x*u-a*n*g+s*c*g)*S,t[3]=(l*c*i-a*d*i-l*n*u+s*d*u+a*n*f-s*c*f)*S,t[4]=N*S,t[5]=(h*x*i-p*d*i+p*n*f-e*x*f-h*n*g+e*d*g)*S,t[6]=(p*c*i-o*x*i-p*n*u+e*x*u+o*n*g-e*c*g)*S,t[7]=(o*d*i-h*c*i+h*n*u-e*d*u-o*n*f+e*c*f)*S,t[8]=w*S,t[9]=(p*l*i-h*m*i-p*s*f+e*m*f+h*s*g-e*l*g)*S,t[10]=(o*m*i-p*a*i+p*s*u-e*m*u-o*s*g+e*a*g)*S,t[11]=(h*a*i-o*l*i-h*s*u+e*l*u+o*s*f-e*a*f)*S,t[12]=T*S,t[13]=(h*m*n-p*l*n+p*s*d-e*m*d-h*s*x+e*l*x)*S,t[14]=(p*a*n-o*m*n-p*s*c+e*m*c+o*s*x-e*a*x)*S,t[15]=(o*l*n-h*a*n+h*s*c-e*l*c-o*s*d+e*a*d)*S,this}scale(t){const e=this.elements,s=t.x,n=t.y,i=t.z;return e[0]*=s,e[4]*=n,e[8]*=i,e[1]*=s,e[5]*=n,e[9]*=i,e[2]*=s,e[6]*=n,e[10]*=i,e[3]*=s,e[7]*=n,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,n))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),n=Math.sin(e),i=1-s,o=t.x,a=t.y,c=t.z,u=i*o,h=i*a;return this.set(u*o+s,u*a-n*c,u*c+n*a,0,u*a+n*c,h*a+s,h*c-n*o,0,u*c-n*a,h*c+n*o,i*c*c+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,n,i,o){return this.set(1,s,i,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,s){const n=this.elements,i=e._x,o=e._y,a=e._z,c=e._w,u=i+i,h=o+o,l=a+a,d=i*u,f=i*h,p=i*l,m=o*h,x=o*l,g=a*l,y=c*u,N=c*h,w=c*l,T=s.x,_=s.y,S=s.z;return n[0]=(1-(m+g))*T,n[1]=(f+w)*T,n[2]=(p-N)*T,n[3]=0,n[4]=(f-w)*_,n[5]=(1-(d+g))*_,n[6]=(x+y)*_,n[7]=0,n[8]=(p+N)*S,n[9]=(x-y)*S,n[10]=(1-(d+m))*S,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,s){const n=this.elements;let i=Re.set(n[0],n[1],n[2]).length();const o=Re.set(n[4],n[5],n[6]).length(),a=Re.set(n[8],n[9],n[10]).length();this.determinant()<0&&(i=-i),t.x=n[12],t.y=n[13],t.z=n[14],Pt.copy(this);const u=1/i,h=1/o,l=1/a;return Pt.elements[0]*=u,Pt.elements[1]*=u,Pt.elements[2]*=u,Pt.elements[4]*=h,Pt.elements[5]*=h,Pt.elements[6]*=h,Pt.elements[8]*=l,Pt.elements[9]*=l,Pt.elements[10]*=l,e.setFromRotationMatrix(Pt),s.x=i,s.y=o,s.z=a,this}makePerspective(t,e,s,n,i,o,a=2e3){const c=this.elements,u=2*i/(e-t),h=2*i/(s-n),l=(e+t)/(e-t),d=(s+n)/(s-n);let f,p;if(a===2e3)f=-(o+i)/(o-i),p=-2*o*i/(o-i);else if(a===2001)f=-o/(o-i),p=-o*i/(o-i);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=l,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,s,n,i,o,a=2e3){const c=this.elements,u=1/(e-t),h=1/(s-n),l=1/(o-i),d=(e+t)*u,f=(s+n)*h;let p,m;if(a===2e3)p=(o+i)*l,m=-2*l;else if(a===2001)p=i*l,m=-1*l;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=m,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let n=0;n<16;n++)if(e[n]!==s[n])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const Re=new M,Pt=new Q,ra=new M(0,0,0),oa=new M(1,1,1),oe=new M,Ds=new M,At=new M,or=new Q,ar=new os;class Vs{constructor(t=0,e=0,s=0,n=Vs.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,n=this._order){return this._x=t,this._y=e,this._z=s,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const n=t.elements,i=n[0],o=n[4],a=n[8],c=n[1],u=n[5],h=n[9],l=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(lt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-lt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-l,i),this._z=0);break;case"ZXY":this._x=Math.asin(lt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-l,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,i));break;case"ZYX":this._y=Math.asin(-lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,i)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(lt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-l,i)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return or.makeRotationFromQuaternion(t),this.setFromRotationMatrix(or,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ar.setFromEuler(this),this.setFromQuaternion(ar,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Vs.DEFAULT_ORDER="XYZ";class aa{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 ca=0;const cr=new M,Ie=new os,Xt=new Q,Us=new M,hs=new M,ha=new M,ua=new os,hr=new M(1,0,0),ur=new M(0,1,0),lr=new M(0,0,1),dr={type:"added"},la={type:"removed"},Pe={type:"childadded",child:null},Dn={type:"childremoved",child:null};class ae extends ns{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ca++}),this.uuid=se(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ae.DEFAULT_UP.clone();const t=new M,e=new Vs,s=new os,n=new M(1,1,1);function i(){s.setFromEuler(e,!1)}function o(){e.setFromQuaternion(s,void 0,!1)}e._onChange(i),s._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Q},normalMatrix:{value:new Bt}}),this.matrix=new Q,this.matrixWorld=new Q,this.matrixAutoUpdate=ae.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ae.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ie.setFromAxisAngle(t,e),this.quaternion.multiply(Ie),this}rotateOnWorldAxis(t,e){return Ie.setFromAxisAngle(t,e),this.quaternion.premultiply(Ie),this}rotateX(t){return this.rotateOnAxis(hr,t)}rotateY(t){return this.rotateOnAxis(ur,t)}rotateZ(t){return this.rotateOnAxis(lr,t)}translateOnAxis(t,e){return cr.copy(t).applyQuaternion(this.quaternion),this.position.add(cr.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(hr,t)}translateY(t){return this.translateOnAxis(ur,t)}translateZ(t){return this.translateOnAxis(lr,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Xt.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?Us.copy(t):Us.set(t,e,s);const n=this.parent;this.updateWorldMatrix(!0,!1),hs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xt.lookAt(hs,Us,this.up):Xt.lookAt(Us,hs,this.up),this.quaternion.setFromRotationMatrix(Xt),n&&(Xt.extractRotation(n.matrixWorld),Ie.setFromRotationMatrix(Xt),this.quaternion.premultiply(Ie.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(dr),Pe.child=t,this.dispatchEvent(Pe),Pe.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(la),Dn.child=t,this.dispatchEvent(Dn),Dn.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),Xt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Xt.multiply(t.parent.matrixWorld)),t.applyMatrix4(Xt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(dr),Pe.child=t,this.dispatchEvent(Pe),Pe.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,n=this.children.length;s<n;s++){const o=this.children[s].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const n=this.children;for(let i=0,o=n.length;i<o;i++)n[i].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,t,ha),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,ua,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,n=e.length;s<n;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,n=e.length;s<n;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),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 e=this.children;for(let s=0,n=e.length;s<n;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.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)),e===!0){const n=this.children;for(let i=0,o=n.length;i<o;i++)n[i].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),this.boundingBox!==null&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()}));function i(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=i(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let u=0,h=c.length;u<h;u++){const l=c[u];i(t.shapes,l)}else i(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,u=this.material.length;c<u;c++)a.push(i(t.materials,this.material[c]));n.material=a}else n.material=i(t.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];n.animations.push(i(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),u=o(t.textures),h=o(t.images),l=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(s.geometries=a),c.length>0&&(s.materials=c),u.length>0&&(s.textures=u),h.length>0&&(s.images=h),l.length>0&&(s.shapes=l),d.length>0&&(s.skeletons=d),f.length>0&&(s.animations=f),p.length>0&&(s.nodes=p)}return s.object=n,s;function o(a){const c=[];for(const u in a){const h=a[u];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const n=t.children[s];this.add(n.clone())}return this}}ae.DEFAULT_UP=new M(0,1,0),ae.DEFAULT_MATRIX_AUTO_UPDATE=!0,ae.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const vt=new M,Yt=new M,Vn=new M,Zt=new M,ve=new M,Le=new M,fr=new M,Un=new M,kn=new M,qn=new M,Hn=new Rt,Wn=new Rt,$n=new Rt;class _t{constructor(t=new M,e=new M,s=new M){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,n){n.subVectors(s,e),vt.subVectors(t,e),n.cross(vt);const i=n.lengthSq();return i>0?n.multiplyScalar(1/Math.sqrt(i)):n.set(0,0,0)}static getBarycoord(t,e,s,n,i){vt.subVectors(n,e),Yt.subVectors(s,e),Vn.subVectors(t,e);const o=vt.dot(vt),a=vt.dot(Yt),c=vt.dot(Vn),u=Yt.dot(Yt),h=Yt.dot(Vn),l=o*u-a*a;if(l===0)return i.set(0,0,0),null;const d=1/l,f=(u*c-a*h)*d,p=(o*h-a*c)*d;return i.set(1-f-p,p,f)}static containsPoint(t,e,s,n){return this.getBarycoord(t,e,s,n,Zt)===null?!1:Zt.x>=0&&Zt.y>=0&&Zt.x+Zt.y<=1}static getInterpolation(t,e,s,n,i,o,a,c){return this.getBarycoord(t,e,s,n,Zt)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(i,Zt.x),c.addScaledVector(o,Zt.y),c.addScaledVector(a,Zt.z),c)}static getInterpolatedAttribute(t,e,s,n,i,o){return Hn.setScalar(0),Wn.setScalar(0),$n.setScalar(0),Hn.fromBufferAttribute(t,e),Wn.fromBufferAttribute(t,s),$n.fromBufferAttribute(t,n),o.setScalar(0),o.addScaledVector(Hn,i.x),o.addScaledVector(Wn,i.y),o.addScaledVector($n,i.z),o}static isFrontFacing(t,e,s,n){return vt.subVectors(s,e),Yt.subVectors(t,e),vt.cross(Yt).dot(n)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,n){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,s,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,n),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 vt.subVectors(this.c,this.b),Yt.subVectors(this.a,this.b),vt.cross(Yt).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return _t.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return _t.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,n,i){return _t.getInterpolation(t,this.a,this.b,this.c,e,s,n,i)}containsPoint(t){return _t.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return _t.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,n=this.b,i=this.c;let o,a;ve.subVectors(n,s),Le.subVectors(i,s),Un.subVectors(t,s);const c=ve.dot(Un),u=Le.dot(Un);if(c<=0&&u<=0)return e.copy(s);kn.subVectors(t,n);const h=ve.dot(kn),l=Le.dot(kn);if(h>=0&&l<=h)return e.copy(n);const d=c*l-h*u;if(d<=0&&c>=0&&h<=0)return o=c/(c-h),e.copy(s).addScaledVector(ve,o);qn.subVectors(t,i);const f=ve.dot(qn),p=Le.dot(qn);if(p>=0&&f<=p)return e.copy(i);const m=f*u-c*p;if(m<=0&&u>=0&&p<=0)return a=u/(u-p),e.copy(s).addScaledVector(Le,a);const x=h*p-f*l;if(x<=0&&l-h>=0&&f-p>=0)return fr.subVectors(i,n),a=(l-h)/(l-h+(f-p)),e.copy(n).addScaledVector(fr,a);const g=1/(x+m+d);return o=m*g,a=d*g,e.copy(s).addScaledVector(ve,o).addScaledVector(Le,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const pr={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},ce={h:0,s:0,l:0},ks={h:0,s:0,l:0};function Gn(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class Xn{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Wt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,wt.toWorkingColorSpace(this,e),this}setRGB(t,e,s,n=wt.workingColorSpace){return this.r=t,this.g=e,this.b=s,wt.toWorkingColorSpace(this,n),this}setHSL(t,e,s,n=wt.workingColorSpace){if(t=En(t,1),e=lt(e,0,1),s=lt(s,0,1),e===0)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+e):s+e-s*e,o=2*s-i;this.r=Gn(o,i,t+1/3),this.g=Gn(o,i,t),this.b=Gn(o,i,t-1/3)}return wt.toWorkingColorSpace(this,n),this}setStyle(t,e=Wt){function s(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let i;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,e);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,e);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],o=i.length;if(o===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(i,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Wt){const s=pr[t.toLowerCase()];return s!==void 0?this.setHex(s,e):console.warn("THREE.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=be(t.r),this.g=be(t.g),this.b=be(t.b),this}copyLinearToSRGB(t){return this.r=Fn(t.r),this.g=Fn(t.g),this.b=Fn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Wt){return wt.fromWorkingColorSpace(dt.copy(this),t),Math.round(lt(dt.r*255,0,255))*65536+Math.round(lt(dt.g*255,0,255))*256+Math.round(lt(dt.b*255,0,255))}getHexString(t=Wt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=wt.workingColorSpace){wt.fromWorkingColorSpace(dt.copy(this),e);const s=dt.r,n=dt.g,i=dt.b,o=Math.max(s,n,i),a=Math.min(s,n,i);let c,u;const h=(a+o)/2;if(a===o)c=0,u=0;else{const l=o-a;switch(u=h<=.5?l/(o+a):l/(2-o-a),o){case s:c=(n-i)/l+(n<i?6:0);break;case n:c=(i-s)/l+2;break;case i:c=(s-n)/l+4;break}c/=6}return t.h=c,t.s=u,t.l=h,t}getRGB(t,e=wt.workingColorSpace){return wt.fromWorkingColorSpace(dt.copy(this),e),t.r=dt.r,t.g=dt.g,t.b=dt.b,t}getStyle(t=Wt){wt.fromWorkingColorSpace(dt.copy(this),t);const e=dt.r,s=dt.g,n=dt.b;return t!==Wt?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(n*255)})`}offsetHSL(t,e,s){return this.getHSL(ce),this.setHSL(ce.h+t,ce.s+e,ce.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.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,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(ce),t.getHSL(ks);const s=is(ce.h,ks.h,e),n=is(ce.s,ks.s,e),i=is(ce.l,ks.l,e);return this.setHSL(s,n,i),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,n=this.b,i=t.elements;return this.r=i[0]*e+i[3]*s+i[6]*n,this.g=i[1]*e+i[4]*s+i[7]*n,this.b=i[2]*e+i[5]*s+i[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const dt=new Xn;Xn.NAMES=pr;const j=new M,qs=new Z;class Lt{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}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,e,s){t*=this.itemSize,s*=e.itemSize;for(let n=0,i=this.itemSize;n<i;n++)this.array[t+n]=e.array[s+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)qs.fromBufferAttribute(this,e),qs.applyMatrix3(t),this.setXY(e,qs.x,qs.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix3(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix4(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyNormalMatrix(t),this.setXYZ(e,j.x,j.y,j.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.transformDirection(t),this.setXYZ(e,j.x,j.y,j.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Ft(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=W(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ft(e,this.array)),e}setX(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ft(e,this.array)),e}setY(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ft(e,this.array)),e}setZ(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ft(e,this.array)),e}setW(t,e){return this.normalized&&(e=W(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=W(e,this.array),s=W(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,n){return t*=this.itemSize,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=n,this}setXYZW(t,e,s,n,i){return t*=this.itemSize,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array),i=W(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=n,this.array[t+3]=i,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!==35044&&(t.usage=this.usage),t}}class da extends Lt{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class fa extends Lt{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class pa extends Lt{constructor(t,e,s){super(new Float32Array(t),e,s)}}let ma=0;const zt=new Q,Yn=new ae,Oe=new M,St=new mt,us=new mt,ot=new M;class Zn extends ns{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ma++}),this.uuid=se(),this.name="",this.type="BufferGeometry",this.index=null,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(Qo(t)?fa:da)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const i=new Bt().getNormalMatrix(t);s.applyNormalMatrix(i),s.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return zt.makeRotationFromQuaternion(t),this.applyMatrix4(zt),this}rotateX(t){return zt.makeRotationX(t),this.applyMatrix4(zt),this}rotateY(t){return zt.makeRotationY(t),this.applyMatrix4(zt),this}rotateZ(t){return zt.makeRotationZ(t),this.applyMatrix4(zt),this}translate(t,e,s){return zt.makeTranslation(t,e,s),this.applyMatrix4(zt),this}scale(t,e,s){return zt.makeScale(t,e,s),this.applyMatrix4(zt),this}lookAt(t){return Yn.lookAt(t),Yn.updateMatrix(),this.applyMatrix4(Yn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Oe).negate(),this.translate(Oe.x,Oe.y,Oe.z),this}setFromPoints(t){const e=[];for(let s=0,n=t.length;s<n;s++){const i=t[s];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new pa(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,n=e.length;s<n;s++){const i=e[s];St.setFromBufferAttribute(i),this.morphTargetsRelative?(ot.addVectors(this.boundingBox.min,St.min),this.boundingBox.expandByPoint(ot),ot.addVectors(this.boundingBox.max,St.max),this.boundingBox.expandByPoint(ot)):(this.boundingBox.expandByPoint(St.min),this.boundingBox.expandByPoint(St.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 na);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new M,1/0);return}if(t){const s=this.boundingSphere.center;if(St.setFromBufferAttribute(t),e)for(let i=0,o=e.length;i<o;i++){const a=e[i];us.setFromBufferAttribute(a),this.morphTargetsRelative?(ot.addVectors(St.min,us.min),St.expandByPoint(ot),ot.addVectors(St.max,us.max),St.expandByPoint(ot)):(St.expandByPoint(us.min),St.expandByPoint(us.max))}St.getCenter(s);let n=0;for(let i=0,o=t.count;i<o;i++)ot.fromBufferAttribute(t,i),n=Math.max(n,s.distanceToSquared(ot));if(e)for(let i=0,o=e.length;i<o;i++){const a=e[i],c=this.morphTargetsRelative;for(let u=0,h=a.count;u<h;u++)ot.fromBufferAttribute(a,u),c&&(Oe.fromBufferAttribute(t,u),ot.add(Oe)),n=Math.max(n,s.distanceToSquared(ot))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=e.position,n=e.normal,i=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Lt(new Float32Array(4*s.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let z=0;z<s.count;z++)a[z]=new M,c[z]=new M;const u=new M,h=new M,l=new M,d=new Z,f=new Z,p=new Z,m=new M,x=new M;function g(z,B,b){u.fromBufferAttribute(s,z),h.fromBufferAttribute(s,B),l.fromBufferAttribute(s,b),d.fromBufferAttribute(i,z),f.fromBufferAttribute(i,B),p.fromBufferAttribute(i,b),h.sub(u),l.sub(u),f.sub(d),p.sub(d);const I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(l,-f.y).multiplyScalar(I),x.copy(l).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),a[z].add(m),a[B].add(m),a[b].add(m),c[z].add(x),c[B].add(x),c[b].add(x))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let z=0,B=y.length;z<B;++z){const b=y[z],I=b.start,C=b.count;for(let P=I,L=I+C;P<L;P+=3)g(t.getX(P+0),t.getX(P+1),t.getX(P+2))}const N=new M,w=new M,T=new M,_=new M;function S(z){T.fromBufferAttribute(n,z),_.copy(T);const B=a[z];N.copy(B),N.sub(T.multiplyScalar(T.dot(B))).normalize(),w.crossVectors(_,B);const I=w.dot(c[z])<0?-1:1;o.setXYZW(z,N.x,N.y,N.z,I)}for(let z=0,B=y.length;z<B;++z){const b=y[z],I=b.start,C=b.count;for(let P=I,L=I+C;P<L;P+=3)S(t.getX(P+0)),S(t.getX(P+1)),S(t.getX(P+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new Lt(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let d=0,f=s.count;d<f;d++)s.setXYZ(d,0,0,0);const n=new M,i=new M,o=new M,a=new M,c=new M,u=new M,h=new M,l=new M;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),m=t.getX(d+1),x=t.getX(d+2);n.fromBufferAttribute(e,p),i.fromBufferAttribute(e,m),o.fromBufferAttribute(e,x),h.subVectors(o,i),l.subVectors(n,i),h.cross(l),a.fromBufferAttribute(s,p),c.fromBufferAttribute(s,m),u.fromBufferAttribute(s,x),a.add(h),c.add(h),u.add(h),s.setXYZ(p,a.x,a.y,a.z),s.setXYZ(m,c.x,c.y,c.z),s.setXYZ(x,u.x,u.y,u.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),i.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,i),l.subVectors(n,i),h.cross(l),s.setXYZ(d+0,h.x,h.y,h.z),s.setXYZ(d+1,h.x,h.y,h.z),s.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)ot.fromBufferAttribute(t,e),ot.normalize(),t.setXYZ(e,ot.x,ot.y,ot.z)}toNonIndexed(){function t(a,c){const u=a.array,h=a.itemSize,l=a.normalized,d=new u.constructor(c.length*h);let f=0,p=0;for(let m=0,x=c.length;m<x;m++){a.isInterleavedBufferAttribute?f=c[m]*a.data.stride+a.offset:f=c[m]*h;for(let g=0;g<h;g++)d[p++]=u[f++]}return new Lt(d,h,l)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Zn,s=this.index.array,n=this.attributes;for(const a in n){const c=n[a],u=t(c,s);e.setAttribute(a,u)}const i=this.morphAttributes;for(const a in i){const c=[],u=i[a];for(let h=0,l=u.length;h<l;h++){const d=u[h],f=t(d,s);c.push(f)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const u=o[a];e.addGroup(u.start,u.count,u.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,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 c=this.parameters;for(const u in c)c[u]!==void 0&&(t[u]=c[u]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const c in s){const u=s[c];t.data.attributes[c]=u.toJSON(t.data)}const n={};let i=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],h=[];for(let l=0,d=u.length;l<d;l++){const f=u[l];h.push(f.toJSON(t.data))}h.length>0&&(n[c]=h,i=!0)}i&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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 e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone(e));const n=t.attributes;for(const u in n){const h=n[u];this.setAttribute(u,h.clone(e))}const i=t.morphAttributes;for(const u in i){const h=[],l=i[u];for(let d=0,f=l.length;d<f;d++)h.push(l[d].clone(e));this.morphAttributes[u]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let u=0,h=o.length;u<h;u++){const l=o[u];this.addGroup(l.start,l.count,l.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Jn=new M,ya=new M,ga=new Bt;class Qn{constructor(t=new M(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,n){return this.normal.set(t,e,s),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const n=Jn.subVectors(s,e).cross(ya.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(Jn),n=this.normal.dot(s);if(n===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/n;return i<0||i>1?null:e.copy(t.start).addScaledVector(s,i)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||ga.getNormalMatrix(t),n=this.coplanarPoint(Jn).applyMatrix4(t),i=this.normal.applyMatrix3(s).normalize();return this.constant=-n.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}class mr extends Ut{constructor(t,e,s,n,i,o,a,c,u,h=1026){if(h!==1026&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");s===void 0&&h===1026&&(s=1014),s===void 0&&h===1027&&(s=1020),super(null,n,i,o,a,c,h,s,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:1003,this.minFilter=c!==void 0?c:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class xa{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=se()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,s){t*=this.stride,s*=e.stride;for(let n=0,i=this.stride;n<i;n++)this.array[t+n]=e.array[s+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=se()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(e,this.stride);return s.setUsage(this.usage),s}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=se()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const yt=new M;class jn{constructor(t,e,s,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)yt.fromBufferAttribute(this,e),yt.applyMatrix4(t),this.setXYZ(e,yt.x,yt.y,yt.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)yt.fromBufferAttribute(this,e),yt.applyNormalMatrix(t),this.setXYZ(e,yt.x,yt.y,yt.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)yt.fromBufferAttribute(this,e),yt.transformDirection(t),this.setXYZ(e,yt.x,yt.y,yt.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Ft(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=W(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=W(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ft(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ft(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ft(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ft(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=W(e,this.array),s=W(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=n,this}setXYZW(t,e,s,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=W(e,this.array),s=W(s,this.array),n=W(n,this.array),i=W(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=n,this.data.array[t+3]=i,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const n=s*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)e.push(this.data.array[n+i])}return new Lt(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new jn(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const n=s*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)e.push(this.data.array[n+i])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ta extends Ut{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}const yr=new M,Hs=new M;class Jt{constructor(t=new M,e=new M){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){yr.subVectors(t,this.start),Hs.subVectors(this.end,this.start);const s=Hs.dot(Hs);let i=Hs.dot(yr)/s;return e&&(i=lt(i,0,1)),i}closestPointToPoint(t,e,s){const n=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}function Kn(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let n=0,i;n<r.length;n++)i=r[n],e=Math.imul(e^i,2654435761),s=Math.imul(s^i,1597334677);else for(let n=0,i;n<r.length;n++)i=r.charCodeAt(n),e=Math.imul(e^i,2654435761),s=Math.imul(s^i,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const Na=(...r)=>Kn(r);function wa(r,t=!1){const e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(const{property:s,childNode:n}of ti(r))e.push(e,Kn(s.slice(0,-4)),n.getCacheKey(t));return Kn(e)}function*ti(r,t=!1){for(const e in r){if(e.startsWith("_")===!0)continue;const s=r[e];if(Array.isArray(s)===!0)for(let n=0;n<s.length;n++){const i=s[n];i&&(i.isNode===!0||t&&typeof i.toJSON=="function")&&(yield{property:e,index:n,childNode:i})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(const n in s){const i=s[n];i&&(i.isNode===!0||t&&typeof i.toJSON=="function")&&(yield{property:e,index:n,childNode:i})}}}function Ws(r){if(r==null)return null;const t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function gr(r,...t){const e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new Xn(...t):e==="vec2"?new Z(...t):e==="vec3"?new M(...t):e==="vec4"?new Rt(...t):e==="mat3"?new Bt(...t):e==="mat4"?new Q(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Sa(t[0]):null}function Aa(r){let t="";const e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Sa(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}const xr={VERTEX:"vertex"},K={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ls=["x","y","z","w"];let Ma=0;class U extends ns{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=K.NONE,this.updateBeforeType=K.NONE,this.updateAfterType=K.NONE,this.uuid=Jo.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Ma++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,K.FRAME)}onRenderUpdate(t){return this.onUpdate(t,K.RENDER)}onObjectUpdate(t){return this.onUpdate(t,K.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of ti(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t=t||this.version!==this._cacheKeyVersion,(t===!0||this._cacheKey===null)&&(this._cacheKey=wa(this,t),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){const e=this.getNodeType(t);return t.getElementType(e)}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){const e=t.getNodeProperties(this);let s=0;for(const n of this.getChildren())e["node"+s++]=n;return null}analyze(t){if(t.increaseUsage(this)===1){const s=t.getNodeProperties(this);for(const n of Object.values(s))n&&n.isNode===!0&&n.build(t)}}generate(t,e){const{outputNode:s}=t.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){const s=this.getShared(t);if(this!==s)return s.build(t,e);t.addNode(this),t.addChain(this);let n=null;const i=t.getBuildStage();if(i==="setup"){this.updateReference(t);const o=t.getNodeProperties(this);if(o.initialized!==!0){const a=t.stack.nodes.length;o.initialized=!0,o.outputNode=this.setup(t),o.outputNode!==null&&t.stack.nodes.length;for(const c of Object.values(o))c&&c.isNode===!0&&c.build(t)}}else if(i==="analyze")this.analyze(t);else if(i==="generate")if(this.generate.length===1){const a=this.getNodeType(t),c=t.getDataFromNode(this);n=c.snippet,n===void 0?(n=this.generate(t)||"",c.snippet=n):c.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,a,e)}else n=this.generate(t,e)||"";return t.removeChain(this),n}getSerializeChildren(){return ti(this)}serialize(t){const e=this.getSerializeChildren(),s={};for(const{property:n,index:i,childNode:o}of e)i!==void 0?(s[n]===void 0&&(s[n]=Number.isInteger(i)?[]:{}),s[n][i]=o.toJSON(t.meta).uuid):s[n]=o.toJSON(t.meta).uuid;Object.keys(s).length>0&&(t.inputNodes=s)}deserialize(t){if(t.inputNodes!==void 0){const e=t.meta.nodes;for(const s in t.inputNodes)if(Array.isArray(t.inputNodes[s])){const n=[];for(const i of t.inputNodes[s])n.push(e[i]);this[s]=n}else if(typeof t.inputNodes[s]=="object"){const n={};for(const i in t.inputNodes[s]){const o=t.inputNodes[s][i];n[i]=e[o]}this[s]=n}else{const n=t.inputNodes[s];this[s]=e[n]}}}toJSON(t){const{uuid:e,type:s}=this,n=t===void 0||typeof t=="string";n&&(t={textures:{},images:{},nodes:{}});let i=t.nodes[e];i===void 0&&(i={uuid:e,type:s,meta:t,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},n!==!0&&(t.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function o(a){const c=[];for(const u in a){const h=a[u];delete h.metadata,c.push(h)}return c}if(n){const a=o(t.textures),c=o(t.images),u=o(t.nodes);a.length>0&&(i.textures=a),c.length>0&&(i.images=c),u.length>0&&(i.nodes=u)}return i}}class ds extends U{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){const e=this.node.build(t),s=this.indexNode.build(t,"uint");return`${e}[ ${s} ]`}}class Tr extends U{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let s=null;for(const n of this.convertTo.split("|"))(s===null||t.getTypeLength(e)===t.getTypeLength(n))&&(s=n);return s}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const s=this.node,n=this.getNodeType(t),i=s.build(t,n);return t.format(i,n,e)}}class Tt extends U{static get type(){return"TempNode"}constructor(t){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){const n=t.getVectorType(this.getNodeType(t,e)),i=t.getDataFromNode(this);if(i.propertyName!==void 0)return t.format(i.propertyName,n,e);if(n!=="void"&&e!=="void"&&this.hasDependencies(t)){const o=super.build(t,n),a=t.getVarFromNode(this,null,n),c=t.getPropertyName(a);return t.addLineFlowCode(`${c} = ${o}`,this),i.snippet=o,i.propertyName=c,t.format(i.propertyName,n,e)}}return super.build(t,e)}}class _a extends Tt{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,s)=>e+t.getTypeLength(s.getNodeType(t)),0))}generate(t,e){const s=this.getNodeType(t),n=this.nodes,i=t.getComponentType(s),o=[];for(const c of n){let u=c.build(t);const h=t.getComponentType(c.getNodeType(t));h!==i&&(u=t.format(u,h,i)),o.push(u)}const a=`${t.getType(s)}( ${o.join(", ")} )`;return t.format(a,s,e)}}const za=ls.join("");class Nr extends U{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(ls.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){const s=this.node,n=t.getTypeLength(s.getNodeType(t));let i=null;if(n>1){let o=null;this.getVectorLength()>=n&&(o=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const c=s.build(t,o);this.components.length===n&&this.components===za.slice(0,this.components.length)?i=t.format(c,o,e):i=t.format(`${c}.${this.components}`,this.getNodeType(t),e)}else i=s.build(t,e);return i}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class ba extends Tt{static get type(){return"SetNode"}constructor(t,e,s){super(),this.sourceNode=t,this.components=e,this.targetNode=s}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:s,targetNode:n}=this,i=this.getNodeType(t),o=t.getTypeFromLength(s.length,n.getNodeType(t)),a=n.build(t,o),c=e.build(t,i),u=t.getTypeLength(i),h=[];for(let l=0;l<u;l++){const d=ls[l];d===s[0]?(h.push(a),l+=s.length-1):h.push(c+"."+d)}return`${t.getType(i)}( ${h.join(", ")} )`}}class Ea extends Tt{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:s}=this,n=this.getNodeType(t),i=s.build(t),o=t.getVarFromNode(this),a=t.getPropertyName(o);t.addLineFlowCode(a+" = "+i,this);const c=t.getTypeLength(n),u=[];let h=0;for(let l=0;l<c;l++){const d=ls[l];d===e[h]?(u.push("1.0 - "+(a+"."+d)),h++):u.push(a+"."+d)}return`${t.getType(n)}( ${u.join(", ")} )`}}class ei extends U{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Ws(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Ws(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=Aa(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?gr(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}}class Qt extends ei{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const s=this.getNodeType(t);return t.format(this.generateConst(t),s,e)}}let wr=null;const De=new Map;function F(r,t){if(De.has(r)){console.warn(`Redefinition of method chaining ${r}`);return}if(typeof t!="function")throw new Error(`Node element ${r} is not a function`);De.set(r,t)}const Ar=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Sr=r=>Ar(r).split("").sort().join(""),Mr={setup(r,t){const e=t.shift();return r(Xs(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(wr.assign(e,...s),e);if(De.has(t)){const s=De.get(t);return r.isStackNode?(...n)=>e.add(s(...n)):(...n)=>s(e,...n)}else{if(t==="self")return r;if(t.endsWith("Assign")&&De.has(t.slice(0,t.length-6))){const s=De.get(t.slice(0,t.length-6));return r.isStackNode?(...n)=>e.assign(n[0],s(...n)):(...n)=>e.assign(s(e,...n))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=Ar(t),v(new Nr(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Sr(t.slice(3).toLowerCase()),s=>v(new ba(r,t,s));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Sr(t.slice(4).toLowerCase()),()=>v(new Ea(v(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),v(new Nr(r,t));if(/^\d+$/.test(t)===!0)return v(new ds(e,new Qt(Number(t),"uint")))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},si=new WeakMap,_r=new WeakMap,Ca=function(r,t=null){const e=Ws(r);if(e==="node"){let s=si.get(r);return s===void 0&&(s=new Proxy(r,Mr),si.set(r,s),si.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return v(oi(r,t));if(e==="shader")return et(r)}return r},Fa=function(r,t=null){for(const e in r)r[e]=v(r[e],t);return r},Ba=function(r,t=null){const e=r.length;for(let s=0;s<e;s++)r[s]=v(r[s],t);return r},Ra=function(r,t=null,e=null,s=null){const n=i=>v(s!==null?Object.assign(i,s):i);return t===null?(...i)=>n(new r(...Ve(i))):e!==null?(e=v(e),(...i)=>n(new r(t,...Ve(i),e))):(...i)=>n(new r(t,...Ve(i)))},Ia=function(r,...t){return v(new r(...Ve(t)))};class Pa extends U{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}call(t){const{shaderNode:e,inputNodes:s}=this,n=t.getNodeProperties(e);if(n.onceOutput)return n.onceOutput;let i=null;if(e.layout){let o=_r.get(t.constructor);o===void 0&&(o=new WeakMap,_r.set(t.constructor,o));let a=o.get(e);a===void 0&&(a=v(t.buildFunctionNode(e)),o.set(e,a)),t.currentFunctionNode!==null&&t.currentFunctionNode.includes.push(a),i=v(a.call(s))}else{const o=e.jsFunc,a=s!==null?o(s,t):o(t);i=v(a)}return e.once&&(n.onceOutput=i),i}getOutputNode(t){const e=t.getNodeProperties(this);return e.outputNode===null&&(e.outputNode=this.setupOutput(t)),e.outputNode}setup(t){return this.getOutputNode(t)}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}generate(t,e){return this.getOutputNode(t).build(t,e)}}class va extends U{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}call(t=null){return Xs(t),v(new Pa(this,t))}setup(){return this.call()}}const La=[!1,!0],Oa=[0,1,2,3],Da=[-1,-2],zr=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],ni=new Map;for(const r of La)ni.set(r,new Qt(r));const ii=new Map;for(const r of Oa)ii.set(r,new Qt(r,"uint"));const ri=new Map([...ii].map(r=>new Qt(r.value,"int")));for(const r of Da)ri.set(r,new Qt(r,"int"));const $s=new Map([...ri].map(r=>new Qt(r.value)));for(const r of zr)$s.set(r,new Qt(r));for(const r of zr)$s.set(-r,new Qt(-r));const Gs={bool:ni,uint:ii,ints:ri,float:$s},br=new Map([...ni,...$s]),oi=(r,t)=>br.has(r)?br.get(r):r.isNode===!0?r:new Qt(r,t),Va=r=>{try{return r.getNodeType()}catch{return}},tt=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(n=>typeof n!="object"))&&(e=[gr(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return v(t.get(e[0]));if(e.length===1){const n=oi(e[0],r);return Va(n)===r?v(n):v(new Tr(n,r))}const s=e.map(n=>oi(n));return v(new _a(s,r))}},Ua=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function ka(r,t){return new Proxy(new va(r,t),Mr)}const v=(r,t=null)=>Ca(r,t),Xs=(r,t=null)=>new Fa(r,t),Ve=(r,t=null)=>new Ba(r,t),R=(...r)=>new Ra(...r),O=(...r)=>new Ia(...r),et=(r,t)=>{const e=new ka(r,t),s=(...n)=>{let i;return Xs(n),n[0]&&n[0].isNode?i=[...n]:i=n[0],e.call(i)};return s.shaderNode=e,s.setLayout=n=>(e.setLayout(n),s),s.once=()=>(e.once=!0,s),s};F("toGlobal",r=>(r.global=!0,r));const ai=(...r)=>wr.If(...r);function qa(r){return r}F("append",qa);const Ha=new tt("color"),H=new tt("float",Gs.float),Ue=new tt("int",Gs.ints),Wa=new tt("uint",Gs.uint),$a=new tt("bool",Gs.bool),V=new tt("vec2"),Ga=new tt("ivec2"),Xa=new tt("uvec2"),Ya=new tt("bvec2"),k=new tt("vec3"),Za=new tt("ivec3"),Ja=new tt("uvec3"),Qa=new tt("bvec3"),ke=new tt("vec4"),ja=new tt("ivec4"),Ka=new tt("uvec4"),tc=new tt("bvec4"),Er=new tt("mat2"),Ys=new tt("mat3"),ec=new tt("mat4");F("toColor",Ha),F("toFloat",H),F("toInt",Ue),F("toUint",Wa),F("toBool",$a),F("toVec2",V),F("toIVec2",Ga),F("toUVec2",Xa),F("toBVec2",Ya),F("toVec3",k),F("toIVec3",Za),F("toUVec3",Ja),F("toBVec3",Qa),F("toVec4",ke),F("toIVec4",ja),F("toUVec4",Ka),F("toBVec4",tc),F("toMat2",Er),F("toMat3",Ys),F("toMat4",ec);const sc=R(ds),nc=(r,t)=>v(new Tr(v(r),t));F("element",sc),F("convert",nc);class Cr extends U{static get type(){return"UniformGroupNode"}constructor(t,e=!1,s=1){super("string"),this.name=t,this.version=0,this.shared=e,this.order=s,this.isUniformGroup=!0}set needsUpdate(t){t===!0&&this.version++}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const ic=r=>new Cr(r),xe=((r,t=0)=>new Cr(r,!0,t))("render"),rc=ic("object");class qe extends ei{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=rc}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){const s=this.getSelf();return t=t.bind(s),super.onUpdate(n=>{const i=t(n,s);i!==void 0&&(this.value=i)},e)}generate(t,e){const s=this.getNodeType(t),n=this.getUniformHash(t);let i=t.getNodeFromHash(n);i===void 0&&(t.setHashNode(this,n),i=this);const o=i.getInputType(t),a=t.getUniformFromNode(i,o,t.shaderStage,this.name||t.context.label),c=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(c,s,e)}}const Mt=(r,t)=>{const e=Ua(t||r),s=r&&r.isNode===!0?r.node&&r.node.value||r.value:r;return v(new qe(s,e))};class Fr extends U{static get type(){return"PropertyNode"}constructor(t,e=null,s=!1){super(t),this.name=e,this.varying=s,this.isPropertyNode=!0}getHash(t){return this.name||super.getHash(t)}isGlobal(){return!0}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const He=(r,t)=>v(new Fr(r,t)),Br=O(Fr,"vec4","DiffuseColor");class oc extends Tt{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e}hasDependencies(){return!1}getNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){const s=t.getTypeLength(e.node.getNodeType(t));return ls.join("").slice(0,s)!==e.components}return!1}generate(t,e){const{targetNode:s,sourceNode:n}=this,i=this.needsSplitAssign(t),o=s.getNodeType(t),a=s.context({assign:!0}).build(t),c=n.build(t,o),u=n.getNodeType(t),h=t.getDataFromNode(this);let l;if(h.initialized===!0)e!=="void"&&(l=a);else if(i){const d=t.getVarFromNode(this,null,o),f=t.getPropertyName(d);t.addLineFlowCode(`${f} = ${c}`,this);const p=s.node.context({assign:!0}).build(t);for(let m=0;m<s.components.length;m++){const x=s.components[m];t.addLineFlowCode(`${p}.${x} = ${f}[ ${m} ]`,this)}e!=="void"&&(l=a)}else l=`${a} = ${c}`,(e==="void"||u==="void")&&(t.addLineFlowCode(l,this),e!=="void"&&(l=a));return h.initialized=!0,t.format(l,o,e)}}F("assign",R(oc));class ac extends Tt{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){const e=[],s=this.functionNode,n=s.getInputs(t),i=this.parameters;if(Array.isArray(i))for(let a=0;a<i.length;a++){const c=n[a],u=i[a];e.push(u.build(t,c.type))}else for(const a of n){const c=i[a.name];if(c!==void 0)e.push(c.build(t,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${s.build(t,"property")}( ${e.join(", ")} )`}}F("call",(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Ve(t):Xs(t[0]),v(new ac(v(r),t))));class Y extends Tt{static get type(){return"OperatorNode"}constructor(t,e,s,...n){if(super(),n.length>0){let i=new Y(t,e,s);for(let o=0;o<n.length-1;o++)i=new Y(t,i,n[o]);e=i,s=n[n.length-1]}this.op=t,this.aNode=e,this.bNode=s}getNodeType(t,e){const s=this.op,n=this.aNode,i=this.bNode,o=n.getNodeType(t),a=typeof i<"u"?i.getNodeType(t):null;if(o==="void"||a==="void")return"void";if(s==="%")return o;if(s==="~"||s==="&"||s==="|"||s==="^"||s===">>"||s==="<<")return t.getIntegerType(o);if(s==="!"||s==="=="||s==="&&"||s==="||"||s==="^^")return"bool";if(s==="<"||s===">"||s==="<="||s===">="){const c=e?t.getTypeLength(e):Math.max(t.getTypeLength(o),t.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else return o==="float"&&t.isMatrix(a)?a:t.isMatrix(o)&&t.isVector(a)?t.getVectorFromMatrix(o):t.isVector(o)&&t.isMatrix(a)?t.getVectorFromMatrix(a):t.getTypeLength(a)>t.getTypeLength(o)?a:o}generate(t,e){const s=this.op,n=this.aNode,i=this.bNode,o=this.getNodeType(t,e);let a=null,c=null;o!=="void"?(a=n.getNodeType(t),c=typeof i<"u"?i.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="?t.isVector(a)?c=a:a!==c&&(a=c="float"):s===">>"||s==="<<"?(a=o,c=t.changeComponentType(c,"uint")):t.isMatrix(a)&&t.isVector(c)?c=t.getVectorFromMatrix(a):t.isVector(a)&&t.isMatrix(c)?a=t.getVectorFromMatrix(c):a=c=o):a=c=o;const u=n.build(t,a),h=typeof i<"u"?i.build(t,c):null,l=t.getTypeLength(e),d=t.getFunctionOperator(s);if(e!=="void")return s==="<"&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThan",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} < ${h} )`,o,e):s==="<="&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("lessThanEqual",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} <= ${h} )`,o,e):s===">"&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThan",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} > ${h} )`,o,e):s===">="&&l>1?t.useComparisonMethod?t.format(`${t.getMethod("greaterThanEqual",e)}( ${u}, ${h} )`,o,e):t.format(`( ${u} >= ${h} )`,o,e):s==="!"||s==="~"?t.format(`(${s}${u})`,a,e):d?t.format(`${d}( ${u}, ${h} )`,o,e):t.format(`( ${u} ${s} ${h} )`,o,e);if(a!=="void")return d?t.format(`${d}( ${u}, ${h} )`,o,e):t.format(`${u} ${s} ${h}`,o,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const Te=R(Y,"+"),Zs=R(Y,"-"),Js=R(Y,"*"),Rr=R(Y,"/"),Ir=R(Y,"%"),cc=R(Y,"=="),hc=R(Y,"!="),uc=R(Y,"<"),lc=R(Y,">"),dc=R(Y,"<="),fc=R(Y,">="),pc=R(Y,"&&"),mc=R(Y,"||"),yc=R(Y,"!"),gc=R(Y,"^^"),xc=R(Y,"&"),Tc=R(Y,"~"),Nc=R(Y,"|"),wc=R(Y,"^"),Ac=R(Y,"<<"),Sc=R(Y,">>");F("add",Te),F("sub",Zs),F("mul",Js),F("div",Rr),F("modInt",Ir),F("equal",cc),F("notEqual",hc),F("lessThan",uc),F("greaterThan",lc),F("lessThanEqual",dc),F("greaterThanEqual",fc),F("and",pc),F("or",mc),F("not",yc),F("xor",gc),F("bitAnd",xc),F("bitNot",Tc),F("bitOr",Nc),F("bitXor",wc),F("shiftLeft",Ac),F("shiftRight",Sc),F("remainder",(...r)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Ir(...r)));class A extends Tt{static get type(){return"MathNode"}constructor(t,e,s=null,n=null){super(),this.method=t,this.aNode=e,this.bNode=s,this.cNode=n}getInputType(t){const e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,n=this.cNode?this.cNode.getNodeType(t):null,i=t.isMatrix(e)?0:t.getTypeLength(e),o=t.isMatrix(s)?0:t.getTypeLength(s),a=t.isMatrix(n)?0:t.getTypeLength(n);return i>o&&i>a?e:o>a?s:a>i?n:e}getNodeType(t){const e=this.method;return e===A.LENGTH||e===A.DISTANCE||e===A.DOT?"float":e===A.CROSS?"vec3":e===A.ALL?"bool":e===A.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):e===A.MOD?this.aNode.getNodeType(t):this.getInputType(t)}generate(t,e){const s=this.method,n=this.getNodeType(t),i=this.getInputType(t),o=this.aNode,a=this.bNode,c=this.cNode,u=t.renderer.isWebGLRenderer===!0;if(s===A.TRANSFORM_DIRECTION){let h=o,l=a;t.isMatrix(h.getNodeType(t))?l=ke(k(l),0):h=ke(k(h),0);const d=Js(h,l).xyz;return Pr(d).build(t,e)}else{if(s===A.NEGATE)return t.format("( - "+o.build(t,i)+" )",n,e);if(s===A.ONE_MINUS)return Zs(1,o).build(t,e);if(s===A.RECIPROCAL)return Rr(1,o).build(t,e);if(s===A.DIFFERENCE)return ui(Zs(o,a)).build(t,e);{const h=[];return s===A.CROSS||s===A.MOD?h.push(o.build(t,n),a.build(t,n)):u&&s===A.STEP?h.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":i),a.build(t,i)):u&&(s===A.MIN||s===A.MAX)||s===A.MOD?h.push(o.build(t,i),a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":i)):s===A.REFRACT?h.push(o.build(t,i),a.build(t,i),c.build(t,"float")):s===A.MIX?h.push(o.build(t,i),a.build(t,i),c.build(t,t.getTypeLength(c.getNodeType(t))===1?"float":i)):(h.push(o.build(t,i)),a!==null&&h.push(a.build(t,i)),c!==null&&h.push(c.build(t,i))),t.format(`${t.getMethod(s,n)}( ${h.join(", ")} )`,n,e)}}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}A.ALL="all",A.ANY="any",A.EQUALS="equals",A.RADIANS="radians",A.DEGREES="degrees",A.EXP="exp",A.EXP2="exp2",A.LOG="log",A.LOG2="log2",A.SQRT="sqrt",A.INVERSE_SQRT="inversesqrt",A.FLOOR="floor",A.CEIL="ceil",A.NORMALIZE="normalize",A.FRACT="fract",A.SIN="sin",A.COS="cos",A.TAN="tan",A.ASIN="asin",A.ACOS="acos",A.ATAN="atan",A.ABS="abs",A.SIGN="sign",A.LENGTH="length",A.NEGATE="negate",A.ONE_MINUS="oneMinus",A.DFDX="dFdx",A.DFDY="dFdy",A.ROUND="round",A.RECIPROCAL="reciprocal",A.TRUNC="trunc",A.FWIDTH="fwidth",A.BITCAST="bitcast",A.TRANSPOSE="transpose",A.ATAN2="atan2",A.MIN="min",A.MAX="max",A.MOD="mod",A.STEP="step",A.REFLECT="reflect",A.DISTANCE="distance",A.DIFFERENCE="difference",A.DOT="dot",A.CROSS="cross",A.POW="pow",A.TRANSFORM_DIRECTION="transformDirection",A.MIX="mix",A.CLAMP="clamp",A.REFRACT="refract",A.SMOOTHSTEP="smoothstep",A.FACEFORWARD="faceforward";const Mc=H(Math.PI),_c=R(A,A.ALL),zc=R(A,A.ANY),bc=R(A,A.EQUALS),Ec=R(A,A.RADIANS),Cc=R(A,A.DEGREES),Fc=R(A,A.EXP),Bc=R(A,A.EXP2),Rc=R(A,A.LOG),Ic=R(A,A.LOG2),ci=R(A,A.SQRT),Pc=R(A,A.INVERSE_SQRT),vc=R(A,A.FLOOR),Lc=R(A,A.CEIL),Pr=R(A,A.NORMALIZE),hi=R(A,A.FRACT),vr=R(A,A.SIN),Oc=R(A,A.COS),Dc=R(A,A.TAN),Vc=R(A,A.ASIN),Uc=R(A,A.ACOS),kc=R(A,A.ATAN),ui=R(A,A.ABS),Lr=R(A,A.SIGN),qc=R(A,A.LENGTH),Hc=R(A,A.NEGATE),Wc=R(A,A.ONE_MINUS),$c=R(A,A.DFDX),Gc=R(A,A.DFDY),Xc=R(A,A.ROUND),Yc=R(A,A.RECIPROCAL),Zc=R(A,A.TRUNC),Jc=R(A,A.FWIDTH);A.BITCAST;const Qc=R(A,A.TRANSPOSE),jc=R(A,A.ATAN2),Kc=R(A,A.MIN),li=R(A,A.MAX),Or=R(A,A.MOD),Dr=R(A,A.STEP),th=R(A,A.REFLECT),eh=R(A,A.DISTANCE),sh=R(A,A.DIFFERENCE),di=R(A,A.DOT),nh=R(A,A.CROSS),Vr=R(A,A.POW),ih=R(A,A.POW,2),rh=R(A,A.POW,3),oh=R(A,A.POW,4),ah=R(A,A.TRANSFORM_DIRECTION),ch=r=>Js(Lr(r),Vr(ui(r),1/3)),hh=r=>di(r,r),he=R(A,A.MIX),Qs=(r,t=0,e=1)=>v(new A(A.CLAMP,v(r),v(t),v(e))),uh=r=>Qs(r),lh=R(A,A.REFRACT),fi=R(A,A.SMOOTHSTEP),dh=R(A,A.FACEFORWARD),fh=et(([r])=>{const s=43758.5453,n=di(r.xy,V(12.9898,78.233)),i=Or(n,Mc);return hi(vr(i).mul(s))}),ph=(r,t,e)=>he(t,e,r),mh=(r,t,e)=>fi(t,e,r);F("all",_c),F("any",zc),F("equals",bc),F("radians",Ec),F("degrees",Cc),F("exp",Fc),F("exp2",Bc),F("log",Rc),F("log2",Ic),F("sqrt",ci),F("inverseSqrt",Pc),F("floor",vc),F("ceil",Lc),F("normalize",Pr),F("fract",hi),F("sin",vr),F("cos",Oc),F("tan",Dc),F("asin",Vc),F("acos",Uc),F("atan",kc),F("abs",ui),F("sign",Lr),F("length",qc),F("lengthSq",hh),F("negate",Hc),F("oneMinus",Wc),F("dFdx",$c),F("dFdy",Gc),F("round",Xc),F("reciprocal",Yc),F("trunc",Zc),F("fwidth",Jc),F("atan2",jc),F("min",Kc),F("max",li),F("mod",Or),F("step",Dr),F("reflect",th),F("distance",eh),F("dot",di),F("cross",nh),F("pow",Vr),F("pow2",ih),F("pow3",rh),F("pow4",oh),F("transformDirection",ah),F("mix",ph),F("clamp",Qs),F("refract",lh),F("smoothstep",mh),F("faceForward",dh),F("difference",sh),F("saturate",uh),F("cbrt",ch),F("transpose",Qc),F("rand",fh);class yh extends U{static get type(){return"ConditionalNode"}constructor(t,e,s=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=s}getNodeType(t){const e=this.ifNode.getNodeType(t);if(this.elseNode!==null){const s=this.elseNode.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(e))return s}return e}setup(t){const e=this.condNode.cache(),s=this.ifNode.cache(),n=this.elseNode?this.elseNode.cache():null,i=t.context.nodeBlock;t.getDataFromNode(s).parentNodeBlock=i,n!==null&&(t.getDataFromNode(n).parentNodeBlock=i);const o=t.getNodeProperties(this);o.condNode=e,o.ifNode=s.context({nodeBlock:s}),o.elseNode=n?n.context({nodeBlock:n}):null}generate(t,e){const s=this.getNodeType(t),n=t.getDataFromNode(this);if(n.nodeProperty!==void 0)return n.nodeProperty;const{condNode:i,ifNode:o,elseNode:a}=t.getNodeProperties(this),c=e!=="void",u=c?He(s).build(t):"";n.nodeProperty=u;const h=i.build(t,"bool");t.addFlowCode(`
2
2
  ${t.tab}if ( ${h} ) {
3
3
 
4
4
  `).addFlowTab();let l=o.build(t,s);if(l&&(c?l=u+" = "+l+";":l="return "+l+";"),t.removeFlowTab().addFlowCode(t.tab+" "+l+`