nova64 0.2.4 โ 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -8
- package/bin/nova64.js +165 -0
- package/dist/assets/console-CY_kygm3.js +14 -0
- package/dist/assets/console-CY_kygm3.js.map +1 -0
- package/dist/assets/main-l0sNRNKZ.js.map +1 -0
- package/dist/assets/sky/studio/nx.png +0 -0
- package/dist/assets/sky/studio/ny.png +0 -0
- package/dist/assets/sky/studio/nz.png +0 -0
- package/dist/assets/sky/studio/px.png +0 -0
- package/dist/assets/sky/studio/py.png +0 -0
- package/dist/assets/sky/studio/pz.png +0 -0
- package/dist/assets/vanilla-Dcuy32gi.js +2 -0
- package/dist/assets/vanilla-Dcuy32gi.js.map +1 -0
- package/dist/console.html +899 -0
- package/dist/docs/BENCHMARK.md +77 -0
- package/dist/docs/CHEATSHEET.md +255 -0
- package/dist/docs/EFFECTS_API_GUIDE.md +577 -0
- package/dist/docs/EFFECTS_QUICK_REFERENCE.md +331 -0
- package/dist/docs/FONT_CHARACTER_REFERENCE.md +219 -0
- package/dist/docs/FREE_GLB_ASSETS.md +330 -0
- package/dist/docs/FULLSCREEN_BUTTON_FEATURE.md +296 -0
- package/dist/docs/GAMEPAD_SUPPORT.md +348 -0
- package/dist/docs/GAME_IMPROVEMENTS.md +278 -0
- package/dist/docs/GAME_QUALITY_STATUS.md +300 -0
- package/dist/docs/MIGRATION_GUIDE.md +553 -0
- package/dist/docs/NOVA64_3D_API.md +356 -0
- package/dist/docs/NOVA64_API_REFERENCE.md +1406 -0
- package/dist/docs/NOVA64_UI_API.md +503 -0
- package/dist/docs/UI_SYSTEM_SUMMARY.md +445 -0
- package/dist/docs/VOXEL_ENGINE_GUIDE.md +662 -0
- package/dist/docs/VOXEL_QUICK_REFERENCE.md +386 -0
- package/dist/docs/api-3d.html +750 -0
- package/dist/docs/api-effects.html +385 -0
- package/dist/docs/api-improvements.md +121 -0
- package/dist/docs/api-skybox.html +407 -0
- package/dist/docs/api-sprites.html +321 -0
- package/dist/docs/api-voxel.html +337 -0
- package/dist/docs/api.html +543 -0
- package/dist/docs/assets.html +306 -0
- package/dist/docs/audio.html +340 -0
- package/dist/docs/blogs.html +286 -0
- package/dist/docs/collision.html +316 -0
- package/dist/docs/console.html +247 -0
- package/dist/docs/editor.html +297 -0
- package/dist/docs/font.html +247 -0
- package/dist/docs/framebuffer.html +247 -0
- package/dist/docs/fullscreen-button.html +297 -0
- package/dist/docs/gpu-systems.html +247 -0
- package/dist/docs/index.html +580 -0
- package/dist/docs/input.html +491 -0
- package/dist/docs/physics.html +311 -0
- package/dist/docs/screens.html +311 -0
- package/dist/docs/storage.html +311 -0
- package/dist/docs/textinput.html +332 -0
- package/dist/docs/ui.html +488 -0
- package/dist/examples/3d-advanced/code.js +695 -0
- package/dist/examples/adventure-comic-3d/code.js +342 -0
- package/dist/examples/audio-lab/code.js +150 -0
- package/dist/examples/boids-flocking/code.js +270 -0
- package/dist/examples/crystal-cathedral-3d/code.js +706 -0
- package/dist/examples/cyberpunk-city-3d/code.js +1383 -0
- package/dist/examples/demoscene/README.md +192 -0
- package/dist/examples/demoscene/code.js +1081 -0
- package/dist/examples/demoscene/meta.json +21 -0
- package/dist/examples/dungeon-crawler-3d/code.js +1117 -0
- package/dist/examples/f-zero-nova-3d/code.js +865 -0
- package/dist/examples/f-zero-nova-3d/code_old.js +1555 -0
- package/dist/examples/fps-demo-3d/code.js +744 -0
- package/dist/examples/game-of-life-3d/code.js +338 -0
- package/dist/examples/generative-art/code.js +632 -0
- package/dist/examples/hello-3d/code.js +325 -0
- package/dist/examples/hello-skybox/code.js +183 -0
- package/dist/examples/hello-world/code.js +19 -0
- package/dist/examples/input-showcase/code.js +109 -0
- package/dist/examples/instancing-demo/code.js +315 -0
- package/dist/examples/minecraft-demo/code.js +387 -0
- package/dist/examples/model-viewer-3d/code.js +114 -0
- package/dist/examples/mystical-realm-3d/code.js +1203 -0
- package/dist/examples/nature-explorer-3d/code.js +1318 -0
- package/dist/examples/particles-demo/code.js +522 -0
- package/dist/examples/pbr-showcase/code.js +140 -0
- package/dist/examples/physics-demo-3d/code.js +948 -0
- package/dist/examples/screen-demo/code.js +267 -0
- package/dist/examples/shooter-demo-3d/code.js +1286 -0
- package/dist/examples/space-combat-3d/IMPLEMENTATION_SUMMARY.md +109 -0
- package/dist/examples/space-combat-3d/README.md +135 -0
- package/dist/examples/space-combat-3d/code.js +1332 -0
- package/dist/examples/space-harrier-3d/code.js +923 -0
- package/dist/examples/star-fox-nova-3d/code.js +1116 -0
- package/dist/examples/star-fox-nova-3d/code_backup.js +410 -0
- package/dist/examples/star-fox-nova-3d/code_broken.js +1821 -0
- package/dist/examples/storage-quest/code.js +209 -0
- package/dist/examples/strider-demo-3d/IMPROVEMENT_OPTIONS.md +285 -0
- package/dist/examples/strider-demo-3d/cache-test.html +132 -0
- package/dist/examples/strider-demo-3d/code-fixed.js +582 -0
- package/dist/examples/strider-demo-3d/code-old.js +1537 -0
- package/dist/examples/strider-demo-3d/code.js +1462 -0
- package/dist/examples/strider-demo-3d/code.js.bak2 +1169 -0
- package/dist/examples/strider-demo-3d/fix-game.sh +53 -0
- package/dist/examples/super-plumber-64/README.md +128 -0
- package/dist/examples/super-plumber-64/code.js +1185 -0
- package/dist/examples/super-plumber-64/index.html +88 -0
- package/dist/examples/test-2d-overlay/code.js +32 -0
- package/dist/examples/test-font/code.js +51 -0
- package/dist/examples/test-minimal/code.js +21 -0
- package/dist/examples/ui-demo/code.js +306 -0
- package/dist/examples/wing-commander-space/README.md +180 -0
- package/dist/examples/wing-commander-space/code.js +1285 -0
- package/dist/examples/wizardry-3d/CHANGELOG.md +366 -0
- package/dist/examples/wizardry-3d/code.js +3928 -0
- package/dist/index.html +666 -0
- package/dist/os9-shell/assets/index-DIHfrTaW.css +1 -0
- package/dist/os9-shell/assets/index-KchE_ngx.js +483 -0
- package/dist/os9-shell/assets/index-KchE_ngx.js.map +1 -0
- package/dist/os9-shell/index.html +23 -0
- package/dist/os9-shell/nova-icon.svg +12 -0
- package/index.html +6 -1
- package/package.json +37 -32
- package/public/assets/sky/studio/nx.png +0 -0
- package/public/assets/sky/studio/ny.png +0 -0
- package/public/assets/sky/studio/nz.png +0 -0
- package/public/assets/sky/studio/px.png +0 -0
- package/public/assets/sky/studio/py.png +0 -0
- package/public/assets/sky/studio/pz.png +0 -0
- package/public/os9-shell/assets/index-KchE_ngx.js +483 -0
- package/public/os9-shell/assets/index-KchE_ngx.js.map +1 -0
- package/public/os9-shell/index.html +10 -1
- package/runtime/api-2d.js +301 -21
- package/runtime/api-3d/pbr.js +45 -1
- package/runtime/api-3d.js +1 -0
- package/runtime/api-effects.js +90 -3
- package/runtime/api-gameutils.js +476 -0
- package/runtime/api-generative.js +610 -0
- package/runtime/api-skybox.js +54 -0
- package/runtime/api-voxel.js +139 -28
- package/runtime/gpu-threejs.js +13 -9
- package/runtime/ui.js +2 -2
- package/src/main.js +24 -1
- package/public/os9-shell/assets/index-B1Uvacma.js +0 -32825
- package/public/os9-shell/assets/index-B1Uvacma.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();const t=Object.freeze({DEBUG:0,INFO:1,WARN:2,ERROR:3,NONE:4});const e=new class{constructor(e=t.INFO){this.level=e,this.history=[],this.maxHistory=200}_record(t,e){this.history.push({level:t,args:e,ts:Date.now()}),this.history.length>this.maxHistory&&this.history.shift()}debug(...e){this.level>t.DEBUG||(console.log("[Nova64:DEBUG]",...e),this._record("DEBUG",e))}info(...e){this.level>t.INFO||(console.log("[Nova64:INFO]",...e),this._record("INFO",e))}warn(...e){this.level>t.WARN||(console.warn("[Nova64:WARN]",...e),this._record("WARN",e))}error(...e){this.level>t.ERROR||(console.error("[Nova64:ERROR]",...e),this._record("ERROR",e))}setLevel(t){this.level=t}getHistory(){return[...this.history]}clearHistory(){this.history=[]}}(void 0!==import.meta&&{}?t.WARN:t.INFO);
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2010-2025 Three.js Authors
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
const n="182",i=1,r=3,s=0,a=1,o=2,l=100,c=101,h=102,u=200,d=201,p=202,f=203,m=204,g=205,v=206,_=207,x=208,y=209,M=210,b=211,S=212,w=213,T=214,E=0,A=1,C=2,R=3,P=4,I=5,L=6,D=7,N=0,U=1,O=2,F=1,B=2,z=3,k=4,V=5,G=6,H=7,W="attached",j="detached",X=300,q=301,Y=302,Z=303,K=304,J=306,$=1e3,Q=1001,tt=1002,et=1003,nt=1004,it=1005,rt=1006,st=1007,at=1008,ot=1009,lt=1010,ct=1011,ht=1012,ut=1013,dt=1014,pt=1015,ft=1016,mt=1017,gt=1018,vt=1020,_t=35902,xt=35899,yt=1021,Mt=1022,bt=1023,St=1026,wt=1027,Tt=1028,Et=1029,At=1030,Ct=1031,Rt=1033,Pt=33776,It=33777,Lt=33778,Dt=33779,Nt=35840,Ut=35841,Ot=35842,Ft=35843,Bt=36196,zt=37492,kt=37496,Vt=37488,Gt=37489,Ht=37490,Wt=37491,jt=37808,Xt=37809,qt=37810,Yt=37811,Zt=37812,Kt=37813,Jt=37814,$t=37815,Qt=37816,te=37817,ee=37818,ne=37819,ie=37820,re=37821,se=36492,ae=36494,oe=36495,le=36283,ce=36284,he=36285,ue=36286,de=2200,pe=2201,fe=2300,me=2301,ge=2302,ve=2400,_e=2401,xe=2402,ye=2500,Me=2501,be="",Se="srgb",we="srgb-linear",Te="linear",Ee="srgb",Ae=7680,Ce=512,Re=513,Pe=514,Ie=515,Le=516,De=517,Ne=518,Ue=519,Oe=35044,Fe=35048,Be="300 es",ze=2e3,ke=2001;function Ve(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const Ge={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function He(t,e){return new Ge[t](e)}function We(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function je(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Xe(){const t=je("canvas");return t.style.display="block",t}const qe={};let Ye=null;function Ze(...t){const e="THREE."+t.shift();Ye?Ye("log",e,...t):console.log(e,...t)}function Ke(...t){const e="THREE."+t.shift();Ye?Ye("warn",e,...t):console.warn(e,...t)}function Je(...t){const e="THREE."+t.shift();Ye?Ye("error",e,...t):console.error(e,...t)}function $e(...t){const e=t.join(" ");e in qe||(qe[e]=!0,Ke(...t))}class Qe{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return void 0!==n&&(void 0!==n[t]&&-1!==n[t].indexOf(e))}removeEventListener(t,e){const n=this._listeners;if(void 0===n)return;const i=n[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const n=e[t.type];if(void 0!==n){t.target=this;const e=n.slice(0);for(let n=0,i=e.length;n<i;n++)e[n].call(this,t);t.target=null}}}const tn=["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 en=1234567;const nn=Math.PI/180,rn=180/Math.PI;function sn(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(tn[255&t]+tn[t>>8&255]+tn[t>>16&255]+tn[t>>24&255]+"-"+tn[255&e]+tn[e>>8&255]+"-"+tn[e>>16&15|64]+tn[e>>24&255]+"-"+tn[63&n|128]+tn[n>>8&255]+"-"+tn[n>>16&255]+tn[n>>24&255]+tn[255&i]+tn[i>>8&255]+tn[i>>16&255]+tn[i>>24&255]).toLowerCase()}function an(t,e,n){return Math.max(e,Math.min(n,t))}function on(t,e){return(t%e+e)%e}function ln(t,e,n){return(1-n)*t+n*e}function cn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function hn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const un={DEG2RAD:nn,RAD2DEG:rn,generateUUID:sn,clamp:an,euclideanModulo:on,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:ln,damp:function(t,e,n,i){return ln(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(on(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(en=t);let e=en+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*nn},radToDeg:function(t){return t*rn},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*f,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*f,o*c);break;case"ZYZ":t.set(l*f,l*p,o*h,o*c);break;default:Ke("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:hn,denormalize:cn};class dn{constructor(t=0,e=0){dn.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,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=an(this.x,t.x,e.x),this.y=an(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=an(this.x,t,e),this.y=an(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(an(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(an(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class pn{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,a){let o=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3],u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(a<=0)return t[e+0]=o,t[e+1]=l,t[e+2]=c,void(t[e+3]=h);if(a>=1)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=f);if(h!==f||o!==u||l!==d||c!==p){let t=o*u+l*d+c*p+h*f;t<0&&(u=-u,d=-d,p=-p,f=-f,t=-t);let e=1-a;if(t<.9995){const n=Math.acos(t),i=Math.sin(n);e=Math.sin(e*n)/i,o=o*e+u*(a=Math.sin(a*n)/i),l=l*e+d*a,c=c*e+p*a,h=h*e+f*a}else{o=o*e+u*a,l=l*e+d*a,c=c*e+p*a,h=h*e+f*a;const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:Ke("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(an(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(e<=0)return this;if(e>=1)return this.copy(t);let n=t._x,i=t._y,r=t._z,s=t._w,a=this.dot(t);a<0&&(n=-n,i=-i,r=-r,s=-s,a=-a);let o=1-e;if(a<.9995){const t=Math.acos(a),l=Math.sin(t);o=Math.sin(o*t)/l,e=Math.sin(e*t)/l,this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this._onChangeCallback()}else this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class fn{constructor(t=0,e=0,n=0){fn.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,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(gn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(gn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),h=2*(r*n-s*e);return this.x=e+o*l+s*h-a*c,this.y=n+o*c+a*l-r*h,this.z=i+o*h+r*c-s*l,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,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=an(this.x,t.x,e.x),this.y=an(this.y,t.y,e.y),this.z=an(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=an(this.x,t,e),this.y=an(this.y,t,e),this.z=an(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(an(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return mn.copy(this).projectOnVector(t),this.sub(mn)}reflect(t){return this.sub(mn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(an(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,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(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const mn=new fn,gn=new pn;class vn{constructor(t,e,n,i,r,s,a,o,l){vn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],M=i[5],b=i[8];return r[0]=s*f+a*v+o*y,r[3]=s*m+a*_+o*M,r[6]=s*g+a*x+o*b,r[1]=l*f+c*v+h*y,r[4]=l*m+c*_+h*M,r[7]=l*g+c*x+h*b,r[2]=u*f+d*v+p*y,r[5]=u*m+d*_+p*M,r[8]=u*g+d*x+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=h*f,t[1]=(i*l-c*n)*f,t[2]=(a*n-i*s)*f,t[3]=u*f,t[4]=(c*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=d*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,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,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(_n.makeScale(t,e)),this}rotate(t){return this.premultiply(_n.makeRotation(-t)),this}translate(t,e){return this.premultiply(_n.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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const _n=new vn,xn=(new vn).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yn=(new vn).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Mn(){const t={enabled:!0,workingColorSpace:we,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===Ee&&(t.r=Sn(t.r),t.g=Sn(t.g),t.b=Sn(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Ee&&(t.r=wn(t.r),t.g=wn(t.g),t.b=wn(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===be?Te:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,n){return $e("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,n)},toWorkingColorSpace:function(e,n){return $e("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,n)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[we]:{primaries:e,whitePoint:i,transfer:Te,toXYZ:xn,fromXYZ:yn,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Se},outputColorSpaceConfig:{drawingBufferColorSpace:Se}},[Se]:{primaries:e,whitePoint:i,transfer:Ee,toXYZ:xn,fromXYZ:yn,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Se}}}),t}const bn=Mn();function Sn(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function wn(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Tn;class En{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{void 0===Tn&&(Tn=je("canvas")),Tn.width=t.width,Tn.height=t.height;const e=Tn.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),n=Tn}return n.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=je("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*Sn(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Sn(e[t]/255)):e[t]=Sn(e[t]);return{data:e,width:t.width,height:t.height}}return Ke("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let An=0;class Cn{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:An++}),this.uuid=sn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(Rn(i[e].image)):t.push(Rn(i[e]))}else t=Rn(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function Rn(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?En.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Ke("Texture: Unable to serialize Texture."),{})}let Pn=0;const In=new fn;class Ln extends Qe{constructor(t=Ln.DEFAULT_IMAGE,e=Ln.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=ot,l=Ln.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Pn++}),this.uuid=sn(),this.name="",this.source=new Cn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new dn(0,0),this.repeat=new dn(1,1),this.center=new dn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(In).x}get height(){return this.source.getSize(In).y}get depth(){return this.source.getSize(In).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(void 0===n){Ke(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n:Ke(`Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==X)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case $:t.x=t.x-Math.floor(t.x);break;case Q:t.x=t.x<0?0:1;break;case tt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case $:t.y=t.y-Math.floor(t.y);break;case Q:t.y=t.y<0?0:1;break;case tt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Ln.DEFAULT_IMAGE=null,Ln.DEFAULT_MAPPING=X,Ln.DEFAULT_ANISOTROPY=1;class Dn{constructor(t=0,e=0,n=0,i=1){Dn.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}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,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)<s&&Math.abs(h-f)<s&&Math.abs(p-m)<s){if(Math.abs(c+u)<a&&Math.abs(h+f)<a&&Math.abs(p+m)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,v=(g+1)/2,_=(c+u)/4,x=(h+f)/4,y=(p+m)/4;return t>o&&t>v?t<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=_/n,r=x/n):o>v?o<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=_/i,r=y/i):v<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=x/r,i=y/r),this.set(n,i,r,e),this}let v=Math.sqrt((m-p)*(m-p)+(h-f)*(h-f)+(u-c)*(u-c));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(h-f)/v,this.z=(u-c)/v,this.w=Math.acos((l+d+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=an(this.x,t.x,e.x),this.y=an(this.y,t.y,e.y),this.z=an(this.z,t.z,e.z),this.w=an(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=an(this.x,t,e),this.y=an(this.y,t,e),this.z=an(this.z,t,e),this.w=an(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(an(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,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 Nn extends Qe{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Dn(0,0,t,e),this.scissorTest=!1,this.viewport=new Dn(0,0,t,e);const i={width:t,height:e,depth:n.depth},r=new Ln(i);this.textures=[];const s=n.count;for(let a=0;a<s;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){const e={minFilter:rt,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==t.mapping&&(e.mapping=t.mapping),void 0!==t.wrapS&&(e.wrapS=t.wrapS),void 0!==t.wrapT&&(e.wrapT=t.wrapT),void 0!==t.wrapR&&(e.wrapR=t.wrapR),void 0!==t.magFilter&&(e.magFilter=t.magFilter),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.anisotropy&&(e.anisotropy=t.anisotropy),void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),void 0!==t.internalFormat&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++){this.textures[n].setValues(e)}}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);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 e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new Cn(n)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Un extends Nn{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class On extends Ln{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=et,this.minFilter=et,this.wrapR=Q,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Fn extends Ln{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=et,this.minFilter=et,this.wrapR=Q,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Bn{constructor(t=new fn(1/0,1/0,1/0),e=new fn(-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,n=t.length;e<n;e+=3)this.expandByPoint(kn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(kn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=kn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),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 n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,kn):kn.fromBufferAttribute(i,e),kn.applyMatrix4(t.matrixWorld),this.expandByPoint(kn);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Vn.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Vn.copy(n.boundingBox)),Vn.applyMatrix4(t.matrixWorld),this.union(Vn)}const i=t.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],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,kn),kn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Yn),Zn.subVectors(this.max,Yn),Gn.subVectors(t.a,Yn),Hn.subVectors(t.b,Yn),Wn.subVectors(t.c,Yn),jn.subVectors(Hn,Gn),Xn.subVectors(Wn,Hn),qn.subVectors(Gn,Wn);let e=[0,-jn.z,jn.y,0,-Xn.z,Xn.y,0,-qn.z,qn.y,jn.z,0,-jn.x,Xn.z,0,-Xn.x,qn.z,0,-qn.x,-jn.y,jn.x,0,-Xn.y,Xn.x,0,-qn.y,qn.x,0];return!!$n(e,Gn,Hn,Wn,Zn)&&(e=[1,0,0,0,1,0,0,0,1],!!$n(e,Gn,Hn,Wn,Zn)&&(Kn.crossVectors(jn,Xn),e=[Kn.x,Kn.y,Kn.z],$n(e,Gn,Hn,Wn,Zn)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,kn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(kn).length()),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()||(zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(zn)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const zn=[new fn,new fn,new fn,new fn,new fn,new fn,new fn,new fn],kn=new fn,Vn=new Bn,Gn=new fn,Hn=new fn,Wn=new fn,jn=new fn,Xn=new fn,qn=new fn,Yn=new fn,Zn=new fn,Kn=new fn,Jn=new fn;function $n(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){Jn.fromArray(t,s);const a=r.x*Math.abs(Jn.x)+r.y*Math.abs(Jn.y)+r.z*Math.abs(Jn.z),o=e.dot(Jn),l=n.dot(Jn),c=i.dot(Jn);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Qn=new Bn,ti=new fn,ei=new fn;class ni{constructor(t=new fn,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 n=this.center;void 0!==e?n.copy(e):Qn.setFromPoints(t).getCenter(n);let i=0;for(let r=0,s=t.length;r<s;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(t);return e.copy(t),n>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;ti.subVectors(t,this.center);const e=ti.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(ti,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(ei.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ti.copy(t.center).add(ei)),this.expandByPoint(ti.copy(t.center).sub(ei))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const ii=new fn,ri=new fn,si=new fn,ai=new fn,oi=new fn,li=new fn,ci=new fn;class hi{constructor(t=new fn,e=new fn(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,ii)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=ii.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ii.copy(this.origin).addScaledVector(this.direction,e),ii.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){ri.copy(t).add(e).multiplyScalar(.5),si.copy(e).sub(t).normalize(),ai.copy(this.origin).sub(ri);const r=.5*t.distanceTo(e),s=-this.direction.dot(si),a=ai.dot(this.direction),o=-ai.dot(si),l=ai.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(ri).addScaledVector(si,u),d}intersectSphere(t,e){ii.subVectors(t.center,this.origin);const n=ii.dot(this.direction),i=ii.dot(ii)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),h>=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,ii)}intersectTriangle(t,e,n,i,r){oi.subVectors(e,t),li.subVectors(n,t),ci.crossVectors(oi,li);let s,a=this.direction.dot(ci);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}ai.subVectors(this.origin,t);const o=s*this.direction.dot(li.crossVectors(ai,li));if(o<0)return null;const l=s*this.direction.dot(oi.cross(ai));if(l<0)return null;if(o+l>a)return null;const c=-s*ai.dot(ci);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ui{constructor(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){ui.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,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 ui).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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,n){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,n=t.elements,i=1/di.setFromMatrixColumn(t,0).length(),r=1/di.setFromMatrixColumn(t,1).length(),s=1/di.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}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(fi,t,mi)}lookAt(t,e,n){const i=this.elements;return _i.subVectors(t,e),0===_i.lengthSq()&&(_i.z=1),_i.normalize(),gi.crossVectors(n,_i),0===gi.lengthSq()&&(1===Math.abs(n.z)?_i.x+=1e-4:_i.z+=1e-4,_i.normalize(),gi.crossVectors(n,_i)),gi.normalize(),vi.crossVectors(_i,gi),i[0]=gi.x,i[4]=vi.x,i[8]=_i.x,i[1]=gi.y,i[5]=vi.y,i[9]=_i.y,i[2]=gi.z,i[6]=vi.z,i[10]=_i.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],M=i[0],b=i[4],S=i[8],w=i[12],T=i[1],E=i[5],A=i[9],C=i[13],R=i[2],P=i[6],I=i[10],L=i[14],D=i[3],N=i[7],U=i[11],O=i[15];return r[0]=s*M+a*T+o*R+l*D,r[4]=s*b+a*E+o*P+l*N,r[8]=s*S+a*A+o*I+l*U,r[12]=s*w+a*C+o*L+l*O,r[1]=c*M+h*T+u*R+d*D,r[5]=c*b+h*E+u*P+d*N,r[9]=c*S+h*A+u*I+d*U,r[13]=c*w+h*C+u*L+d*O,r[2]=p*M+f*T+m*R+g*D,r[6]=p*b+f*E+m*P+g*N,r[10]=p*S+f*A+m*I+g*U,r[14]=p*w+f*C+m*L+g*O,r[3]=v*M+_*T+x*R+y*D,r[7]=v*b+_*E+x*P+y*N,r[11]=v*S+_*A+x*I+y*U,r[15]=v*w+_*C+x*L+y*O,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],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14],p=t[3],f=t[7],m=t[11],g=t[15],v=o*d-l*u,_=a*d-l*h,x=a*u-o*h,y=s*d-l*c,M=s*u-o*c,b=s*h-a*c;return e*(f*v-m*_+g*x)-n*(p*v-m*y+g*M)+i*(p*_-f*y+g*b)-r*(p*x-f*M+m*b)}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,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],v=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,_=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,x=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,y=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,M=e*v+n*_+i*x+r*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/M;return t[0]=v*b,t[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*b,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*b,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*b,t[4]=_*b,t[5]=(c*m*r-p*u*r+p*i*d-e*m*d-c*i*g+e*u*g)*b,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*b,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*b,t[8]=x*b,t[9]=(p*h*r-c*f*r-p*n*d+e*f*d+c*n*g-e*h*g)*b,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*b,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*b,t[12]=y*b,t[13]=(c*f*i-p*h*i+p*n*u-e*f*u-c*n*m+e*h*m)*b,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*b,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*b,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,v=o*l,_=o*c,x=o*h,y=n.x,M=n.y,b=n.z;return i[0]=(1-(f+g))*y,i[1]=(d+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(d-x)*M,i[5]=(1-(u+g))*M,i[6]=(m+v)*M,i[7]=0,i[8]=(p+_)*b,i[9]=(m-v)*b,i[10]=(1-(u+f))*b,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;if(t.x=i[12],t.y=i[13],t.z=i[14],0===this.determinant())return n.set(1,1,1),e.identity(),this;let r=di.set(i[0],i[1],i[2]).length();const s=di.set(i[4],i[5],i[6]).length(),a=di.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),pi.copy(this);const o=1/r,l=1/s,c=1/a;return pi.elements[0]*=o,pi.elements[1]*=o,pi.elements[2]*=o,pi.elements[4]*=l,pi.elements[5]*=l,pi.elements[6]*=l,pi.elements[8]*=c,pi.elements[9]*=c,pi.elements[10]*=c,e.setFromRotationMatrix(pi),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=2e3,o=!1){const l=this.elements,c=2*r/(e-t),h=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let p,f;if(o)p=r/(s-r),f=s*r/(s-r);else if(a===ze)p=-(s+r)/(s-r),f=-2*s*r/(s-r);else{if(a!==ke)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-s/(s-r),f=-s*r/(s-r)}return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=2e3,o=!1){const l=this.elements,c=2/(e-t),h=2/(n-i),u=-(e+t)/(e-t),d=-(n+i)/(n-i);let p,f;if(o)p=1/(s-r),f=s/(s-r);else if(a===ze)p=-2/(s-r),f=-(s+r)/(s-r);else{if(a!==ke)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=-1/(s-r),f=-r/(s-r)}return l[0]=c,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=h,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const di=new fn,pi=new ui,fi=new fn(0,0,0),mi=new fn(1,1,1),gi=new fn,vi=new fn,_i=new fn,xi=new ui,yi=new pn;class Mi{constructor(t=0,e=0,n=0,i=Mi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(an(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-an(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(an(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-an(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(an(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-an(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:Ke("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return xi.makeRotationFromQuaternion(t),this.setFromRotationMatrix(xi,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return yi.setFromEuler(this),this.setFromQuaternion(yi,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],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}}Mi.DEFAULT_ORDER="XYZ";class bi{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let Si=0;const wi=new fn,Ti=new pn,Ei=new ui,Ai=new fn,Ci=new fn,Ri=new fn,Pi=new pn,Ii=new fn(1,0,0),Li=new fn(0,1,0),Di=new fn(0,0,1),Ni={type:"added"},Ui={type:"removed"},Oi={type:"childadded",child:null},Fi={type:"childremoved",child:null};class Bi extends Qe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Si++}),this.uuid=sn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Bi.DEFAULT_UP.clone();const t=new fn,e=new Mi,n=new pn,i=new fn(1,1,1);e._onChange(function(){n.setFromEuler(e,!1)}),n._onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ui},normalMatrix:{value:new vn}}),this.matrix=new ui,this.matrixWorld=new ui,this.matrixAutoUpdate=Bi.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Bi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.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 Ti.setFromAxisAngle(t,e),this.quaternion.multiply(Ti),this}rotateOnWorldAxis(t,e){return Ti.setFromAxisAngle(t,e),this.quaternion.premultiply(Ti),this}rotateX(t){return this.rotateOnAxis(Ii,t)}rotateY(t){return this.rotateOnAxis(Li,t)}rotateZ(t){return this.rotateOnAxis(Di,t)}translateOnAxis(t,e){return wi.copy(t).applyQuaternion(this.quaternion),this.position.add(wi.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ii,t)}translateY(t){return this.translateOnAxis(Li,t)}translateZ(t){return this.translateOnAxis(Di,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ei.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ai.copy(t):Ai.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ci.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ei.lookAt(Ci,Ai,this.up):Ei.lookAt(Ai,Ci,this.up),this.quaternion.setFromRotationMatrix(Ei),i&&(Ei.extractRotation(i.matrixWorld),Ti.setFromRotationMatrix(Ei),this.quaternion.premultiply(Ti.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(Je("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(Ni),Oi.child=t,this.dispatchEvent(Oi),Oi.child=null):Je("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ui),Fi.child=t,this.dispatchEvent(Fi),Fi.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ei.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Ei.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ei),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Ni),Oi.child=t,this.dispatchEvent(Oi),Oi.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 n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ci,t,Ri),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ci,Pi,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 n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(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)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(t=>({...t})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),c=s(t.animations),h=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}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)),!0===e)for(let n=0;n<t.children.length;n++){const e=t.children[n];this.add(e.clone())}return this}}Bi.DEFAULT_UP=new fn(0,1,0),Bi.DEFAULT_MATRIX_AUTO_UPDATE=!0,Bi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zi=new fn,ki=new fn,Vi=new fn,Gi=new fn,Hi=new fn,Wi=new fn,ji=new fn,Xi=new fn,qi=new fn,Yi=new fn,Zi=new Dn,Ki=new Dn,Ji=new Dn;class $i{constructor(t=new fn,e=new fn,n=new fn){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),zi.subVectors(t,e),i.cross(zi);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){zi.subVectors(i,e),ki.subVectors(n,e),Vi.subVectors(t,e);const s=zi.dot(zi),a=zi.dot(ki),o=zi.dot(Vi),l=ki.dot(ki),c=ki.dot(Vi),h=s*l-a*a;if(0===h)return r.set(0,0,0),null;const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Gi)&&(Gi.x>=0&&Gi.y>=0&&Gi.x+Gi.y<=1)}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Gi)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Gi.x),o.addScaledVector(s,Gi.y),o.addScaledVector(a,Gi.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return Zi.setScalar(0),Ki.setScalar(0),Ji.setScalar(0),Zi.fromBufferAttribute(t,e),Ki.fromBufferAttribute(t,n),Ji.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(Zi,r.x),s.addScaledVector(Ki,r.y),s.addScaledVector(Ji,r.z),s}static isFrontFacing(t,e,n,i){return zi.subVectors(n,e),ki.subVectors(t,e),zi.cross(ki).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 zi.subVectors(this.c,this.b),ki.subVectors(this.a,this.b),.5*zi.cross(ki).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return $i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return $i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return $i.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return $i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return $i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Hi.subVectors(i,n),Wi.subVectors(r,n),Xi.subVectors(t,n);const o=Hi.dot(Xi),l=Wi.dot(Xi);if(o<=0&&l<=0)return e.copy(n);qi.subVectors(t,i);const c=Hi.dot(qi),h=Wi.dot(qi);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(Hi,s);Yi.subVectors(t,r);const d=Hi.dot(Yi),p=Wi.dot(Yi);if(p>=0&&d<=p)return e.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Wi,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return ji.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector(ji,a);const g=1/(m+f+u);return s=f*g,a=u*g,e.copy(n).addScaledVector(Hi,s).addScaledVector(Wi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Qi={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},tr={h:0,s:0,l:0},er={h:0,s:0,l:0};function nr(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class ir{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Se){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,bn.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=bn.workingColorSpace){return this.r=t,this.g=e,this.b=n,bn.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=bn.workingColorSpace){if(t=on(t,1),e=an(e,0,1),n=an(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=nr(r,i,t+1/3),this.g=nr(r,i,t),this.b=nr(r,i,t-1/3)}return bn.colorSpaceToWorking(this,i),this}setStyle(t,e=Se){function n(e){void 0!==e&&parseFloat(e)<1&&Ke("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Ke("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);Ke("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Se){const n=Qi[t.toLowerCase()];return void 0!==n?this.setHex(n,e):Ke("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=Sn(t.r),this.g=Sn(t.g),this.b=Sn(t.b),this}copyLinearToSRGB(t){return this.r=wn(t.r),this.g=wn(t.g),this.b=wn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Se){return bn.workingToColorSpace(rr.copy(this),t),65536*Math.round(an(255*rr.r,0,255))+256*Math.round(an(255*rr.g,0,255))+Math.round(an(255*rr.b,0,255))}getHexString(t=Se){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=bn.workingColorSpace){bn.workingToColorSpace(rr.copy(this),e);const n=rr.r,i=rr.g,r=rr.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-n)/t+2;break;case r:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=bn.workingColorSpace){return bn.workingToColorSpace(rr.copy(this),e),t.r=rr.r,t.g=rr.g,t.b=rr.b,t}getStyle(t=Se){bn.workingToColorSpace(rr.copy(this),t);const e=rr.r,n=rr.g,i=rr.b;return t!==Se?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(tr),this.setHSL(tr.h+t,tr.s+e,tr.l+n)}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,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(tr),t.getHSL(er);const n=ln(tr.h,er.h,e),i=ln(tr.s,er.s,e),r=ln(tr.l,er.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,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 rr=new ir;ir.NAMES=Qi;let sr=0;class ar extends Qe{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:sr++}),this.uuid=sn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=m,this.blendDst=g,this.blendEquation=l,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ir(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ae,this.stencilZFail=Ae,this.stencilZPass=Ae,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){Ke(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:Ke(`Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==m&&(n.blendSrc=this.blendSrc),this.blendDst!==g&&(n.blendDst=this.blendDst),this.blendEquation!==l&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ae&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ae&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ae&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class or extends ar{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ir(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Mi,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const lr=cr();function cr(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const t=l-127;t<-27?(i[l]=0,i[256|l]=32768,r[l]=24,r[256|l]=24):t<-14?(i[l]=1024>>-t-14,i[256|l]=1024>>-t-14|32768,r[l]=-t-1,r[256|l]=-t-1):t<=15?(i[l]=t+15<<10,i[256|l]=t+15<<10|32768,r[l]=13,r[256|l]=13):t<128?(i[l]=31744,i[256|l]=64512,r[l]=24,r[256|l]=24):(i[l]=31744,i[256|l]=64512,r[l]=13,r[256|l]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let t=l<<13,e=0;for(;!(8388608&t);)t<<=1,e-=8388608;t&=-8388609,e+=947912704,s[l]=t|e}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function hr(t){Math.abs(t)>65504&&Ke("DataUtils.toHalfFloat(): Value out of range."),t=an(t,-65504,65504),lr.floatView[0]=t;const e=lr.uint32View[0],n=e>>23&511;return lr.baseTable[n]+((8388607&e)>>lr.shiftTable[n])}function ur(t){const e=t>>10;return lr.uint32View[0]=lr.mantissaTable[lr.offsetTable[e]+(1023&t)]+lr.exponentTable[e],lr.floatView[0]}const dr=new fn,pr=new dn;let fr=0;class mr{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:fr++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Oe,this.updateRanges=[],this.gpuType=pt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&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,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)pr.fromBufferAttribute(this,e),pr.applyMatrix3(t),this.setXY(e,pr.x,pr.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)dr.fromBufferAttribute(this,e),dr.applyMatrix3(t),this.setXYZ(e,dr.x,dr.y,dr.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)dr.fromBufferAttribute(this,e),dr.applyMatrix4(t),this.setXYZ(e,dr.x,dr.y,dr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)dr.fromBufferAttribute(this,e),dr.applyNormalMatrix(t),this.setXYZ(e,dr.x,dr.y,dr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)dr.fromBufferAttribute(this,e),dr.transformDirection(t),this.setXYZ(e,dr.x,dr.y,dr.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=cn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=hn(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=cn(e,this.array)),e}setX(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=cn(e,this.array)),e}setY(t,e){return this.normalized&&(e=hn(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=cn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=hn(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=cn(e,this.array)),e}setW(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),i=hn(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),i=hn(i,this.array),r=hn(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,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!==Oe&&(t.usage=this.usage),t}}class gr extends mr{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class vr extends mr{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class _r extends mr{constructor(t,e,n){super(new Float32Array(t),e,n)}}let xr=0;const yr=new ui,Mr=new Bi,br=new fn,Sr=new Bn,wr=new Bn,Tr=new fn;class Er extends Qe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:xr++}),this.uuid=sn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Ve(t)?vr:gr)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}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 void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new vn).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return yr.makeRotationFromQuaternion(t),this.applyMatrix4(yr),this}rotateX(t){return yr.makeRotationX(t),this.applyMatrix4(yr),this}rotateY(t){return yr.makeRotationY(t),this.applyMatrix4(yr),this}rotateZ(t){return yr.makeRotationZ(t),this.applyMatrix4(yr),this}translate(t,e,n){return yr.makeTranslation(t,e,n),this.applyMatrix4(yr),this}scale(t,e,n){return yr.makeScale(t,e,n),this.applyMatrix4(yr),this}lookAt(t){return Mr.lookAt(t),Mr.updateMatrix(),this.applyMatrix4(Mr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(br).negate(),this.translate(br.x,br.y,br.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new _r(e,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&Ke("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Bn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return Je("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new fn(-1/0,-1/0,-1/0),new fn(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const t=e[n];Sr.setFromBufferAttribute(t),this.morphTargetsRelative?(Tr.addVectors(this.boundingBox.min,Sr.min),this.boundingBox.expandByPoint(Tr),Tr.addVectors(this.boundingBox.max,Sr.max),this.boundingBox.expandByPoint(Tr)):(this.boundingBox.expandByPoint(Sr.min),this.boundingBox.expandByPoint(Sr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Je('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ni);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return Je("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new fn,1/0);if(t){const n=this.boundingSphere.center;if(Sr.setFromBufferAttribute(t),e)for(let t=0,r=e.length;t<r;t++){const n=e[t];wr.setFromBufferAttribute(n),this.morphTargetsRelative?(Tr.addVectors(Sr.min,wr.min),Sr.expandByPoint(Tr),Tr.addVectors(Sr.max,wr.max),Sr.expandByPoint(Tr)):(Sr.expandByPoint(wr.min),Sr.expandByPoint(wr.max))}Sr.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)Tr.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(Tr));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)Tr.fromBufferAttribute(s,e),a&&(br.fromBufferAttribute(t,e),Tr.add(br)),i=Math.max(i,n.distanceToSquared(Tr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Je('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(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void Je("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new mr(new Float32Array(4*n.count),4));const s=this.getAttribute("tangent"),a=[],o=[];for(let S=0;S<n.count;S++)a[S]=new fn,o[S]=new fn;const l=new fn,c=new fn,h=new fn,u=new dn,d=new dn,p=new dn,f=new fn,m=new fn;function g(t,e,i){l.fromBufferAttribute(n,t),c.fromBufferAttribute(n,e),h.fromBufferAttribute(n,i),u.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),c.sub(l),h.sub(l),d.sub(u),p.sub(u);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(c).multiplyScalar(p.y).addScaledVector(h,-d.y).multiplyScalar(s),m.copy(h).multiplyScalar(d.x).addScaledVector(c,-p.x).multiplyScalar(s),a[t].add(f),a[e].add(f),a[i].add(f),o[t].add(m),o[e].add(m),o[i].add(m))}let v=this.groups;0===v.length&&(v=[{start:0,count:t.count}]);for(let S=0,w=v.length;S<w;++S){const e=v[S],n=e.start;for(let i=n,r=n+e.count;i<r;i+=3)g(t.getX(i+0),t.getX(i+1),t.getX(i+2))}const _=new fn,x=new fn,y=new fn,M=new fn;function b(t){y.fromBufferAttribute(i,t),M.copy(y);const e=a[t];_.copy(e),_.sub(y.multiplyScalar(y.dot(e))).normalize(),x.crossVectors(M,e);const n=x.dot(o[t])<0?-1:1;s.setXYZW(t,_.x,_.y,_.z,n)}for(let S=0,w=v.length;S<w;++S){const e=v[S],n=e.start;for(let i=n,r=n+e.count;i<r;i+=3)b(t.getX(i+0)),b(t.getX(i+1)),b(t.getX(i+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new mr(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new fn,r=new fn,s=new fn,a=new fn,o=new fn,l=new fn,c=new fn,h=new fn;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),c.subVectors(s,r),h.subVectors(i,r),c.cross(h),a.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),a.add(c),o.add(c),l.add(c),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let t=0,u=e.count;t<u;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),c.subVectors(s,r),h.subVectors(i,r),c.cross(h),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Tr.fromBufferAttribute(t,e),Tr.normalize(),t.setXYZ(e,Tr.x,Tr.y,Tr.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let a=0,o=0;for(let l=0,c=e.length;l<c;l++){a=t.isInterleavedBufferAttribute?e[l]*t.data.stride+t.offset:e[l]*i;for(let t=0;t<i;t++)s[o++]=n[a++]}return new mr(s,i,r)}if(null===this.index)return Ke("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Er,n=this.index.array,i=this.attributes;for(const a in i){const r=t(i[a],n);e.setAttribute(a,r)}const r=this.morphAttributes;for(const a in r){const i=[],s=r[a];for(let e=0,r=s.length;e<r;e++){const r=t(s[e],n);i.push(r)}e.morphAttributes[a]=i}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let a=0,o=s.length;a<o;a++){const t=s[a];e.addGroup(t.start,t.count,t.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const o in n){const e=n[o];t.data.attributes[o]=e.toJSON(t.data)}const i={};let r=!1;for(const o in this.morphAttributes){const e=this.morphAttributes[o],n=[];for(let i=0,r=e.length;i<r;i++){const r=e[i];n.push(r.toJSON(t.data))}n.length>0&&(i[o]=n,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.toJSON()),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone());const i=t.attributes;for(const l in i){const t=i[l];this.setAttribute(l,t.clone(e))}const r=t.morphAttributes;for(const l in r){const t=[],n=r[l];for(let i=0,r=n.length;i<r;i++)t.push(n[i].clone(e));this.morphAttributes[l]=t}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let l=0,c=s.length;l<c;l++){const t=s[l];this.addGroup(t.start,t.count,t.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ar=new ui,Cr=new hi,Rr=new ni,Pr=new fn,Ir=new fn,Lr=new fn,Dr=new fn,Nr=new fn,Ur=new fn,Or=new fn,Fr=new fn;class Br extends Bi{constructor(t=new Er,e=new or){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(r&&a){Ur.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=a[n],o=r[n];0!==i&&(Nr.fromBufferAttribute(o,t),s?Ur.addScaledVector(Nr,i):Ur.addScaledVector(Nr.sub(e),i))}e.add(Ur)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),Rr.copy(n.boundingSphere),Rr.applyMatrix4(r),Cr.copy(t.ray).recast(t.near),!1===Rr.containsPoint(Cr.origin)){if(null===Cr.intersectSphere(Rr,Pr))return;if(Cr.origin.distanceToSquared(Pr)>(t.far-t.near)**2)return}Ar.copy(r).invert(),Cr.copy(t.ray).applyMatrix4(Ar),null!==n.boundingBox&&!1===Cr.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,Cr)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let p=0,f=u.length;p<f;p++){const r=u[p],o=s[r.materialIndex];for(let s=Math.max(r.start,d.start),u=Math.min(a.count,Math.min(r.start+r.count,d.start+d.count));s<u;s+=3){i=zr(this,o,t,n,l,c,h,a.getX(s),a.getX(s+1),a.getX(s+2)),i&&(i.faceIndex=Math.floor(s/3),i.face.materialIndex=r.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=zr(this,s,t,n,l,c,h,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let p=0,f=u.length;p<f;p++){const r=u[p],a=s[r.materialIndex];for(let s=Math.max(r.start,d.start),u=Math.min(o.count,Math.min(r.start+r.count,d.start+d.count));s<u;s+=3){i=zr(this,a,t,n,l,c,h,s,s+1,s+2),i&&(i.faceIndex=Math.floor(s/3),i.face.materialIndex=r.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=zr(this,s,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function zr(t,e,n,i,r,s,a,o,l,c){t.getVertexPosition(o,Ir),t.getVertexPosition(l,Lr),t.getVertexPosition(c,Dr);const h=function(t,e,n,i,r,s,a,o){let l;if(l=1===e.side?i.intersectTriangle(a,s,r,!0,o):i.intersectTriangle(r,s,a,0===e.side,o),null===l)return null;Fr.copy(o),Fr.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Fr);return c<n.near||c>n.far?null:{distance:c,point:Fr.clone(),object:t}}(t,e,n,i,Ir,Lr,Dr,Or);if(h){const t=new fn;$i.getBarycoord(Or,Ir,Lr,Dr,t),r&&(h.uv=$i.getInterpolatedAttribute(r,o,l,c,t,new dn)),s&&(h.uv1=$i.getInterpolatedAttribute(s,o,l,c,t,new dn)),a&&(h.normal=$i.getInterpolatedAttribute(a,o,l,c,t,new fn),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c:c,normal:new fn,materialIndex:0};$i.getNormal(Ir,Lr,Dr,e.normal),h.face=e,h.barycoord=t}return h}class kr extends Er{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,g,v){const _=s/m,x=p/g,y=s/2,M=p/2,b=f/2,S=m+1,w=g+1;let T=0,E=0;const A=new fn;for(let a=0;a<w;a++){const s=a*x-M;for(let o=0;o<S;o++){const u=o*_-y;A[t]=u*i,A[e]=s*r,A[n]=b,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=f>0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-a/g),T+=1}}for(let a=0;a<g;a++)for(let t=0;t<m;t++){const e=u+t+S*a,n=u+t+S*(a+1),i=u+(t+1)+S*(a+1),r=u+(t+1)+S*a;o.push(e,n,r),o.push(n,i,r),E+=6}a.addGroup(d,E,v),d+=E,u+=T}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new _r(l,3)),this.setAttribute("normal",new _r(c,3)),this.setAttribute("uv",new _r(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new kr(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Vr(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Ke("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function Gr(t){const e={};for(let n=0;n<t.length;n++){const i=Vr(t[n]);for(const t in i)e[t]=i[t]}return e}function Hr(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:bn.workingColorSpace}const Wr={clone:Vr,merge:Gr};class jr extends ar{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Vr(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)!0===this.extensions[i]&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Xr extends Bi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ui,this.projectionMatrix=new ui,this.projectionMatrixInverse=new ui,this.coordinateSystem=ze,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const qr=new fn,Yr=new dn,Zr=new dn;class Kr extends Xr{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*rn*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*nn*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*rn*Math.atan(Math.tan(.5*nn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){qr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(qr.x,qr.y).multiplyScalar(-t/qr.z),qr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(qr.x,qr.y).multiplyScalar(-t/qr.z)}getViewSize(t,e){return this.getViewBounds(t,Yr,Zr),e.subVectors(Zr,Yr)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*nn*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Jr=-90;class $r extends Bi{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Kr(Jr,1,t,e);i.layers=this.layers,this.add(i);const r=new Kr(Jr,1,t,e);r.layers=this.layers,this.add(r);const s=new Kr(Jr,1,t,e);s.layers=this.layers,this.add(s);const a=new Kr(Jr,1,t,e);a.layers=this.layers,this.add(a);const o=new Kr(Jr,1,t,e);o.layers=this.layers,this.add(o);const l=new Kr(Jr,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const l of e)this.remove(l);if(t===ze)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==ke)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Qr extends Ln{constructor(t=[],e=301,n,i,r,s,a,o,l,c){super(t,e,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ts extends Un{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Qr(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new kr(5,5,5),r=new jr({name:"CubemapFromEquirect",uniforms:Vr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Br(i,r),a=e.minFilter;e.minFilter===at&&(e.minFilter=rt);return new $r(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const r=t.getRenderTarget();for(let s=0;s<6;s++)t.setRenderTarget(this,s),t.clear(e,n,i);t.setRenderTarget(r)}}class es extends Bi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ns={type:"move"};class is{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new es,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new es,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new fn,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new fn),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new es,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new fn,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new fn),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const s of t.hand.values()){const t=e.getJointPose(s,n),i=this._getHandJoint(l,s);null!==t&&(i.matrix.fromArray(t.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=t.radius),i.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(ns)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new es;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class rs{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ir(t),this.density=e}clone(){return new rs(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ss{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ir(t),this.near=e,this.far=n}clone(){return new ss(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class as extends Bi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Mi,this.environmentIntensity=1,this.environmentRotation=new Mi,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class os{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Oe,this.updateRanges=[],this.version=0,this.uuid=sn()}onUploadCallback(){}set needsUpdate(t){!0===t&&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,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=sn()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=sn()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(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 ls=new fn;class cs{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}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,n=this.data.count;e<n;e++)ls.fromBufferAttribute(this,e),ls.applyMatrix4(t),this.setXYZ(e,ls.x,ls.y,ls.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ls.fromBufferAttribute(this,e),ls.applyNormalMatrix(t),this.setXYZ(e,ls.x,ls.y,ls.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ls.fromBufferAttribute(this,e),ls.transformDirection(t),this.setXYZ(e,ls.x,ls.y,ls.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=cn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=hn(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=hn(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=hn(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=hn(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=hn(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=cn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=cn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=cn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=cn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),i=hn(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),i=hn(i,this.array),r=hn(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){Ze("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new mr(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new cs(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){Ze("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(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 hs extends ar{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ir(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let us;const ds=new fn,ps=new fn,fs=new fn,ms=new dn,gs=new dn,vs=new ui,_s=new fn,xs=new fn,ys=new fn,Ms=new dn,bs=new dn,Ss=new dn;class ws extends Bi{constructor(t=new hs){if(super(),this.isSprite=!0,this.type="Sprite",void 0===us){us=new Er;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new os(t,5);us.setIndex([0,1,2,0,2,3]),us.setAttribute("position",new cs(e,3,0,!1)),us.setAttribute("uv",new cs(e,2,3,!1))}this.geometry=us,this.material=t,this.center=new dn(.5,.5),this.count=1}raycast(t,e){null===t.camera&&Je('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ps.setFromMatrixScale(this.matrixWorld),vs.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),fs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&ps.multiplyScalar(-fs.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;Ts(_s.set(-.5,-.5,0),fs,s,ps,i,r),Ts(xs.set(.5,-.5,0),fs,s,ps,i,r),Ts(ys.set(.5,.5,0),fs,s,ps,i,r),Ms.set(0,0),bs.set(1,0),Ss.set(1,1);let a=t.ray.intersectTriangle(_s,xs,ys,!1,ds);if(null===a&&(Ts(xs.set(-.5,.5,0),fs,s,ps,i,r),bs.set(0,1),a=t.ray.intersectTriangle(_s,ys,xs,!1,ds),null===a))return;const o=t.ray.origin.distanceTo(ds);o<t.near||o>t.far||e.push({distance:o,point:ds.clone(),uv:$i.getInterpolation(ds,_s,xs,ys,Ms,bs,Ss,new dn),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Ts(t,e,n,i,r,s){ms.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(gs.x=s*ms.x-r*ms.y,gs.y=r*ms.x+s*ms.y):gs.copy(ms),t.copy(e),t.x+=gs.x,t.y+=gs.y,t.applyMatrix4(vs)}const Es=new fn,As=new fn;class Cs extends Bi{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let n=0,i=e.length;n<i;n++){const t=e[n];this.addLevel(t.object.clone(),t.distance,t.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){const t=e.splice(n,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let i=e[n].distance;if(e[n].object.visible&&(i-=i*e[n].hysteresis),t<i)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Es.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(Es);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Es.setFromMatrixPosition(t.matrixWorld),As.setFromMatrixPosition(this.matrixWorld);const n=Es.distanceTo(As)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i<r;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(n>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let i=0,r=n.length;i<r;i++){const t=n[i];e.object.levels.push({object:t.object.uuid,distance:t.distance,hysteresis:t.hysteresis})}return e}}const Rs=new fn,Ps=new Dn,Is=new Dn,Ls=new fn,Ds=new ui,Ns=new fn,Us=new ni,Os=new ui,Fs=new hi;class Bs extends Br{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=W,this.bindMatrix=new ui,this.bindMatrixInverse=new ui,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Bn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Ns),this.boundingBox.expandByPoint(Ns)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new ni),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Ns),this.boundingSphere.expandByPoint(Ns)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),Us.copy(this.boundingSphere),Us.applyMatrix4(i),!1!==t.ray.intersectsSphere(Us)&&(Os.copy(i).invert(),Fs.copy(t.ray).applyMatrix4(Os),null!==this.boundingBox&&!1===Fs.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,Fs)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Dn,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===W?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===j?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ke("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Ps.fromBufferAttribute(i.attributes.skinIndex,t),Is.fromBufferAttribute(i.attributes.skinWeight,t),Rs.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){const t=Is.getComponent(r);if(0!==t){const i=Ps.getComponent(r);Ds.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),e.addScaledVector(Ls.copy(Rs).applyMatrix4(Ds),t)}}return e.applyMatrix4(this.bindMatrixInverse)}}class zs extends Bi{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ks extends Ln{constructor(t=null,e=1,n=1,i,r,s,a,o,l=1003,c=1003,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Vs=new ui,Gs=new ui;class Hs{constructor(t=[],e=[]){this.uuid=sn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){Ke("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new ui)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new ui;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=t.length;r<s;r++){const i=t[r]?t[r].matrixWorld:Gs;Vs.multiplyMatrices(i,e[r]),Vs.toArray(n,16*r)}null!==i&&(i.needsUpdate=!0)}clone(){return new Hs(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new ks(e,t,t,bt,pt);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(Ke("Skeleton: No bone found with UUID:",i),r=new zs),this.bones.push(r),this.boneInverses.push((new ui).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const s=n[i];t.boneInverses.push(s.toArray())}return t}}class Ws extends mr{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const js=new ui,Xs=new ui,qs=[],Ys=new Bn,Zs=new ui,Ks=new Br,Js=new ni;class $s extends Br{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Ws(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Zs)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Bn),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,js),Ys.copy(t.boundingBox).applyMatrix4(js),this.boundingBox.union(Ys)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new ni),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,js),Js.copy(t.boundingSphere).applyMatrix4(js),this.boundingSphere.union(Js)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let s=0;s<n.length;s++)n[s]=i[r+s]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Ks.geometry=this.geometry,Ks.material=this.material,void 0!==Ks.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Js.copy(this.boundingSphere),Js.applyMatrix4(n),!1!==t.ray.intersectsSphere(Js)))for(let r=0;r<i;r++){this.getMatrixAt(r,js),Xs.multiplyMatrices(n,js),Ks.matrixWorld=Xs,Ks.raycast(t,qs);for(let t=0,n=qs.length;t<n;t++){const n=qs[t];n.instanceId=r,n.object=this,e.push(n)}qs.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Ws(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new ks(new Float32Array(i*this.count),i,this.count,Tt,pt));const r=this.morphTexture.source.data.data;let s=0;for(let l=0;l<n.length;l++)s+=n[l];const a=this.geometry.morphTargetsRelative?1:1-s,o=i*t;r[o]=a,r.set(n,o+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Qs=new fn,ta=new fn,ea=new vn;class na{constructor(t=new fn(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,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Qs.subVectors(n,e).cross(ta.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 n=t.delta(Qs),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<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 n=e||ea.getNormalMatrix(t),i=this.coplanarPoint(Qs).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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)}}const ia=new ni,ra=new dn(.5,.5),sa=new fn;class aa{constructor(t=new na,e=new na,n=new na,i=new na,r=new na,s=new na){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3,n=!1){const i=this.planes,r=t.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],h=r[5],u=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],_=r[13],x=r[14],y=r[15];if(i[0].setComponents(l-s,d-c,g-p,y-v).normalize(),i[1].setComponents(l+s,d+c,g+p,y+v).normalize(),i[2].setComponents(l+a,d+h,g+f,y+_).normalize(),i[3].setComponents(l-a,d-h,g-f,y-_).normalize(),n)i[4].setComponents(o,u,m,x).normalize(),i[5].setComponents(l-o,d-u,g-m,y-x).normalize();else if(i[4].setComponents(l-o,d-u,g-m,y-x).normalize(),e===ze)i[5].setComponents(l+o,d+u,g+m,y+x).normalize();else{if(e!==ke)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(o,u,m,x).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),ia.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),ia.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ia)}intersectsSprite(t){ia.center.set(0,0,0);const e=ra.distanceTo(t.center);return ia.radius=.7071067811865476+e,ia.applyMatrix4(t.matrixWorld),this.intersectsSphere(ia)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++){if(e[r].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(sa.x=i.normal.x>0?t.max.x:t.min.x,sa.y=i.normal.y>0?t.max.y:t.min.y,sa.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(sa)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const oa=new ui,la=new aa;class ca{constructor(){this.coordinateSystem=ze}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(oa.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),la.setFromProjectionMatrix(oa,i.coordinateSystem,i.reversedDepth),la.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(oa.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),la.setFromProjectionMatrix(oa,i.coordinateSystem,i.reversedDepth),la.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(oa.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),la.setFromProjectionMatrix(oa,i.coordinateSystem,i.reversedDepth),la.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(oa.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),la.setFromProjectionMatrix(oa,i.coordinateSystem,i.reversedDepth),la.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let n=0;n<e.cameras.length;n++){const i=e.cameras[n];if(oa.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),la.setFromProjectionMatrix(oa,i.coordinateSystem,i.reversedDepth),la.containsPoint(t))return!0}return!1}clone(){return new ca}}function ha(t,e){return t-e}function ua(t,e){return t.z-e.z}function da(t,e){return e.z-t.z}class pa{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const fa=new ui,ma=new ir(1,1,1),ga=new aa,va=new ca,_a=new Bn,xa=new ni,ya=new fn,Ma=new fn,ba=new fn,Sa=new pa,wa=new Br,Ta=[];function Ea(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s<r;s++)for(let r=0;r<i;r++)e.setComponent(s+n,r,t.getComponent(s,r))}else e.array.set(t.array,n*i);e.needsUpdate=!0}function Aa(t,e){if(t.constructor!==e.constructor){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++)e[i]=t[i]}else{const n=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,n))}}class Ca extends Br{constructor(t,e,n=2*e,i){super(new Er,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new ks(e,t,t,bt,pt);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),n=new ks(e,t,t,Et,dt);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new ks(e,t,t,bt,pt);n.colorSpace=bn.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const r=t.getAttribute(i),{array:s,itemSize:a,normalized:o}=r,l=new s.constructor(n*a),c=new mr(l,a,o);e.setAttribute(i,c)}if(null!==t.getIndex()){const t=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new mr(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Bn);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,fa),this.getBoundingBoxAt(i,_a).applyMatrix4(fa),t.union(_a)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new ni);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(!1===e[n].active)continue;const i=e[n].geometryIndex;this.getMatrixAt(n,fa),this.getBoundingSphereAt(i,xa).applyMatrix4(fa),t.union(xa)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ha),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;fa.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(ma.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const s=t.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?s.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ha),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=e.getIndex(),a=this._geometryInfo[t];if(i&&s.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const c in n.attributes){const t=e.getAttribute(c),i=n.getAttribute(c);Ea(t,i,o);const r=t.itemSize;for(let e=t.count,n=l;e<n;e++){const t=o+e;for(let e=0;e<r;e++)i.setComponent(t,e,0)}i.needsUpdate=!0,i.addUpdateRange(o*r,l*r)}if(i){const t=a.indexStart,n=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let e=0;e<s.count;e++)r.setX(t+e,o+s.getX(e));for(let e=s.count,i=n;e<i;e++)r.setX(t+e,o);r.needsUpdate=!0,r.addUpdateRange(t,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,null!==e.boundingBox&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,null!==e.boundingSphere&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let i=0,r=n.length;i<r;i++)n[i].active&&n[i].geometryIndex===t&&this.deleteInstance(i);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const n=this._geometryInfo,i=n.map((t,e)=>e).sort((t,e)=>n[t].vertexStart-n[e].vertexStart),r=this.geometry;for(let s=0,a=n.length;s<a;s++){const a=i[s],o=n[a];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==e){const{indexStart:n,vertexStart:i,reservedIndexCount:s}=o,a=r.index,l=a.array,c=t-i;for(let t=n;t<n+s;t++)l[t]=l[t]+c;a.array.copyWithin(e,n,n+s),a.addUpdateRange(e,s),a.needsUpdate=!0,o.indexStart=e}e+=o.reservedIndexCount}if(o.vertexStart!==t){const{vertexStart:e,reservedVertexCount:n}=o,i=r.attributes;for(const r in i){const s=i[r],{array:a,itemSize:o}=s;a.copyWithin(t*o,e*o,(e+n)*o),s.addUpdateRange(t*o,n*o),s.needsUpdate=!0}o.vertexStart=t}t+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart,this._nextIndexStart=r.index?o.indexStart+o.reservedIndexCount:0,this._nextVertexStart=o.vertexStart+o.reservedVertexCount}}return this._visibilityChanged=!0,this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Bn,e=n.index,r=n.attributes.position;for(let n=i.start,s=i.start+i.count;n<s;n++){let i=n;e&&(i=e.getX(i)),t.expandByPoint(ya.fromBufferAttribute(r,i))}i.boundingBox=t}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new ni;this.getBoundingBoxAt(t,_a),_a.getCenter(e.center);const r=n.index,s=n.attributes.position;let a=0;for(let t=i.start,n=i.start+i.count;t<n;t++){let n=t;r&&(n=r.getX(n)),ya.fromBufferAttribute(s,n),a=Math.max(a,e.center.distanceToSquared(ya))}e.radius=Math.sqrt(a),i.boundingSphere=e}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,16*t),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,16*t)}setColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,4*t),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,4*t)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e||(this._instanceInfo[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){const e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(ha);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),r=new Int32Array(t);Aa(this._multiDrawCounts,i),Aa(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;const s=this._indirectTexture,a=this._matricesTexture,o=this._colorsTexture;s.dispose(),this._initIndirectTexture(),Aa(s.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),Aa(a.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),Aa(o.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const n=[...this._geometryInfo].filter(t=>t.active);if(Math.max(...n.map(t=>t.vertexStart+t.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...n.map(t=>t.indexStart+t.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`)}const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Er,this._initializeGeometry(i));const r=this.geometry;i.index&&Aa(i.index.array,r.index.array);for(const s in i.attributes)Aa(i.attributes[s].array,r.attributes[s].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,s=this.geometry;wa.material=this.material,wa.geometry.index=s.index,wa.geometry.attributes=s.attributes,null===wa.geometry.boundingBox&&(wa.geometry.boundingBox=new Bn),null===wa.geometry.boundingSphere&&(wa.geometry.boundingSphere=new ni);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;const s=n[a].geometryIndex,o=i[s];wa.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(a,wa.matrixWorld).premultiply(r),this.getBoundingBoxAt(s,wa.geometry.boundingBox),this.getBoundingSphereAt(s,wa.geometry.boundingSphere),wa.raycast(t,Ta);for(let t=0,n=Ta.length;t<n;t++){const n=Ta[t];n.object=this,n.batchId=a,e.push(n)}Ta.length=0}wa.material=null,wa.geometry.index=null,wa.geometry.attributes={},wa.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(t=>({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(t=>({...t})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,h=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,f=n.isArrayCamera?va:ga;u&&!n.isArrayCamera&&(fa.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ga.setFromProjectionMatrix(fa,n.coordinateSystem,n.reversedDepth));let m=0;if(this.sortObjects){fa.copy(this.matrixWorld).invert(),ya.setFromMatrixPosition(n.matrixWorld).applyMatrix4(fa),Ma.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(fa);for(let i=0,r=o.length;i<r;i++)if(o[i].visible&&o[i].active){const t=o[i].geometryIndex;this.getMatrixAt(i,fa),this.getBoundingSphereAt(t,xa).applyMatrix4(fa);let e=!1;if(u&&(e=!f.intersectsSphere(xa,n)),!e){const e=h[t],n=ba.subVectors(xa.center,ya).dot(Ma);Sa.push(e.start,e.count,n,i)}}const t=Sa.list,e=this.customSort;null===e?t.sort(r.transparent?da:ua):e.call(this,t,n);for(let n=0,i=t.length;n<i;n++){const e=t[n];l[m]=e.start*a,c[m]=e.count,p[m]=e.index,m++}Sa.reset()}else for(let g=0,v=o.length;g<v;g++)if(o[g].visible&&o[g].active){const t=o[g].geometryIndex;let e=!1;if(u&&(this.getMatrixAt(g,fa),this.getBoundingSphereAt(t,xa).applyMatrix4(fa),e=!f.intersectsSphere(xa,n)),!e){const e=h[t];l[m]=e.start*a,c[m]=e.count,p[m]=g,m++}}d.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,s){this.onBeforeRender(t,null,i,r,s)}}class Ra extends ar{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ir(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Pa=new fn,Ia=new fn,La=new ui,Da=new hi,Na=new ni,Ua=new fn,Oa=new fn;class Fa extends Bi{constructor(t=new Er,e=new Ra){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)Pa.fromBufferAttribute(e,t-1),Ia.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Pa.distanceTo(Ia);t.setAttribute("lineDistance",new _r(n,1))}else Ke("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Na.copy(n.boundingSphere),Na.applyMatrix4(i),Na.radius+=r,!1===t.ray.intersectsSphere(Na))return;La.copy(i).invert(),Da.copy(t.ray).applyMatrix4(La);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,c=n.index,h=n.attributes.position;if(null!==c){const n=Math.max(0,s.start),i=Math.min(c.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=c.getX(r),i=c.getX(r+1),s=Ba(this,t,Da,o,n,i,r);s&&e.push(s)}if(this.isLineLoop){const r=c.getX(i-1),s=c.getX(n),a=Ba(this,t,Da,o,r,s,i-1);a&&e.push(a)}}else{const n=Math.max(0,s.start),i=Math.min(h.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=Ba(this,t,Da,o,r,r+1,r);n&&e.push(n)}if(this.isLineLoop){const r=Ba(this,t,Da,o,i-1,n,i-1);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Ba(t,e,n,i,r,s,a){const o=t.geometry.attributes.position;Pa.fromBufferAttribute(o,r),Ia.fromBufferAttribute(o,s);if(n.distanceSqToSegment(Pa,Ia,Ua,Oa)>i)return;Ua.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(Ua);return l<e.near||l>e.far?void 0:{distance:l,point:Oa.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const za=new fn,ka=new fn;class Va extends Fa{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)za.fromBufferAttribute(e,t),ka.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+za.distanceTo(ka);t.setAttribute("lineDistance",new _r(n,1))}else Ke("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ga extends Fa{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Ha extends ar{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ir(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Wa=new ui,ja=new hi,Xa=new ni,qa=new fn;class Ya extends Bi{constructor(t=new Er,e=new Ha){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Xa.copy(n.boundingSphere),Xa.applyMatrix4(i),Xa.radius+=r,!1===t.ray.intersectsSphere(Xa))return;Wa.copy(i).invert(),ja.copy(t.ray).applyMatrix4(Wa);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);n<r;n++){const r=l.getX(n);qa.fromBufferAttribute(c,r),Za(qa,r,o,i,t,e,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(c.count,s.start+s.count);n<r;n++)qa.fromBufferAttribute(c,n),Za(qa,n,o,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Za(t,e,n,i,r,s,a){const o=ja.distanceSqToPoint(t);if(o<n){const n=new fn;ja.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Ka extends Ln{constructor(t,e,n,i,r=1006,s=1006,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const c=this;"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(function e(){c.needsUpdate=!0,c._requestVideoFrameCallbackId=t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class Ja extends Ln{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class $a extends Ln{constructor(t,e,n=1014,i,r,s,a=1003,o=1003,l,c=1026,h=1){if(c!==St&&c!==wt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:h},i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Cn(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class Qa extends $a{constructor(t,e=1014,n=301,i,r,s=1003,a=1003,o,l=1026){const c={width:t,height:t,depth:1},h=[c,c,c,c,c,c];super(t,t,e,n,i,r,s,a,o,l),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class to extends Ln{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class eo extends Er{constructor(t=1,e=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:r},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));const s=[],a=[],o=[],l=[],c=e/2,h=Math.PI/2*t,u=e,d=2*h+u,p=2*n+r,f=i+1,m=new fn,g=new fn;for(let v=0;v<=p;v++){let _=0,x=0,y=0,M=0;if(v<=n){const e=v/n,i=e*Math.PI/2;x=-c-t*Math.cos(i),y=t*Math.sin(i),M=-t*Math.cos(i),_=e*h}else if(v<=n+r){const i=(v-n)/r;x=i*e-c,y=t,M=0,_=h+i*u}else{const e=(v-n-r)/n,i=e*Math.PI/2;x=c+t*Math.sin(i),y=t*Math.cos(i),M=t*Math.sin(i),_=h+u+e*h}const b=Math.max(0,Math.min(1,_/d));let S=0;0===v?S=.5/i:v===p&&(S=-.5/i);for(let t=0;t<=i;t++){const e=t/i,n=e*Math.PI*2,r=Math.sin(n),s=Math.cos(n);g.x=-y*s,g.y=x,g.z=y*r,a.push(g.x,g.y,g.z),m.set(-y*s,M,y*r),m.normalize(),o.push(m.x,m.y,m.z),l.push(e+S,b)}if(v>0){const t=(v-1)*f;for(let e=0;e<i;e++){const n=t+e,i=t+e+1,r=v*f+e,a=v*f+e+1;s.push(n,i,r),s.push(i,a,r)}}}this.setIndex(s),this.setAttribute("position",new _r(a,3)),this.setAttribute("normal",new _r(o,3)),this.setAttribute("uv",new _r(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new eo(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class no extends Er{constructor(t=1,e=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],s=[],a=[],o=[],l=new fn,c=new dn;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let h=0,u=3;h<=e;h++,u+=3){const r=n+h/e*i;l.x=t*Math.cos(r),l.y=t*Math.sin(r),s.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(s[u]/t+1)/2,c.y=(s[u+1]/t+1)/2,o.push(c.x,c.y)}for(let h=1;h<=e;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new _r(s,3)),this.setAttribute("normal",new _r(a,3)),this.setAttribute("uv",new _r(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new no(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class io extends Er{constructor(t=1,e=1,n=1,i=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],h=[],u=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const r=p,s=new dn,f=new fn;let v=0;const _=!0===n?t:e,x=!0===n?1:-1;for(let t=1;t<=i;t++)h.push(0,m*x,0),u.push(0,x,0),d.push(.5,.5),p++;const y=p;for(let t=0;t<=i;t++){const e=t/i*o+a,n=Math.cos(e),r=Math.sin(e);f.x=_*r,f.y=m*x,f.z=_*n,h.push(f.x,f.y,f.z),u.push(0,x,0),s.x=.5*n+.5,s.y=.5*r*x+.5,d.push(s.x,s.y),p++}for(let t=0;t<i;t++){const e=r+t,i=y+t;!0===n?c.push(i,i+1,e):c.push(i+1,i,e),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const s=new fn,v=new fn;let _=0;const x=(e-t)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,_=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+a,l=Math.sin(r),f=Math.cos(r);v.x=_*l,v.y=-g*n+m,v.z=_*f,h.push(v.x,v.y,v.z),s.set(l,x,f).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-g),c.push(p++)}f.push(c)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const s=f[i][n],a=f[i+1][n],o=f[i+1][n+1],l=f[i][n+1];(t>0||0!==i)&&(c.push(s,a,l),_+=3),(e>0||i!==r-1)&&(c.push(a,o,l),_+=3)}l.addGroup(g,_,0),g+=_}(),!1===s&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new _r(h,3)),this.setAttribute("normal",new _r(u,3)),this.setAttribute("uv",new _r(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new io(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ro extends io{constructor(t=1,e=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new ro(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class so extends Er{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let a=0;a<=r;a++){s[a]=[];const i=t.clone().lerp(n,a/r),o=e.clone().lerp(n,a/r),l=r-a;for(let t=0;t<=l;t++)s[a][t]=0===t&&a===r?i:i.clone().lerp(o,t/l)}for(let a=0;a<r;a++)for(let t=0;t<2*(r-a)-1;t++){const e=Math.floor(t/2);t%2==0?(o(s[a][e+1]),o(s[a+1][e]),o(s[a][e])):(o(s[a][e+1]),o(s[a+1][e+1]),o(s[a+1][e]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function c(t,e,n,i){i<0&&1===t.x&&(s[e]=t.x-1),0===n.x&&0===n.z&&(s[e]=i/2/Math.PI+.5)}function h(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const n=new fn,i=new fn,r=new fn;for(let s=0;s<e.length;s+=3)l(e[s+0],n),l(e[s+1],i),l(e[s+2],r),a(n,i,r,t)}(i),function(t){const e=new fn;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new fn;for(let e=0;e<r.length;e+=3){t.x=r[e+0],t.y=r[e+1],t.z=r[e+2];const n=h(t)/2/Math.PI+.5,i=u(t)/Math.PI+.5;s.push(n,1-i)}(function(){const t=new fn,e=new fn,n=new fn,i=new fn,a=new dn,o=new dn,l=new dn;for(let u=0,d=0;u<r.length;u+=9,d+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),n.set(r[u+6],r[u+7],r[u+8]),a.set(s[d+0],s[d+1]),o.set(s[d+2],s[d+3]),l.set(s[d+4],s[d+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=h(i);c(a,d+0,t,p),c(o,d+2,e,p),c(l,d+4,n,p)}})(),function(){for(let t=0;t<s.length;t+=6){const e=s[t+0],n=s[t+2],i=s[t+4],r=Math.max(e,n,i),a=Math.min(e,n,i);r>.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new _r(r,3)),this.setAttribute("normal",new _r(r.slice(),3)),this.setAttribute("uv",new _r(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new so(t.vertices,t.indices,t.radius,t.detail)}}class ao extends so{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ao(t.radius,t.detail)}}const oo=new fn,lo=new fn,co=new fn,ho=new $i;class uo extends Er{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(nn*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t<o;t+=3){s?(l[0]=s.getX(t),l[1]=s.getX(t+1),l[2]=s.getX(t+2)):(l[0]=t,l[1]=t+1,l[2]=t+2);const{a:e,b:n,c:o}=ho;if(e.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),o.fromBufferAttribute(a,l[2]),ho.getNormal(co),h[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,h[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,h[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let t=0;t<3;t++){const e=(t+1)%3,n=h[t],i=h[e],s=ho[c[t]],a=ho[c[e]],o=`${n}_${i}`,p=`${i}_${n}`;p in u&&u[p]?(co.dot(u[p].normal)<=r&&(d.push(s.x,s.y,s.z),d.push(a.x,a.y,a.z)),u[p]=null):o in u||(u[o]={index0:l[t],index1:l[e],normal:co.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:n}=u[t];oo.fromBufferAttribute(a,e),lo.fromBufferAttribute(a,n),d.push(oo.x,oo.y,oo.z),d.push(lo.x,lo.y,lo.z)}this.setAttribute("position",new _r(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class po{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ke("Curve: .getPoint() not implemented.")}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=e||(s.isVector2?new dn:new fn);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){const n=new fn,i=[],r=[],s=[],a=new fn,o=new ui;for(let d=0;d<=t;d++){const e=d/t;i[d]=this.getTangentAt(e,new fn)}r[0]=new fn,s[0]=new fn;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let d=1;d<=t;d++){if(r[d]=r[d-1].clone(),s[d]=s[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(an(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(o.makeRotationAxis(a,t))}s[d].crossVectors(i[d],r[d])}if(!0===e){let e=Math.acos(an(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class fo extends po{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new dn){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=s?0:i),!0!==this.aClockwise||s||(r===i?r=-i:r-=i);const a=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*t-i*e+this.aX,l=n*e+i*t+this.aY}return n.set(o,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class mo extends fo{constructor(t,e,n,i,r,s){super(t,e,n,n,i,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function go(){let t=0,e=0,n=0,i=0;function r(r,s,a,o){t=r,e=a,n=-3*r+3*s-2*a-o,i=2*r-2*s+a+o}return{initCatmullRom:function(t,e,n,i,s){r(e,n,s*(n-t),s*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,s,a,o){let l=(e-t)/s-(n-t)/(s+a)+(n-e)/a,c=(n-e)/a-(i-e)/(a+o)+(i-n)/o;l*=a,c*=a,r(e,n,l,c)},calc:function(r){const s=r*r;return t+e*r+n*s+i*(s*r)}}}const vo=new fn,_o=new go,xo=new go,yo=new go;class Mo extends po{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new fn){const n=e,i=this.points,r=i.length,s=(r-(this.closed?0:1))*t;let a,o,l=Math.floor(s),c=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(vo.subVectors(i[0],i[1]).add(i[0]),a=vo);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2<r?o=i[(l+2)%r]:(vo.subVectors(i[r-1],i[r-2]).add(i[r-1]),o=vo),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(h),t),n=Math.pow(h.distanceToSquared(u),t),i=Math.pow(u.distanceToSquared(o),t);n<1e-4&&(n=1),e<1e-4&&(e=n),i<1e-4&&(i=n),_o.initNonuniformCatmullRom(a.x,h.x,u.x,o.x,e,n,i),xo.initNonuniformCatmullRom(a.y,h.y,u.y,o.y,e,n,i),yo.initNonuniformCatmullRom(a.z,h.z,u.z,o.z,e,n,i)}else"catmullrom"===this.curveType&&(_o.initCatmullRom(a.x,h.x,u.x,o.x,this.tension),xo.initCatmullRom(a.y,h.y,u.y,o.y,this.tension),yo.initCatmullRom(a.z,h.z,u.z,o.z,this.tension));return n.set(_o.calc(c),xo.calc(c),yo.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new fn).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function bo(t,e,n,i,r){const s=.5*(i-e),a=.5*(r-n),o=t*t;return(2*n-2*i+s+a)*(t*o)+(-3*n+3*i-2*s-a)*o+s*t+n}function So(t,e,n,i){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function wo(t,e,n,i,r){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}class To extends po{constructor(t=new dn,e=new dn,n=new dn,i=new dn){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new dn){const n=e,i=this.v0,r=this.v1,s=this.v2,a=this.v3;return n.set(wo(t,i.x,r.x,s.x,a.x),wo(t,i.y,r.y,s.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Eo extends po{constructor(t=new fn,e=new fn,n=new fn,i=new fn){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new fn){const n=e,i=this.v0,r=this.v1,s=this.v2,a=this.v3;return n.set(wo(t,i.x,r.x,s.x,a.x),wo(t,i.y,r.y,s.y,a.y),wo(t,i.z,r.z,s.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Ao extends po{constructor(t=new dn,e=new dn){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new dn){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new dn){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Co extends po{constructor(t=new fn,e=new fn){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new fn){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new fn){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Ro extends po{constructor(t=new dn,e=new dn,n=new dn){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new dn){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(So(t,i.x,r.x,s.x),So(t,i.y,r.y,s.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Po extends po{constructor(t=new fn,e=new fn,n=new fn){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new fn){const n=e,i=this.v0,r=this.v1,s=this.v2;return n.set(So(t,i.x,r.x,s.x),So(t,i.y,r.y,s.y),So(t,i.z,r.z,s.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Io extends po{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new dn){const n=e,i=this.points,r=(i.length-1)*t,s=Math.floor(r),a=r-s,o=i[0===s?s:s-1],l=i[s],c=i[s>i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(bo(a,o.x,l.x,c.x,h.x),bo(a,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new dn).fromArray(n))}return this}}var Lo=Object.freeze({__proto__:null,ArcCurve:mo,CatmullRomCurve3:Mo,CubicBezierCurve:To,CubicBezierCurve3:Eo,EllipseCurve:fo,LineCurve:Ao,LineCurve3:Co,QuadraticBezierCurve:Ro,QuadraticBezierCurve3:Po,SplineCurve:Io});class Do extends po{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Lo[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const t=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const s=r[i],a=s.isEllipseCurve?2*t:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?t*s.points.length:t,o=s.getPoints(a);for(let t=0;t<o.length;t++){const i=o[t];n&&n.equals(i)||(e.push(i),n=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new Lo[n.type]).fromJSON(n))}return this}}class No extends Do{constructor(t){super(),this.type="Path",this.currentPoint=new dn,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Ao(this.currentPoint.clone(),new dn(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const r=new Ro(this.currentPoint.clone(),new dn(t,e),new dn(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,s){const a=new To(this.currentPoint.clone(),new dn(t,e),new dn(n,i),new dn(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new Io(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,n,i,r,s),this}absarc(t,e,n,i,r,s){return this.absellipse(t,e,n,n,i,r,s),this}ellipse(t,e,n,i,r,s,a,o){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+l,e+c,n,i,r,s,a,o),this}absellipse(t,e,n,i,r,s,a,o){const l=new fo(t,e,n,i,r,s,a,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Uo extends No{constructor(t){super(t),this.uuid=sn(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new No).fromJSON(n))}return this}}function Oo(t,e,n=2){const i=e&&e.length,r=i?e[0]*n:t.length;let s=Fo(t,0,r,n,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c;if(i&&(s=function(t,e,n,i){const r=[];for(let s=0,a=e.length;s<a;s++){const n=Fo(t,e[s]*i,s<a-1?e[s+1]*i:t.length,i,!1);n===n.next&&(n.steiner=!0),r.push(Yo(n))}r.sort(Wo);for(let s=0;s<r.length;s++)n=jo(r[s],n);return n}(t,e,s,n)),t.length>80*n){o=t[0],l=t[1];let e=o,i=l;for(let s=n;s<r;s+=n){const n=t[s],r=t[s+1];n<o&&(o=n),r<l&&(l=r),n>e&&(e=n),r>i&&(i=r)}c=Math.max(e-o,i-l),c=0!==c?32767/c:0}return zo(s,a,n,o,l,c,0),a}function Fo(t,e,n,i,r){let s;if(r===function(t,e,n,i){let r=0;for(let s=e,a=n-i;s<n;s+=i)r+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return r}(t,e,n,i)>0)for(let a=e;a<n;a+=i)s=sl(a/i|0,t[a],t[a+1],s);else for(let a=n-i;a>=e;a-=i)s=sl(a/i|0,t[a],t[a+1],s);return s&&Qo(s,s.next)&&(al(s),s=s.next),s}function Bo(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!Qo(i,i.next)&&0!==$o(i.prev,i,i.next))i=i.next;else{if(al(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function zo(t,e,n,i,r,s,a){if(!t)return;!a&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=qo(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n=1;do{let i,r=t;t=null;let s=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t<n&&(o++,a=a.nextZ,a);t++);let l=n;for(;o>0||l>0&&a;)0!==o&&(0===l||!a||r.z<=a.z)?(i=r,r=r.nextZ,o--):(i=a,a=a.nextZ,l--),s?s.nextZ=i:t=i,i.prevZ=s,s=i;r=a}s.nextZ=null,n*=2}while(e>1)}(r)}(t,i,r,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(s?Vo(t,i,r,s):ko(t))e.push(l.i,t.i,c.i),al(t),t=c.next,o=c.next;else if((t=c)===o){a?1===a?zo(t=Go(Bo(t),e),e,n,i,r,s,2):2===a&&Ho(t,e,n,i,r,s):zo(Bo(t),e,n,i,r,s,1);break}}}function ko(t){const e=t.prev,n=t,i=t.next;if($o(e,n,i)>=0)return!1;const r=e.x,s=n.x,a=i.x,o=e.y,l=n.y,c=i.y,h=Math.min(r,s,a),u=Math.min(o,l,c),d=Math.max(r,s,a),p=Math.max(o,l,c);let f=i.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Ko(r,o,s,l,a,c,f.x,f.y)&&$o(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Vo(t,e,n,i){const r=t.prev,s=t,a=t.next;if($o(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=Math.min(o,l,c),f=Math.min(h,u,d),m=Math.max(o,l,c),g=Math.max(h,u,d),v=qo(p,f,e,n,i),_=qo(m,g,e,n,i);let x=t.prevZ,y=t.nextZ;for(;x&&x.z>=v&&y&&y.z<=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Ko(o,h,l,u,c,d,x.x,x.y)&&$o(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Ko(o,h,l,u,c,d,y.x,y.y)&&$o(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&Ko(o,h,l,u,c,d,x.x,x.y)&&$o(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&Ko(o,h,l,u,c,d,y.x,y.y)&&$o(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Go(t,e){let n=t;do{const i=n.prev,r=n.next.next;!Qo(i,r)&&tl(i,n,n.next,r)&&il(i,r)&&il(r,i)&&(e.push(i.i,n.i,r.i),al(n),al(n.next),n=t=r),n=n.next}while(n!==t);return Bo(n)}function Ho(t,e,n,i,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Jo(a,t)){let o=rl(a,t);return a=Bo(a,a.next),o=Bo(o,o.next),zo(a,e,n,i,r,s,0),void zo(o,e,n,i,r,s,0)}t=t.next}a=a.next}while(a!==t)}function Wo(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function jo(t,e){const n=function(t,e){let n=e;const i=t.x,r=t.y;let s,a=-1/0;if(Qo(t,n))return n;do{if(Qo(t,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const t=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=i&&t>a&&(a=t,s=n.x<n.next.x?n:n.next,t===i))return s}n=n.next}while(n!==e);if(!s)return null;const o=s,l=s.x,c=s.y;let h=1/0;n=s;do{if(i>=n.x&&n.x>=l&&i!==n.x&&Zo(r<c?i:a,r,l,c,r<c?a:i,r,n.x,n.y)){const e=Math.abs(r-n.y)/(i-n.x);il(n,t)&&(e<h||e===h&&(n.x>s.x||n.x===s.x&&Xo(s,n)))&&(s=n,h=e)}n=n.next}while(n!==o);return s}(t,e);if(!n)return e;const i=rl(n,t);return Bo(i,i.next),Bo(n,n.next)}function Xo(t,e){return $o(t.prev,t,e.prev)<0&&$o(e.next,t,t.next)<0}function qo(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yo(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Zo(t,e,n,i,r,s,a,o){return(r-a)*(e-o)>=(t-a)*(s-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function Ko(t,e,n,i,r,s,a,o){return!(t===a&&e===o)&&Zo(t,e,n,i,r,s,a,o)}function Jo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&tl(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(il(t,e)&&il(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&($o(t.prev,t,e.prev)||$o(t,e.prev,e))||Qo(t,e)&&$o(t.prev,t,t.next)>0&&$o(e.prev,e,e.next)>0)}function $o(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Qo(t,e){return t.x===e.x&&t.y===e.y}function tl(t,e,n,i){const r=nl($o(t,e,n)),s=nl($o(t,e,i)),a=nl($o(n,i,t)),o=nl($o(n,i,e));return r!==s&&a!==o||(!(0!==r||!el(t,n,e))||(!(0!==s||!el(t,i,e))||(!(0!==a||!el(n,t,i))||!(0!==o||!el(n,e,i)))))}function el(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function nl(t){return t>0?1:t<0?-1:0}function il(t,e){return $o(t.prev,t,t.next)<0?$o(t,e,t.next)>=0&&$o(t,t.prev,e)>=0:$o(t,e,t.prev)<0||$o(t,t.next,e)<0}function rl(t,e){const n=ol(t.i,t.x,t.y),i=ol(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function sl(t,e,n,i){const r=ol(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function al(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ol(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ll{static triangulate(t,e,n=2){return Oo(t,e,n)}}class cl{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n}static isClockWise(t){return cl.area(t)<0}static triangulateShape(t,e){const n=[],i=[],r=[];hl(t),ul(n,t);let s=t.length;e.forEach(hl);for(let o=0;o<e.length;o++)i.push(s),s+=e[o].length,ul(n,e[o]);const a=ll.triangulate(n,i);for(let o=0;o<a.length;o+=3)r.push(a.slice(o,o+3));return r}}function hl(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function ul(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class dl extends Er{constructor(t=new Uo([new dn(.5,.5),new dn(-.5,.5),new dn(-.5,-.5),new dn(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],r=[];for(let a=0,o=t.length;a<o;a++){s(t[a])}function s(t){const s=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let c=void 0===e.bevelEnabled||e.bevelEnabled,h=void 0!==e.bevelThickness?e.bevelThickness:.2,u=void 0!==e.bevelSize?e.bevelSize:h-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:pl;let g,v,_,x,y,M=!1;if(f){g=f.getSpacedPoints(o),M=!0,c=!1;const t=!!f.isCatmullRomCurve3&&f.closed;v=f.computeFrenetFrames(o,t),_=new fn,x=new fn,y=new fn}c||(p=0,h=0,u=0,d=0);const b=t.extractPoints(a);let S=b.shape;const w=b.holes;if(!cl.isClockWise(S)){S=S.reverse();for(let t=0,e=w.length;t<e;t++){const e=w[t];cl.isClockWise(e)&&(w[t]=e.reverse())}}function T(t){const e=1e-10*1e-10;let n=t[0];for(let i=1;i<=t.length;i++){const r=i%t.length,s=t[r],a=s.x-n.x,o=s.y-n.y,l=a*a+o*o,c=Math.max(Math.abs(s.x),Math.abs(s.y),Math.abs(n.x),Math.abs(n.y));l<=e*c*c?(t.splice(r,1),i--):n=s}}T(S),w.forEach(T);const E=w.length,A=S;for(let e=0;e<E;e++){const t=w[e];S=S.concat(t)}function C(t,e,n){return e||Je("ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,n)}const R=S.length;function P(t,e,n){let i,r,s;const a=t.x-e.x,o=t.y-e.y,l=n.x-t.x,c=n.y-t.y,h=a*a+o*o,u=a*c-o*l;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-o/u,f=e.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-t.x,r=f+o*m-t.y;const g=i*i+r*r;if(g<=2)return new dn(i,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new dn(i/s,r/s)}const I=[];for(let e=0,n=A.length,i=n-1,r=e+1;e<n;e++,i++,r++)i===n&&(i=0),r===n&&(r=0),I[e]=P(A[e],A[i],A[r]);const L=[];let D,N,U=I.concat();for(let e=0,n=E;e<n;e++){const t=w[e];D=[];for(let e=0,n=t.length,i=n-1,r=e+1;e<n;e++,i++,r++)i===n&&(i=0),r===n&&(r=0),D[e]=P(t[e],t[i],t[r]);L.push(D),U=U.concat(D)}if(0===p)N=cl.triangulateShape(A,w);else{const t=[],e=[];for(let n=0;n<p;n++){const i=n/p,r=h*Math.cos(i*Math.PI/2),s=u*Math.sin(i*Math.PI/2)+d;for(let e=0,n=A.length;e<n;e++){const n=C(A[e],I[e],s);z(n.x,n.y,-r),0===i&&t.push(n)}for(let t=0,n=E;t<n;t++){const n=w[t];D=L[t];const a=[];for(let t=0,e=n.length;t<e;t++){const e=C(n[t],D[t],s);z(e.x,e.y,-r),0===i&&a.push(e)}0===i&&e.push(a)}}N=cl.triangulateShape(t,e)}const O=N.length,F=u+d;for(let e=0;e<R;e++){const t=c?C(S[e],U[e],F):S[e];M?(x.copy(v.normals[0]).multiplyScalar(t.x),_.copy(v.binormals[0]).multiplyScalar(t.y),y.copy(g[0]).add(x).add(_),z(y.x,y.y,y.z)):z(t.x,t.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<R;t++){const n=c?C(S[t],U[t],F):S[t];M?(x.copy(v.normals[e]).multiplyScalar(n.x),_.copy(v.binormals[e]).multiplyScalar(n.y),y.copy(g[e]).add(x).add(_),z(y.x,y.y,y.z)):z(n.x,n.y,l/o*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,r=A.length;e<r;e++){const t=C(A[e],I[e],i);z(t.x,t.y,l+n)}for(let e=0,r=w.length;e<r;e++){const t=w[e];D=L[e];for(let e=0,r=t.length;e<r;e++){const r=C(t[e],D[e],i);M?z(r.x,r.y+g[o-1].y,g[o-1].x+n):z(r.x,r.y,l+n)}}}function B(t,e){let n=t.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t<n;t++){const n=R*t,s=R*(t+1);V(e+i+n,e+r+n,e+r+s,e+i+s)}}}function z(t,e,n){s.push(t),s.push(e),s.push(n)}function k(t,e,r){G(t),G(e),G(r);const s=i.length/3,a=m.generateTopUV(n,i,s-3,s-2,s-1);H(a[0]),H(a[1]),H(a[2])}function V(t,e,r,s){G(t),G(e),G(s),G(e),G(r),G(s);const a=i.length/3,o=m.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function G(t){i.push(s[3*t+0]),i.push(s[3*t+1]),i.push(s[3*t+2])}function H(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(c){let t=0,e=R*t;for(let n=0;n<O;n++){const t=N[n];k(t[2]+e,t[1]+e,t[0]+e)}t=o+2*p,e=R*t;for(let n=0;n<O;n++){const t=N[n];k(t[0]+e,t[1]+e,t[2]+e)}}else{for(let t=0;t<O;t++){const e=N[t];k(e[2],e[1],e[0])}for(let t=0;t<O;t++){const e=N[t];k(e[0]+R*o,e[1]+R*o,e[2]+R*o)}}n.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;B(A,e),e+=A.length;for(let n=0,i=w.length;n<i;n++){const t=w[n];B(t,e),e+=t.length}n.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new _r(i,3)),this.setAttribute("uv",new _r(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let i=0,r=t.length;i<r;i++){const e=t[i];n.shapes.push(e.uuid)}else n.shapes.push(t.uuid);n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let r=0,s=t.shapes.length;r<s;r++){const i=e[t.shapes[r]];n.push(i)}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new Lo[i.type]).fromJSON(i)),new dl(n,t.options)}}const pl={generateTopUV:function(t,e,n,i,r){const s=e[3*n],a=e[3*n+1],o=e[3*i],l=e[3*i+1],c=e[3*r],h=e[3*r+1];return[new dn(s,a),new dn(o,l),new dn(c,h)]},generateSideWallUV:function(t,e,n,i,r,s){const a=e[3*n],o=e[3*n+1],l=e[3*n+2],c=e[3*i],h=e[3*i+1],u=e[3*i+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*s],g=e[3*s+1],v=e[3*s+2];return Math.abs(o-h)<Math.abs(a-c)?[new dn(a,1-l),new dn(c,1-u),new dn(d,1-f),new dn(m,1-v)]:[new dn(o,1-l),new dn(h,1-u),new dn(p,1-f),new dn(g,1-v)]}};class fl extends so{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new fl(t.radius,t.detail)}}class ml extends Er{constructor(t=[new dn(0,-.5),new dn(.5,0),new dn(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=an(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/e,h=new fn,u=new dn,d=new fn,p=new fn,f=new fn;let m=0,g=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:m=t[v+1].x-t[v].x,g=t[v+1].y-t[v].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(f.x,f.y,f.z);break;default:m=t[v+1].x-t[v].x,g=t[v+1].y-t[v].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=e;v++){const r=n+v*c*i,d=Math.sin(r),p=Math.cos(r);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*d,h.y=t[n].y,h.z=t[n].x*p,s.push(h.x,h.y,h.z),u.x=v/e,u.y=n/(t.length-1),a.push(u.x,u.y);const i=o[3*n+0]*d,r=o[3*n+1],c=o[3*n+0]*p;l.push(i,r,c)}}for(let v=0;v<e;v++)for(let e=0;e<t.length-1;e++){const n=e+v*t.length,i=n,s=n+t.length,a=n+t.length+1,o=n+1;r.push(i,s,o),r.push(a,o,s)}this.setIndex(r),this.setAttribute("position",new _r(s,3)),this.setAttribute("uv",new _r(a,2)),this.setAttribute("normal",new _r(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ml(t.points,t.segments,t.phiStart,t.phiLength)}}class gl extends so{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new gl(t.radius,t.detail)}}class vl extends Er{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,h=t/a,u=e/o,d=[],p=[],f=[],m=[];for(let g=0;g<c;g++){const t=g*u-s;for(let e=0;e<l;e++){const n=e*h-r;p.push(n,-t,0),f.push(0,0,1),m.push(e/a),m.push(1-g/o)}}for(let g=0;g<o;g++)for(let t=0;t<a;t++){const e=t+l*g,n=t+l*(g+1),i=t+1+l*(g+1),r=t+1+l*g;d.push(e,n,r),d.push(n,i,r)}this.setIndex(d),this.setAttribute("position",new _r(p,3)),this.setAttribute("normal",new _r(f,3)),this.setAttribute("uv",new _r(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new vl(t.width,t.height,t.widthSegments,t.heightSegments)}}class _l extends Er{constructor(t=.5,e=1,n=32,i=1,r=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:s},n=Math.max(3,n);const a=[],o=[],l=[],c=[];let h=t;const u=(e-t)/(i=Math.max(1,i)),d=new fn,p=new dn;for(let f=0;f<=i;f++){for(let t=0;t<=n;t++){const i=r+t/n*s;d.x=h*Math.cos(i),d.y=h*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,c.push(p.x,p.y)}h+=u}for(let f=0;f<i;f++){const t=f*(n+1);for(let e=0;e<n;e++){const i=e+t,r=i,s=i+n+1,o=i+n+2,l=i+1;a.push(r,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new _r(o,3)),this.setAttribute("normal",new _r(l,3)),this.setAttribute("uv",new _r(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new _l(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class xl extends Er{constructor(t=new Uo([new dn(0,.5),new dn(-.5,-.5),new dn(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let c=0;c<t.length;c++)l(t[c]),this.addGroup(a,o,c),a+=o,o=0;function l(t){const a=i.length/3,l=t.extractPoints(e);let c=l.shape;const h=l.holes;!1===cl.isClockWise(c)&&(c=c.reverse());for(let e=0,n=h.length;e<n;e++){const t=h[e];!0===cl.isClockWise(t)&&(h[e]=t.reverse())}const u=cl.triangulateShape(c,h);for(let e=0,n=h.length;e<n;e++){const t=h[e];c=c.concat(t)}for(let e=0,n=c.length;e<n;e++){const t=c[e];i.push(t.x,t.y,0),r.push(0,0,1),s.push(t.x,t.y)}for(let e=0,i=u.length;e<i;e++){const t=u[e],i=t[0]+a,r=t[1]+a,s=t[2]+a;n.push(i,r,s),o+=3}}this.setIndex(n),this.setAttribute("position",new _r(i,3)),this.setAttribute("normal",new _r(r,3)),this.setAttribute("uv",new _r(s,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let n=0,i=t.length;n<i;n++){const i=t[n];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const n=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];n.push(r)}return new xl(n,t.curveSegments)}}class yl extends Er{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const c=[],h=new fn,u=new fn,d=[],p=[],f=[],m=[];for(let g=0;g<=n;g++){const d=[],v=g/n;let _=0;0===g&&0===s?_=.5/e:g===n&&o===Math.PI&&(_=-.5/e);for(let n=0;n<=e;n++){const o=n/e;h.x=-t*Math.cos(i+o*r)*Math.sin(s+v*a),h.y=t*Math.cos(s+v*a),h.z=t*Math.sin(i+o*r)*Math.sin(s+v*a),p.push(h.x,h.y,h.z),u.copy(h).normalize(),f.push(u.x,u.y,u.z),m.push(o+_,1-v),d.push(l++)}c.push(d)}for(let g=0;g<n;g++)for(let t=0;t<e;t++){const e=c[g][t+1],i=c[g][t],r=c[g+1][t],a=c[g+1][t+1];(0!==g||s>0)&&d.push(e,i,a),(g!==n-1||o<Math.PI)&&d.push(i,r,a)}this.setIndex(d),this.setAttribute("position",new _r(p,3)),this.setAttribute("normal",new _r(f,3)),this.setAttribute("uv",new _r(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new yl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Ml extends so{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ml(t.radius,t.detail)}}class bl extends Er{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const s=[],a=[],o=[],l=[],c=new fn,h=new fn,u=new fn;for(let d=0;d<=n;d++)for(let s=0;s<=i;s++){const p=s/i*r,f=d/n*Math.PI*2;h.x=(t+e*Math.cos(f))*Math.cos(p),h.y=(t+e*Math.cos(f))*Math.sin(p),h.z=e*Math.sin(f),a.push(h.x,h.y,h.z),c.x=t*Math.cos(p),c.y=t*Math.sin(p),u.subVectors(h,c).normalize(),o.push(u.x,u.y,u.z),l.push(s/i),l.push(d/n)}for(let d=1;d<=n;d++)for(let t=1;t<=i;t++){const e=(i+1)*d+t-1,n=(i+1)*(d-1)+t-1,r=(i+1)*(d-1)+t,a=(i+1)*d+t;s.push(e,n,a),s.push(n,r,a)}this.setIndex(s),this.setAttribute("position",new _r(a,3)),this.setAttribute("normal",new _r(o,3)),this.setAttribute("uv",new _r(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new bl(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Sl extends Er{constructor(t=1,e=.4,n=64,i=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],h=new fn,u=new fn,d=new fn,p=new fn,f=new fn,m=new fn,g=new fn;for(let _=0;_<=n;++_){const a=_/n*r*Math.PI*2;v(a,r,s,t,d),v(a+.01,r,s,t,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let t=0;t<=i;++t){const r=t/i*Math.PI*2,s=-e*Math.cos(r),a=e*Math.sin(r);h.x=d.x+(s*g.x+a*f.x),h.y=d.y+(s*g.y+a*f.y),h.z=d.z+(s*g.z+a*f.z),o.push(h.x,h.y,h.z),u.subVectors(h,d).normalize(),l.push(u.x,u.y,u.z),c.push(_/n),c.push(t/i)}}for(let _=1;_<=n;_++)for(let t=1;t<=i;t++){const e=(i+1)*(_-1)+(t-1),n=(i+1)*_+(t-1),r=(i+1)*_+t,s=(i+1)*(_-1)+t;a.push(e,n,s),a.push(n,r,s)}function v(t,e,n,i,r){const s=Math.cos(t),a=Math.sin(t),o=n/e*t,l=Math.cos(o);r.x=i*(2+l)*.5*s,r.y=i*(2+l)*a*.5,r.z=i*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new _r(o,3)),this.setAttribute("normal",new _r(l,3)),this.setAttribute("uv",new _r(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Sl(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class wl extends Er{constructor(t=new Po(new fn(-1,-1,0),new fn(-1,1,0),new fn(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};const s=t.computeFrenetFrames(e,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const a=new fn,o=new fn,l=new dn;let c=new fn;const h=[],u=[],d=[],p=[];function f(r){c=t.getPointAt(r/e,c);const l=s.normals[r],d=s.binormals[r];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,r=Math.sin(e),s=-Math.cos(e);o.x=s*l.x+r*d.x,o.y=s*l.y+r*d.y,o.z=s*l.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=c.x+n*o.x,a.y=c.y+n*o.y,a.z=c.z+n*o.z,h.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)f(t);f(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=i;n++)l.x=t/e,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const n=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),s=(i+1)*t+e,a=(i+1)*(t-1)+e;p.push(n,r,a),p.push(r,s,a)}}()}(),this.setIndex(p),this.setAttribute("position",new _r(h,3)),this.setAttribute("normal",new _r(u,3)),this.setAttribute("uv",new _r(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new wl((new Lo[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class Tl extends Er{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],n=new Set,i=new fn,r=new fn;if(null!==t.index){const s=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,l=o.length;t<l;++t){const l=o[t],c=l.start;for(let t=c,o=c+l.count;t<o;t+=3)for(let l=0;l<3;l++){const o=a.getX(t+l),c=a.getX(t+(l+1)%3);i.fromBufferAttribute(s,o),r.fromBufferAttribute(s,c),!0===El(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{const s=t.attributes.position;for(let t=0,a=s.count/3;t<a;t++)for(let o=0;o<3;o++){const a=3*t+o,l=3*t+(o+1)%3;i.fromBufferAttribute(s,a),r.fromBufferAttribute(s,l),!0===El(i,r,n)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new _r(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function El(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var Al=Object.freeze({__proto__:null,BoxGeometry:kr,CapsuleGeometry:eo,CircleGeometry:no,ConeGeometry:ro,CylinderGeometry:io,DodecahedronGeometry:ao,EdgesGeometry:uo,ExtrudeGeometry:dl,IcosahedronGeometry:fl,LatheGeometry:ml,OctahedronGeometry:gl,PlaneGeometry:vl,PolyhedronGeometry:so,RingGeometry:_l,ShapeGeometry:xl,SphereGeometry:yl,TetrahedronGeometry:Ml,TorusGeometry:bl,TorusKnotGeometry:Sl,TubeGeometry:wl,WireframeGeometry:Tl});class Cl extends ar{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ir(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class Rl extends jr{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Pl extends ar{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ir(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ir(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Il extends Pl{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new dn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return an(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ir(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ir(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ir(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Ll extends ar{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ir(16777215),this.specular=new ir(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ir(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Mi,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Dl extends ar{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ir(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ir(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Nl extends ar{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Ul extends ar{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ir(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ir(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Mi,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Ol extends ar{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Fl extends ar{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Bl extends ar{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ir(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class zl extends Ra{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function kl(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Vl(t){const e=t.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(function(e,n){return t[e]-t[n]}),n}function Gl(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function Hl(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push(...a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}class Wl{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let s;n:{i:if(!(t<i)){for(let s=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=e[++n],t<i)break e}s=e.length;break n}if(!(t>=r)){const a=e[1];t<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=e[--n-1],t>=r)break e}s=n,n=0;break n}break t}for(;n<s;){const i=n+s>>>1;t<e[i]?s=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let s=0;s!==i;++s)e[s]=n[r+s];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class jl extends Wl{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ve,endingEnd:ve}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,s=t+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case _e:r=t,a=2*e-n;break;case xe:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case _e:s=t,o=2*n-e;break;case xe:s=1,o=n+i[1]-i[0];break;default:s=t-1,o=e}const l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,_=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let y=0;y!==a;++y)r[y]=g*s[c+y]+v*s[l+y]+_*s[o+y]+x*s[h+y];return r}}class Xl extends Wl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=(n-e)/(i-e),h=1-c;for(let u=0;u!==a;++u)r[u]=s[l+u]*h+s[o+u]*c;return r}}class ql extends Wl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class Yl{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=kl(e,this.TimeBufferType),this.values=kl(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:kl(t.times,Array),values:kl(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new ql(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Xl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new jl(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case fe:e=this.InterpolantFactoryMethodDiscrete;break;case me:e=this.InterpolantFactoryMethodLinear;break;case ge:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return Ke("KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return fe;case this.InterpolantFactoryMethodLinear:return me;case this.InterpolantFactoryMethodSmooth:return ge}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==s&&n[s]>e;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Je("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(Je("KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let a=0;a!==r;a++){const e=n[a];if("number"==typeof e&&isNaN(e)){Je("KeyframeTrack: Time is not a valid number.",this,a,e),t=!1;break}if(null!==s&&s>e){Je("KeyframeTrack: Out of order keys.",this,a,e,s),t=!1;break}s=e}if(void 0!==i&&We(i))for(let a=0,o=i.length;a!==o;++a){const e=i[a];if(isNaN(e)){Je("KeyframeTrack: Value is not a valid number.",this,a,e),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===ge,r=t.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)r=!0;else{const t=a*n,i=t-n,s=t+n;for(let a=0;a!==n;++a){const n=e[t+a];if(n!==e[i+a]||n!==e[s+a]){r=!0;break}}}if(r){if(a!==s){t[s]=t[a];const i=a*n,r=s*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Yl.prototype.ValueTypeName="",Yl.prototype.TimeBufferType=Float32Array,Yl.prototype.ValueBufferType=Float32Array,Yl.prototype.DefaultInterpolation=me;class Zl extends Yl{constructor(t,e,n){super(t,e,n)}}Zl.prototype.ValueTypeName="bool",Zl.prototype.ValueBufferType=Array,Zl.prototype.DefaultInterpolation=fe,Zl.prototype.InterpolantFactoryMethodLinear=void 0,Zl.prototype.InterpolantFactoryMethodSmooth=void 0;class Kl extends Yl{constructor(t,e,n,i){super(t,e,n,i)}}Kl.prototype.ValueTypeName="color";class Jl extends Yl{constructor(t,e,n,i){super(t,e,n,i)}}Jl.prototype.ValueTypeName="number";class $l extends Wl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let c=l+a;l!==c;l+=4)pn.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Ql extends Yl{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new $l(this.times,this.values,this.getValueSize(),t)}}Ql.prototype.ValueTypeName="quaternion",Ql.prototype.InterpolantFactoryMethodSmooth=void 0;class tc extends Yl{constructor(t,e,n){super(t,e,n)}}tc.prototype.ValueTypeName="string",tc.prototype.ValueBufferType=Array,tc.prototype.DefaultInterpolation=fe,tc.prototype.InterpolantFactoryMethodLinear=void 0,tc.prototype.InterpolantFactoryMethodSmooth=void 0;class ec extends Yl{constructor(t,e,n,i){super(t,e,n,i)}}ec.prototype.ValueTypeName="vector";class nc{constructor(t="",e=-1,n=[],i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=sn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let s=0,a=n.length;s!==a;++s)e.push(ic(n[s]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,s=n.length;r!==s;++r)e.push(Yl.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let a=0;a<r;a++){let t=[],o=[];t.push((a+r-1)%r,a,(a+1)%r),o.push(0,1,0);const l=Vl(t);t=Gl(t,1,l),o=Gl(o,1,l),i||0!==t[0]||(t.push(r),o.push(o[0])),s.push(new Jl(".morphTargetInfluences["+e[a].name+"]",t,o).scale(1/n))}return new this(t,-1,s)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,o=t.length;a<o;a++){const e=t[a],n=e.name.match(r);if(n&&n.length>1){const t=n[1];let r=i[t];r||(i[t]=r=[]),r.push(e)}}const s=[];for(const a in i)s.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return s}static parseAnimation(t,e){if(Ke("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return Je("AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];Hl(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let c=0;c<l.length;c++){const t=l[c].keys;if(t&&0!==t.length)if(t[0].morphTargets){const e={};let n;for(n=0;n<t.length;n++)if(t[n].morphTargets)for(let i=0;i<t[n].morphTargets.length;i++)e[t[n].morphTargets[i]]=-1;for(const r in e){const e=[],s=[];for(let i=0;i!==t[n].morphTargets.length;++i){const i=t[n];e.push(i.time),s.push(i.morphTarget===r?1:0)}i.push(new Jl(".morphTargetInfluence["+r+"]",e,s))}o=e.length*s}else{const r=".bones["+e[c].name+"]";n(ec,r+".position",t,"pos",i),n(Ql,r+".quaternion",t,"rot",i),n(ec,r+".scale",t,"scl",i)}}if(0===i.length)return null;return new this(r,o,i,a)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function ic(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Jl;case"vector":case"vector2":case"vector3":case"vector4":return ec;case"color":return Kl;case"quaternion":return Ql;case"bool":case"boolean":return Zl;case"string":return tc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];Hl(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const rc={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class sc{constructor(t,e,n){const i=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(t){o++,!1===s&&void 0!==i.onStart&&i.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(s=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const ac=new sc;class oc{constructor(t){this.manager=void 0!==t?t:ac,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}oc.DEFAULT_MATERIAL_NAME="__DEFAULT";const lc={};class cc extends Error{constructor(t,e){super(t),this.response=e}}class hc extends oc{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=rc.get(`file:${t}`);if(void 0!==r)return this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0),r;if(void 0!==lc[t])return void lc[t].push({onLoad:e,onProgress:n,onError:i});lc[t]=[],lc[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(s).then(e=>{if(200===e.status||0===e.status){if(0===e.status&&Ke("FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=lc[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then(({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}},e=>{t.error(e)})}()}});return new Response(l)}throw new cc(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>(new DOMParser).parseFromString(t,a));case"json":return t.json();default:if(""===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then(t=>i.decode(t))}}}).then(e=>{rc.add(`file:${t}`,e);const n=lc[t];delete lc[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}}).catch(e=>{const n=lc[t];if(void 0===n)throw this.manager.itemError(t),e;delete lc[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const uc=new WeakMap;class dc extends oc{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=rc.get(`image:${t}`);if(void 0!==s){if(!0===s.complete)r.manager.itemStart(t),setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0);else{let t=uc.get(s);void 0===t&&(t=[],uc.set(s,t)),t.push({onLoad:e,onError:i})}return s}const a=je("img");function o(){c(),e&&e(this);const n=uc.get(this)||[];for(let t=0;t<n.length;t++){const e=n[t];e.onLoad&&e.onLoad(this)}uc.delete(this),r.manager.itemEnd(t)}function l(e){c(),i&&i(e),rc.remove(`image:${t}`);const n=uc.get(this)||[];for(let t=0;t<n.length;t++){const i=n[t];i.onError&&i.onError(e)}uc.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),rc.add(`image:${t}`,a),r.manager.itemStart(t),a.src=t,a}}class pc extends oc{constructor(t){super(t)}load(t,e,n,i){const r=new Qr;r.colorSpace=Se;const s=new dc(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(n){s.load(t[n],function(t){r.images[n]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))},void 0,i)}for(let l=0;l<t.length;++l)o(l);return r}}class fc extends oc{constructor(t){super(t)}load(t,e,n,i){const r=new Ln,s=new dc(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)},n,i),r}}class mc extends Bi{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ir(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class gc extends mc{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Bi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ir(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const vc=new ui,_c=new fn,xc=new fn;class yc{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new dn(512,512),this.mapType=ot,this.map=null,this.mapPass=null,this.matrix=new ui,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new aa,this._frameExtents=new dn(1,1),this._viewportCount=1,this._viewports=[new Dn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;_c.setFromMatrixPosition(t.matrixWorld),e.position.copy(_c),xc.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(xc),e.updateMatrixWorld(),vc.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vc,e.coordinateSystem,e.reversedDepth),e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(vc)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Mc extends yc{constructor(){super(new Kr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=2*rn*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class bc extends mc{constructor(t,e,n=0,i=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Bi.DEFAULT_UP),this.updateMatrix(),this.target=new Bi,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Mc}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class Sc extends yc{constructor(){super(new Kr(90,1,.5,500)),this.isPointLightShadow=!0}}class wc extends mc{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Sc}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Tc extends Xr{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}class Ec extends yc{constructor(){super(new Tc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ac extends mc{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Bi.DEFAULT_UP),this.updateMatrix(),this.target=new Bi,this.shadow=new Ec}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class Cc extends mc{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Rc extends mc{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Pc{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new fn)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*i),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*n),e.addScaledVector(s[4],n*i*1.092548),e.addScaledVector(s[5],i*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],n*r*1.092548),e.addScaledVector(s[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*i),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*n),e.addScaledVector(s[4],.858086*n*i),e.addScaledVector(s[5],.858086*i*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*n*r),e.addScaledVector(s[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}}class Ic extends mc{constructor(t=new Pc,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Lc extends oc{constructor(t){super(t),this.textures={}}load(t,e,n,i){const r=this,s=new hc(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,function(n){try{e(r.parse(JSON.parse(n)))}catch(s){i?i(s):Je(s),r.manager.itemError(t)}},n,i)}parse(t){const e=this.textures;function n(t){return void 0===e[t]&&Ke("MaterialLoader: Undefined texture",t),e[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new ir).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(i.allowOverride=t.allowOverride),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const r in t.uniforms){const e=t.uniforms[r];switch(i.uniforms[r]={},e.type){case"t":i.uniforms[r].value=n(e.value);break;case"c":i.uniforms[r].value=(new ir).setHex(e.value);break;case"v2":i.uniforms[r].value=(new dn).fromArray(e.value);break;case"v3":i.uniforms[r].value=(new fn).fromArray(e.value);break;case"v4":i.uniforms[r].value=(new Dn).fromArray(e.value);break;case"m3":i.uniforms[r].value=(new vn).fromArray(e.value);break;case"m4":i.uniforms[r].value=(new ui).fromArray(e.value);break;default:i.uniforms[r].value=e.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const r in t.extensions)i.extensions[r]=t.extensions[r];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new dn).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new dn).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Lc.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Cl,SpriteMaterial:hs,RawShaderMaterial:Rl,ShaderMaterial:jr,PointsMaterial:Ha,MeshPhysicalMaterial:Il,MeshStandardMaterial:Pl,MeshPhongMaterial:Ll,MeshToonMaterial:Dl,MeshNormalMaterial:Nl,MeshLambertMaterial:Ul,MeshDepthMaterial:Ol,MeshDistanceMaterial:Fl,MeshBasicMaterial:or,MeshMatcapMaterial:Bl,LineDashedMaterial:zl,LineBasicMaterial:Ra,Material:ar}[t]}}class Dc{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Nc extends Er{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Uc extends oc{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new hc(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,function(n){try{e(r.parse(JSON.parse(n)))}catch(s){i?i(s):Je(s),r.manager.itemError(t)}},n,i)}parse(t){const e={},n={};function i(t,i){if(void 0!==e[i])return e[i];const r=t.interleavedBuffers[i],s=function(t,e){if(void 0!==n[e])return n[e];const i=t.arrayBuffers,r=i[e],s=new Uint32Array(r).buffer;return n[e]=s,s}(t,r.buffer),a=He(r.type,s),o=new os(a,r.stride);return o.uuid=r.uuid,e[i]=o,o}const r=t.isInstancedBufferGeometry?new Nc:new Er,s=t.data.index;if(void 0!==s){const t=He(s.type,s.array);r.setIndex(new mr(t,1))}const a=t.data.attributes;for(const h in a){const e=a[h];let n;if(e.isInterleavedBufferAttribute){const r=i(t.data,e.data);n=new cs(r,e.itemSize,e.offset,e.normalized)}else{const t=He(e.type,e.array);n=new(e.isInstancedBufferAttribute?Ws:mr)(t,e.itemSize,e.normalized)}void 0!==e.name&&(n.name=e.name),void 0!==e.usage&&n.setUsage(e.usage),r.setAttribute(h,n)}const o=t.data.morphAttributes;if(o)for(const h in o){const e=o[h],n=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];let a;if(s.isInterleavedBufferAttribute){const e=i(t.data,s.data);a=new cs(e,s.itemSize,s.offset,s.normalized)}else{const t=He(s.type,s.array);a=new mr(t,s.itemSize,s.normalized)}void 0!==s.name&&(a.name=s.name),n.push(a)}r.morphAttributes[h]=n}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==l)for(let h=0,u=l.length;h!==u;++h){const t=l[h];r.addGroup(t.start,t.count,t.materialIndex)}const c=t.data.boundingSphere;return void 0!==c&&(r.boundingSphere=(new ni).fromJSON(c)),t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}const Oc={UVMapping:X,CubeReflectionMapping:q,CubeRefractionMapping:Y,EquirectangularReflectionMapping:Z,EquirectangularRefractionMapping:K,CubeUVReflectionMapping:J},Fc={RepeatWrapping:$,ClampToEdgeWrapping:Q,MirroredRepeatWrapping:tt},Bc={NearestFilter:et,NearestMipmapNearestFilter:nt,NearestMipmapLinearFilter:it,LinearFilter:rt,LinearMipmapNearestFilter:st,LinearMipmapLinearFilter:at},zc=new WeakMap;class kc extends oc{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&Ke("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&Ke("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=rc.get(`image-bitmap:${t}`);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then(n=>{if(!0!==zc.has(s))return e&&e(n),r.manager.itemEnd(t),n;i&&i(zc.get(s)),r.manager.itemError(t),r.manager.itemEnd(t)}):(setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(n){return rc.add(`image-bitmap:${t}`,n),e&&e(n),r.manager.itemEnd(t),n}).catch(function(e){i&&i(e),zc.set(o,e),rc.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});rc.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Vc;class Gc{static getContext(){return void 0===Vc&&(Vc=new(window.AudioContext||window.webkitAudioContext)),Vc}static setContext(t){Vc=t}}const Hc=new ui,Wc=new ui,jc=new ui;class Xc extends Kr{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class qc{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}const Yc=new fn,Zc=new pn,Kc=new fn,Jc=new fn,$c=new fn;class Qc extends Bi{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void Ke("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void Ke("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;Ke("Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;Ke("Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;Ke("Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1===this.hasPlaybackControl?(Ke("Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;Ke("Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),"buffer"!==t.sourceType?(Ke("Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}}const th=new fn,eh=new pn,nh=new fn,ih=new fn;class rh{constructor(t,e,n){let i,r,s;switch(this.binding=t,this.valueSize=n,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==i;++t)n[r+t]=n[t];s=e}else{s+=e;const t=e/s;this._mixBufferRegion(n,r,0,t,i)}this.cumulativeWeight=s}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(n,i,t,1-r,e)}s>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let o=e,l=e+e;o!==l;++o)if(n[o]!==n[o+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,s=i;r!==s;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let s=0;s!==r;++s)t[e+s]=t[n+s]}_slerp(t,e,n,i){pn.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;pn.multiplyQuaternionsFlat(t,s,t,e,t,n),pn.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const sh="\\[\\]\\.:\\/",ah=new RegExp("["+sh+"]","g"),oh="[^"+sh+"]",lh="[^"+sh.replace("\\.","")+"]",ch=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",oh)+/(WCOD+)?/.source.replace("WCOD",lh)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",oh)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",oh)+"$"),hh=["material","materials","bones","map"];class uh{constructor(t,e,n){this.path=e,this.parsedPath=n||uh.parseTrackName(e),this.node=uh.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new uh.Composite(t,e,n):new uh(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ah,"")}static parseTrackName(t){const e=ch.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==hh.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const s=n(r.children);if(s)return s}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=uh.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void Ke("PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void Je("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void Je("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void Je("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void Je("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void Je("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void Je("PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void Je("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const s=t[i];if(void 0===s){return void Je("PropertyBinding: Trying to update property for track: "+e.nodeName+"."+i+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,!0===t.isMaterial?a=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void Je("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void Je("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}uh.Composite=class{constructor(t,e,n){const i=n||uh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},uh.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},uh.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},uh.prototype.GetterByBindingType=[uh.prototype._getValue_direct,uh.prototype._getValue_array,uh.prototype._getValue_arrayElement,uh.prototype._getValue_toArray],uh.prototype.SetterByBindingTypeAndVersioning=[[uh.prototype._setValue_direct,uh.prototype._setValue_direct_setNeedsUpdate,uh.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[uh.prototype._setValue_array,uh.prototype._setValue_array_setNeedsUpdate,uh.prototype._setValue_array_setMatrixWorldNeedsUpdate],[uh.prototype._setValue_arrayElement,uh.prototype._setValue_arrayElement_setNeedsUpdate,uh.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[uh.prototype._setValue_fromArray,uh.prototype._setValue_fromArray_setNeedsUpdate,uh.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class dh{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:ve,endingEnd:ve};for(let l=0;l!==s;++l){const t=r[l].createInterpolant(null);a[l]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=pe,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),!0===n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Me)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(a);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=2202===n;if(0===t)return-1===r||!s||1&~r?i:e-i;if(n===de){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=_e,i.endingEnd=_e):(i.endingStart=t?this.zeroSlopeAtStart?_e:ve:xe,i.endingEnd=e?this.zeroSlopeAtEnd?_e:ve:xe)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=n,this}}const ph=new Float32Array(1);class fh extends Qe{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let h=0;h!==r;++h){const t=i[h],r=t.name;let l=c[r];if(void 0!==l)++l.referenceCount,s[h]=l;else{if(l=s[h],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,r));continue}const i=e&&e._propertyBindings[h].binding.parsedPath;l=new rh(uh.create(n,r,i),t.ValueTypeName,t.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,r),s[h]=l}a[h].resultBuffer=l.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),s.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,l=o[o.length-1],c=t._byClipCacheIndex;l._byClipCacheIndex=c,o[c]=l,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const t=e[n];0===--t.referenceCount&&this._removeInactiveBinding(t)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,r=this._bindings;let s=i[e];void 0===s&&(s={},i[e]=s),s[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,a=s[i],o=e[e.length-1],l=t._cacheIndex;o._cacheIndex=l,e[l]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete s[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return void 0===n&&(n=new Xl(new Float32Array(2),new Float32Array(2),1,ph),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){const i=e||this._root,r=i.uuid;let s="string"==typeof t?nc.findByName(i,t):t;const a=null!==s?s.uuid:t,o=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==s?s.blendMode:ye),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===n)return t;l=o.knownActions[0],null===s&&(s=l._clip)}if(null===s)return null;const c=new dh(this,s,e,n);return this._bindAction(c,l),this._addInactiveAction(c,a,r),c}existingAction(t,e){const n=e||this._root,i=n.uuid,r="string"==typeof t?nc.findByName(n,t):t,s=r?r.uuid:t,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let l=0;l!==n;++l){e[l]._update(i,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(s);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const t=r.knownActions;for(let n=0,i=t.length;n!==i;++n){const i=t[n];this._deactivateAction(i);const r=i._cacheIndex,s=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const r in n){const t=n[r].actionByRoot[e];void 0!==t&&(this._deactivateAction(t),this._removeInactiveAction(t))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const r in i){const t=i[r];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(t,e){const n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class mh{constructor(t){this.value=t}clone(){return new mh(void 0===this.value.clone?this.value:this.value.clone())}}let gh=0;const vh=new ui;class _h{constructor(t,e,n=0,i=1/0){this.ray=new hi(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new bi,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Je("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return vh.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(vh),this}intersectObject(t,e=!0,n=[]){return yh(t,this,n,e),n.sort(xh),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)yh(t[i],this,n,e);return n.sort(xh),n}}function xh(t,e){return t.distance-e.distance}function yh(t,e,n,i){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,n)&&(r=!1)}if(!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)yh(i[t],e,n,!0)}}function Mh(){!1===this._document.hidden&&this.reset()}class bh{constructor(t,e,n,i){bh.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}const Sh=new dn;const wh=new fn,Th=new fn,Eh=new fn,Ah=new fn,Ch=new fn,Rh=new fn,Ph=new fn;const Ih=new fn;const Lh=new fn,Dh=new ui,Nh=new ui;function Uh(t){const e=[];!0===t.isBone&&e.push(t);for(let n=0;n<t.children.length;n++)e.push(...Uh(t.children[n]));return e}const Oh=new fn,Fh=new ir,Bh=new ir;const zh=new fn,kh=new fn,Vh=new fn;const Gh=new fn,Hh=new Xr;function Wh(t,e,n,i,r,s,a){Gh.set(r,s,a).unproject(i);const o=e[t];if(void 0!==o){const t=n.getAttribute("position");for(let e=0,n=o.length;e<n;e++)t.setXYZ(o[e],Gh.x,Gh.y,Gh.z)}}const jh=new Bn;const Xh=new fn;let qh,Yh;function Zh(t,e,n,i){const r=function(t){switch(t){case ot:case lt:return{byteLength:1,components:1};case ht:case ct:case ft:return{byteLength:2,components:1};case mt:case gt:return{byteLength:2,components:4};case dt:case ut:case pt:return{byteLength:4,components:1};case _t:case xt:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(n){case yt:return t*e;case Tt:case Et:return t*e/r.components*r.byteLength;case At:case Ct:return t*e*2/r.components*r.byteLength;case Mt:return t*e*3/r.components*r.byteLength;case bt:case Rt:return t*e*4/r.components*r.byteLength;case Pt:case It:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Lt:case Dt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Ut:case Ft:return Math.max(t,16)*Math.max(e,8)/4;case Nt:case Ot:return Math.max(t,8)*Math.max(e,8)/2;case Bt:case zt:case Vt:case Gt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case kt:case Ht:case Wt:case jt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Xt:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case qt:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case Yt:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case Zt:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case Kt:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case Jt:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case $t:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Qt:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case te:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case ee:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case ne:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case ie:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case re:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case se:case ae:case oe:return Math.ceil(t/4)*Math.ceil(e/4)*16;case le:case ce:return Math.ceil(t/4)*Math.ceil(e/4)*8;case he:case ue:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2010-2025 Three.js Authors
|
|
11
|
+
* SPDX-License-Identifier: MIT
|
|
12
|
+
*/
|
|
13
|
+
function Kh(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Jh(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=e.get(n);if(void 0===r)e.set(n,function(e,n){const i=e.array,r=e.usage,s=i.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(n,a),t.bufferData(n,i,r),e.onUploadCallback(),i instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=t.HALF_FLOAT;else if(i instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=t.SHORT;else if(i instanceof Uint32Array)o=t.UNSIGNED_INT;else if(i instanceof Int32Array)o=t.INT;else if(i instanceof Int8Array)o=t.BYTE;else if(i instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:s}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,n,i){const r=n.array,s=n.updateRanges;if(t.bindBuffer(i,e),0===s.length)t.bufferSubData(i,0,r);else{s.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<s.length;t++){const n=s[e],i=s[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,s[e]=i)}s.length=e+1;for(let n=0,a=s.length;n<a;n++){const e=s[n];t.bufferSubData(i,e.start*r.BYTES_PER_ELEMENT,r,e.start,e.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:n}})),"undefined"!=typeof window&&(window.__THREE__?Ke("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=n);const $h={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn v;\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadow = step( depth, dp );\n\t\t\t#else\n\t\t\t\tshadow = step( dp, depth );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Qh={common:{diffuse:{value:new ir(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new vn}},envmap:{envMap:{value:null},envMapRotation:{value:new vn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new vn},normalScale:{value:new dn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ir(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ir(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0},uvTransform:{value:new vn}},sprite:{diffuse:{value:new ir(16777215)},opacity:{value:1},center:{value:new dn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}}},tu={basic:{uniforms:Gr([Qh.common,Qh.specularmap,Qh.envmap,Qh.aomap,Qh.lightmap,Qh.fog]),vertexShader:$h.meshbasic_vert,fragmentShader:$h.meshbasic_frag},lambert:{uniforms:Gr([Qh.common,Qh.specularmap,Qh.envmap,Qh.aomap,Qh.lightmap,Qh.emissivemap,Qh.bumpmap,Qh.normalmap,Qh.displacementmap,Qh.fog,Qh.lights,{emissive:{value:new ir(0)}}]),vertexShader:$h.meshlambert_vert,fragmentShader:$h.meshlambert_frag},phong:{uniforms:Gr([Qh.common,Qh.specularmap,Qh.envmap,Qh.aomap,Qh.lightmap,Qh.emissivemap,Qh.bumpmap,Qh.normalmap,Qh.displacementmap,Qh.fog,Qh.lights,{emissive:{value:new ir(0)},specular:{value:new ir(1118481)},shininess:{value:30}}]),vertexShader:$h.meshphong_vert,fragmentShader:$h.meshphong_frag},standard:{uniforms:Gr([Qh.common,Qh.envmap,Qh.aomap,Qh.lightmap,Qh.emissivemap,Qh.bumpmap,Qh.normalmap,Qh.displacementmap,Qh.roughnessmap,Qh.metalnessmap,Qh.fog,Qh.lights,{emissive:{value:new ir(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$h.meshphysical_vert,fragmentShader:$h.meshphysical_frag},toon:{uniforms:Gr([Qh.common,Qh.aomap,Qh.lightmap,Qh.emissivemap,Qh.bumpmap,Qh.normalmap,Qh.displacementmap,Qh.gradientmap,Qh.fog,Qh.lights,{emissive:{value:new ir(0)}}]),vertexShader:$h.meshtoon_vert,fragmentShader:$h.meshtoon_frag},matcap:{uniforms:Gr([Qh.common,Qh.bumpmap,Qh.normalmap,Qh.displacementmap,Qh.fog,{matcap:{value:null}}]),vertexShader:$h.meshmatcap_vert,fragmentShader:$h.meshmatcap_frag},points:{uniforms:Gr([Qh.points,Qh.fog]),vertexShader:$h.points_vert,fragmentShader:$h.points_frag},dashed:{uniforms:Gr([Qh.common,Qh.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$h.linedashed_vert,fragmentShader:$h.linedashed_frag},depth:{uniforms:Gr([Qh.common,Qh.displacementmap]),vertexShader:$h.depth_vert,fragmentShader:$h.depth_frag},normal:{uniforms:Gr([Qh.common,Qh.bumpmap,Qh.normalmap,Qh.displacementmap,{opacity:{value:1}}]),vertexShader:$h.meshnormal_vert,fragmentShader:$h.meshnormal_frag},sprite:{uniforms:Gr([Qh.sprite,Qh.fog]),vertexShader:$h.sprite_vert,fragmentShader:$h.sprite_frag},background:{uniforms:{uvTransform:{value:new vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$h.background_vert,fragmentShader:$h.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new vn}},vertexShader:$h.backgroundCube_vert,fragmentShader:$h.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$h.cube_vert,fragmentShader:$h.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$h.equirect_vert,fragmentShader:$h.equirect_frag},distance:{uniforms:Gr([Qh.common,Qh.displacementmap,{referencePosition:{value:new fn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$h.distance_vert,fragmentShader:$h.distance_frag},shadow:{uniforms:Gr([Qh.lights,Qh.fog,{color:{value:new ir(0)},opacity:{value:1}}]),vertexShader:$h.shadow_vert,fragmentShader:$h.shadow_frag}};tu.physical={uniforms:Gr([tu.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new vn},clearcoatNormalScale:{value:new dn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new vn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new vn},sheen:{value:0},sheenColor:{value:new ir(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new vn},transmissionSamplerSize:{value:new dn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new vn},attenuationDistance:{value:0},attenuationColor:{value:new ir(0)},specularColor:{value:new ir(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new vn},anisotropyVector:{value:new dn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new vn}}]),vertexShader:$h.meshphysical_vert,fragmentShader:$h.meshphysical_frag};const eu={r:0,b:0,g:0},nu=new Mi,iu=new ui;function ru(t,e,n,i,r,s,a){const o=new ir(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){i=(t.backgroundBlurriness>0?n:e).get(i)}return i}function m(e,n){e.getRGB(eu,Hr(t)),i.buffers.color.setClear(eu.r,eu.g,eu.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),h=e,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,m(o,h)},render:function(e){let n=!1;const r=f(e);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===J)?(void 0===c&&(c=new Br(new kr(1,1,1),new jr({name:"BackgroundCubeMaterial",uniforms:Vr(tu.backgroundCube.uniforms),vertexShader:tu.backgroundCube.vertexShader,fragmentShader:tu.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),nu.copy(n.backgroundRotation),nu.x*=-1,nu.y*=-1,nu.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(nu.y*=-1,nu.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(iu.makeRotationFromEuler(nu)),c.material.toneMapped=bn.getTransfer(i.colorSpace)!==Ee,u===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Br(new vl(2,2),new jr({name:"BackgroundMaterial",uniforms:Vr(tu.background.uniforms),vertexShader:tu.background.vertexShader,fragmentShader:tu.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=bn.getTransfer(i.colorSpace)!==Ee,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),u===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose(),c=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function su(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let s=0;s<n;s++)e[s]=0,i[s]=0,r[s]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:r,object:t,attributes:{},index:null}}function h(){const t=s.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function u(t){d(t,0)}function d(e,n){const i=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;i[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==n&&(t.vertexAttribDivisor(e,n),a[e]=n)}function p(){const e=s.newAttributes,n=s.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function f(e,n,i,r,s,a,o){!0===o?t.vertexAttribIPointer(e,n,i,s,a):t.vertexAttribPointer(e,n,i,r,s,a)}function m(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let v=!1;const _=function(e,n,r){const s=!0===r.wireframe;let a=i[e.id];void 0===a&&(a={},i[e.id]=a);let o=a[n.id];void 0===o&&(o={},a[n.id]=o);let l=o[s];void 0===l&&(l=c(t.createVertexArray()),o[s]=l);return l}(m,l,r);s!==_&&(s=_,o(s.object)),v=function(t,e,n,i){const r=s.attributes,a=e.attributes;let o=0;const l=n.getAttributes();for(const s in l){if(l[s].location>=0){const e=r[s];let n=a[s];if(void 0===n&&("instanceMatrix"===s&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===s&&t.instanceColor&&(n=t.instanceColor)),void 0===e)return!0;if(e.attribute!==n)return!0;if(n&&e.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==i}(n,m,l,g),v&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const s in l){if(l[s].location>=0){let e=a[s];void 0===e&&("instanceMatrix"===s&&t.instanceMatrix&&(e=t.instanceMatrix),"instanceColor"===s&&t.instanceColor&&(e=t.instanceColor));const n={};n.attribute=e,e&&e.data&&(n.data=e.data),r[s]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(n,i,r,s){h();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const c in o){const i=o[c];if(i.location>=0){let r=a[c];if(void 0===r&&("instanceMatrix"===c&&n.instanceMatrix&&(r=n.instanceMatrix),"instanceColor"===c&&n.instanceColor&&(r=n.instanceColor)),void 0!==r){const a=r.normalized,o=r.itemSize,l=e.get(r);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===t.INT||h===t.UNSIGNED_INT||r.gpuType===ut;if(r.isInterleavedBufferAttribute){const e=r.data,l=e.stride,g=r.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<i.locationSize;t++)d(i.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<i.locationSize;t++)u(i.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<i.locationSize;t++)f(i.location+t,o/i.locationSize,h,a,l*p,(g+o/i.locationSize*t)*p,m)}else{if(r.isInstancedBufferAttribute){for(let t=0;t<i.locationSize;t++)d(i.location+t,r.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=r.meshPerAttribute*r.count)}else for(let t=0;t<i.locationSize;t++)u(i.location+t);t.bindBuffer(t.ARRAY_BUFFER,c);for(let t=0;t<i.locationSize;t++)f(i.location+t,o/i.locationSize,h,a,o*p,o/i.locationSize*t*p,m)}}else if(void 0!==l){const e=l[c];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(i.location,e);break;case 3:t.vertexAttrib3fv(i.location,e);break;case 4:t.vertexAttrib4fv(i.location,e);break;default:t.vertexAttrib1fv(i.location,e)}}}}p()}(n,r,l,m),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const n in e){const t=e[n];for(const e in t)l(t[e].object),delete t[e];delete e[n]}delete i[t.id]},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)l(r[t].object),delete r[t];delete n[t.id]}},initAttributes:h,enableAttribute:u,disableUnusedAttributes:p}}function au(t,e,n){let i;function r(e,r,s){0!==s&&(t.drawArraysInstanced(i,e,r,s),n.update(r,i,s))}this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,r,0,s);let a=0;for(let e=0;e<s;e++)a+=r[e];n.update(a,i,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{l.multiDrawArraysInstancedWEBGL(i,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];n.update(e,i,1)}}}function ou(t,e,n,i){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(Ke("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===bt||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===ft&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==ot&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==pt&&!r)},precision:a,logarithmicDepthBuffer:!0===n.logarithmicDepthBuffer,reversedDepthBuffer:!0===n.reversedDepthBuffer&&e.has("EXT_clip_control"),maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function lu(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new na,o=new vn,l={value:null,needsUpdate:!1};function c(t,n,i,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<e)&&(c=new Float32Array(e));for(let n=0,l=i;n!==s;++n,l+=4)a.copy(t[n]).applyMatrix4(r,o),a.normal.toArray(c,l),c[l+3]=a.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){n=c(t,e,0)},this.setState=function(a,o,h){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,f=t.get(a);if(!r||null===u||0===u.length||s&&!p)s?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);e.numPlanes=i,e.numIntersection=0}();else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(u,o,e,h);for(let i=0;i!==e;++i)r[i]=n[i];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function cu(t){let e=new WeakMap;function n(t,e){return e===Z?t.mapping=q:e===K&&(t.mapping=Y),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===Z||s===K){if(e.has(r)){return n(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new ts(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const hu=[.125,.215,.35,.446,.526,.582],uu=20,du=new Tc,pu=new ir;let fu=null,mu=0,gu=0,vu=!1;const _u=new fn;class xu{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:s=256,position:a=_u}=r;fu=this._renderer.getRenderTarget(),mu=this._renderer.getActiveCubeFace(),gu=this._renderer.getActiveMipmapLevel(),vu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,n,i,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Su(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=bu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(fu,mu,gu),this._renderer.xr.enabled=vu,t.scissorTest=!1,Mu(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===q||t.mapping===Y?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),fu=this._renderer.getRenderTarget(),mu=this._renderer.getActiveCubeFace(),gu=this._renderer.getActiveMipmapLevel(),vu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:rt,minFilter:rt,generateMipmaps:!1,type:ft,format:bt,colorSpace:we,depthBuffer:!1},i=yu(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=yu(t,e,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],n=[],i=[];let r=t;const s=t-4+1+hu.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);e.push(s);let o=1/s;a>t-4?o=hu[a-t+4-1]:0===a&&(o=0),n.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),_=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];v.set(i,f*p*t),_.set(u,m*p*t);const r=[t,t,t,t,t,t];x.set(r,g*p*t)}const y=new Er;y.setAttribute("position",new mr(v,f)),y.setAttribute("uv",new mr(_,m)),y.setAttribute("faceIndex",new mr(x,g)),i.push(new Br(y,null)),r>4&&r--}return{lodMeshes:i,sizeLods:e,sigmas:n}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(uu),r=new fn(0,1,0),s=new jr({name:"SphericalGaussianBlur",defines:{n:uu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:wu(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(i,t,e),this._ggxMaterial=function(t,e,n){const i=new jr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:wu(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 3.2: Transform view direction to hemisphere configuration\n\t\t\t\tvec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tfloat lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n\t\t\t\tvec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(Vh, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + Vh.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(i,t,e)}return i}_compileMaterial(t){const e=new Br(new Er,t);this._renderer.compile(e,du)}_sceneToCubeUV(t,e,n,i,r){const s=new Kr(90,1,e,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,h=l.toneMapping;l.getClearColor(pu),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new Br(new kr,new or({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,d=u.material;let p=!1;const f=t.background;f?f.isColor&&(d.color.copy(f),t.background=null,p=!0):(d.color.copy(pu),p=!0);for(let m=0;m<6;m++){const e=m%3;0===e?(s.up.set(0,a[m],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+o[m],r.y,r.z)):1===e?(s.up.set(0,0,a[m]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+o[m],r.z)):(s.up.set(0,a[m],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+o[m]));const n=this._cubeSize;Mu(i,e*n,m>2?n:0,n,n),l.setRenderTarget(i),p&&l.render(u,s),l.render(t,s)}l.toneMapping=h,l.autoClear=c,t.background=f}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===q||t.mapping===Y;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Su()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=bu());const r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;r.uniforms.envMap.value=t;const a=this._cubeSize;Mu(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,du)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[n];a.material=s;const o=s.uniforms,l=n/(this._lodMeshes.length-1),c=e/(this._lodMeshes.length-1),h=Math.sqrt(l*l-c*c)*(0+1.25*l),{_lodMax:u}=this,d=this._sizeLods[n],p=3*d*(n>u-4?n-u+4:0),f=4*(this._cubeSize-d);o.envMap.value=t.texture,o.roughness.value=h,o.mipInt.value=u-e,Mu(r,p,f,3*d,2*d),i.setRenderTarget(r),i.render(a,du),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=u-n,Mu(t,p,f,3*d,2*d),i.setRenderTarget(t),i.render(a,du)}_blur(t,e,n,i,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,n,i,"latitudinal",r),this._halfBlur(s,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&Je("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const h=l.uniforms,u=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):uu;f>uu&&Ke(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let x=0;x<uu;++x){const t=x/p,e=Math.exp(-t*t/2);m.push(e),0===x?g+=e:x<f&&(g+=2*e)}for(let x=0;x<m.length;x++)m[x]=m[x]/g;h.envMap.value=t.texture,h.samples.value=f,h.weights.value=m,h.latitudinal.value="latitudinal"===s,a&&(h.poleAxis.value=a);const{_lodMax:v}=this;h.dTheta.value=d,h.mipInt.value=v-n;const _=this._sizeLods[i];Mu(e,3*_*(i>v-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(c,du)}}function yu(t,e,n){const i=new Un(t,e,n);return i.texture.mapping=J,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Mu(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function bu(){return new jr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:wu(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Su(){return new jr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:wu(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function wu(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Tu(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Z||s===K,o=s===q||s===Y;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new xu(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(null===n&&(n=new xu(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Eu(t){const e={};function n(n){if(void 0!==e[n])return e[n];const i=t.getExtension(n);return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&$e("WebGLRenderer: "+t+" extension not supported."),e}}}function Au(t,e,n,i){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const n in o.attributes)e.remove(o.attributes[n]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],s=t[e+2];n.push(i,r,r,s,s,i)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}}const o=new(Ve(n)?vr:gr)(n,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const r in i)e.update(i[r],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return s.get(t)}}}function Cu(t,e,n){let i,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(i,a,r,e*s,o),n.update(a,i,o))}this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(i,a,r,e*s),n.update(a,i,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,s,0,r,t,0,a);let o=0;for(let e=0;e<a;e++)o+=s[e];n.update(o,i,1)},this.renderMultiDrawInstances=function(t,o,l,c){if(0===l)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],c[e]);else{h.multiDrawElementsInstancedWEBGL(i,o,0,r,t,0,c,0,l);let e=0;for(let t=0;t<l;t++)e+=o[t]*c[t];n.update(e,i,1)}}}function Ru(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n;break;default:Je("WebGLInfo: Unknown draw mode:",i)}}}}function Pu(t,e,n){const i=new WeakMap,r=new Dn;return{update:function(s,a,o){const l=s.morphTargetInfluences,c=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=void 0!==c?c.length:0;let u=i.get(a);if(void 0===u||u.count!==h){let t=function(){v.dispose(),i.delete(a),a.removeEventListener("dispose",t)};void 0!==u&&u.texture.dispose();const n=void 0!==a.morphAttributes.position,s=void 0!==a.morphAttributes.normal,o=void 0!==a.morphAttributes.color,l=a.morphAttributes.position||[],c=a.morphAttributes.normal||[],d=a.morphAttributes.color||[];let p=0;!0===n&&(p=1),!0===s&&(p=2),!0===o&&(p=3);let f=a.attributes.position.count*p,m=1;f>e.maxTextureSize&&(m=Math.ceil(f/e.maxTextureSize),f=e.maxTextureSize);const g=new Float32Array(f*m*4*h),v=new On(g,f,m,h);v.type=pt,v.needsUpdate=!0;const _=4*p;for(let e=0;e<h;e++){const t=l[e],i=c[e],a=d[e],h=f*m*4*e;for(let e=0;e<t.count;e++){const l=e*_;!0===n&&(r.fromBufferAttribute(t,e),g[h+l+0]=r.x,g[h+l+1]=r.y,g[h+l+2]=r.z,g[h+l+3]=0),!0===s&&(r.fromBufferAttribute(i,e),g[h+l+4]=r.x,g[h+l+5]=r.y,g[h+l+6]=r.z,g[h+l+7]=0),!0===o&&(r.fromBufferAttribute(a,e),g[h+l+8]=r.x,g[h+l+9]=r.y,g[h+l+10]=r.z,g[h+l+11]=4===a.itemSize?r.w:1)}}u={count:h,texture:v,size:new dn(f,m)},i.set(a,u),a.addEventListener("dispose",t)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let e=0;for(let t=0;t<l.length;t++)e+=l[t];const n=a.morphTargetsRelative?1:1-e;o.getUniforms().setValue(t,"morphTargetBaseInfluence",n),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",u.texture,n),o.getUniforms().setValue(t,"morphTargetsTextureSize",u.size)}}}function Iu(t,e,n,i){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(a){const o=i.render.frame,l=a.geometry,c=e.get(a,l);if(r.get(c)!==o&&(e.update(c),r.set(c,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(n.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return c},dispose:function(){r=new WeakMap}}}const Lu={[F]:"LINEAR_TONE_MAPPING",[B]:"REINHARD_TONE_MAPPING",[z]:"CINEON_TONE_MAPPING",[k]:"ACES_FILMIC_TONE_MAPPING",[G]:"AGX_TONE_MAPPING",[H]:"NEUTRAL_TONE_MAPPING",[V]:"CUSTOM_TONE_MAPPING"};function Du(t,e,n,i,r){const s=new Un(e,n,{type:t,depthBuffer:i,stencilBuffer:r}),a=new Un(e,n,{type:ft,depthBuffer:!1,stencilBuffer:!1}),o=new Er;o.setAttribute("position",new _r([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new _r([0,2,0,0,2,0],2));const l=new Rl({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),c=new Br(o,l),h=new Tc(-1,1,1,-1,0,1);let u,d=null,p=null,f=!1,m=null,g=[],v=!1;this.setSize=function(t,e){s.setSize(t,e),a.setSize(t,e);for(let n=0;n<g.length;n++){const i=g[n];i.setSize&&i.setSize(t,e)}},this.setEffects=function(t){g=t,v=g.length>0&&!0===g[0].isRenderPass;const e=s.width,n=s.height;for(let i=0;i<g.length;i++){const t=g[i];t.setSize&&t.setSize(e,n)}},this.begin=function(t,e){if(f)return!1;if(0===t.toneMapping&&0===g.length)return!1;if(m=e,null!==e){const t=e.width,n=e.height;s.width===t&&s.height===n||this.setSize(t,n)}return!1===v&&t.setRenderTarget(s),u=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(t,e){t.toneMapping=u,f=!0;let n=s,i=a;for(let r=0;r<g.length;r++){const s=g[r];if(!1!==s.enabled&&(s.render(t,i,n,e),!1!==s.needsSwap)){const t=n;n=i,i=t}}if(d!==t.outputColorSpace||p!==t.toneMapping){d=t.outputColorSpace,p=t.toneMapping,l.defines={},bn.getTransfer(d)===Ee&&(l.defines.SRGB_TRANSFER="");const e=Lu[p];e&&(l.defines[e]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=n.texture,t.setRenderTarget(m),t.render(c,h),m=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){s.dispose(),a.dispose(),o.dispose(),l.dispose()}}const Nu=new Ln,Uu=new $a(1,1),Ou=new On,Fu=new Fn,Bu=new Qr,zu=[],ku=[],Vu=new Float32Array(16),Gu=new Float32Array(9),Hu=new Float32Array(4);function Wu(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let s=zu[r];if(void 0===s&&(s=new Float32Array(r),zu[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function ju(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function Xu(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function qu(t,e){let n=ku[e];void 0===n&&(n=new Int32Array(e),ku[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function Yu(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Zu(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ju(n,e))return;t.uniform2fv(this.addr,e),Xu(n,e)}}function Ku(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ju(n,e))return;t.uniform3fv(this.addr,e),Xu(n,e)}}function Ju(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ju(n,e))return;t.uniform4fv(this.addr,e),Xu(n,e)}}function $u(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ju(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Xu(n,e)}else{if(ju(n,i))return;Hu.set(i),t.uniformMatrix2fv(this.addr,!1,Hu),Xu(n,i)}}function Qu(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ju(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Xu(n,e)}else{if(ju(n,i))return;Gu.set(i),t.uniformMatrix3fv(this.addr,!1,Gu),Xu(n,i)}}function td(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ju(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Xu(n,e)}else{if(ju(n,i))return;Vu.set(i),t.uniformMatrix4fv(this.addr,!1,Vu),Xu(n,i)}}function ed(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function nd(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ju(n,e))return;t.uniform2iv(this.addr,e),Xu(n,e)}}function id(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ju(n,e))return;t.uniform3iv(this.addr,e),Xu(n,e)}}function rd(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ju(n,e))return;t.uniform4iv(this.addr,e),Xu(n,e)}}function sd(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ad(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ju(n,e))return;t.uniform2uiv(this.addr,e),Xu(n,e)}}function od(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ju(n,e))return;t.uniform3uiv(this.addr,e),Xu(n,e)}}function ld(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ju(n,e))return;t.uniform4uiv(this.addr,e),Xu(n,e)}}function cd(t,e,n){const i=this.cache,r=n.allocateTextureUnit();let s;i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Uu.compareFunction=n.isReversedDepthBuffer()?Ne:Ie,s=Uu):s=Nu,n.setTexture2D(e||s,r)}function hd(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||Fu,r)}function ud(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||Bu,r)}function dd(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||Ou,r)}function pd(t,e){t.uniform1fv(this.addr,e)}function fd(t,e){const n=Wu(e,this.size,2);t.uniform2fv(this.addr,n)}function md(t,e){const n=Wu(e,this.size,3);t.uniform3fv(this.addr,n)}function gd(t,e){const n=Wu(e,this.size,4);t.uniform4fv(this.addr,n)}function vd(t,e){const n=Wu(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function _d(t,e){const n=Wu(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function xd(t,e){const n=Wu(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function yd(t,e){t.uniform1iv(this.addr,e)}function Md(t,e){t.uniform2iv(this.addr,e)}function bd(t,e){t.uniform3iv(this.addr,e)}function Sd(t,e){t.uniform4iv(this.addr,e)}function wd(t,e){t.uniform1uiv(this.addr,e)}function Td(t,e){t.uniform2uiv(this.addr,e)}function Ed(t,e){t.uniform3uiv(this.addr,e)}function Ad(t,e){t.uniform4uiv(this.addr,e)}function Cd(t,e,n){const i=this.cache,r=e.length,s=qu(n,r);let a;ju(i,s)||(t.uniform1iv(this.addr,s),Xu(i,s)),a=this.type===t.SAMPLER_2D_SHADOW?Uu:Nu;for(let o=0;o!==r;++o)n.setTexture2D(e[o]||a,s[o])}function Rd(t,e,n){const i=this.cache,r=e.length,s=qu(n,r);ju(i,s)||(t.uniform1iv(this.addr,s),Xu(i,s));for(let a=0;a!==r;++a)n.setTexture3D(e[a]||Fu,s[a])}function Pd(t,e,n){const i=this.cache,r=e.length,s=qu(n,r);ju(i,s)||(t.uniform1iv(this.addr,s),Xu(i,s));for(let a=0;a!==r;++a)n.setTextureCube(e[a]||Bu,s[a])}function Id(t,e,n){const i=this.cache,r=e.length,s=qu(n,r);ju(i,s)||(t.uniform1iv(this.addr,s),Xu(i,s));for(let a=0;a!==r;++a)n.setTexture2DArray(e[a]||Ou,s[a])}class Ld{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Yu;case 35664:return Zu;case 35665:return Ku;case 35666:return Ju;case 35674:return $u;case 35675:return Qu;case 35676:return td;case 5124:case 35670:return ed;case 35667:case 35671:return nd;case 35668:case 35672:return id;case 35669:case 35673:return rd;case 5125:return sd;case 36294:return ad;case 36295:return od;case 36296:return ld;case 35678:case 36198:case 36298:case 36306:case 35682:return cd;case 35679:case 36299:case 36307:return hd;case 35680:case 36300:case 36308:case 36293:return ud;case 36289:case 36303:case 36311:case 36292:return dd}}(e.type)}}class Dd{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return pd;case 35664:return fd;case 35665:return md;case 35666:return gd;case 35674:return vd;case 35675:return _d;case 35676:return xd;case 5124:case 35670:return yd;case 35667:case 35671:return Md;case 35668:case 35672:return bd;case 35669:case 35673:return Sd;case 5125:return wd;case 36294:return Td;case 36295:return Ed;case 36296:return Ad;case 35678:case 36198:case 36298:case 36306:case 35682:return Cd;case 35679:case 36299:case 36307:return Rd;case 35680:case 36300:case 36308:case 36293:return Pd;case 36289:case 36303:case 36311:case 36292:return Id}}(e.type)}}class Nd{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(t,e[s.id],n)}}}const Ud=/(\w+)(\])?(\[|\.)?/g;function Od(t,e){t.seq.push(e),t.map[e.id]=e}function Fd(t,e,n){const i=t.name,r=i.length;for(Ud.lastIndex=0;;){const s=Ud.exec(i),a=Ud.lastIndex;let o=s[1];const l="]"===s[2],c=s[3];if(l&&(o|=0),void 0===c||"["===c&&a+2===r){Od(n,void 0===c?new Ld(o,t,e):new Dd(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new Nd(o),Od(n,t)),n=t}}}class Bd{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const n=t.getActiveUniform(e,s);Fd(n,t.getUniformLocation(e,n.name),this)}const i=[],r=[];for(const s of this.seq)s.type===t.SAMPLER_2D_SHADOW||s.type===t.SAMPLER_CUBE_SHADOW||s.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(s):r.push(s);i.length>0&&(this.seq=i.concat(r))}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=n[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function zd(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}let kd=0;const Vd=new vn;function Gd(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(i&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const i=parseInt(s[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=r;a<s;a++){const t=a+1;i.push(`${t===e?">":" "} ${t}: ${n[a]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function Hd(t,e){const n=function(t){bn._getMatrix(Vd,bn.workingColorSpace,t);const e=`mat3( ${Vd.elements.map(t=>t.toFixed(4))} )`;switch(bn.getTransfer(t)){case Te:return[e,"LinearTransferOETF"];case Ee:return[e,"sRGBTransferOETF"];default:return Ke("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}const Wd={[F]:"Linear",[B]:"Reinhard",[z]:"Cineon",[k]:"ACESFilmic",[G]:"AgX",[H]:"Neutral",[V]:"Custom"};function jd(t,e){const n=Wd[e];return void 0===n?(Ke("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Xd=new fn;function qd(){bn.getLuminanceCoefficients(Xd);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Xd.x.toFixed(4)}, ${Xd.y.toFixed(4)}, ${Xd.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Yd(t){return""!==t}function Zd(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Kd(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Jd=/^[ \t]*#include +<([\w\d./]+)>/gm;function $d(t){return t.replace(Jd,tp)}const Qd=new Map;function tp(t,e){let n=$h[e];if(void 0===n){const t=Qd.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=$h[t],Ke('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return $d(n)}const ep=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function np(t){return t.replace(ep,ip)}function ip(t,e,n,i){let r="";for(let s=parseInt(e);s<parseInt(n);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function rp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const sp={[i]:"SHADOWMAP_TYPE_PCF",[r]:"SHADOWMAP_TYPE_VSM"};const ap={[q]:"ENVMAP_TYPE_CUBE",[Y]:"ENVMAP_TYPE_CUBE",[J]:"ENVMAP_TYPE_CUBE_UV"};const op={[Y]:"ENVMAP_MODE_REFRACTION"};const lp={[N]:"ENVMAP_BLENDING_MULTIPLY",[U]:"ENVMAP_BLENDING_MIX",[O]:"ENVMAP_BLENDING_ADD"};function cp(t,e,n,i){const r=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(t){return sp[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),c=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":ap[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),h=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":op[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),u=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":lp[t.combine]||"ENVMAP_BLENDING_NONE"}(n),d=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Yd).join("\n")}(n),f=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(s),m=r.createProgram();let g,v,_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Yd).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Yd).join("\n"),v.length>0&&(v+="\n")):(g=[rp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Yd).join("\n"),v=[rp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?$h.tonemapping_pars_fragment:"",0!==n.toneMapping?jd("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",$h.colorspace_pars_fragment,Hd("linearToOutputTexel",n.outputColorSpace),qd(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Yd).join("\n")),a=$d(a),a=Zd(a,n),a=Kd(a,n),o=$d(o),o=Zd(o,n),o=Kd(o,n),a=np(a),o=np(o),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Be?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Be?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const x=_+g+a,y=_+v+o,M=zd(r,r.VERTEX_SHADER,x),b=zd(r,r.FRAGMENT_SHADER,y);function S(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m)||"",i=r.getShaderInfoLog(M)||"",s=r.getShaderInfoLog(b)||"",a=n.trim(),o=i.trim(),l=s.trim();let c=!0,h=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(c=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,M,b);else{const t=Gd(r,M,"vertex"),n=Gd(r,b,"fragment");Je("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+n)}else""!==a?Ke("WebGLProgram: Program Info Log:",a):""!==o&&""!==l||(h=!1);h&&(e.diagnostics={runnable:c,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(M),r.deleteShader(b),w=new Bd(r,m),T=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),s=i.name;let a=1;i.type===t.FLOAT_MAT2&&(a=2),i.type===t.FLOAT_MAT3&&(a=3),i.type===t.FLOAT_MAT4&&(a=4),n[s]={type:i.type,location:t.getAttribLocation(e,s),locationSize:a}}return n}(r,m)}let w,T;r.attachShader(m,M),r.attachShader(m,b),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===w&&S(this),w},this.getAttributes=function(){return void 0===T&&S(this),T};let E=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=r.getProgramParameter(m,37297)),E},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=kd++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=M,this.fragmentShader=b,this}let hp=0;class up{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),s=this._getShaderCacheForMaterial(t);return!1===s.has(i)&&(s.add(i),i.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,0===n.usedTimes&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new dp(t),e.set(t,n)),n}}class dp{constructor(t){this.id=hp++,this.code=t,this.usedTimes=0}}function pp(t,e,n,i,r,s,a){const o=new bi,l=new up,c=new Set,h=[],u=new Map,d=r.logarithmicDepthBuffer;let p=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(t){return c.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,h,u,g){const v=u.fog,_=g.geometry,x=s.isMeshStandardMaterial?u.environment:null,y=(s.isMeshStandardMaterial?n:e).get(s.envMap||x),M=y&&y.mapping===J?y.image.height:null,b=f[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&Ke("WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const S=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,w=void 0!==S?S.length:0;let T,E,A,C,R=0;if(void 0!==_.morphAttributes.position&&(R=1),void 0!==_.morphAttributes.normal&&(R=2),void 0!==_.morphAttributes.color&&(R=3),b){const t=tu[b];T=t.vertexShader,E=t.fragmentShader}else T=s.vertexShader,E=s.fragmentShader,l.update(s),A=l.getVertexShaderID(s),C=l.getFragmentShaderID(s);const P=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),L=!0===g.isInstancedMesh,D=!0===g.isBatchedMesh,N=!!s.map,U=!!s.matcap,O=!!y,F=!!s.aoMap,B=!!s.lightMap,z=!!s.bumpMap,k=!!s.normalMap,V=!!s.displacementMap,G=!!s.emissiveMap,H=!!s.metalnessMap,W=!!s.roughnessMap,j=s.anisotropy>0,X=s.clearcoat>0,q=s.dispersion>0,Y=s.iridescence>0,Z=s.sheen>0,K=s.transmission>0,$=j&&!!s.anisotropyMap,Q=X&&!!s.clearcoatMap,tt=X&&!!s.clearcoatNormalMap,et=X&&!!s.clearcoatRoughnessMap,nt=Y&&!!s.iridescenceMap,it=Y&&!!s.iridescenceThicknessMap,rt=Z&&!!s.sheenColorMap,st=Z&&!!s.sheenRoughnessMap,at=!!s.specularMap,ot=!!s.specularColorMap,lt=!!s.specularIntensityMap,ct=K&&!!s.transmissionMap,ht=K&&!!s.thicknessMap,ut=!!s.gradientMap,dt=!!s.alphaMap,pt=s.alphaTest>0,ft=!!s.alphaHash,mt=!!s.extensions;let gt=0;s.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(gt=t.toneMapping));const vt={shaderID:b,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:E,defines:s.defines,customVertexShaderID:A,customFragmentShaderID:C,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:D,batchingColor:D&&null!==g._colorsTexture,instancing:L,instancingColor:L&&null!==g.instanceColor,instancingMorph:L&&null!==g.morphTexture,outputColorSpace:null===P?t.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:we,alphaToCoverage:!!s.alphaToCoverage,map:N,matcap:U,envMap:O,envMapMode:O&&y.mapping,envMapCubeUVHeight:M,aoMap:F,lightMap:B,bumpMap:z,normalMap:k,displacementMap:V,emissiveMap:G,normalMapObjectSpace:k&&1===s.normalMapType,normalMapTangentSpace:k&&0===s.normalMapType,metalnessMap:H,roughnessMap:W,anisotropy:j,anisotropyMap:$,clearcoat:X,clearcoatMap:Q,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:q,iridescence:Y,iridescenceMap:nt,iridescenceThicknessMap:it,sheen:Z,sheenColorMap:rt,sheenRoughnessMap:st,specularMap:at,specularColorMap:ot,specularIntensityMap:lt,transmission:K,transmissionMap:ct,thicknessMap:ht,gradientMap:ut,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:dt,alphaTest:pt,alphaHash:ft,combine:s.combine,mapUv:N&&m(s.map.channel),aoMapUv:F&&m(s.aoMap.channel),lightMapUv:B&&m(s.lightMap.channel),bumpMapUv:z&&m(s.bumpMap.channel),normalMapUv:k&&m(s.normalMap.channel),displacementMapUv:V&&m(s.displacementMap.channel),emissiveMapUv:G&&m(s.emissiveMap.channel),metalnessMapUv:H&&m(s.metalnessMap.channel),roughnessMapUv:W&&m(s.roughnessMap.channel),anisotropyMapUv:$&&m(s.anisotropyMap.channel),clearcoatMapUv:Q&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:tt&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:it&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:st&&m(s.sheenRoughnessMap.channel),specularMapUv:at&&m(s.specularMap.channel),specularColorMapUv:ot&&m(s.specularColorMap.channel),specularIntensityMapUv:lt&&m(s.specularIntensityMap.channel),transmissionMapUv:ct&&m(s.transmissionMap.channel),thicknessMapUv:ht&&m(s.thicknessMap.channel),alphaMapUv:dt&&m(s.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(k||j),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!_.attributes.uv&&(N||dt),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading&&!1===s.wireframe,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:w,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:gt,decodeVideoTexture:N&&!0===s.map.isVideoTexture&&bn.getTransfer(s.map.colorSpace)===Ee,decodeVideoTextureEmissive:G&&!0===s.emissiveMap.isVideoTexture&&bn.getTransfer(s.emissiveMap.colorSpace)===Ee,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:mt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(mt&&!0===s.extensions.multiDraw||D)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return vt.vertexUv1s=c.has(1),vt.vertexUv2s=c.has(2),vt.vertexUv3s=c.has(3),c.clear(),vt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){o.disableAll(),e.instancing&&o.enable(0);e.instancingColor&&o.enable(1);e.instancingMorph&&o.enable(2);e.matcap&&o.enable(3);e.envMap&&o.enable(4);e.normalMapObjectSpace&&o.enable(5);e.normalMapTangentSpace&&o.enable(6);e.clearcoat&&o.enable(7);e.iridescence&&o.enable(8);e.alphaTest&&o.enable(9);e.vertexColors&&o.enable(10);e.vertexAlphas&&o.enable(11);e.vertexUv1s&&o.enable(12);e.vertexUv2s&&o.enable(13);e.vertexUv3s&&o.enable(14);e.vertexTangents&&o.enable(15);e.anisotropy&&o.enable(16);e.alphaHash&&o.enable(17);e.batching&&o.enable(18);e.dispersion&&o.enable(19);e.batchingColor&&o.enable(20);e.gradientMap&&o.enable(21);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reversedDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=tu[e];n=Wr.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i=u.get(n);return void 0!==i?++i.usedTimes:(i=new cp(t,n,e,s),h.push(i),u.set(n,i)),i},releaseProgram:function(t){if(0===--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),u.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){l.remove(t)},programs:h,dispose:function(){l.dispose()}}}function fp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function mp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function gp(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function vp(){const t=[];let e=0;const n=[],i=[],r=[];function s(n,i,r,s,a,o){let l=t[e];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:s,renderOrder:n.renderOrder,z:a,group:o},t[e]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=s,l.renderOrder=n.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||mp),i.length>1&&i.sort(e||gp),r.length>1&&r.sort(e||gp)}}}function _p(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new vp,t.set(e,[r])):n>=i.length?(r=new vp,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function xp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new fn,color:new ir};break;case"SpotLight":n={position:new fn,direction:new fn,color:new ir,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new fn,color:new ir,distance:0,decay:0};break;case"HemisphereLight":n={direction:new fn,skyColor:new ir,groundColor:new ir};break;case"RectAreaLight":n={color:new ir,position:new fn,halfWidth:new fn,halfHeight:new fn}}return t[e.id]=n,n}}}let yp=0;function Mp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function bp(t){const e=new xp,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dn,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let o=0;o<9;o++)i.probe.push(new fn);const r=new fn,s=new ui,a=new ui;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,_=0;r.sort(Mp);for(let t=0,y=r.length;t<y;t++){const x=r[t],y=x.color,M=x.intensity,b=x.distance;let S=null;if(x.shadow&&x.shadow.map&&(S=x.shadow.map.texture.format===At?x.shadow.map.texture:x.shadow.map.depthTexture||x.shadow.map.texture),x.isAmbientLight)s+=y.r*M,a+=y.g*M,o+=y.b*M;else if(x.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(x.sh.coefficients[t],M);_++}else if(x.isDirectionalLight){const t=e.get(x);if(t.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){const t=x.shadow,e=n.get(x);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=S,i.directionalShadowMatrix[l]=x.shadow.matrix,p++}i.directional[l]=t,l++}else if(x.isSpotLight){const t=e.get(x);t.position.setFromMatrixPosition(x.matrixWorld),t.color.copy(y).multiplyScalar(M),t.distance=b,t.coneCos=Math.cos(x.angle),t.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),t.decay=x.decay,i.spot[h]=t;const r=x.shadow;if(x.map&&(i.spotLightMap[g]=x.map,g++,r.updateMatrices(x),x.castShadow&&v++),i.spotLightMatrix[h]=r.matrix,x.castShadow){const t=n.get(x);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,i.spotShadow[h]=t,i.spotShadowMap[h]=S,m++}h++}else if(x.isRectAreaLight){const t=e.get(x);t.color.copy(y).multiplyScalar(M),t.halfWidth.set(.5*x.width,0,0),t.halfHeight.set(0,.5*x.height,0),i.rectArea[u]=t,u++}else if(x.isPointLight){const t=e.get(x);if(t.color.copy(x.color).multiplyScalar(x.intensity),t.distance=x.distance,t.decay=x.decay,x.castShadow){const t=x.shadow,e=n.get(x);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,i.pointShadow[c]=e,i.pointShadowMap[c]=S,i.pointShadowMatrix[c]=x.shadow.matrix,f++}i.point[c]=t,c++}else if(x.isHemisphereLight){const t=e.get(x);t.skyColor.copy(x.color).multiplyScalar(M),t.groundColor.copy(x.groundColor).multiplyScalar(M),i.hemi[d]=t,d++}}u>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=Qh.LTC_FLOAT_1,i.rectAreaLTC2=Qh.LTC_FLOAT_2):(i.rectAreaLTC1=Qh.LTC_HALF_1,i.rectAreaLTC2=Qh.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===h&&x.rectAreaLength===u&&x.hemiLength===d&&x.numDirectionalShadows===p&&x.numPointShadows===f&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===_||(i.directional.length=l,i.spot.length=h,i.rectArea.length=u,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=_,x.directionalLength=l,x.pointLength=c,x.spotLength=h,x.rectAreaLength=u,x.hemiLength=d,x.numDirectionalShadows=p,x.numPointShadows=f,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=_,i.version=yp++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let d=0,p=t.length;d<p;d++){const e=t[d];if(e.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(e.matrixWorld),r.setFromMatrixPosition(e.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),n++}else if(e.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(e.matrixWorld),r.setFromMatrixPosition(e.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),l++}else if(e.isRectAreaLight){const t=i.rectArea[c];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),a.identity(),s.copy(e.matrixWorld),s.premultiply(u),a.extractRotation(s),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),c++}else if(e.isPointLight){const t=i.point[o];t.position.setFromMatrixPosition(e.matrixWorld),t.position.applyMatrix4(u),o++}else if(e.isHemisphereLight){const t=i.hemi[h];t.direction.setFromMatrixPosition(e.matrixWorld),t.direction.transformDirection(u),h++}}},state:i}}function Sp(t){const e=new bp(t),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,n.length=0,i.length=0},state:r,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)}}}function wp(t){let e=new WeakMap;return{get:function(n,i=0){const r=e.get(n);let s;return void 0===r?(s=new Sp(t),e.set(n,[s])):i>=r.length?(s=new Sp(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}const Tp=[new fn(1,0,0),new fn(-1,0,0),new fn(0,1,0),new fn(0,-1,0),new fn(0,0,1),new fn(0,0,-1)],Ep=[new fn(0,-1,0),new fn(0,-1,0),new fn(0,0,1),new fn(0,0,-1),new fn(0,-1,0),new fn(0,-1,0)],Ap=new ui,Cp=new fn,Rp=new fn;function Pp(t,e,n){let i=new aa;const r=new dn,l=new dn,c=new Dn,h=new Ol,u=new Fl,d={},p=n.maxTextureSize,f={[s]:1,[a]:0,[o]:2},m=new jr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new dn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const v=new Er;v.setAttribute("position",new mr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Br(v,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let y=this.type;function M(n,i){const s=e.update(_);m.defines.VSM_SAMPLES!==n.blurSamples&&(m.defines.VSM_SAMPLES=n.blurSamples,g.defines.VSM_SAMPLES=n.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Un(r.x,r.y,{format:At,type:ft})),m.uniforms.shadow_pass.value=n.map.depthTexture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,m,_,null),g.uniforms.shadow_pass.value=n.mapPass.texture,g.uniforms.resolution.value=n.mapSize,g.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,g,_,null)}function b(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?u:h,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const t=s.uuid,e=n.uuid;let i=d[t];void 0===i&&(i={},d[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",w)),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:f[n.side],s.alphaMap=n.alphaMap,s.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=i}return s}function S(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;c<h;c++){const h=e[c],u=l[h.materialIndex];if(u&&u.visible){const e=b(n,u,a,o);n.onBeforeShadow(t,n,r,s,i,e,h),t.renderBufferDirect(s,null,i,e,n,h),n.onAfterShadow(t,n,r,s,i,e,h)}}}else if(l.visible){const e=b(n,l,a,o);n.onBeforeShadow(t,n,r,s,i,e,null),t.renderBufferDirect(s,null,i,e,n,null),n.onAfterShadow(t,n,r,s,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)S(l[t],r,s,a,o)}function w(t){t.target.removeEventListener("dispose",w);for(const e in d){const n=d[e],i=t.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(e,n,s){if(!1===x.enabled)return;if(!1===x.autoUpdate&&!1===x.needsUpdate)return;if(0===e.length)return;2===e.type&&(Ke("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),e.type=1);const a=t.getRenderTarget(),o=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const d=y!==this.type;d&&n.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.needsUpdate=!0):t.material.needsUpdate=!0)});for(let f=0,m=e.length;f<m;f++){const a=e[f],o=a.shadow;if(void 0===o){Ke("WebGLShadowMap:",a,"has no shadow.");continue}if(!1===o.autoUpdate&&!1===o.needsUpdate)continue;r.copy(o.mapSize);const h=o.getFrameExtents();if(r.multiply(h),l.copy(o.mapSize),(r.x>p||r.y>p)&&(r.x>p&&(l.x=Math.floor(p/h.x),r.x=l.x*h.x,o.mapSize.x=l.x),r.y>p&&(l.y=Math.floor(p/h.y),r.y=l.y*h.y,o.mapSize.y=l.y)),null===o.map||!0===d){if(null!==o.map&&(null!==o.map.depthTexture&&(o.map.depthTexture.dispose(),o.map.depthTexture=null),o.map.dispose()),3===this.type){if(a.isPointLight){Ke("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}o.map=new Un(r.x,r.y,{format:At,type:ft,minFilter:rt,magFilter:rt,generateMipmaps:!1}),o.map.texture.name=a.name+".shadowMap",o.map.depthTexture=new $a(r.x,r.y,pt),o.map.depthTexture.name=a.name+".shadowMapDepth",o.map.depthTexture.format=St,o.map.depthTexture.compareFunction=null,o.map.depthTexture.minFilter=et,o.map.depthTexture.magFilter=et}else{a.isPointLight?(o.map=new ts(r.x),o.map.depthTexture=new Qa(r.x,dt)):(o.map=new Un(r.x,r.y),o.map.depthTexture=new $a(r.x,r.y,dt)),o.map.depthTexture.name=a.name+".shadowMap",o.map.depthTexture.format=St;const e=t.state.buffers.depth.getReversed();1===this.type?(o.map.depthTexture.compareFunction=e?Ne:Ie,o.map.depthTexture.minFilter=rt,o.map.depthTexture.magFilter=rt):(o.map.depthTexture.compareFunction=null,o.map.depthTexture.minFilter=et,o.map.depthTexture.magFilter=et)}o.camera.updateProjectionMatrix()}const m=o.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e<m;e++){if(o.map.isWebGLCubeRenderTarget)t.setRenderTarget(o.map,e),t.clear();else{0===e&&(t.setRenderTarget(o.map),t.clear());const n=o.getViewport(e);c.set(l.x*n.x,l.y*n.y,l.x*n.z,l.y*n.w),u.viewport(c)}if(a.isPointLight){const t=o.camera,n=o.matrix,i=a.distance||t.far;i!==t.far&&(t.far=i,t.updateProjectionMatrix()),Cp.setFromMatrixPosition(a.matrixWorld),t.position.copy(Cp),Rp.copy(t.position),Rp.add(Tp[e]),t.up.copy(Ep[e]),t.lookAt(Rp),t.updateMatrixWorld(),n.makeTranslation(-Cp.x,-Cp.y,-Cp.z),Ap.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),o._frustum.setFromProjectionMatrix(Ap,t.coordinateSystem,t.reversedDepth)}else o.updateMatrices(a);i=o.getFrustum(),S(n,s,o.camera,a,this.type)}!0!==o.isPointLightShadow&&3===this.type&&M(o,s),o.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(a,o,h)}}const Ip={[E]:1,[C]:6,[P]:7,[R]:5,[A]:0,[L]:2,[D]:4,[I]:3};function Lp(t,e){const n=new function(){let e=!1;const n=new Dn;let i=null;const r=new Dn(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,s,a,o){!0===o&&(e*=a,i*=a,s*=a),n.set(e,i,s,a),!1===r.equals(n)&&(t.clearColor(e,i,s,a),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,s=null,a=null;return{setReversed:function(t){if(i!==t){const n=e.get("EXT_clip_control");t?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=t;const r=a;a=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(e){e?rt(t.DEPTH_TEST):st(t.DEPTH_TEST)},setMask:function(e){r===e||n||(t.depthMask(e),r=e)},setFunc:function(e){if(i&&(e=Ip[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){n=t},setClear:function(e){a!==e&&(i&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){n=!1,r=null,s=null,a=null,i=!1}}},r=new function(){let e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(n){e||(n?rt(t.STENCIL_TEST):st(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,a){i===e&&r===n&&s===a||(t.stencilFunc(e,n,a),i=e,r=n,s=a)},setOp:function(e,n,i){a===e&&o===n&&l===i||(t.stencilOp(e,n,i),a=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,c=null}}},s=new WeakMap,a=new WeakMap;let o={},E={},A=new WeakMap,C=[],R=null,P=!1,I=null,L=null,D=null,N=null,U=null,O=null,F=null,B=new ir(0,0,0),z=0,k=!1,V=null,G=null,H=null,W=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,Y=0;const Z=t.getParameter(t.VERSION);-1!==Z.indexOf("WebGL")?(Y=parseFloat(/^WebGL (\d)/.exec(Z)[1]),q=Y>=1):-1!==Z.indexOf("OpenGL ES")&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),q=Y>=2);let K=null,J={};const $=t.getParameter(t.SCISSOR_BOX),Q=t.getParameter(t.VIEWPORT),tt=(new Dn).fromArray($),et=(new Dn).fromArray(Q);function nt(e,n,i,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let o=0;o<i;o++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(n+o,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const it={};function rt(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function st(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}it[t.TEXTURE_2D]=nt(t.TEXTURE_2D,t.TEXTURE_2D,1),it[t.TEXTURE_CUBE_MAP]=nt(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),it[t.TEXTURE_2D_ARRAY]=nt(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),it[t.TEXTURE_3D]=nt(t.TEXTURE_3D,t.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),rt(t.DEPTH_TEST),i.setFunc(3),ct(!1),ht(1),rt(t.CULL_FACE),lt(0);const at={[l]:t.FUNC_ADD,[c]:t.FUNC_SUBTRACT,[h]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[u]:t.ZERO,[d]:t.ONE,[p]:t.SRC_COLOR,[m]:t.SRC_ALPHA,[M]:t.SRC_ALPHA_SATURATE,[x]:t.DST_COLOR,[v]:t.DST_ALPHA,[f]:t.ONE_MINUS_SRC_COLOR,[g]:t.ONE_MINUS_SRC_ALPHA,[y]:t.ONE_MINUS_DST_COLOR,[_]:t.ONE_MINUS_DST_ALPHA,[b]:t.CONSTANT_COLOR,[S]:t.ONE_MINUS_CONSTANT_COLOR,[w]:t.CONSTANT_ALPHA,[T]:t.ONE_MINUS_CONSTANT_ALPHA};function lt(e,n,i,r,s,a,o,c,h,u){if(0!==e){if(!1===P&&(rt(t.BLEND),P=!0),5===e)s=s||n,a=a||i,o=o||r,n===L&&s===U||(t.blendEquationSeparate(at[n],at[s]),L=n,U=s),i===D&&r===N&&a===O&&o===F||(t.blendFuncSeparate(ot[i],ot[r],ot[a],ot[o]),D=i,N=r,O=a,F=o),!1!==c.equals(B)&&h===z||(t.blendColor(c.r,c.g,c.b,h),B.copy(c),z=h),I=e,k=!1;else if(e!==I||u!==k){if(L===l&&U===l||(t.blendEquation(t.FUNC_ADD),L=l,U=l),u)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Je("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:Je("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:Je("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Je("WebGLState: Invalid blending: ",e)}D=null,N=null,O=null,F=null,B.set(0,0,0),z=0,I=e,k=u}}else!0===P&&(st(t.BLEND),P=!1)}function ct(e){V!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),V=e)}function ht(e){0!==e?(rt(t.CULL_FACE),e!==G&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):st(t.CULL_FACE),G=e}function ut(e,n,i){e?(rt(t.POLYGON_OFFSET_FILL),W===n&&j===i||(t.polygonOffset(n,i),W=n,j=i)):st(t.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:rt,disable:st,bindFramebuffer:function(e,n){return E[e]!==n&&(t.bindFramebuffer(e,n),E[e]=n,e===t.DRAW_FRAMEBUFFER&&(E[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(E[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=C,r=!1;if(e){i=A.get(n),void 0===i&&(i=[],A.set(n,i));const s=e.textures;if(i.length!==s.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=s.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=s.length,r=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,r=!0);r&&t.drawBuffers(i)},useProgram:function(e){return R!==e&&(t.useProgram(e),R=e,!0)},setBlending:lt,setMaterial:function(e,s){2===e.side?st(t.CULL_FACE):rt(t.CULL_FACE);let a=1===e.side;s&&(a=!a),ct(a),1===e.blending&&!1===e.transparent?lt(0):lt(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),n.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),ut(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?rt(t.SAMPLE_ALPHA_TO_COVERAGE):st(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ct,setCullFace:ht,setLineWidth:function(e){e!==H&&(q&&t.lineWidth(e),H=e)},setPolygonOffset:ut,setScissorTest:function(e){e?rt(t.SCISSOR_TEST):st(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),K!==e&&(t.activeTexture(e),K=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===K?t.TEXTURE0+X-1:K);let r=J[i];void 0===r&&(r={type:void 0,texture:void 0},J[i]=r),r.type===e&&r.texture===n||(K!==i&&(t.activeTexture(i),K=i),t.bindTexture(e,n||it[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=J[K];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(e){Je("WebGLState:",e)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(e){Je("WebGLState:",e)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(e){Je("WebGLState:",e)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(e){Je("WebGLState:",e)}},updateUBOMapping:function(e,n){let i=a.get(n);void 0===i&&(i=new WeakMap,a.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=a.get(n).get(e);s.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),s.set(n,i))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(e){Je("WebGLState:",e)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(e){Je("WebGLState:",e)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(e){Je("WebGLState:",e)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(e){Je("WebGLState:",e)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(e){Je("WebGLState:",e)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(e){Je("WebGLState:",e)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),i.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},K=null,J={},E={},A=new WeakMap,C=[],R=null,P=!1,I=null,L=null,D=null,N=null,U=null,O=null,F=null,B=new ir(0,0,0),z=0,k=!1,V=null,G=null,H=null,W=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),n.reset(),i.reset(),r.reset()}}}function Dp(t,e,n,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new dn,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(W){}function f(t,e){return p?new OffscreenCanvas(t,e):je("canvas")}function m(t,e,n){let i=1;const r=H(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===u&&(u=f(n,s));const a=e?f(n,s):u;a.width=n,a.height=s;return a.getContext("2d").drawImage(t,0,0,n,s),Ke("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&Ke("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function _(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function x(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];Ke("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&(r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(o=t.R11F_G11F_B10F)),i===t.RGBA){const e=a?Te:bn.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Ee?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function y(e,n){let i;return e?null===n||n===dt||n===vt?i=t.DEPTH24_STENCIL8:n===pt?i=t.DEPTH32F_STENCIL8:n===ht&&(i=t.DEPTH24_STENCIL8,Ke("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===dt||n===vt?i=t.DEPTH_COMPONENT24:n===pt?i=t.DEPTH_COMPONENT32F:n===ht&&(i=t.DEPTH_COMPONENT16),i}function M(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==et&&t.minFilter!==rt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&w(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e)}function S(e){const n=e.target;n.removeEventListener("dispose",S),function(e){const n=i.get(e);e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let i=0;i<6;i++){if(Array.isArray(n.__webglFramebuffer[i]))for(let e=0;e<n.__webglFramebuffer[i].length;e++)t.deleteFramebuffer(n.__webglFramebuffer[i][e]);else t.deleteFramebuffer(n.__webglFramebuffer[i]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[i])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=e.textures;for(let s=0,o=r.length;s<o;s++){const e=i.get(r[s]);e.__webglTexture&&(t.deleteTexture(e.__webglTexture),a.memory.textures--),i.remove(r[s])}i.remove(e)}(n)}function w(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const r=e.source;delete d.get(r)[n.__cacheKey],a.memory.textures--}let T=0;function E(e,r){const s=i.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;h.get(t)!==e&&(h.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)Ke("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);Ke("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[$]:t.REPEAT,[Q]:t.CLAMP_TO_EDGE,[tt]:t.MIRRORED_REPEAT},C={[et]:t.NEAREST,[nt]:t.NEAREST_MIPMAP_NEAREST,[it]:t.NEAREST_MIPMAP_LINEAR,[rt]:t.LINEAR,[st]:t.LINEAR_MIPMAP_NEAREST,[at]:t.LINEAR_MIPMAP_LINEAR},R={[Ce]:t.NEVER,[Ue]:t.ALWAYS,[Re]:t.LESS,[Ie]:t.LEQUAL,[Pe]:t.EQUAL,[Ne]:t.GEQUAL,[Le]:t.GREATER,[De]:t.NOTEQUAL};function P(n,s){if(s.type!==pt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==rt&&s.magFilter!==st&&s.magFilter!==it&&s.magFilter!==at&&s.minFilter!==rt&&s.minFilter!==st&&s.minFilter!==it&&s.minFilter!==at||Ke("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,A[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===et)return;if(s.minFilter!==it&&s.minFilter!==at)return;if(s.type===pt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function I(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",b));const r=n.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&w(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function L(t,e,n){return Math.floor(Math.floor(t/n)/e)}function D(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const c=I(e,a),h=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){n.activeTexture(t.TEXTURE0+o);const e=bn.getPrimaries(bn.workingColorSpace),i=a.colorSpace===be?null:bn.getPrimaries(a.colorSpace),d=a.colorSpace===be||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(a.image,!1,r.maxTextureSize);p=G(a,p);const f=s.convert(a.format,a.colorSpace),_=s.convert(a.type);let b,S=x(a.internalFormat,f,_,a.colorSpace,a.isVideoTexture);P(l,a);const w=a.mipmaps,T=!0!==a.isVideoTexture,E=void 0===u.__version||!0===c,A=h.dataReady,C=M(a,p);if(a.isDepthTexture)S=y(a.format===wt,a.type),E&&(T?n.texStorage2D(t.TEXTURE_2D,1,S,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,f,_,null));else if(a.isDataTexture)if(w.length>0){T&&E&&n.texStorage2D(t.TEXTURE_2D,C,S,w[0].width,w[0].height);for(let e=0,i=w.length;e<i;e++)b=w[e],T?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,_,b.data):n.texImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,f,_,b.data);a.generateMipmaps=!1}else T?(E&&n.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height),A&&function(e,i,r,s){const a=e.updateRanges;if(0===a.length)n.texSubImage2D(t.TEXTURE_2D,0,0,0,i.width,i.height,r,s,i.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],n=a[t],r=e.start+e.count,s=L(n.start,i.width,4),l=L(e.start,i.width,4);n.start<=r+1&&s===l&&L(n.start+n.count-1,i.width,4)===s?e.count=Math.max(e.count,n.start+n.count-e.start):(++o,a[o]=n)}a.length=o+1;const l=t.getParameter(t.UNPACK_ROW_LENGTH),c=t.getParameter(t.UNPACK_SKIP_PIXELS),h=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,i.width);for(let e=0,u=a.length;e<u;e++){const o=a[e],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),h=l%i.width,u=Math.floor(l/i.width),d=c,p=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,h),t.pixelStorei(t.UNPACK_SKIP_ROWS,u),n.texSubImage2D(t.TEXTURE_2D,0,h,u,d,p,r,s,i.data)}e.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,l),t.pixelStorei(t.UNPACK_SKIP_PIXELS,c),t.pixelStorei(t.UNPACK_SKIP_ROWS,h)}}(a,p,f,_)):n.texImage2D(t.TEXTURE_2D,0,S,p.width,p.height,0,f,_,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){T&&E&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,w[0].width,w[0].height,p.depth);for(let e=0,i=w.length;e<i;e++)if(b=w[e],a.format!==bt)if(null!==f)if(T){if(A)if(a.layerUpdates.size>0){const i=Zh(b.width,b.height,a.format,a.type);for(const r of a.layerUpdates){const s=b.data.subarray(r*i/b.data.BYTES_PER_ELEMENT,(r+1)*i/b.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,b.width,b.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,f,b.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,S,b.width,b.height,p.depth,0,b.data,0,0);else Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,f,_,b.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,S,b.width,b.height,p.depth,0,f,_,b.data)}else{T&&E&&n.texStorage2D(t.TEXTURE_2D,C,S,w[0].width,w[0].height);for(let e=0,i=w.length;e<i;e++)b=w[e],a.format!==bt?null!==f?T?A&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,b.data):n.compressedTexImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,b.data):Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):T?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,_,b.data):n.texImage2D(t.TEXTURE_2D,e,S,b.width,b.height,0,f,_,b.data)}else if(a.isDataArrayTexture)if(T){if(E&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,S,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Zh(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,_,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,_,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,S,p.width,p.height,p.depth,0,f,_,p.data);else if(a.isData3DTexture)T?(E&&n.texStorage3D(t.TEXTURE_3D,C,S,p.width,p.height,p.depth),A&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,_,p.data)):n.texImage3D(t.TEXTURE_3D,0,S,p.width,p.height,p.depth,0,f,_,p.data);else if(a.isFramebufferTexture){if(E)if(T)n.texStorage2D(t.TEXTURE_2D,C,S,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r<C;r++)n.texImage2D(t.TEXTURE_2D,r,S,e,i,0,f,_,null),e>>=1,i>>=1}}else if(w.length>0){if(T&&E){const e=H(w[0]);n.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}for(let e=0,i=w.length;e<i;e++)b=w[e],T?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,f,_,b):n.texImage2D(t.TEXTURE_2D,e,S,f,_,b);a.generateMipmaps=!1}else if(T){if(E){const e=H(p);n.texStorage2D(t.TEXTURE_2D,C,S,e.width,e.height)}A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,f,_,p)}else n.texImage2D(t.TEXTURE_2D,0,S,f,_,p);g(a)&&v(l),u.__version=h.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function N(e,r,a,l,c,h){const u=s.convert(a.format,a.colorSpace),d=s.convert(a.type),p=x(a.internalFormat,u,d,a.colorSpace),f=i.get(r),m=i.get(a);if(m.__renderTarget=r,!f.__hasExternalTextures){const e=Math.max(1,r.width>>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,u,d,null):n.texImage2D(c,h,p,e,i,0,u,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,m.__webglTexture,0,k(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function U(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=y(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,k(n),a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,k(n),a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r<e.length;r++){const a=e[r],l=s.convert(a.format,a.colorSpace),c=s.convert(a.type),h=x(a.internalFormat,l,c,a.colorSpace);V(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,k(n),h,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,k(n),h,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,h,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function O(e,r,a){const l=!0===r.isWebGLCubeRenderTarget;if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const c=i.get(r.depthTexture);if(c.__renderTarget=r,c.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===c.__webglInit&&(c.__webglInit=!0,r.depthTexture.addEventListener("dispose",b)),void 0===c.__webglTexture){c.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__webglTexture),P(t.TEXTURE_CUBE_MAP,r.depthTexture);const e=s.convert(r.depthTexture.format),i=s.convert(r.depthTexture.type);let a;r.depthTexture.format===St?a=t.DEPTH_COMPONENT24:r.depthTexture.format===wt&&(a=t.DEPTH24_STENCIL8);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,a,r.width,r.height,0,e,i,null)}}else E(r.depthTexture,0);const h=c.__webglTexture,u=k(r),d=l?t.TEXTURE_CUBE_MAP_POSITIVE_X+a:t.TEXTURE_2D,p=r.depthTexture.format===wt?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(r.depthTexture.format===St)V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,d,h,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,p,d,h,0);else{if(r.depthTexture.format!==wt)throw new Error("Unknown depthTexture format");V(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,d,h,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,p,d,h,0)}}function F(e){const r=i.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer)if(s)for(let t=0;t<6;t++)O(r.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?O(r.__webglFramebuffer[0],e,0):O(r.__webglFramebuffer,e,0)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),U(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else{const i=e.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),U(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}const B=[],z=[];function k(t){return Math.min(r.maxSamples,t.samples)}function V(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==we&&n!==be&&(bn.getTransfer(n)===Ee?i===bt&&r===ot||Ke("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Je("WebGLTextures: Unsupported texture color space:",n)),e}function H(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=T;return t>=r.maxTextures&&Ke("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,r){const s=i.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):(e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null),n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r))},this.setTexture3D=function(e,r){const s=i.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=I(e,a),c=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=bn.getPrimaries(bn.workingColorSpace),i=a.colorSpace===be?null:bn.getPrimaries(a.colorSpace),u=a.colorSpace===be||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=G(a,f[t]);const _=f[0],y=s.convert(a.format,a.colorSpace),b=s.convert(a.type),S=x(a.internalFormat,y,b,a.colorSpace),w=!0!==a.isVideoTexture,T=void 0===h.__version||!0===l,E=c.dataReady;let A,C=M(a,_);if(P(t.TEXTURE_CUBE_MAP,a),d){w&&T&&n.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,_.width,_.height);for(let e=0;e<6;e++){A=f[e].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];a.format!==bt?null!==y?w?E&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,y,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,S,r.width,r.height,0,r.data):Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,y,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,S,r.width,r.height,0,y,b,r.data)}}}else{if(A=a.mipmaps,w&&T){A.length>0&&C++;const e=H(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,C,S,e.width,e.height)}for(let e=0;e<6;e++)if(p){w?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,y,b,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,f[e].width,f[e].height,0,y,b,f[e].data);for(let i=0;i<A.length;i++){const r=A[i].image[e].image;w?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,y,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,S,r.width,r.height,0,y,b,r.data)}}else{w?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,y,b,f[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,S,y,b,f[e]);for(let i=0;i<A.length;i++){const r=A[i];w?E&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,y,b,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,S,y,b,r.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),h.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,n,r){const s=i.get(e);void 0!==n&&N(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&F(e)},this.setupRenderTarget=function(e){const r=e.texture,o=i.get(e),l=i.get(r);e.addEventListener("dispose",S);const c=e.textures,h=!0===e.isWebGLCubeRenderTarget,u=c.length>1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[e][n]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(u)for(let e=0,n=c.length;e<n;e++){const n=i.get(c[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===V(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=s.convert(i.format,i.colorSpace),a=s.convert(i.type),l=x(i.internalFormat,r,a,i.colorSpace,!0===e.isXRRenderTarget),h=k(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,h,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,o.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),U(o.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(h){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)N(o.__webglFramebuffer[n][i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else N(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(r)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(u){for(let r=0,s=c.length;r<s;r++){const s=c[r],a=i.get(s);let l=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(l=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(l,a.__webglTexture),P(l,s),N(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,l,0),g(s)&&v(l)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),P(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)N(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,i,n);else N(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,i,0);g(r)&&v(i),n.unbindTexture()}e.depthBuffer&&F(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=_(t),r=i.get(s).__webglTexture;n.bindTexture(e,r),v(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===V(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),u=r.length>1;if(u)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,h.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,h.__webglMultisampledFramebuffer);const d=e.texture.mipmaps;d&&d.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglFramebuffer);for(let n=0;n<r.length;n++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),u){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,h.__webglColorRenderbuffer[n]);const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===l&&(B.length=0,z.length=0,B.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(B.push(c),z.push(c),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,z)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),u)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,h.__webglColorRenderbuffer[e]);const s=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,h.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,h.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=N,this.useMultisampledRTT=V,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Np(t,e){return{convert:function(n,i=""){let r;const s=bn.getTransfer(i);if(n===ot)return t.UNSIGNED_BYTE;if(n===mt)return t.UNSIGNED_SHORT_4_4_4_4;if(n===gt)return t.UNSIGNED_SHORT_5_5_5_1;if(n===_t)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===xt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(n===lt)return t.BYTE;if(n===ct)return t.SHORT;if(n===ht)return t.UNSIGNED_SHORT;if(n===ut)return t.INT;if(n===dt)return t.UNSIGNED_INT;if(n===pt)return t.FLOAT;if(n===ft)return t.HALF_FLOAT;if(n===yt)return t.ALPHA;if(n===Mt)return t.RGB;if(n===bt)return t.RGBA;if(n===St)return t.DEPTH_COMPONENT;if(n===wt)return t.DEPTH_STENCIL;if(n===Tt)return t.RED;if(n===Et)return t.RED_INTEGER;if(n===At)return t.RG;if(n===Ct)return t.RG_INTEGER;if(n===Rt)return t.RGBA_INTEGER;if(n===Pt||n===It||n===Lt||n===Dt)if(s===Ee){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Pt)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===It)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Lt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Dt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Pt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===It)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Lt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Dt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Nt||n===Ut||n===Ot||n===Ft){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Nt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ut)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ot)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ft)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Bt||n===zt||n===kt||n===Vt||n===Gt||n===Ht||n===Wt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===Bt||n===zt)return s===Ee?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===kt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Vt)return r.COMPRESSED_R11_EAC;if(n===Gt)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ht)return r.COMPRESSED_RG11_EAC;if(n===Wt)return r.COMPRESSED_SIGNED_RG11_EAC}if(n===jt||n===Xt||n===qt||n===Yt||n===Zt||n===Kt||n===Jt||n===$t||n===Qt||n===te||n===ee||n===ne||n===ie||n===re){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===jt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Yt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Kt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Jt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===$t)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Qt)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===te)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ee)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ne)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ie)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===re)return s===Ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===se||n===ae||n===oe){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(n===se)return s===Ee?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ae)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===oe)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===le||n===ce||n===he||n===ue){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===le)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ce)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===he)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ue)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===vt?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}class Up{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const n=new to(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new jr({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Br(new vl(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Op extends Qe{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f="undefined"!=typeof XRWebGLBinding,m=new Up,g={},v=e.getContextAttributes();let _=null,x=null;const y=[],M=[],b=new dn;let S=null;const w=new Kr;w.viewport=new Dn;const T=new Kr;T.viewport=new Dn;const E=[w,T],A=new Xc;let C=null,R=null;function P(t){const e=M.indexOf(t.inputSource);if(-1===e)return;const n=y[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function I(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",L);for(let t=0;t<y.length;t++){const e=M[t];null!==e&&(M[t]=null,y[t].disconnect(e))}C=null,R=null,m.reset();for(const t in g)delete g[t];t.setRenderTarget(_),d=null,u=null,h=null,i=null,x=null,F.stop(),n.isPresenting=!1,t.setPixelRatio(S),t.setSize(b.width,b.height,!1),n.dispatchEvent({type:"sessionend"})}function L(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=M.indexOf(n);i>=0&&(M[i]=null,y[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=M.indexOf(n);if(-1===i){for(let t=0;t<y.length;t++){if(t>=M.length){M.push(n),i=t;break}if(null===M[t]){M[t]=n,i=t;break}}if(-1===i)break}const r=y[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=y[t];return void 0===e&&(e=new is,y[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=y[t];return void 0===e&&(e=new is,y[t]=e),e.getGripSpace()},this.getHand=function(t){let e=y[t];return void 0===e&&(e=new is,y[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&Ke("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&Ke("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return null===h&&f&&(h=new XRWebGLBinding(i,e)),h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){_=t.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",I),i.addEventListener("inputsourceschange",L),!0!==v.xrCompatible&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(b);if(f&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,s=null,a=null;v.depth&&(a=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=v.stencil?wt:St,s=v.stencil?vt:dt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=this.getBinding(),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),x=new Un(u.textureWidth,u.textureHeight,{format:bt,type:ot,depthTexture:new $a(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}else{const n={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),x=new Un(d.framebufferWidth,d.framebufferHeight,{format:bt,type:ot,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}x.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),F.setContext(i),F.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const D=new fn,N=new fn;function U(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==m.texture&&(m.depthNear>0&&(e=m.depthNear),m.depthFar>0&&(n=m.depthFar)),A.near=T.near=w.near=e,A.far=T.far=w.far=n,C===A.near&&R===A.far||(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|t.layers.mask,w.layers.mask=3&A.layers.mask,T.layers.mask=5&A.layers.mask;const r=t.parent,s=A.cameras;U(A,r);for(let i=0;i<s.length;i++)U(s[i],r);2===s.length?function(t,e,n){D.setFromMatrixPosition(e.matrixWorld),N.setFromMatrixPosition(n.matrixWorld);const i=D.distanceTo(N),r=e.projectionMatrix.elements,s=n.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*h,p=a*u,f=i/(-h+u),m=f*-h;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+f,n=o+f,r=d-m,s=p+(i-m),h=l*o/n*e,u=c*o/n*e;t.projectionMatrix.makePerspective(r,s,h,u,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,w,T):A.projectionMatrix.copy(w.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*rn*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let O=null;const F=new Kh;F.setAnimationLoop(function(e,r){if(c=r.getViewerPose(l||s),p=r,null!==c){const e=c.views;null!==d&&(t.setRenderTargetFramebuffer(x,d.framebuffer),t.setRenderTarget(x));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let n=0;n<e.length;n++){const i=e[n];let s=null;if(null!==d)s=d.getViewport(i);else{const e=h.getViewSubImage(u,i);s=e.viewport,0===n&&(t.setRenderTargetTextures(x,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(x))}let a=E[n];void 0===a&&(a=new Kr,a.layers.enable(n),a.viewport=new Dn,E[n]=a),a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(i.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===n&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(a)}const s=i.enabledFeatures;if(s&&s.includes("depth-sensing")&&"gpu-optimized"==i.depthUsage&&f){h=n.getBinding();const t=h.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&m.init(t,i.renderState)}if(s&&s.includes("camera-access")&&f){t.state.unbindTexture(),h=n.getBinding();for(let t=0;t<e.length;t++){const n=e[t].camera;if(n){let t=g[n];t||(t=new to,g[n]=t);const e=h.getCameraImage(n);t.sourceTexture=e}}}}for(let t=0;t<y.length;t++){const e=M[t],n=y[t];null!==e&&void 0!==n&&n.update(e,r,l||s)}O&&O(e,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(t){O=t},this.dispose=function(){}}}const Fp=new Mi,Bp=new ui;function zp(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,Fp.copy(a),Fp.x*=-1,Fp.y*=-1,Fp.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(Fp.y*=-1,Fp.z*=-1),t.envMapRotation.value.setFromMatrix4(Bp.makeRotationFromEuler(Fp)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,Hr(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function kp(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?Ke("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ke("WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,u){let d=r[n.id];void 0===d&&(!function(t){const e=t.uniforms;let n=0;const i=16;for(let s=0,a=e.length;s<a;s++){const t=Array.isArray(e[s])?e[s]:[e[s]];for(let e=0,r=t.length;e<r;e++){const r=t[e],s=Array.isArray(r.value)?r.value:[r.value];for(let t=0,e=s.length;t<e;t++){const e=c(s[t]),a=n%i,o=a%e.boundary,l=a+o;n+=o,0!==l&&i-l<e.storage&&(n+=i-l),r.__data=new Float32Array(e.storage/Float32Array.BYTES_PER_ELEMENT),r.__offset=n,n+=e.storage}}}const r=n%i;r>0&&(n+=i-r);t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return Je("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",h));const p=u.program;i.updateUBOMapping(n,p);const f=e.render.frame;s[n.id]!==f&&(!function(e){const n=r[e.id],i=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let r=0,a=i.length;r<a;r++){const e=Array.isArray(i[r])?i[r]:[i[r]];for(let n=0,i=e.length;n<i;n++){const i=e[n];if(!0===l(i,r,n,s)){const e=i.__offset,n=Array.isArray(i.value)?i.value:[i.value];let r=0;for(let s=0;s<n.length;s++){const a=n[s],o=c(a);"number"==typeof a||"boolean"==typeof a?(i.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+r,i.__data)):a.isMatrix3?(i.__data[0]=a.elements[0],i.__data[1]=a.elements[1],i.__data[2]=a.elements[2],i.__data[3]=0,i.__data[4]=a.elements[3],i.__data[5]=a.elements[4],i.__data[6]=a.elements[5],i.__data[7]=0,i.__data[8]=a.elements[6],i.__data[9]=a.elements[7],i.__data[10]=a.elements[8],i.__data[11]=0):(a.toArray(i.__data,r),r+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,i.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),s[n.id]=f)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}const Vp=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Gp=null;class Hp{constructor(t={}){const{canvas:e=Xe(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:p=ot}=t;let f;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=i.getContextAttributes().alpha}else f=a;const m=p,g=new Set([Rt,Ct,Et]),v=new Set([ot,dt,ht,vt,mt,gt]),_=new Uint32Array(4),x=new Int32Array(4);let y=null,M=null;const b=[],S=[];let w=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let E=!1;this._outputColorSpace=Se;let A=0,C=0,R=null,P=-1,I=null;const L=new Dn,D=new Dn;let N=null;const U=new ir(0);let O=0,F=e.width,B=e.height,z=1,k=null,V=null;const G=new Dn(0,0,F,B),H=new Dn(0,0,F,B);let W=!1;const j=new aa;let X=!1,q=!1;const Y=new ui,Z=new fn,K=new Dn,J={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let $=!1;function tt(){return null===R?z:1}let et,nt,it,st,lt,ct,ut,pt,_t,xt,yt,Mt,bt,St,wt,Tt,Pt,It,Lt,Dt,Nt,Ut,Ot,Ft,Bt=i;function zt(t,n){return e.getContext(t,n)}try{const t={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${n}`),e.addEventListener("webglcontextlost",Gt,!1),e.addEventListener("webglcontextrestored",Ht,!1),e.addEventListener("webglcontextcreationerror",Wt,!1),null===Bt){const e="webgl2";if(Bt=zt(e,t),null===Bt)throw zt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(le){throw Je("WebGLRenderer: "+le.message),le}function kt(){et=new Eu(Bt),et.init(),Ut=new Np(Bt,et),nt=new ou(Bt,et,t,Ut),it=new Lp(Bt,et),nt.reversedDepthBuffer&&d&&it.buffers.depth.setReversed(!0),st=new Ru(Bt),lt=new fp,ct=new Dp(Bt,et,it,lt,nt,Ut,st),ut=new cu(T),pt=new Tu(T),_t=new Jh(Bt),Ot=new su(Bt,_t),xt=new Au(Bt,_t,st,Ot),yt=new Iu(Bt,xt,_t,st),Lt=new Pu(Bt,nt,ct),Tt=new lu(lt),Mt=new pp(T,ut,pt,et,nt,Ot,Tt),bt=new zp(T,lt),St=new _p,wt=new wp(et),It=new ru(T,ut,pt,it,yt,f,l),Pt=new Pp(T,yt,nt),Ft=new kp(Bt,st,nt,it),Dt=new au(Bt,et,st),Nt=new Cu(Bt,et,st),st.programs=Mt.programs,T.capabilities=nt,T.extensions=et,T.properties=lt,T.renderLists=St,T.shadowMap=Pt,T.state=it,T.info=st}kt(),m!==ot&&(w=new Du(m,e.width,e.height,r,s));const Vt=new Op(T,Bt);function Gt(t){t.preventDefault(),Ze("WebGLRenderer: Context Lost."),E=!0}function Ht(){Ze("WebGLRenderer: Context Restored."),E=!1;const t=st.autoReset,e=Pt.enabled,n=Pt.autoUpdate,i=Pt.needsUpdate,r=Pt.type;kt(),st.autoReset=t,Pt.enabled=e,Pt.autoUpdate=n,Pt.needsUpdate=i,Pt.type=r}function Wt(t){Je("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function jt(t){const e=t.target;e.removeEventListener("dispose",jt),function(t){(function(t){const e=lt.get(t).programs;void 0!==e&&(e.forEach(function(t){Mt.releaseProgram(t)}),t.isShaderMaterial&&Mt.releaseShaderCache(t))})(t),lt.remove(t)}(e)}function Xt(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,ne(t,e,n),t.side=0,t.needsUpdate=!0,ne(t,e,n),t.side=2):ne(t,e,n)}this.xr=Vt,this.getContext=function(){return Bt},this.getContextAttributes=function(){return Bt.getContextAttributes()},this.forceContextLoss=function(){const t=et.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=et.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(t){void 0!==t&&(z=t,this.setSize(F,B,!1))},this.getSize=function(t){return t.set(F,B)},this.setSize=function(t,n,i=!0){Vt.isPresenting?Ke("WebGLRenderer: Can't change size while VR device is presenting."):(F=t,B=n,e.width=Math.floor(t*z),e.height=Math.floor(n*z),!0===i&&(e.style.width=t+"px",e.style.height=n+"px"),null!==w&&w.setSize(e.width,e.height),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(F*z,B*z).floor()},this.setDrawingBufferSize=function(t,n,i){F=t,B=n,z=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.setEffects=function(t){if(m!==ot){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}w.setEffects(t||[])}else console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(L)},this.getViewport=function(t){return t.copy(G)},this.setViewport=function(t,e,n,i){t.isVector4?G.set(t.x,t.y,t.z,t.w):G.set(t,e,n,i),it.viewport(L.copy(G).multiplyScalar(z).round())},this.getScissor=function(t){return t.copy(H)},this.setScissor=function(t,e,n,i){t.isVector4?H.set(t.x,t.y,t.z,t.w):H.set(t,e,n,i),it.scissor(D.copy(H).multiplyScalar(z).round())},this.getScissorTest=function(){return W},this.setScissorTest=function(t){it.setScissorTest(W=t)},this.setOpaqueSort=function(t){k=t},this.setTransparentSort=function(t){V=t},this.getClearColor=function(t){return t.copy(It.getClearColor())},this.setClearColor=function(){It.setClearColor(...arguments)},this.getClearAlpha=function(){return It.getClearAlpha()},this.setClearAlpha=function(){It.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==R){const e=R.texture.format;t=g.has(e)}if(t){const t=R.texture.type,e=v.has(t),n=It.getClearColor(),i=It.getClearAlpha(),r=n.r,s=n.g,a=n.b;e?(_[0]=r,_[1]=s,_[2]=a,_[3]=i,Bt.clearBufferuiv(Bt.COLOR,0,_)):(x[0]=r,x[1]=s,x[2]=a,x[3]=i,Bt.clearBufferiv(Bt.COLOR,0,x))}else i|=Bt.COLOR_BUFFER_BIT}e&&(i|=Bt.DEPTH_BUFFER_BIT),n&&(i|=Bt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Bt.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Gt,!1),e.removeEventListener("webglcontextrestored",Ht,!1),e.removeEventListener("webglcontextcreationerror",Wt,!1),It.dispose(),St.dispose(),wt.dispose(),lt.dispose(),ut.dispose(),pt.dispose(),yt.dispose(),Ot.dispose(),Ft.dispose(),Mt.dispose(),Vt.dispose(),Vt.removeEventListener("sessionstart",Yt),Vt.removeEventListener("sessionend",Zt),Kt.stop()},this.renderBufferDirect=function(t,e,n,i,r,s){null===e&&(e=J);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,n,i,r){!0!==e.isScene&&(e=J);ct.resetTextureUnits();const s=e.fog,a=i.isMeshStandardMaterial?e.environment:null,o=null===R?T.outputColorSpace:!0===R.isXRRenderTarget?R.texture.colorSpace:we,l=(i.isMeshStandardMaterial?pt:ut).get(i.envMap||a),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=0;i.toneMapped&&(null!==R&&!0!==R.isXRRenderTarget||(f=T.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=lt.get(i),_=M.state.lights;if(!0===X&&(!0===q||t!==I)){const e=t===I&&i.id===P;Tt.setState(i,t,e)}let x=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==_.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?x=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?x=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?x=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?x=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===Tt.numPlanes&&v.numIntersection===Tt.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,v.__version=i.version);let y=v.currentProgram;!0===x&&(y=ne(i,e,r));let b=!1,S=!1,w=!1;const E=y.getUniforms(),A=v.uniforms;it.useProgram(y.program)&&(b=!0,S=!0,w=!0);i.id!==P&&(P=i.id,S=!0);if(b||I!==t){it.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),E.setValue(Bt,"projectionMatrix",t.projectionMatrix),E.setValue(Bt,"viewMatrix",t.matrixWorldInverse);const e=E.map.cameraPosition;void 0!==e&&e.setValue(Bt,Z.setFromMatrixPosition(t.matrixWorld)),nt.logarithmicDepthBuffer&&E.setValue(Bt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&E.setValue(Bt,"isOrthographic",!0===t.isOrthographicCamera),I!==t&&(I=t,S=!0,w=!0)}v.needsLights&&(_.state.directionalShadowMap.length>0&&E.setValue(Bt,"directionalShadowMap",_.state.directionalShadowMap,ct),_.state.spotShadowMap.length>0&&E.setValue(Bt,"spotShadowMap",_.state.spotShadowMap,ct),_.state.pointShadowMap.length>0&&E.setValue(Bt,"pointShadowMap",_.state.pointShadowMap,ct));if(r.isSkinnedMesh){E.setOptional(Bt,r,"bindMatrix"),E.setOptional(Bt,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),E.setValue(Bt,"boneTexture",t.boneTexture,ct))}r.isBatchedMesh&&(E.setOptional(Bt,r,"batchingTexture"),E.setValue(Bt,"batchingTexture",r._matricesTexture,ct),E.setOptional(Bt,r,"batchingIdTexture"),E.setValue(Bt,"batchingIdTexture",r._indirectTexture,ct),E.setOptional(Bt,r,"batchingColorTexture"),null!==r._colorsTexture&&E.setValue(Bt,"batchingColorTexture",r._colorsTexture,ct));const C=n.morphAttributes;void 0===C.position&&void 0===C.normal&&void 0===C.color||Lt.update(r,n,y);(S||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,E.setValue(Bt,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(A.envMap.value=l,A.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(A.envMapIntensity.value=e.environmentIntensity);void 0!==A.dfgLUT&&(A.dfgLUT.value=(null===Gp&&(Gp=new ks(Vp,16,16,At,ft),Gp.name="DFG_LUT",Gp.minFilter=rt,Gp.magFilter=rt,Gp.wrapS=Q,Gp.wrapT=Q,Gp.generateMipmaps=!1,Gp.needsUpdate=!0),Gp));S&&(E.setValue(Bt,"toneMappingExposure",T.toneMappingExposure),v.needsLights&&(D=w,(L=A).ambientLightColor.needsUpdate=D,L.lightProbe.needsUpdate=D,L.directionalLights.needsUpdate=D,L.directionalLightShadows.needsUpdate=D,L.pointLights.needsUpdate=D,L.pointLightShadows.needsUpdate=D,L.spotLights.needsUpdate=D,L.spotLightShadows.needsUpdate=D,L.rectAreaLights.needsUpdate=D,L.hemisphereLights.needsUpdate=D),s&&!0===i.fog&&bt.refreshFogUniforms(A,s),bt.refreshMaterialUniforms(A,i,z,B,M.state.transmissionRenderTarget[t.id]),Bd.upload(Bt,ie(v),A,ct));var L,D;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Bd.upload(Bt,ie(v),A,ct),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&E.setValue(Bt,"center",r.center);if(E.setValue(Bt,"modelViewMatrix",r.modelViewMatrix),E.setValue(Bt,"normalMatrix",r.normalMatrix),E.setValue(Bt,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];Ft.update(n,y),Ft.bind(n,y)}}return y}(t,e,n,i,r);it.setMaterial(i,a);let l=n.index,c=1;if(!0===i.wireframe){if(l=xt.getWireframeAttribute(n),void 0===l)return;c=2}const h=n.drawRange,u=n.attributes.position;let d=h.start*c,p=(h.start+h.count)*c;null!==s&&(d=Math.max(d,s.start*c),p=Math.min(p,(s.start+s.count)*c)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));const f=p-d;if(f<0||f===1/0)return;let m;Ot.setup(r,i,o,n,l);let g=Dt;if(null!==l&&(m=_t.get(l),g=Nt,g.setIndex(m)),r.isMesh)!0===i.wireframe?(it.setLineWidth(i.wireframeLinewidth*tt()),g.setMode(Bt.LINES)):g.setMode(Bt.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),it.setLineWidth(t*tt()),r.isLineSegments?g.setMode(Bt.LINES):r.isLineLoop?g.setMode(Bt.LINE_LOOP):g.setMode(Bt.LINE_STRIP)}else r.isPoints?g.setMode(Bt.POINTS):r.isSprite&&g.setMode(Bt.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)$e("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(et.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,n=r._multiDrawCount,s=l?_t.get(l).bytesPerElement:1,a=lt.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)a.setValue(Bt,"_gl_DrawID",i),g.render(t[i]/s,e[i])}else if(r.isInstancedMesh)g.renderInstances(d,f,r.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);g.renderInstances(d,f,e)}else g.render(d,f)},this.compile=function(t,e,n=null){null===n&&(n=t),M=wt.get(n),M.init(e),S.push(M),n.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(M.pushLight(t),t.castShadow&&M.pushShadow(t))}),t!==n&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(M.pushLight(t),t.castShadow&&M.pushShadow(t))}),M.setupLights();const i=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];Xt(s,n,t),i.add(s)}else Xt(e,n,t),i.add(e)}),M=S.pop(),i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise(e=>{function n(){i.forEach(function(t){lt.get(t).currentProgram.isReady()&&i.delete(t)}),0!==i.size?setTimeout(n,10):e(t)}null!==et.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let qt=null;function Yt(){Kt.stop()}function Zt(){Kt.start()}const Kt=new Kh;function Jt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)M.pushLight(t),t.castShadow&&M.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||j.intersectsSprite(t)){i&&K.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Y);const e=yt.update(t),r=t.material;r.visible&&y.push(t,e,r,n,K.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||j.intersectsObject(t))){const e=yt.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),K.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),K.copy(e.boundingSphere.center)),K.applyMatrix4(t.matrixWorld).applyMatrix4(Y)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s<a;s++){const a=i[s],o=r[a.materialIndex];o&&o.visible&&y.push(t,e,o,n,K.z,a)}}else r.visible&&y.push(t,e,r,n,K.z,null)}const r=t.children;for(let s=0,a=r.length;s<a;s++)Jt(r[s],e,n,i)}function $t(t,e,n,i){const{opaque:r,transmissive:s,transparent:a}=t;M.setupLightsView(n),!0===X&&Tt.setGlobalState(T.clippingPlanes,n),i&&it.viewport(L.copy(i)),r.length>0&&te(r,e,n),s.length>0&&te(s,e,n),a.length>0&&te(a,e,n),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function Qt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===M.state.transmissionRenderTarget[i.id]){const t=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[i.id]=new Un(1,1,{generateMipmaps:!0,type:t?ft:ot,minFilter:at,samples:nt.samples,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:bn.workingColorSpace})}const r=M.state.transmissionRenderTarget[i.id],a=i.viewport||L;r.setSize(a.z*T.transmissionResolutionScale,a.w*T.transmissionResolutionScale);const o=T.getRenderTarget(),l=T.getActiveCubeFace(),c=T.getActiveMipmapLevel();T.setRenderTarget(r),T.getClearColor(U),O=T.getClearAlpha(),O<1&&T.setClearColor(16777215,.5),T.clear(),$&&It.render(n);const h=T.toneMapping;T.toneMapping=0;const u=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),M.setupLightsView(i),!0===X&&Tt.setGlobalState(T.clippingPlanes,i),te(t,n,i),ct.updateMultisampleRenderTarget(r),ct.updateRenderTargetMipmap(r),!1===et.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],{object:a,geometry:o,material:l,group:c}=s;if(2===l.side&&a.layers.test(i.layers)){const e=l.side;l.side=1,l.needsUpdate=!0,ee(a,n,i,o,l,c),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(ct.updateMultisampleRenderTarget(r),ct.updateRenderTargetMipmap(r))}T.setRenderTarget(o,l,c),T.setClearColor(U,O),void 0!==u&&(i.viewport=u),T.toneMapping=h}function te(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],{object:a,geometry:o,group:l}=s;let c=s.material;!0===c.allowOverride&&null!==i&&(c=i),a.layers.test(n.layers)&&ee(a,e,n,o,c,l)}}function ee(t,e,n,i,r,s){t.onBeforeRender(T,e,n,i,r,s),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(T,e,n,i,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,T.renderBufferDirect(n,e,i,r,t,s),r.side=0,r.needsUpdate=!0,T.renderBufferDirect(n,e,i,r,t,s),r.side=2):T.renderBufferDirect(n,e,i,r,t,s),t.onAfterRender(T,e,n,i,r,s)}function ne(t,e,n){!0!==e.isScene&&(e=J);const i=lt.get(t),r=M.state.lights,s=M.state.shadowsArray,a=r.state.version,o=Mt.getParameters(t,r.state,s,e,n),l=Mt.getProgramCacheKey(o);let c=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=(t.isMeshStandardMaterial?pt:ut).get(t.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===c&&(t.addEventListener("dispose",jt),c=new Map,i.programs=c);let h=c.get(l);if(void 0!==h){if(i.currentProgram===h&&i.lightsStateVersion===a)return re(t,o),h}else o.uniforms=Mt.getUniforms(t),t.onBeforeCompile(o,T),h=Mt.acquireProgram(o,l),c.set(l,h),i.uniforms=o.uniforms;const u=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=Tt.uniform),re(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=a,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=h,i.uniformsList=null,h}function ie(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Bd.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function re(t,e){const n=lt.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Kt.setAnimationLoop(function(t){qt&&qt(t)}),"undefined"!=typeof self&&Kt.setContext(self),this.setAnimationLoop=function(t){qt=t,Vt.setAnimationLoop(t),null===t?Kt.stop():Kt.start()},Vt.addEventListener("sessionstart",Yt),Vt.addEventListener("sessionend",Zt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void Je("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===E)return;const n=!0===Vt.enabled&&!0===Vt.isPresenting,i=null!==w&&(null===R||n)&&w.begin(T,R);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Vt.enabled||!0!==Vt.isPresenting||null!==w&&!1!==w.isCompositing()||(!0===Vt.cameraAutoUpdate&&Vt.updateCamera(e),e=Vt.getCamera()),!0===t.isScene&&t.onBeforeRender(T,t,e,R),M=wt.get(t,S.length),M.init(e),S.push(M),Y.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),j.setFromProjectionMatrix(Y,ze,e.reversedDepth),q=this.localClippingEnabled,X=Tt.init(this.clippingPlanes,q),y=St.get(t,b.length),y.init(),b.push(y),!0===Vt.enabled&&!0===Vt.isPresenting){const t=T.xr.getDepthSensingMesh();null!==t&&Jt(t,e,-1/0,T.sortObjects)}Jt(t,e,0,T.sortObjects),y.finish(),!0===T.sortObjects&&y.sort(k,V),$=!1===Vt.enabled||!1===Vt.isPresenting||!1===Vt.hasDepthSensing(),$&&It.addToRenderList(y,t),this.info.render.frame++,!0===X&&Tt.beginShadows();const r=M.state.shadowsArray;Pt.render(r,t,e),!0===X&&Tt.endShadows(),!0===this.info.autoReset&&this.info.reset();if(!1===(i&&w.hasRenderPass())){const n=y.opaque,i=y.transmissive;if(M.setupLights(),e.isArrayCamera){const r=e.cameras;if(i.length>0)for(let e=0,s=r.length;e<s;e++){Qt(n,i,t,r[e])}$&&It.render(t);for(let e=0,n=r.length;e<n;e++){const n=r[e];$t(y,t,n,n.viewport)}}else i.length>0&&Qt(n,i,t,e),$&&It.render(t),$t(y,t,e)}null!==R&&0===C&&(ct.updateMultisampleRenderTarget(R),ct.updateRenderTargetMipmap(R)),i&&w.end(T),!0===t.isScene&&t.onAfterRender(T,t,e),Ot.resetDefaultState(),P=-1,I=null,S.pop(),S.length>0?(M=S[S.length-1],!0===X&&Tt.setGlobalState(T.clippingPlanes,M.state.camera)):M=null,b.pop(),y=b.length>0?b[b.length-1]:null},this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(t,e,n){const i=lt.get(t);i.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),lt.get(t.texture).__webglTexture=e,lt.get(t.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const n=lt.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e};const se=Bt.createFramebuffer();this.setRenderTarget=function(t,e=0,n=0){R=t,A=e,C=n;let i=null,r=!1,s=!1;if(t){const a=lt.get(t);if(void 0!==a.__useDefaultFramebuffer)return it.bindFramebuffer(Bt.FRAMEBUFFER,a.__webglFramebuffer),L.copy(t.viewport),D.copy(t.scissor),N=t.scissorTest,it.viewport(L),it.scissor(D),it.setScissorTest(N),void(P=-1);if(void 0===a.__webglFramebuffer)ct.setupRenderTarget(t);else if(a.__hasExternalTextures)ct.rebindTextures(t,lt.get(t.texture).__webglTexture,lt.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(a.__boundDepthTexture!==e){if(null!==e&<.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ct.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);const l=lt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=Array.isArray(l[e])?l[e][n]:l[e],r=!0):i=t.samples>0&&!1===ct.useMultisampledRTT(t)?lt.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,L.copy(t.viewport),D.copy(t.scissor),N=t.scissorTest}else L.copy(G).multiplyScalar(z).floor(),D.copy(H).multiplyScalar(z).floor(),N=W;0!==n&&(i=se);if(it.bindFramebuffer(Bt.FRAMEBUFFER,i)&&it.drawBuffers(t,i),it.viewport(L),it.scissor(D),it.setScissorTest(N),r){const i=lt.get(t.texture);Bt.framebufferTexture2D(Bt.FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,Bt.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(s){const i=e;for(let e=0;e<t.textures.length;e++){const r=lt.get(t.textures[e]);Bt.framebufferTextureLayer(Bt.FRAMEBUFFER,Bt.COLOR_ATTACHMENT0+e,r.__webglTexture,n,i)}}else if(null!==t&&0!==n){const e=lt.get(t.texture);Bt.framebufferTexture2D(Bt.FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,Bt.TEXTURE_2D,e.__webglTexture,n)}P=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)return void Je("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=lt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){it.bindFramebuffer(Bt.FRAMEBUFFER,l);try{const a=t.textures[o],l=a.format,c=a.type;if(!nt.textureFormatReadable(l))return void Je("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!nt.textureTypeReadable(c))return void Je("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&(t.textures.length>1&&Bt.readBuffer(Bt.COLOR_ATTACHMENT0+o),Bt.readPixels(e,n,i,r,Ut.convert(l),Ut.convert(c),s))}finally{const t=null!==R?lt.get(R).__webglFramebuffer:null;it.bindFramebuffer(Bt.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=lt.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){it.bindFramebuffer(Bt.FRAMEBUFFER,l);const a=t.textures[o],c=a.format,h=a.type;if(!nt.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!nt.textureTypeReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const u=Bt.createBuffer();Bt.bindBuffer(Bt.PIXEL_PACK_BUFFER,u),Bt.bufferData(Bt.PIXEL_PACK_BUFFER,s.byteLength,Bt.STREAM_READ),t.textures.length>1&&Bt.readBuffer(Bt.COLOR_ATTACHMENT0+o),Bt.readPixels(e,n,i,r,Ut.convert(c),Ut.convert(h),0);const d=null!==R?lt.get(R).__webglFramebuffer:null;it.bindFramebuffer(Bt.FRAMEBUFFER,d);const p=Bt.fenceSync(Bt.SYNC_GPU_COMMANDS_COMPLETE,0);return Bt.flush(),await function(t,e,n){return new Promise(function(i,r){setTimeout(function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}},n)})}(Bt,p,4),Bt.bindBuffer(Bt.PIXEL_PACK_BUFFER,u),Bt.getBufferSubData(Bt.PIXEL_PACK_BUFFER,0,s),Bt.deleteBuffer(u),Bt.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;ct.setTexture2D(t,0),Bt.copyTexSubImage2D(Bt.TEXTURE_2D,n,0,0,a,o,r,s),it.unbindTexture()};const ae=Bt.createFramebuffer(),oe=Bt.createFramebuffer();this.copyTextureToTexture=function(t,e,n=null,i=null,r=0,s=null){let a,o,l,c,h,u,d,p,f;null===s&&(0!==r?($e("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const m=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==n)a=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,h=n.min.y,u=n.isBox3?n.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(m.width*e),o=Math.floor(m.height*e),l=t.isDataArrayTexture?m.depth:t.isData3DTexture?Math.floor(m.depth*e):1,c=0,h=0,u=0}null!==i?(d=i.x,p=i.y,f=i.z):(d=0,p=0,f=0);const g=Ut.convert(e.format),v=Ut.convert(e.type);let _;e.isData3DTexture?(ct.setTexture3D(e,0),_=Bt.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(ct.setTexture2DArray(e,0),_=Bt.TEXTURE_2D_ARRAY):(ct.setTexture2D(e,0),_=Bt.TEXTURE_2D),Bt.pixelStorei(Bt.UNPACK_FLIP_Y_WEBGL,e.flipY),Bt.pixelStorei(Bt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Bt.pixelStorei(Bt.UNPACK_ALIGNMENT,e.unpackAlignment);const x=Bt.getParameter(Bt.UNPACK_ROW_LENGTH),y=Bt.getParameter(Bt.UNPACK_IMAGE_HEIGHT),M=Bt.getParameter(Bt.UNPACK_SKIP_PIXELS),b=Bt.getParameter(Bt.UNPACK_SKIP_ROWS),S=Bt.getParameter(Bt.UNPACK_SKIP_IMAGES);Bt.pixelStorei(Bt.UNPACK_ROW_LENGTH,m.width),Bt.pixelStorei(Bt.UNPACK_IMAGE_HEIGHT,m.height),Bt.pixelStorei(Bt.UNPACK_SKIP_PIXELS,c),Bt.pixelStorei(Bt.UNPACK_SKIP_ROWS,h),Bt.pixelStorei(Bt.UNPACK_SKIP_IMAGES,u);const w=t.isDataArrayTexture||t.isData3DTexture,T=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const n=lt.get(t),i=lt.get(e),m=lt.get(n.__renderTarget),g=lt.get(i.__renderTarget);it.bindFramebuffer(Bt.READ_FRAMEBUFFER,m.__webglFramebuffer),it.bindFramebuffer(Bt.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let v=0;v<l;v++)w&&(Bt.framebufferTextureLayer(Bt.READ_FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,lt.get(t).__webglTexture,r,u+v),Bt.framebufferTextureLayer(Bt.DRAW_FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,lt.get(e).__webglTexture,s,f+v)),Bt.blitFramebuffer(c,h,a,o,d,p,a,o,Bt.DEPTH_BUFFER_BIT,Bt.NEAREST);it.bindFramebuffer(Bt.READ_FRAMEBUFFER,null),it.bindFramebuffer(Bt.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||lt.has(t)){const n=lt.get(t),i=lt.get(e);it.bindFramebuffer(Bt.READ_FRAMEBUFFER,ae),it.bindFramebuffer(Bt.DRAW_FRAMEBUFFER,oe);for(let t=0;t<l;t++)w?Bt.framebufferTextureLayer(Bt.READ_FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,n.__webglTexture,r,u+t):Bt.framebufferTexture2D(Bt.READ_FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,Bt.TEXTURE_2D,n.__webglTexture,r),T?Bt.framebufferTextureLayer(Bt.DRAW_FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,i.__webglTexture,s,f+t):Bt.framebufferTexture2D(Bt.DRAW_FRAMEBUFFER,Bt.COLOR_ATTACHMENT0,Bt.TEXTURE_2D,i.__webglTexture,s),0!==r?Bt.blitFramebuffer(c,h,a,o,d,p,a,o,Bt.COLOR_BUFFER_BIT,Bt.NEAREST):T?Bt.copyTexSubImage3D(_,s,d,p,f+t,c,h,a,o):Bt.copyTexSubImage2D(_,s,d,p,c,h,a,o);it.bindFramebuffer(Bt.READ_FRAMEBUFFER,null),it.bindFramebuffer(Bt.DRAW_FRAMEBUFFER,null)}else T?t.isDataTexture||t.isData3DTexture?Bt.texSubImage3D(_,s,d,p,f,a,o,l,g,v,m.data):e.isCompressedArrayTexture?Bt.compressedTexSubImage3D(_,s,d,p,f,a,o,l,g,m.data):Bt.texSubImage3D(_,s,d,p,f,a,o,l,g,v,m):t.isDataTexture?Bt.texSubImage2D(Bt.TEXTURE_2D,s,d,p,a,o,g,v,m.data):t.isCompressedTexture?Bt.compressedTexSubImage2D(Bt.TEXTURE_2D,s,d,p,m.width,m.height,g,m.data):Bt.texSubImage2D(Bt.TEXTURE_2D,s,d,p,a,o,g,v,m);Bt.pixelStorei(Bt.UNPACK_ROW_LENGTH,x),Bt.pixelStorei(Bt.UNPACK_IMAGE_HEIGHT,y),Bt.pixelStorei(Bt.UNPACK_SKIP_PIXELS,M),Bt.pixelStorei(Bt.UNPACK_SKIP_ROWS,b),Bt.pixelStorei(Bt.UNPACK_SKIP_IMAGES,S),0===s&&e.generateMipmaps&&Bt.generateMipmap(_),it.unbindTexture()},this.initRenderTarget=function(t){void 0===lt.get(t).__webglFramebuffer&&ct.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?ct.setTextureCube(t,0):t.isData3DTexture?ct.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?ct.setTexture2DArray(t,0):ct.setTexture2D(t,0),it.unbindTexture()},this.resetState=function(){A=0,C=0,R=null,it.reset(),Ot.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ze}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=bn._getDrawingBufferColorSpace(t),e.unpackColorSpace=bn._getUnpackColorSpace()}}const Wp=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:4,AddEquation:l,AddOperation:2,AdditiveAnimationBlendMode:Me,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:yt,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Cc,AnimationAction:dh,AnimationClip:nc,AnimationLoader:class extends oc{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new hc(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(n){try{e(r.parse(JSON.parse(n)))}catch(s){i?i(s):Je(s),r.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=nc.parse(t[n]);e.push(i)}return e}},AnimationMixer:fh,AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=sn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,s=r.length;let a,o=t.length,l=this.nCachedObjects_;for(let c=0,h=arguments.length;c!==h;++c){const h=arguments[c],u=h.uuid;let d=e[u];if(void 0===d){d=o++,e[u]=d,t.push(h);for(let t=0,e=s;t!==e;++t)r[t].push(new uh(h,n[t],i[t]))}else if(d<l){a=t[d];const o=--l,c=t[o];e[c.uuid]=d,t[d]=c,e[u]=o,t[o]=h;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[o];let a=e[d];e[d]=s,void 0===a&&(a=new uh(h,n[t],i[t])),e[o]=a}}else t[d]!==a&&Je("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s],o=a.uuid,l=e[o];if(void 0!==l&&l>=r){const s=r++,c=t[s];e[c.uuid]=l,t[l]=c,e[o]=s,t[s]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l<r){const a=--r,o=t[a],c=--s,h=t[c];e[o.uuid]=l,t[l]=o,e[h.uuid]=a,t[a]=h,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[a],r=e[c];e[l]=i,e[a]=r,e.pop()}}else{const r=--s,a=t[r];r>0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,s.push(t),a.push(e),r.push(h);for(let u=c,d=o.length;u!==d;++u){const n=o[u];h[u]=new uh(n,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},AnimationUtils:class{static convertArray(t,e){return kl(t,e)}static isTypedArray(t){return We(t)}static getKeyframeOrder(t){return Vl(t)}static sortedArray(t,e,n){return Gl(t,e,n)}static flattenJSON(t,e,n,i){Hl(t,e,n,i)}static subclip(t,e,n,i,r=30){return function(t,e,n,i,r=30){const s=t.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const t=s.tracks[l],e=t.getValueSize(),o=[],c=[];for(let s=0;s<t.times.length;++s){const a=t.times[s]*r;if(!(a<n||a>=i)){o.push(t.times[s]);for(let n=0;n<e;++n)c.push(t.values[s*e+n])}}0!==o.length&&(t.times=kl(o,t.times.constructor),t.values=kl(c,t.values.constructor),a.push(t))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}(t,e,n,i,r)}static makeClipAdditive(t,e=0,n=t,i=30){return function(t,e=0,n=t,i=30){i<=0&&(i=30);const r=n.tracks.length,s=e/i;for(let a=0;a<r;++a){const e=n.tracks[a],i=e.ValueTypeName;if("bool"===i||"string"===i)continue;const r=t.tracks.find(function(t){return t.name===e.name&&t.ValueTypeName===i});if(void 0===r)continue;let o=0;const l=e.getValueSize();e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let c=0;const h=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);const u=e.times.length-1;let d;if(s<=e.times[0]){const t=o,n=l-o;d=e.values.slice(t,n)}else if(s>=e.times[u]){const t=u*l+o,n=t+l-o;d=e.values.slice(t,n)}else{const t=e.createInterpolant(),n=o,i=l-o;t.evaluate(s),d=t.resultBuffer.slice(n,i)}"quaternion"===i&&(new pn).fromArray(d).normalize().conjugate().toArray(d);const p=r.times.length;for(let t=0;t<p;++t){const e=t*h+c;if("quaternion"===i)pn.multiplyQuaternionsFlat(r.values,e,d,0,r.values,e);else{const t=h-2*c;for(let n=0;n<t;++n)r.values[e+n]-=d[n]}}}return t.blendMode=Me,t}(t,e,n,i)}},ArcCurve:mo,ArrayCamera:Xc,ArrowHelper:class extends Bi{constructor(t=new fn(0,0,1),e=new fn(0,0,0),n=1,i=16776960,r=.2*n,s=.2*r){super(),this.type="ArrowHelper",void 0===qh&&(qh=new Er,qh.setAttribute("position",new _r([0,0,0,0,1,0],3)),Yh=new ro(.5,1,5,1),Yh.translate(0,-.5,0)),this.position.copy(e),this.line=new Fa(qh,new Ra({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Br(Yh,new or({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,r,s)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Xh.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Xh,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:W,Audio:Qc,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}},AudioContext:Gc,AudioListener:class extends Bi{constructor(){super(),this.type="AudioListener",this.context=Gc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new qc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Yc,Zc,Kc),Jc.set(0,0,-1).applyQuaternion(Zc),$c.set(0,1,0).applyQuaternion(Zc),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Yc.x,t),e.positionY.linearRampToValueAtTime(Yc.y,t),e.positionZ.linearRampToValueAtTime(Yc.z,t),e.forwardX.linearRampToValueAtTime(Jc.x,t),e.forwardY.linearRampToValueAtTime(Jc.y,t),e.forwardZ.linearRampToValueAtTime(Jc.z,t),e.upX.linearRampToValueAtTime($c.x,t),e.upY.linearRampToValueAtTime($c.y,t),e.upZ.linearRampToValueAtTime($c.z,t)}else e.setPosition(Yc.x,Yc.y,Yc.z),e.setOrientation(Jc.x,Jc.y,Jc.z,$c.x,$c.y,$c.z)}},AudioLoader:class extends oc{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new hc(this.manager);function a(e){i?i(e):Je(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(t){try{const n=t.slice(0);Gc.getContext().decodeAudioData(n,function(t){e(t)}).catch(a)}catch(n){a(n)}},n,i)}},AxesHelper:class extends Va{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new Er;n.setAttribute("position",new _r(e,3)),n.setAttribute("color",new _r([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new Ra({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new ir,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:Ca,Bone:zs,BooleanKeyframeTrack:Zl,Box2:class{constructor(t=new dn(1/0,1/0),e=new dn(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Sh.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(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}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}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}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Sh).distanceTo(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}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)}},Box3:Bn,Box3Helper:class extends Va{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Er;i.setIndex(new mr(n,1)),i.setAttribute("position",new _r([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Ra({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:kr,BoxHelper:class extends Va{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Er;r.setIndex(new mr(n,1)),r.setAttribute("position",new mr(i,3)),super(r,new Ra({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&jh.setFromObject(this.object),jh.isEmpty())return;const t=jh.min,e=jh.max,n=this.geometry.attributes.position,i=n.array;i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=t.x,i[4]=e.y,i[5]=e.z,i[6]=t.x,i[7]=t.y,i[8]=e.z,i[9]=e.x,i[10]=t.y,i[11]=e.z,i[12]=e.x,i[13]=e.y,i[14]=t.z,i[15]=t.x,i[16]=e.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=e.x,i[22]=t.y,i[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:mr,BufferGeometry:Er,BufferGeometryLoader:Uc,ByteType:lt,Cache:rc,Camera:Xr,CameraHelper:class extends Va{constructor(t){const e=new Er,n=new Ra({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],s={};function a(t,e){o(t),o(e)}function o(t){i.push(0,0,0),r.push(0,0,0),void 0===s[t]&&(s[t]=[]),s[t].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new _r(i,3)),e.setAttribute("color",new _r(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new ir(16755200),c=new ir(16711680),h=new ir(43775),u=new ir(16777215),d=new ir(3355443);this.setColors(l,c,h,u,d)}setColors(t,e,n,i,r){const s=this.geometry.getAttribute("color");return s.setXYZ(0,t.r,t.g,t.b),s.setXYZ(1,t.r,t.g,t.b),s.setXYZ(2,t.r,t.g,t.b),s.setXYZ(3,t.r,t.g,t.b),s.setXYZ(4,t.r,t.g,t.b),s.setXYZ(5,t.r,t.g,t.b),s.setXYZ(6,t.r,t.g,t.b),s.setXYZ(7,t.r,t.g,t.b),s.setXYZ(8,t.r,t.g,t.b),s.setXYZ(9,t.r,t.g,t.b),s.setXYZ(10,t.r,t.g,t.b),s.setXYZ(11,t.r,t.g,t.b),s.setXYZ(12,t.r,t.g,t.b),s.setXYZ(13,t.r,t.g,t.b),s.setXYZ(14,t.r,t.g,t.b),s.setXYZ(15,t.r,t.g,t.b),s.setXYZ(16,t.r,t.g,t.b),s.setXYZ(17,t.r,t.g,t.b),s.setXYZ(18,t.r,t.g,t.b),s.setXYZ(19,t.r,t.g,t.b),s.setXYZ(20,t.r,t.g,t.b),s.setXYZ(21,t.r,t.g,t.b),s.setXYZ(22,t.r,t.g,t.b),s.setXYZ(23,t.r,t.g,t.b),s.setXYZ(24,e.r,e.g,e.b),s.setXYZ(25,e.r,e.g,e.b),s.setXYZ(26,e.r,e.g,e.b),s.setXYZ(27,e.r,e.g,e.b),s.setXYZ(28,e.r,e.g,e.b),s.setXYZ(29,e.r,e.g,e.b),s.setXYZ(30,e.r,e.g,e.b),s.setXYZ(31,e.r,e.g,e.b),s.setXYZ(32,n.r,n.g,n.b),s.setXYZ(33,n.r,n.g,n.b),s.setXYZ(34,n.r,n.g,n.b),s.setXYZ(35,n.r,n.g,n.b),s.setXYZ(36,n.r,n.g,n.b),s.setXYZ(37,n.r,n.g,n.b),s.setXYZ(38,i.r,i.g,i.b),s.setXYZ(39,i.r,i.g,i.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let n,i;if(Hh.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)n=1,i=0;else if(this.camera.coordinateSystem===ze)n=-1,i=1;else{if(this.camera.coordinateSystem!==ke)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);n=0,i=1}Wh("c",e,t,Hh,0,0,n),Wh("t",e,t,Hh,0,0,i),Wh("n1",e,t,Hh,-1,-1,n),Wh("n2",e,t,Hh,1,-1,n),Wh("n3",e,t,Hh,-1,1,n),Wh("n4",e,t,Hh,1,1,n),Wh("f1",e,t,Hh,-1,-1,i),Wh("f2",e,t,Hh,1,-1,i),Wh("f3",e,t,Hh,-1,1,i),Wh("f4",e,t,Hh,1,1,i),Wh("u1",e,t,Hh,.7,1.1,n),Wh("u2",e,t,Hh,-.7,1.1,n),Wh("u3",e,t,Hh,0,2,n),Wh("cf1",e,t,Hh,-1,0,i),Wh("cf2",e,t,Hh,1,0,i),Wh("cf3",e,t,Hh,0,-1,i),Wh("cf4",e,t,Hh,0,1,i),Wh("cn1",e,t,Hh,-1,0,n),Wh("cn2",e,t,Hh,1,0,n),Wh("cn3",e,t,Hh,0,-1,n),Wh("cn4",e,t,Hh,0,1,n),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:class extends Ln{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},CapsuleGeometry:eo,CatmullRomCurve3:Mo,CineonToneMapping:3,CircleGeometry:no,ClampToEdgeWrapping:Q,Clock:qc,Color:ir,ColorKeyframeTrack:Kl,ColorManagement:bn,CompressedArrayTexture:class extends Ja{constructor(t,e,n,i,r,s){super(t,e,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Q,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends Ja{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,q),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:Ja,CompressedTextureLoader:class extends oc{constructor(t){super(t)}load(t,e,n,i){const r=this,s=[],a=new Ja,o=new hc(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function c(c){o.load(t[c],function(t){const n=r.parse(t,!0);s[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=rt),a.image=s,a.format=n.format,a.needsUpdate=!0,e&&e(a))},n,i)}if(Array.isArray(t))for(let h=0,u=t.length;h<u;++h)c(h);else o.load(t,function(t){const n=r.parse(t,!0);if(n.isCubemap){const t=n.mipmaps.length/n.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<n.mipmapCount;t++)s[e].mipmaps.push(n.mipmaps[e*n.mipmapCount+t]),s[e].format=n.format,s[e].width=n.width,s[e].height=n.height}a.image=s}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=rt),a.format=n.format,a.needsUpdate=!0,e&&e(a)},n,i);return a}},ConeGeometry:ro,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:class extends Qe{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){void 0!==t?(null!==this.domElement&&this.disconnect(),this.domElement=t):Ke("Controls: connect() now requires an element.")}disconnect(){}dispose(){}update(){}},CubeCamera:$r,CubeDepthTexture:Qa,CubeReflectionMapping:q,CubeRefractionMapping:Y,CubeTexture:Qr,CubeTextureLoader:pc,CubeUVReflectionMapping:J,CubicBezierCurve:To,CubicBezierCurve3:Eo,CubicInterpolant:jl,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:po,CurvePath:Do,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:io,Cylindrical:class{constructor(t=1,e=0,n=0){this.radius=t,this.theta=e,this.y=n}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Fn,DataArrayTexture:On,DataTexture:ks,DataTextureLoader:class extends oc{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new ks,a=new hc(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(t){let n;try{n=r.parse(t)}catch(a){if(void 0===i)return void a(a);i(a)}void 0!==n.image?s.image=n.image:void 0!==n.data&&(s.image.width=n.width,s.image.height=n.height,s.image.data=n.data),s.wrapS=void 0!==n.wrapS?n.wrapS:Q,s.wrapT=void 0!==n.wrapT?n.wrapT:Q,s.magFilter=void 0!==n.magFilter?n.magFilter:rt,s.minFilter=void 0!==n.minFilter?n.minFilter:rt,s.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(s.colorSpace=n.colorSpace),void 0!==n.flipY&&(s.flipY=n.flipY),void 0!==n.format&&(s.format=n.format),void 0!==n.type&&(s.type=n.type),void 0!==n.mipmaps&&(s.mipmaps=n.mipmaps,s.minFilter=at),1===n.mipmapCount&&(s.minFilter=rt),void 0!==n.generateMipmaps&&(s.generateMipmaps=n.generateMipmaps),s.needsUpdate=!0,e&&e(s,n)},n,i),s}},DataUtils:class{static toHalfFloat(t){return hr(t)}static fromHalfFloat(t){return ur(t)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:ac,DepthFormat:St,DepthStencilFormat:wt,DepthTexture:$a,DetachedBindMode:j,DirectionalLight:Ac,DirectionalLightHelper:class extends Bi{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===e&&(e=1);let i=new Er;i.setAttribute("position",new _r([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new Ra({fog:!1,toneMapped:!1});this.lightPlane=new Fa(i,r),this.add(this.lightPlane),i=new Er,i.setAttribute("position",new _r([0,0,0,0,0,1],3)),this.targetLine=new Fa(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),zh.setFromMatrixPosition(this.light.matrixWorld),kh.setFromMatrixPosition(this.light.target.matrixWorld),Vh.subVectors(kh,zh),this.lightPlane.lookAt(kh),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(kh),this.targetLine.scale.z=Vh.length()}},DiscreteInterpolant:ql,DodecahedronGeometry:ao,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:Fe,DynamicReadUsage:35049,EdgesGeometry:uo,EllipseCurve:fo,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:Z,EquirectangularRefractionMapping:K,Euler:Mi,EventDispatcher:Qe,ExternalTexture:to,ExtrudeGeometry:dl,FileLoader:hc,Float16BufferAttribute:class extends mr{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=ur(this.array[t*this.itemSize]);return this.normalized&&(e=cn(e,this.array)),e}setX(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize]=hr(e),this}getY(t){let e=ur(this.array[t*this.itemSize+1]);return this.normalized&&(e=cn(e,this.array)),e}setY(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+1]=hr(e),this}getZ(t){let e=ur(this.array[t*this.itemSize+2]);return this.normalized&&(e=cn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+2]=hr(e),this}getW(t){let e=ur(this.array[t*this.itemSize+3]);return this.normalized&&(e=cn(e,this.array)),e}setW(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+3]=hr(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array)),this.array[t+0]=hr(e),this.array[t+1]=hr(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),i=hn(i,this.array)),this.array[t+0]=hr(e),this.array[t+1]=hr(n),this.array[t+2]=hr(i),this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),i=hn(i,this.array),r=hn(r,this.array)),this.array[t+0]=hr(e),this.array[t+1]=hr(n),this.array[t+2]=hr(i),this.array[t+3]=hr(r),this}},Float32BufferAttribute:_r,FloatType:pt,Fog:ss,FogExp2:rs,FramebufferTexture:class extends Ln{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=et,this.minFilter=et,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:aa,FrustumArray:ca,GLBufferAttribute:class{constructor(t,e,n,i,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.normalized=s,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:Be,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:Ne,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends Va{constructor(t=10,e=10,n=4473924,i=8947848){n=new ir(n),i=new ir(i);const r=e/2,s=t/e,a=t/2,o=[],l=[];for(let h=0,u=0,d=-a;h<=e;h++,d+=s){o.push(-a,0,d,a,0,d),o.push(d,0,-a,d,0,a);const t=h===r?n:i;t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3}const c=new Er;c.setAttribute("position",new _r(o,3)),c.setAttribute("color",new _r(l,3));super(c,new Ra({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:es,HalfFloatType:ft,HemisphereLight:gc,HemisphereLightHelper:class extends Bi{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new gl(e);i.rotateY(.5*Math.PI),this.material=new or({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),s=new Float32Array(3*r.count);i.setAttribute("color",new mr(s,3)),this.add(new Br(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Fh.copy(this.light.color),Bh.copy(this.light.groundColor);for(let t=0,n=e.count;t<n;t++){const i=t<n/2?Fh:Bh;e.setXYZ(t,i.r,i.g,i.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Oh.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:fl,ImageBitmapLoader:kc,ImageLoader:dc,ImageUtils:En,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:Ws,InstancedBufferGeometry:Nc,InstancedInterleavedBuffer:class extends os{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},InstancedMesh:$s,Int16BufferAttribute:class extends mr{constructor(t,e,n){super(new Int16Array(t),e,n)}},Int32BufferAttribute:class extends mr{constructor(t,e,n){super(new Int32Array(t),e,n)}},Int8BufferAttribute:class extends mr{constructor(t,e,n){super(new Int8Array(t),e,n)}},IntType:ut,InterleavedBuffer:os,InterleavedBufferAttribute:cs,Interpolant:Wl,InterpolateDiscrete:fe,InterpolateLinear:me,InterpolateSmooth:ge,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:Ae,KeyframeTrack:Yl,LOD:Cs,LatheGeometry:ml,Layers:bi,LessCompare:513,LessDepth:2,LessEqualCompare:Ie,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:mc,LightProbe:Ic,Line:Fa,Line3:class{constructor(t=new fn,e=new fn){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){wh.subVectors(t,this.start),Th.subVectors(this.end,this.start);const n=Th.dot(Th);let i=Th.dot(wh)/n;return e&&(i=an(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=Rh,n=Ph){const i=1e-8*1e-8;let r,s;const a=this.start,o=t.start,l=this.end,c=t.end;Eh.subVectors(l,a),Ah.subVectors(c,o),Ch.subVectors(a,o);const h=Eh.dot(Eh),u=Ah.dot(Ah),d=Ah.dot(Ch);if(h<=i&&u<=i)return e.copy(a),n.copy(o),e.sub(n),e.dot(e);if(h<=i)r=0,s=d/u,s=an(s,0,1);else{const t=Eh.dot(Ch);if(u<=i)s=0,r=an(-t/h,0,1);else{const e=Eh.dot(Ah),n=h*u-e*e;r=0!==n?an((e*d-t*u)/n,0,1):0,s=(e*r+d)/u,s<0?(s=0,r=an(-t/h,0,1)):s>1&&(s=1,r=an((e-t)/h,0,1))}}return e.copy(a).add(Eh.multiplyScalar(r)),n.copy(o).add(Ah.multiplyScalar(s)),e.sub(n),e.dot(e)}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)}},LineBasicMaterial:Ra,LineCurve:Ao,LineCurve3:Co,LineDashedMaterial:zl,LineLoop:Ga,LineSegments:Va,LinearFilter:rt,LinearInterpolant:Xl,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:at,LinearMipmapNearestFilter:st,LinearSRGBColorSpace:we,LinearToneMapping:1,LinearTransfer:Te,Loader:oc,LoaderUtils:Dc,LoadingManager:sc,LoopOnce:de,LoopPingPong:2202,LoopRepeat:pe,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:ar,MaterialLoader:Lc,MathUtils:un,Matrix2:bh,Matrix3:vn,Matrix4:ui,MaxEquation:104,Mesh:Br,MeshBasicMaterial:or,MeshDepthMaterial:Ol,MeshDistanceMaterial:Fl,MeshLambertMaterial:Ul,MeshMatcapMaterial:Bl,MeshNormalMaterial:Nl,MeshPhongMaterial:Ll,MeshPhysicalMaterial:Il,MeshStandardMaterial:Pl,MeshToonMaterial:Dl,MinEquation:103,MirroredRepeatWrapping:tt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:et,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:it,NearestMipmapNearestFilter:nt,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:be,NoNormalPacking:"",NoToneMapping:0,NormalAnimationBlendMode:ye,NormalBlending:1,NormalGAPacking:"ga",NormalRGPacking:"rg",NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:Jl,Object3D:Bi,ObjectLoader:class extends oc{constructor(t){super(t)}load(t,e,n,i){const r=this,s=""===this.path?Dc.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const a=new hc(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(n){let s=null;try{s=JSON.parse(n)}catch(o){return void 0!==i&&i(o),void o("ObjectLoader: Can't parse "+t+".",o.message)}const a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t)),void Je("ObjectLoader: Can't load "+t);r.parse(s,e)},n,i)}async loadAsync(t,e){const n=""===this.path?Dc.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const i=new hc(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(t,e),s=JSON.parse(r),a=s.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(s)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),s=this.parseImages(t.images,function(){void 0!==e&&e(l)}),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,r,o,a,n),c=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,c),this.bindLightTargets(l),void 0!==e){let t=!1;for(const e in s)if(s[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(l)}return l}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),s=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,s),o=this.parseObject(t.object,i,a,s,e),l=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let n=0,i=t.length;n<i;n++){const i=(new Uo).fromJSON(t[n]);e[i.uuid]=i}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse(function(t){t.isBone&&(i[t.uuid]=t)}),void 0!==t)for(let r=0,s=t.length;r<s;r++){const e=(new Hs).fromJSON(t[r],i);n[e.uuid]=e}return n}parseGeometries(t,e){const n={};if(void 0!==t){const i=new Uc;for(let r=0,s=t.length;r<s;r++){let s;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":s=i.parse(a);break;default:a.type in Al?s=Al[a.type].fromJSON(a,e):Ke(`ObjectLoader: Unsupported geometry type "${a.type}"`)}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.userData&&(s.userData=a.userData),n[a.uuid]=s}}return n}parseMaterials(t,e){const n={},i={};if(void 0!==t){const r=new Lc;r.setTextures(e);for(let e=0,s=t.length;e<s;e++){const s=t[e];void 0===n[s.uuid]&&(n[s.uuid]=r.parse(s)),i[s.uuid]=n[s.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let n=0;n<t.length;n++){const i=t[n],r=nc.parse(i);e[r.uuid]=r}return e}parseImages(t,e){const n=this,i={};let r;function s(t){if("string"==typeof t){const e=t;return function(t){return n.manager.itemStart(t),r.load(t,function(){n.manager.itemEnd(t)},void 0,function(){n.manager.itemError(t),n.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e)}return t.data?{data:He(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const n=new sc(e);r=new dc(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,r=t.length;e<r;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,n=r.length;e<n;e++){const n=s(r[e]);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new ks(n.data,n.width,n.height)))}i[n.uuid]=new Cn(t)}else{const t=s(n.url);i[n.uuid]=new Cn(t)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function r(t){if("string"==typeof t){const n=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:e.resourcePath+n;return await i.loadAsync(r)}return t.data?{data:He(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new dc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.url;if(Array.isArray(s)){const t=[];for(let e=0,n=s.length;e<n;e++){const n=s[e],i=await r(n);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new ks(i.data,i.width,i.height)))}n[i.uuid]=new Cn(t)}else{const t=await r(i.url);n[i.uuid]=new Cn(t)}}}return n}parseTextures(t,e){function n(t,e){return"number"==typeof t?t:(Ke("ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const i={};if(void 0!==t)for(let r=0,s=t.length;r<s;r++){const s=t[r];void 0===s.image&&Ke('ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&Ke("ObjectLoader: Undefined image",s.image);const a=e[s.image],o=a.data;let l;Array.isArray(o)?(l=new Qr,6===o.length&&(l.needsUpdate=!0)):(l=o&&o.data?new ks:new Ln,o&&(l.needsUpdate=!0)),l.source=a,l.uuid=s.uuid,void 0!==s.name&&(l.name=s.name),void 0!==s.mapping&&(l.mapping=n(s.mapping,Oc)),void 0!==s.channel&&(l.channel=s.channel),void 0!==s.offset&&l.offset.fromArray(s.offset),void 0!==s.repeat&&l.repeat.fromArray(s.repeat),void 0!==s.center&&l.center.fromArray(s.center),void 0!==s.rotation&&(l.rotation=s.rotation),void 0!==s.wrap&&(l.wrapS=n(s.wrap[0],Fc),l.wrapT=n(s.wrap[1],Fc)),void 0!==s.format&&(l.format=s.format),void 0!==s.internalFormat&&(l.internalFormat=s.internalFormat),void 0!==s.type&&(l.type=s.type),void 0!==s.colorSpace&&(l.colorSpace=s.colorSpace),void 0!==s.minFilter&&(l.minFilter=n(s.minFilter,Bc)),void 0!==s.magFilter&&(l.magFilter=n(s.magFilter,Bc)),void 0!==s.anisotropy&&(l.anisotropy=s.anisotropy),void 0!==s.flipY&&(l.flipY=s.flipY),void 0!==s.generateMipmaps&&(l.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(l.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(l.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(l.compareFunction=s.compareFunction),void 0!==s.userData&&(l.userData=s.userData),i[s.uuid]=l}return i}parseObject(t,e,n,i,r){let s,a,o;function l(t){return void 0===e[t]&&Ke("ObjectLoader: Undefined geometry",t),e[t]}function c(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===n[r]&&Ke("ObjectLoader: Undefined material",r),e.push(n[r])}return e}return void 0===n[t]&&Ke("ObjectLoader: Undefined material",t),n[t]}}function h(t){return void 0===i[t]&&Ke("ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":s=new as,void 0!==t.background&&(Number.isInteger(t.background)?s.background=new ir(t.background):s.background=h(t.background)),void 0!==t.environment&&(s.environment=h(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?s.fog=new ss(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(s.fog=new rs(t.fog.color,t.fog.density)),""!==t.fog.name&&(s.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(s.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(s.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&s.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(s.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&s.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":s=new Kr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(s.focus=t.focus),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.filmGauge&&(s.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(s.filmOffset=t.filmOffset),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"OrthographicCamera":s=new Tc(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(s.zoom=t.zoom),void 0!==t.view&&(s.view=Object.assign({},t.view));break;case"AmbientLight":s=new Cc(t.color,t.intensity);break;case"DirectionalLight":s=new Ac(t.color,t.intensity),s.target=t.target||"";break;case"PointLight":s=new wc(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":s=new Rc(t.color,t.intensity,t.width,t.height);break;case"SpotLight":s=new bc(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),s.target=t.target||"";break;case"HemisphereLight":s=new gc(t.color,t.groundColor,t.intensity);break;case"LightProbe":const e=(new Pc).fromArray(t.sh);s=new Ic(e,t.intensity);break;case"SkinnedMesh":a=l(t.geometry),o=c(t.material),s=new Bs(a,o),void 0!==t.bindMode&&(s.bindMode=t.bindMode),void 0!==t.bindMatrix&&s.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(s.skeleton=t.skeleton);break;case"Mesh":a=l(t.geometry),o=c(t.material),s=new Br(a,o);break;case"InstancedMesh":a=l(t.geometry),o=c(t.material);const n=t.count,i=t.instanceMatrix,r=t.instanceColor;s=new $s(a,o,n),s.instanceMatrix=new Ws(new Float32Array(i.array),16),void 0!==r&&(s.instanceColor=new Ws(new Float32Array(r.array),r.itemSize));break;case"BatchedMesh":a=l(t.geometry),o=c(t.material),s=new Ca(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),s.geometry=a,s.perObjectFrustumCulled=t.perObjectFrustumCulled,s.sortObjects=t.sortObjects,s._drawRanges=t.drawRanges,s._reservedRanges=t.reservedRanges,s._geometryInfo=t.geometryInfo.map(t=>{let e=null,n=null;return void 0!==t.boundingBox&&(e=(new Bn).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(n=(new ni).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:n}}),s._instanceInfo=t.instanceInfo,s._availableInstanceIds=t._availableInstanceIds,s._availableGeometryIds=t._availableGeometryIds,s._nextIndexStart=t.nextIndexStart,s._nextVertexStart=t.nextVertexStart,s._geometryCount=t.geometryCount,s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._matricesTexture=h(t.matricesTexture.uuid),s._indirectTexture=h(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=h(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(s.boundingSphere=(new ni).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(s.boundingBox=(new Bn).fromJSON(t.boundingBox));break;case"LOD":s=new Cs;break;case"Line":s=new Fa(l(t.geometry),c(t.material));break;case"LineLoop":s=new Ga(l(t.geometry),c(t.material));break;case"LineSegments":s=new Va(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":s=new Ya(l(t.geometry),c(t.material));break;case"Sprite":s=new ws(c(t.material));break;case"Group":s=new es;break;case"Bone":s=new zs;break;default:s=new Bi}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)s.add(this.parseObject(a[t],e,n,i,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const n=e[t];s.animations.push(r[n])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(s.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const n=e[t],i=s.getObjectByProperty("uuid",n.object);void 0!==i&&s.addLevel(i,n.distance,n.hysteresis)}}return s}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const n=e[t.skeleton];void 0===n?Ke("ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(n,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const n=e.target,i=t.getObjectByProperty("uuid",n);e.target=void 0!==i?i:new Bi}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:gl,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:g,OneMinusSrcColorFactor:203,OrthographicCamera:Tc,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:xu,Path:No,PerspectiveCamera:Kr,Plane:na,PlaneGeometry:vl,PlaneHelper:class extends Fa{constructor(t,e=1,n=16776960){const i=n,r=new Er;r.setAttribute("position",new _r([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new Ra({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const s=new Er;s.setAttribute("position",new _r([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new Br(s,new or({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:wc,PointLightHelper:class extends Br{constructor(t,e,n){super(new yl(e,4,2),new or({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:Ya,PointsMaterial:Ha,PolarGridHelper:class extends Va{constructor(t=10,e=16,n=8,i=64,r=4473924,s=8947848){r=new ir(r),s=new ir(s);const a=[],o=[];if(e>1)for(let c=0;c<e;c++){const n=c/e*(2*Math.PI),i=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(i,0,l);const h=1&c?r:s;o.push(h.r,h.g,h.b),o.push(h.r,h.g,h.b)}for(let c=0;c<n;c++){const e=1&c?r:s,l=t-t/n*c;for(let t=0;t<i;t++){let n=t/i*(2*Math.PI),r=Math.sin(n)*l,s=Math.cos(n)*l;a.push(r,0,s),o.push(e.r,e.g,e.b),n=(t+1)/i*(2*Math.PI),r=Math.sin(n)*l,s=Math.cos(n)*l,a.push(r,0,s),o.push(e.r,e.g,e.b)}}const l=new Er;l.setAttribute("position",new _r(a,3)),l.setAttribute("color",new _r(o,3));super(l,new Ra({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:so,PositionalAudio:class extends Qc{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(th,eh,nh),ih.set(0,0,1).applyQuaternion(eh);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(th.x,t),e.positionY.linearRampToValueAtTime(th.y,t),e.positionZ.linearRampToValueAtTime(th.z,t),e.orientationX.linearRampToValueAtTime(ih.x,t),e.orientationY.linearRampToValueAtTime(ih.y,t),e.orientationZ.linearRampToValueAtTime(ih.z,t)}else e.setPosition(th.x,th.y,th.z),e.setOrientation(ih.x,ih.y,ih.z)}},PropertyBinding:uh,PropertyMixer:rh,QuadraticBezierCurve:Ro,QuadraticBezierCurve3:Po,Quaternion:pn,QuaternionKeyframeTrack:Ql,QuaternionLinearInterpolant:$l,R11_EAC_Format:Vt,RED_GREEN_RGTC2_Format:he,RED_RGTC1_Format:le,REVISION:n,RG11_EAC_Format:Ht,RGBADepthPacking:3201,RGBAFormat:bt,RGBAIntegerFormat:Rt,RGBA_ASTC_10x10_Format:ne,RGBA_ASTC_10x5_Format:Qt,RGBA_ASTC_10x6_Format:te,RGBA_ASTC_10x8_Format:ee,RGBA_ASTC_12x10_Format:ie,RGBA_ASTC_12x12_Format:re,RGBA_ASTC_4x4_Format:jt,RGBA_ASTC_5x4_Format:Xt,RGBA_ASTC_5x5_Format:qt,RGBA_ASTC_6x5_Format:Yt,RGBA_ASTC_6x6_Format:Zt,RGBA_ASTC_8x5_Format:Kt,RGBA_ASTC_8x6_Format:Jt,RGBA_ASTC_8x8_Format:$t,RGBA_BPTC_Format:se,RGBA_ETC2_EAC_Format:kt,RGBA_PVRTC_2BPPV1_Format:Ft,RGBA_PVRTC_4BPPV1_Format:Ot,RGBA_S3TC_DXT1_Format:It,RGBA_S3TC_DXT3_Format:Lt,RGBA_S3TC_DXT5_Format:Dt,RGBDepthPacking:3202,RGBFormat:Mt,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:ae,RGB_BPTC_UNSIGNED_Format:oe,RGB_ETC1_Format:Bt,RGB_ETC2_Format:zt,RGB_PVRTC_2BPPV1_Format:Ut,RGB_PVRTC_4BPPV1_Format:Nt,RGB_S3TC_DXT1_Format:Pt,RGDepthPacking:3203,RGFormat:At,RGIntegerFormat:Ct,RawShaderMaterial:Rl,Ray:hi,Raycaster:_h,RectAreaLight:Rc,RedFormat:Tt,RedIntegerFormat:Et,ReinhardToneMapping:2,RenderTarget:Nn,RenderTarget3D:class extends Nn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Fn(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:$,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:_l,SIGNED_R11_EAC_Format:Gt,SIGNED_RED_GREEN_RGTC2_Format:ue,SIGNED_RED_RGTC1_Format:ce,SIGNED_RG11_EAC_Format:Wt,SRGBColorSpace:Se,SRGBTransfer:Ee,Scene:as,ShaderChunk:$h,ShaderLib:tu,ShaderMaterial:jr,ShadowMaterial:Cl,Shape:Uo,ShapeGeometry:xl,ShapePath:class{constructor(){this.type="ShapePath",this.color=new ir,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new No,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;s<n;r=s++){let n=e[r],a=e[s],o=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=e[s],o=-o,a=e[r],l=-l),t.y<n.y||t.y>a.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=cl.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Uo,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let m=0,g=i.length;m<g;m++)s=i[m],u=s.getPoints(),r=n(u),r=t?!r:r,r?(!l&&h[f]&&f++,h[f]={s:new Uo,p:u},h[f].s.curves=s.curves,l&&f++,p[f]=[]):p[f].push({h:s,p:u[0]});if(!h[0])return function(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n],r=new Uo;r.curves=i.curves,e.push(r)}return e}(i);if(h.length>1){let t=!1,n=0;for(let e=0,i=h.length;e<i;e++)c[e]=[];for(let i=0,r=h.length;i<r;i++){const r=p[i];for(let s=0;s<r.length;s++){const a=r[s];let o=!0;for(let r=0;r<h.length;r++)e(a.p,h[r].p)&&(i!==r&&n++,o?(o=!1,c[r].push(a)):t=!0);o&&c[i].push(a)}}n>0&&!1===t&&(p=c)}for(let m=0,g=h.length;m<g;m++){a=h[m].s,o.push(a),d=p[m];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}},ShapeUtils:cl,ShortType:ct,Skeleton:Hs,SkeletonHelper:class extends Va{constructor(t){const e=Uh(t),n=new Er,i=[],r=[];for(let o=0;o<e.length;o++){const t=e[o];t.parent&&t.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}n.setAttribute("position",new _r(i,3)),n.setAttribute("color",new _r(r,3));super(n,new Ra({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const s=new ir(255),a=new ir(65280);this.setColors(s,a)}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");Nh.copy(this.root.matrixWorld).invert();for(let r=0,s=0;r<e.length;r++){const t=e[r];t.parent&&t.parent.isBone&&(Dh.multiplyMatrices(Nh,t.matrixWorld),Lh.setFromMatrixPosition(Dh),i.setXYZ(s,Lh.x,Lh.y,Lh.z),Dh.multiplyMatrices(Nh,t.parent.matrixWorld),Lh.setFromMatrixPosition(Dh),i.setXYZ(s+1,Lh.x,Lh.y,Lh.z),s+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const n=this.geometry.getAttribute("color");for(let i=0;i<n.count;i+=2)n.setXYZ(i,t.r,t.g,t.b),n.setXYZ(i+1,e.r,e.g,e.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Bs,Source:Cn,Sphere:ni,SphereGeometry:yl,Spherical:class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=an(this.phi,t,Math.PI-t),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(an(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:Pc,SplineCurve:Io,SpotLight:bc,SpotLightHelper:class extends Bi{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Er,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,a=1,o=32;s<o;s++,a++){const t=s/o*Math.PI*2,e=a/o*Math.PI*2;i.push(Math.cos(t),Math.sin(t),1,Math.cos(e),Math.sin(e),1)}n.setAttribute("position",new _r(i,3));const r=new Ra({fog:!1,toneMapped:!1});this.cone=new Va(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Ih.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ih),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:ws,SpriteMaterial:hs,SrcAlphaFactor:m,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:Oe,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Kr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Kr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,jc.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(nn*e.fov*.5)/e.zoom;let s,a;Wc.elements[12]=-n,Hc.elements[12]=n,s=-r*e.aspect+i,a=r*e.aspect+i,jc.elements[0]=2*e.near/(a-s),jc.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(jc),s=-r*e.aspect-i,a=r*e.aspect-i,jc.elements[0]=2*e.near/(a-s),jc.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(jc)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Wc),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Hc)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:tc,SubtractEquation:101,SubtractiveBlending:3,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:0,TetrahedronGeometry:Ml,Texture:Ln,TextureLoader:fc,TextureUtils:class{static contain(t,e){return function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,n,i){return Zh(t,e,n,i)}},Timer:class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=Mh.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}},TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:bl,TorusKnotGeometry:Sl,Triangle:$i,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:wl,UVMapping:X,Uint16BufferAttribute:gr,Uint32BufferAttribute:vr,Uint8BufferAttribute:class extends mr{constructor(t,e,n){super(new Uint8Array(t),e,n)}},Uint8ClampedBufferAttribute:class extends mr{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}},Uniform:mh,UniformsGroup:class extends Qe{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:gh++}),this.name="",this.usage=Oe,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let n=0,i=e.length;n<i;n++){const t=Array.isArray(e[n])?e[n]:[e[n]];for(let e=0;e<t.length;e++)this.uniforms.push(t[e].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:Qh,UniformsUtils:Wr,UnsignedByteType:ot,UnsignedInt101111Type:xt,UnsignedInt248Type:vt,UnsignedInt5999Type:_t,UnsignedIntType:dt,UnsignedShort4444Type:mt,UnsignedShort5551Type:gt,UnsignedShortType:ht,VSMShadowMap:3,Vector2:dn,Vector3:fn,Vector4:Dn,VectorKeyframeTrack:ec,VideoFrameTexture:class extends Ka{constructor(t,e,n,i,r,s,a,o){super({},t,e,n,i,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:Ka,WebGL3DRenderTarget:class extends Un{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Fn(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Un{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new On(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:ze,WebGLCubeRenderTarget:ts,WebGLRenderTarget:Un,WebGLRenderer:Hp,WebGLUtils:Np,WebGPUCoordinateSystem:ke,WebXRController:is,WireframeGeometry:Tl,WrapAroundEnding:xe,ZeroCurvatureEnding:ve,ZeroFactor:200,ZeroSlopeEnding:_e,ZeroStencilOp:0,createCanvasElement:Xe,error:Je,getConsoleFunction:function(){return Ye},log:Ze,setConsoleFunction:function(t){Ye=t},warn:Ke,warnOnce:$e},Symbol.toStringTag,{value:"Module"}));class jp{constructor(t,e){this.width=t,this.height=e,this.pixels=new Uint16Array(t*e*4)}fill(t=0,e=0,n=0,i=65535){const r=this.pixels;for(let s=0;s<r.length;s+=4)r[s]=t,r[s+1]=e,r[s+2]=n,r[s+3]=i}pset(t,e,n,i,r,s=65535){if(t<0||e<0||t>=this.width||e>=this.height)return;const a=4*(e*this.width+t),o=this.pixels;o[a]=n,o[a+1]=i,o[a+2]=r,o[a+3]=s}}class Xp{constructor(t,e,n){this.canvas=t,this.w=e,this.h=n,this.renderer=new Hp({canvas:t,antialias:!0,alpha:!1,premultipliedAlpha:!1,powerPreference:"high-performance",precision:"highp",stencil:!0,preserveDrawingBuffer:!1,failIfMajorPerformanceCaveat:!1}),this.renderer.setSize(t.width,t.height),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.outputColorSpace=Se,this.renderer.toneMapping=4,this.renderer.toneMappingExposure=1.25,this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=1,this.renderer.shadowMap.autoUpdate=!0,this.renderer.sortObjects=!0,this.renderer.setClearColor(657935,1);const i=this.renderer.getContext();i.enable(i.DEPTH_TEST),i.enable(i.CULL_FACE),i.cullFace(i.BACK),this.scene=new as,this.camera=new Kr(75,t.width/t.height,.1,1e3),this.camera.position.z=5,this.setupN64Lighting(),this.fb=new jp(e,n),this.overlay2D=this.create2DOverlay(e,n),this.spriteBatches=new Map,this.texCache=new WeakMap,this.animatedMeshes=[],this.frustum=new aa,this._projScreenMatrix=new ui,this.cameraTarget=new fn(0,0,0),this.cameraOffset=new fn(0,0,5),this.stats={triangles:0,drawCalls:0,geometries:0}}setupN64Lighting(){const t=new Cc(6316160,.5);this.scene.add(t);const e=new gc(16777147,526368,.6);this.scene.add(e),this.mainLight=new Ac(16777215,1.8),this.mainLight.position.set(5,8,3),this.mainLight.castShadow=!0,this.mainLight.shadow.mapSize.width=4096,this.mainLight.shadow.mapSize.height=4096,this.mainLight.shadow.camera.near=.1,this.mainLight.shadow.camera.far=200,this.mainLight.shadow.camera.left=-100,this.mainLight.shadow.camera.right=100,this.mainLight.shadow.camera.top=100,this.mainLight.shadow.camera.bottom=-100,this.mainLight.shadow.bias=-5e-5,this.mainLight.shadow.normalBias=.02,this.scene.add(this.mainLight);const n=new Ac(4227327,.8);n.position.set(-8,4,-5),n.castShadow=!1,this.scene.add(n);const i=new Ac(16728192,.6);i.position.set(5,-3,8),i.castShadow=!1,this.scene.add(i);const r=new Ac(8453952,.4);r.position.set(-3,6,-2),r.castShadow=!1,this.scene.add(r);const s=new wc(16755200,2,30);s.position.set(10,15,10),s.castShadow=!0,s.shadow.mapSize.width=1024,s.shadow.mapSize.height=1024,this.scene.add(s);const a=new wc(43775,1.5,25);a.position.set(-10,10,-10),a.castShadow=!0,a.shadow.mapSize.width=1024,a.shadow.mapSize.height=1024,this.scene.add(a);try{const t=new xu(this.renderer);t.compileEquirectangularShader();const e=new ir(1712192),n=new as;n.background=e,this.scene.environment=t.fromScene(n).texture,t.dispose()}catch(o){}this.scene.fog=new rs(2105424,.005),this.lights={main:this.mainLight,fill1:n,fill2:i,fill3:r,point1:s,point2:a,ambient:t,hemisphere:e}}create2DOverlay(t,e){const n=new Tc(0,t,e,0,-1,1),i=new as,r=new Uint8Array(t*e*4),s=new ks(r,t,e,bt);s.needsUpdate=!0,s.flipY=!1;const a=new vl(t,e),o=new or({map:s,transparent:!0,depthTest:!1,depthWrite:!1,blending:1}),l=new Br(a,o);return l.position.set(t/2,e/2,0),i.add(l),{camera:n,scene:i,texture:s,pixels:r}}beginFrame(){this.spriteBatches.clear(),this.fb.fill(0,0,0,0)}endFrame(){this.update(.016),"function"==typeof globalThis.updateLODs&&globalThis.updateLODs(),"function"==typeof globalThis.isEffectsEnabled&&globalThis.isEffectsEnabled()&&"function"==typeof globalThis.renderEffects?globalThis.renderEffects():this.renderer.render(this.scene,this.camera),this.update2DOverlay()}update2DOverlay(){const t=this.fb.pixels,e=this.fb.width,n=this.fb.height,i=this.overlay2D.pixels;for(let r=0;r<n;r++){const s=r*e*4,a=(n-1-r)*e*4;for(let n=0;n<e;n++){const e=s+4*n,r=a+4*n;i[r]=t[e]/257,i[r+1]=t[e+1]/257,i[r+2]=t[e+2]/257,i[r+3]=t[e+3]/257}}this.overlay2D.texture.needsUpdate=!0,this.renderer.setRenderTarget(null),this.renderer.autoClear=!1,this.renderer.render(this.overlay2D.scene,this.overlay2D.camera),this.renderer.autoClear=!0}updateCameraPosition(){this.camera.position.copy(this.cameraOffset).add(this.cameraTarget),this.camera.lookAt(this.cameraTarget)}getScene(){return this.scene}getCamera(){return this.camera}getRenderer(){return this.renderer}setCameraPosition(t,e,n){this.camera.position.set(t,e,n)}setCameraTarget(t,e,n){this.cameraTarget.set(t,e,n),this.camera.lookAt(this.cameraTarget)}setCameraFOV(t){this.camera.fov=t,this.camera.updateProjectionMatrix()}setFog(t,e=10,n=50){this.scene.fog=new ss(t,e,n)}setLightDirection(t,e,n){this.mainLight&&this.mainLight.position.set(t,e,n)}setLightColor(t){this.mainLight&&this.mainLight.color.setHex(t)}setAmbientLight(t,e){this.lights&&this.lights.ambient&&(this.lights.ambient.color.setHex(t),"number"==typeof e&&(this.lights.ambient.intensity=e))}createN64Material(t={}){const{color:e=16777215,texture:n=null,normalMap:i=null,roughnessMap:r=null,aoMap:s=null,metallic:a=!1,metalness:o=(a?.9:0),emissive:l=0,emissiveIntensity:c=0,roughness:h=.6,transparent:u=!1,alphaTest:d=.5,animated:p=!1,holographic:f=!1}=t;let m;if(f||c>.5?m=new Pl({color:e,emissive:new ir(l),emissiveIntensity:Math.max(c,.4),metalness:.8,roughness:.1,transparent:!0,opacity:.9,side:2,fog:!0}):a?m=new Pl({color:e,metalness:.9,roughness:.4*h,envMapIntensity:2.5,transparent:u,alphaTest:d,side:2,fog:!0}):(m=new Ll({color:e,transparent:u,alphaTest:d,side:2,shininess:60,specular:4473924,fog:!0,reflectivity:.2}),0!==l&&(m.emissive=new ir(l),m.emissiveIntensity=Math.max(c,.3))),n&&(m.map=n,n.magFilter=et,n.minFilter=et,n.generateMipmaps=!1,n.wrapS=$,n.wrapT=$,p&&(n.offset.set(.1*Math.random(),.1*Math.random()),m.userData.animateTexture=!0)),i&&m.isMeshPhongMaterial){const t=new Pl({color:m.color,emissive:m.emissive||new ir(0),emissiveIntensity:m.emissiveIntensity||0,roughness:h,metalness:o,map:m.map||null,transparent:m.transparent,alphaTest:m.alphaTest,side:m.side,fog:m.fog});m.dispose(),m=t}return i&&void 0!==m.normalMap&&(m.normalMap=i,i.wrapS=$,i.wrapT=$,m.normalMapType=0),r&&void 0!==m.roughnessMap&&(m.roughnessMap=r),s&&void 0!==m.aoMap&&(m.aoMap=s,m.aoMapIntensity=1),m.userData.animated=p,m.userData.holographic=f,m}createBoxGeometry(t=1,e=1,n=1){return new kr(t,e,n)}createSphereGeometry(t=1,e=8){return new yl(t,e,e)}createPlaneGeometry(t=1,e=1){return new vl(t,e)}createCylinderGeometry(t=1,e=1,n=1,i=16){return new io(t,e,n,i)}createConeGeometry(t=1,e=2,n=16){return new ro(t,e,n)}createCapsuleGeometry(t=.5,e=1,n=8){return new eo(t,e,n,2*n)}getFramebuffer(){return this.fb}supportsSpriteBatch(){return!0}queueSprite(t,e,n,i,r,s,a,o=1){const l=this._getTexture(t);let c=this.spriteBatches.get(l);c||(c=[],this.spriteBatches.set(l,c)),c.push({sx:e,sy:n,sw:i,sh:r,dx:s,dy:a,scale:o,tex:l,iw:t.naturalWidth,ih:t.naturalHeight})}_getTexture(t){let e=this.texCache.get(t);return e||(e=new Ln(t),e.generateMipmaps=!1,e.minFilter=et,e.magFilter=et,e.needsUpdate=!0,this.texCache.set(t,e),e)}flushSprites(){for(const[,t]of this.spriteBatches)for(const e of t)this.renderSpriteToFramebuffer(e)}renderSpriteToFramebuffer(t){}getStats(){return{...this.stats,memory:this.renderer.info.memory,render:this.renderer.info.render}}enablePixelation(t=2){t<=0?this.renderer.setPixelRatio(window.devicePixelRatio||1):this.renderer.setPixelRatio(1/t)}enableDithering(t=!0){this.renderer.dithering=t}enableBloom(t=!0){this.renderer.toneMappingExposure=t?1.2:1}enableMotionBlur(t=.5){this.motionBlurFactor=t}registerAnimatedMesh(t){t&&!this.animatedMeshes.includes(t)&&this.animatedMeshes.push(t)}clearAnimatedMeshes(){this.animatedMeshes=[]}update(t){const e=.001*performance.now();this.camera.updateMatrixWorld(),this._projScreenMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this._projScreenMatrix),this.animatedMeshes=this.animatedMeshes.filter(t=>t.parent);for(const n of this.animatedMeshes){const i=n.material;i&&i.userData.animated&&(this.frustum.intersectsObject(n)&&(i.userData.animateTexture&&i.map&&(i.map.offset.x+=.1*t,i.map.offset.y+=.05*t),i.emissive&&i.userData.holographic&&(i.emissiveIntensity=.3+.2*Math.sin(4*e))))}this.lights&&(this.lights.point1.position.x=10+3*Math.sin(.5*e),this.lights.point1.position.y=15+2*Math.cos(.7*e),this.lights.point2.position.x=4*Math.cos(.6*e)-10,this.lights.point2.position.z=3*Math.sin(.4*e)-10),this.scene.fog&&this.scene.fog.density&&(this.scene.fog.density=.005+.001*Math.sin(.5*e))}render(){this.renderer.render(this.scene,this.camera),this.stats.triangles=this.renderer.info.render.triangles,this.stats.drawCalls=this.renderer.info.render.calls,this.stats.geometries=this.renderer.info.memory.geometries}}const qp=new Map,Yp={A:[" # "," # # ","# #","#####","# #","# #","# #"],B:["#### ","# #","#### ","# #","# #","# #","#### "],C:[" ### ","# #","# ","# ","# ","# #"," ### "],D:["#### ","# #","# #","# #","# #","# #","#### "],E:["#####","# ","### ","# ","# ","# ","#####"],F:["#####","# ","### ","# ","# ","# ","# "],G:[" ### ","# #","# ","# ###","# #","# #"," ### "],H:["# #","# #","# #","#####","# #","# #","# #"],I:["#####"," # "," # "," # "," # "," # ","#####"],J:["#####"," #"," #"," #","# #","# #"," ### "],K:["# #","# # ","### ","# # ","# # ","# #","# #"],L:["# ","# ","# ","# ","# ","# ","#####"],M:["# #","## ##","# # #","# #","# #","# #","# #"],N:["# #","## #","# # #","# ##","# #","# #","# #"],O:[" ### ","# #","# #","# #","# #","# #"," ### "],P:["#### ","# #","# #","#### ","# ","# ","# "],Q:[" ### ","# #","# #","# #","# # #","# # "," ## #"],R:["#### ","# #","# #","#### ","# # ","# # ","# #"],S:[" ### ","# #","# "," ### "," #","# #"," ### "],T:["#####"," # "," # "," # "," # "," # "," # "],U:["# #","# #","# #","# #","# #","# #"," ### "],V:["# #","# #","# #","# #","# #"," # # "," # "],W:["# #","# #","# #","# # #","# # #","## ##","# #"],X:["# #"," # # "," # "," # "," # "," # # ","# #"],Y:["# #"," # # "," # "," # "," # "," # "," # "],Z:["#####"," #"," # "," # "," # ","# ","#####"],0:[" ### ","# #","# ##","# # #","## #","# #"," ### "],1:[" # "," ## "," # "," # "," # "," # ","#####"],2:[" ### ","# #"," #"," # "," # "," # ","#####"],3:[" ### ","# #"," #"," ### "," #","# #"," ### "],4:[" # "," ## "," # # ","# # ","#####"," # "," # "],5:["#####","# ","#### "," #"," #","# #"," ### "],6:[" ### ","# ","# ","#### ","# #","# #"," ### "],7:["#####"," #"," # "," # "," # "," # "," # "],8:[" ### ","# #","# #"," ### ","# #","# #"," ### "],9:[" ### ","# #","# #"," ####"," #"," #"," ### "]," ":[" "," "," "," "," "," "," "],"!":[" # "," # "," # "," # "," # "," "," # "],"?":[" ### ","# #"," #"," # "," # "," "," # "],".":[" "," "," "," "," "," ## "," ## "],",":[" "," "," "," "," "," ## "," # "],":":[" "," ## "," ## "," "," ## "," ## "," "],"-":[" "," "," "," ### "," "," "," "],_:[" "," "," "," "," "," ","#####"],"/":[" #"," # "," # "," # "," # ","# "," "],a:[" "," "," ### "," #"," ####","# #"," ####"],b:["# ","# ","#### ","# #","# #","# #","#### "],c:[" "," "," ### ","# ","# ","# #"," ### "],d:[" #"," #"," ####","# #","# #","# #"," ####"],e:[" "," "," ### ","# #","#####","# "," ### "],f:[" ## "," # #"," # ","#### "," # "," # "," # "],g:[" "," "," ####","# #","# #"," ####"," #"," ### "],h:["# ","# ","#### ","# #","# #","# #","# #"],i:[" # "," "," # "," # "," # "," # "," # "],j:[" # "," "," # "," # "," # "," # ","# # "," ## "],k:["# ","# ","# # ","# # ","### ","# # ","# #"],l:[" # "," # "," # "," # "," # "," # "," # "],m:[" "," ","## # ","# # #","# # #","# # #","# # #"],n:[" "," ","#### ","# #","# #","# #","# #"],o:[" "," "," ### ","# #","# #","# #"," ### "],p:[" "," ","#### ","# #","# #","#### ","# ","# "],q:[" "," "," ####","# #","# #"," ####"," #"," #"],r:[" "," ","# ## ","## ","# ","# ","# "],s:[" "," "," ### ","# "," ### "," #","#### "],t:[" # "," # ","#### "," # "," # "," # #"," ## "],u:[" "," ","# #","# #","# #","# #"," ####"],v:[" "," ","# #","# #","# #"," # # "," # "],w:[" "," ","# #","# # #","# # #","# # #"," # # "],x:[" "," ","# #"," # # "," # "," # # ","# #"],y:[" "," ","# #","# #","# #"," ####"," #"," ### "],z:[" "," ","#####"," # "," # "," # ","#####"],"(":[" # "," # ","# ","# ","# "," # "," # "],")":[" # "," # "," #"," #"," #"," # "," # "],"[":["### ","# ","# ","# ","# ","# ","### "],"]":[" ###"," #"," #"," #"," #"," #"," ###"],"{":[" ## "," # "," # ","## "," # "," # "," ## "],"}":["## "," # "," # "," ##"," # "," # ","## "],"<":[" # "," # "," # ","# "," # "," # "," # "],">":["# "," # "," # "," # "," # "," # ","# "],"=":[" "," ","#####"," ","#####"," "," "],"+":[" "," # "," # ","#####"," # "," # "," "],"*":[" ","# # #"," ### "," # "," ### ","# # #"," "],"&":[" ## ","# # "," ## "," ### ","# # ","# # "," ## #"],"%":["# #"," # "," # "," # ","# ","# #"," "],$:[" # "," ####","# # "," ### "," # #","#### "," # "],"#":[" # # "," # # ","#####"," # # ","#####"," ## #"," # # "],"@":[" ### ","# #","# # #","# ###","# ","# #"," ### "],"^":[" # "," # # ","# #"," "," "," "," "],"~":[" "," ## ","# # "," ## "," "," "," "],"`":[" # "," # "," "," "," "," "," "],"'":[" # "," # "," "," "," "," "," "],'"':[" # # "," # # "," "," "," "," "," "],"|":[" # "," # "," # "," # "," # "," # "," # "],"\\":["# "," # "," # "," # "," # "," #"," "],";":[" "," ## "," ## "," "," ## "," ## "," # "]},Zp=[["โ",[" # "," ## "," ### ","#### "," ### "," ## "," # "]],["โ",["# ","## ","### ","#### ","### ","## ","# "]],["โ",[" # "," ### ","# # #"," # "," # "," # "," # "]],["โ",[" # "," # "," # "," # ","# # #"," ### "," # "]],["โ",["# #","## #"," ####","#### "," ####","## ##","# #"]],["โ",[" # "," ### ","# # #"," # ","# # #"," ### "," # "]]];for(const[lv,cv]of Zp)qp.set(lv,cv),Yp[lv]=cv;for(const[lv,cv]of Object.entries(Yp))qp.set(lv,cv);const Kp={"๐ฎ":"","๐":"","๐":"","๐๏ธ":"","๐ฐ":"","๐ฎ":"*","๐":"","โก":"*","โจ":"*","โ
":"+","๐":"o","๐ฏ":"o","๐ก๏ธ":"","๐ฑ๏ธ":"","๐ฅ๏ธ":"","โ๏ธ":"*","๐ค":""};const Jp={w:5,h:7,spacing:1,draw(t,e,n,i,r,s=1){e=function(t){let e="";for(let n=0;n<t.length;n++){const i=t[n],r=i.charCodeAt(0);Object.prototype.hasOwnProperty.call(Kp,i)?e+=Kp[i]:r>127&&!qp.has(i)||(e+=i)}return e}(e);const{r:a,g:o,b:l,a:c}=function(t){if("bigint"==typeof t)return{r:Number(t>>48n&0xffffn),g:Number(t>>32n&0xffffn),b:Number(t>>16n&0xffffn),a:Number(0xffffn&t)};{const e=BigInt(t);return{r:Number(e>>48n&0xffffn),g:Number(e>>32n&0xffffn),b:Number(e>>16n&0xffffn),a:Number(0xffffn&e)}}}(r),h=Math.max(1,Math.round(s));let u=0|n,d=0|i;for(let p=0;p<e.length;p++){const i=e[p];if("\n"===i){d+=8*h,u=0|n;continue}const r=qp.get(i)||qp.get("?");for(let e=0;e<7;e++){const n=r[e];for(let i=0;i<5;i++)if(" "!==n[i])if(1===h)t.pset(u+i,d+e,a,o,l,c);else for(let n=0;n<h;n++)for(let r=0;r<h;r++)t.pset(u+i*h+r,d+e*h+n,a,o,l,c)}u+=6*h}}};function $p(t,e,n,i){return BigInt(Math.floor(t))<<48n|BigInt(Math.floor(e))<<32n|BigInt(Math.floor(n))<<16n|BigInt(Math.floor(i))}function Qp(t){if("bigint"==typeof t)return{r:Number(t>>48n&0xffffn),g:Number(t>>32n&0xffffn),b:Number(t>>16n&0xffffn),a:Number(0xffffn&t)};{const e=BigInt(Math.floor(t));return{r:Number(e>>48n&0xffffn),g:Number(e>>32n&0xffffn),b:Number(e>>16n&0xffffn),a:Number(0xffffn&e)}}}function tf(t,e,n,i=255){const r=257;return $p(Math.max(0,Math.min(255,Math.floor(t)))*r,Math.max(0,Math.min(255,Math.floor(e)))*r,Math.max(0,Math.min(255,Math.floor(n)))*r,Math.max(0,Math.min(255,Math.floor(i)))*r)}class ef{constructor(t,e,n=8){this.image=t,this.sheetWidth=e,this.tileSize=n,this.cols=Math.floor(e/n)}}async function nf(t){const e=new Image;return e.src=t,await e.decode(),e}function rf(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let n=t.getIndex();if(null===n){const e=[],i=t.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<i.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const i=n.count-2,r=[];if(2===e)for(let t=1;t<=i;t++)r.push(n.getX(0)),r.push(n.getX(t)),r.push(n.getX(t+1));else for(let t=0;t<i;t++)t%2==0?(r.push(n.getX(t)),r.push(n.getX(t+1)),r.push(n.getX(t+2))):(r.push(n.getX(t+2)),r.push(n.getX(t+1)),r.push(n.getX(t)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}class sf extends oc{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new uf(t)}),this.register(function(t){return new df(t)}),this.register(function(t){return new Mf(t)}),this.register(function(t){return new bf(t)}),this.register(function(t){return new Sf(t)}),this.register(function(t){return new ff(t)}),this.register(function(t){return new mf(t)}),this.register(function(t){return new gf(t)}),this.register(function(t){return new vf(t)}),this.register(function(t){return new hf(t)}),this.register(function(t){return new _f(t)}),this.register(function(t){return new pf(t)}),this.register(function(t){return new yf(t)}),this.register(function(t){return new xf(t)}),this.register(function(t){return new lf(t)}),this.register(function(t){return new wf(t)}),this.register(function(t){return new Tf(t)})}load(t,e,n,i){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const e=Dc.extractUrlBase(t);s=Dc.resolveURL(e,this.path)}else s=Dc.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){i?i(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new hc(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(n){try{r.parse(n,s,function(n){e(n),r.manager.itemEnd(t)},a)}catch(i){a(i)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},a={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===Ef){try{s[of.KHR_BINARY_GLTF]=new Rf(t)}catch(c){return void(i&&i(c))}r=JSON.parse(s[of.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new em(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const t=this.pluginCallbacks[h](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[t.name]=t,s[t.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const t=r.extensionsUsed[h],e=r.extensionsRequired||[];switch(t){case of.KHR_MATERIALS_UNLIT:s[t]=new cf;break;case of.KHR_DRACO_MESH_COMPRESSION:s[t]=new Pf(r,this.dracoLoader);break;case of.KHR_TEXTURE_TRANSFORM:s[t]=new If;break;case of.KHR_MESH_QUANTIZATION:s[t]=new Lf;break;default:e.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise(function(i,r){n.parse(t,e,i,r)})}}function af(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const of={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lf{constructor(t){this.parser=t,this.name=of.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let a;const o=new ir(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],we);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new Ac(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new wc(o),a.distance=l;break;case"spot":a=new bc(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),Zf(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),i=Promise.resolve(a),e.cache.add(n,i),i}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(t){return n._getNodeRef(e.cache,r,t)})}}class cf{constructor(){this.name=of.KHR_MATERIALS_UNLIT}getMaterialType(){return or}extendParams(t,e,n){const i=[];t.color=new ir(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],we),t.opacity=e[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(t,"map",r.baseColorTexture,Se))}return Promise.all(i)}}class hf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class uf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new dn(t,t)}return Promise.all(r)}}class df{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class pf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class ff{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new ir(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=i.extensions[this.name];if(void 0!==s.sheenColorFactor){const t=s.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],we)}return void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Se)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class mf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=(new ir).setRGB(a[0],a[1],a[2],we),Promise.all(r)}}class vf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class _f{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=(new ir).setRGB(a[0],a[1],a[2],we),void 0!==s.specularColorTexture&&r.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture,Se)),Promise.all(r)}}class xf{constructor(t){this.parser=t,this.name=of.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return e.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(n.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class yf{constructor(t){this.parser=t,this.name=of.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Il:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class Mf{constructor(t){this.parser=t,this.name=of.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class bf{constructor(t){this.parser=t,this.name=of.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return n.loadTextureImage(t,s.source,o)}}class Sf{constructor(t){this.parser=t,this.name=of.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return n.loadTextureImage(t,s.source,o)}}class wf{constructor(t){this.name=of.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then(function(t){return t.buffer}):r.ready.then(function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e})})}return null}}class Tf{constructor(t){this.name=of.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const o of i.primitives)if(o.mode!==Of.TRIANGLES&&o.mode!==Of.TRIANGLE_STRIP&&o.mode!==Of.TRIANGLE_FAN&&void 0!==o.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const o in r)s.push(this.parser.getDependency("accessor",r[o]).then(t=>(a[o]=t,a[o])));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then(t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const s of n){const t=new ui,e=new fn,n=new pn,o=new fn(1,1,1),l=new $s(s.geometry,s.material,i);for(let r=0;r<i;r++)a.TRANSLATION&&e.fromBufferAttribute(a.TRANSLATION,r),a.ROTATION&&n.fromBufferAttribute(a.ROTATION,r),a.SCALE&&o.fromBufferAttribute(a.SCALE,r),l.setMatrixAt(r,t.compose(e,n,o));for(const i in a)if("_COLOR_0"===i){const t=a[i];l.instanceColor=new Ws(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==i&&"ROTATION"!==i&&"SCALE"!==i&&s.geometry.setAttribute(i,a[i]);Bi.prototype.copy.call(l,s),this.parser.assignFinalMaterial(l),r.push(l)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]}))}}const Ef="glTF",Af=1313821514,Cf=5130562;class Rf{constructor(t){this.name=of.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Ef)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<i;){const e=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Af){const i=new Uint8Array(t,12+s,e);this.content=n.decode(i)}else if(i===Cf){const n=12+s;this.body=t.slice(n,n+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Pf{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=of.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},l={};for(const c in s){const t=Vf[c]||c.toLowerCase();a[t]=s[c]}for(const c in t.attributes){const e=Vf[c]||c.toLowerCase();if(void 0!==s[c]){const i=n.accessors[t.attributes[c]],r=Ff[i.componentType];l[e]=r.name,o[e]=!0===i.normalized}}return e.getDependency("bufferView",r).then(function(t){return new Promise(function(e,n){i.decodeDracoFile(t,function(t){for(const e in t.attributes){const n=t.attributes[e],i=o[e];void 0!==i&&(n.normalized=i)}e(t)},a,l,we,n)})})}}class If{constructor(){this.name=of.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Lf{constructor(){this.name=of.KHR_MESH_QUANTIZATION}}class Df extends Wl{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let s=0;s!==i;s++)e[s]=n[r+s];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,c=i-e,h=(n-e)/c,u=h*h,d=u*h,p=t*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,_=g-u+h;for(let x=0;x!==a;x++){const t=s[f+x+a],e=s[f+x+o]*c,n=s[p+x+a],i=s[p+x]*c;r[x]=v*t+_*e+m*n+g*i}return r}}const Nf=new pn;class Uf extends Df{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return Nf.fromArray(r).normalize().toArray(r),r}}const Of={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ff={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Bf={9728:et,9729:rt,9984:nt,9985:st,9986:it,9987:at},zf={33071:Q,33648:tt,10497:$},kf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vf={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Gf={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Hf={CUBICSPLINE:void 0,LINEAR:me,STEP:fe},Wf="OPAQUE",jf="MASK",Xf="BLEND";function qf(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new Pl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),t.DefaultMaterial}function Yf(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function Zf(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Kf(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Jf(t){let e;const n=t.extensions&&t.extensions[of.KHR_DRACO_MESH_COMPRESSION];if(e=n?"draco:"+n.bufferView+":"+n.indices+":"+$f(n.attributes):t.indices+":"+$f(t.attributes)+":"+t.mode,void 0!==t.targets)for(let i=0,r=t.targets.length;i<r;i++)e+=":"+$f(t.targets[i]);return e}function $f(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function Qf(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const tm=new ui;class em{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new af,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);i=n&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new fc(this.options.manager):this.textureLoader=new kc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new hc(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(t){return t._markDefs&&t._markDefs()}),Promise.all(this._invokeAll(function(t){return t.beforeRoot&&t.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return Yf(r,s,i),Zf(s,i),Promise.all(n._invokeAll(function(t){return t.afterRoot&&t.afterRoot(s)})).then(function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=e.length;i<r;i++){const n=e[i].joints;for(let e=0,i=n.length;e<i;e++)t[n[e]].isBone=!0}for(let i=0,r=t.length;i<r;i++){const e=t[i];void 0!==e.mesh&&(this._addNodeRef(this.meshCache,e.mesh),void 0!==e.skin&&(n[e.mesh].isSkinnedMesh=!0)),void 0!==e.camera&&this._addNodeRef(this.cameraCache,e.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[i,s]of t.children.entries())r(s,e.children[i])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne(function(t){return t.loadNode&&t.loadNode(e)});break;case"mesh":i=this._invokeOne(function(t){return t.loadMesh&&t.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(function(t){return t.loadBufferView&&t.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(function(t){return t.loadMaterial&&t.loadMaterial(e)});break;case"texture":i=this._invokeOne(function(t){return t.loadTexture&&t.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne(function(t){return t.loadAnimation&&t.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map(function(e,i){return n.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[of.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(t,r){n.load(Dc.resolveURL(e.uri,i.path),t,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(t){const n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)})}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse){const t=kf[i.type],e=Ff[i.componentType],n=!0===i.normalized,r=new e(i.count*t);return Promise.resolve(new mr(r,t,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(t){const r=t[0],s=kf[i.type],a=Ff[i.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,c=i.byteOffset||0,h=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,u=!0===i.normalized;let d,p;if(h&&h!==l){const t=Math.floor(c/h),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let l=e.cache.get(n);l||(d=new a(r,t*h,i.count*h/o),l=new os(d,h/o),e.cache.add(n,l)),p=new cs(l,s,c%h/o,u)}else d=null===r?new a(i.count*s):new a(r,c,i.count*s),p=new mr(d,s,u);if(void 0!==i.sparse){const e=kf.SCALAR,n=Ff[i.sparse.indices.componentType],o=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(t[1],o,i.sparse.count*e),h=new a(t[2],l,i.sparse.count*s);null!==r&&(p=new mr(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let t=0,i=c.length;t<i;t++){const e=c[t];if(p.setX(e,h[t*s]),s>=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=u}return p})}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then(function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=Bf[n.magFilter]||rt,e.minFilter=Bf[n.minFilter]||at,e.wrapS=zf[n.wrapS]||$,e.wrapT=zf[n.wrapT]||$,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==et&&e.minFilter!==rt,i.associations.set(e,{textures:t}),e}).catch(function(){return null});return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(t=>t.clone());const s=i.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then(function(t){l=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o});else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const c=Promise.resolve(o).then(function(t){return new Promise(function(n,i){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new Ln(t);e.needsUpdate=!0,n(e)}),e.load(Dc.resolveURL(t,r.path),s,void 0,i)})}).then(function(t){var e;return!0===l&&a.revokeObjectURL(o),Zf(t,s),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t}).catch(function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t});return this.sourceCache[t]=c,c}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[of.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[of.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[of.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Ha,ar.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Ra,ar.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return Pl}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[of.KHR_MATERIALS_UNLIT]){const t=i[of.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new ir(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],we),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,Se)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne(function(e){return e.getMaterialType&&e.getMaterialType(t)}),o.push(Promise.all(this._invokeAll(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)})))}!0===r.doubleSided&&(a.side=2);const l=r.alphaMode||Wf;if(l===Xf?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===jf&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==or&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new dn(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==or&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==or){const t=r.emissiveFactor;a.emissive=(new ir).setRGB(t[0],t[1],t[2],we)}return void 0!==r.emissiveTexture&&s!==or&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Se)),Promise.all(o).then(function(){const n=new s(a);return r.name&&(n.name=r.name),Zf(n,r),e.associations.set(n,{materials:t}),r.extensions&&Yf(i,n,r),n})}createUniqueName(t){const e=uh.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[of.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then(function(n){return nm(n,t,e)})}const s=[];for(let a=0,o=t.length;a<o;a++){const n=t[a],o=Jf(n),l=i[o];if(l)s.push(l.promise);else{let t;t=n.extensions&&n.extensions[of.KHR_DRACO_MESH_COMPRESSION]?r(n):nm(new Er,n,e),i[o]={primitive:n,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,i=this.extensions,r=n.meshes[t],s=r.primitives,a=[];for(let o=0,l=s.length;o<l;o++){const t=void 0===s[o].material?qf(this.cache):this.getDependency("material",s[o].material);a.push(t)}return a.push(e.loadGeometries(s)),Promise.all(a).then(function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let h=0,u=o.length;h<u;h++){const n=o[h],c=s[h];let u;const d=a[h];if(c.mode===Of.TRIANGLES||c.mode===Of.TRIANGLE_STRIP||c.mode===Of.TRIANGLE_FAN||void 0===c.mode)u=!0===r.isSkinnedMesh?new Bs(n,d):new Br(n,d),!0===u.isSkinnedMesh&&u.normalizeSkinWeights(),c.mode===Of.TRIANGLE_STRIP?u.geometry=rf(u.geometry,1):c.mode===Of.TRIANGLE_FAN&&(u.geometry=rf(u.geometry,2));else if(c.mode===Of.LINES)u=new Va(n,d);else if(c.mode===Of.LINE_STRIP)u=new Fa(n,d);else if(c.mode===Of.LINE_LOOP)u=new Ga(n,d);else{if(c.mode!==Of.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);u=new Ya(n,d)}Object.keys(u.geometry.morphAttributes).length>0&&Kf(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),Zf(u,r),c.extensions&&Yf(i,u,c),e.assignFinalMaterial(u),l.push(u)}for(let i=0,r=l.length;i<r;i++)e.associations.set(l[i],{meshes:t,primitives:i});if(1===l.length)return r.extensions&&Yf(i,l[0],r),l[0];const c=new es;r.extensions&&Yf(i,c,r),e.associations.set(c,{meshes:t});for(let t=0,e=l.length;t<e;t++)c.add(l[t]);return c})}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(i)return"perspective"===n.type?e=new Kr(un.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new Tc(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),Zf(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n=[];for(let i=0,r=e.joints.length;i<r;i++)n.push(this._loadNodeShallow(e.joints[i]));return void 0!==e.inverseBindMatrices?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(t){const n=t.pop(),i=t,r=[],s=[];for(let a=0,o=i.length;a<o;a++){const t=i[a];if(t){r.push(t);const e=new ui;null!==n&&e.fromArray(n.array,16*a),s.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[a])}return new Hs(r,s)})}loadAnimation(t){const e=this.json,n=this,i=e.animations[t],r=i.name?i.name:"animation_"+t,s=[],a=[],o=[],l=[],c=[];for(let h=0,u=i.channels.length;h<u;h++){const t=i.channels[h],e=i.samplers[t.sampler],n=t.target,r=n.node,u=void 0!==i.parameters?i.parameters[e.input]:e.input,d=void 0!==i.parameters?i.parameters[e.output]:e.output;void 0!==n.node&&(s.push(this.getDependency("node",r)),a.push(this.getDependency("accessor",u)),o.push(this.getDependency("accessor",d)),l.push(e),c.push(n))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c)]).then(function(t){const e=t[0],s=t[1],a=t[2],o=t[3],l=t[4],c=[];for(let i=0,r=e.length;i<r;i++){const t=e[i],r=s[i],h=a[i],u=o[i],d=l[i];if(void 0===t)continue;t.updateMatrix&&t.updateMatrix();const p=n._createAnimationTracks(t,r,h,u,d);if(p)for(let e=0;e<p.length;e++)c.push(p[e])}const h=new nc(r,void 0,c);return Zf(h,i),h})}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then(function(t){const e=n._getNodeRef(n.meshCache,i.mesh,t);return void 0!==i.weights&&e.traverse(function(t){if(t.isMesh)for(let e=0,n=i.weights.length;e<n;e++)t.morphTargetInfluences[e]=i.weights[e]}),e})}loadNode(t){const e=this,n=this.json.nodes[t],i=e._loadNodeShallow(t),r=[],s=n.children||[];for(let o=0,l=s.length;o<l;o++)r.push(e.getDependency("node",s[o]));const a=void 0===n.skin?Promise.resolve(null):e.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),a]).then(function(t){const e=t[0],n=t[1],i=t[2];null!==i&&e.traverse(function(t){t.isSkinnedMesh&&t.bind(i,tm)});for(let r=0,s=n.length;r<s;r++)e.add(n[r]);return e})}_loadNodeShallow(t){const e=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return o&&a.push(o),void 0!==r.camera&&a.push(i.getDependency("camera",r.camera).then(function(t){return i._getNodeRef(i.cameraCache,r.camera,t)})),i._invokeAll(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(t){a.push(t)}),this.nodeCache[t]=Promise.all(a).then(function(e){let a;if(a=!0===r.isBone?new zs:e.length>1?new es:1===e.length?e[0]:new Bi,a!==e[0])for(let t=0,n=e.length;t<n;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),Zf(a,r),r.extensions&&Yf(n,a,r),void 0!==r.matrix){const t=new ui;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);if(i.associations.has(a)){if(void 0!==r.mesh&&i.meshCache.refs[r.mesh]>1){const t=i.associations.get(a);i.associations.set(a,{...t})}}else i.associations.set(a,{});return i.associations.get(a).nodes=t,a}),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],i=this,r=new es;n.name&&(r.name=i.createUniqueName(n.name)),Zf(r,n),n.extensions&&Yf(e,r,n);const s=n.nodes||[],a=[];for(let o=0,l=s.length;o<l;o++)a.push(i.getDependency("node",s[o]));return Promise.all(a).then(function(t){for(let e=0,n=t.length;e<n;e++)r.add(t[e]);return i.associations=(t=>{const e=new Map;for(const[n,r]of i.associations)(n instanceof ar||n instanceof Ln)&&e.set(n,r);return t.traverse(t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)}),e})(r),r})}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(Gf[r.path]===Gf.weights?t.traverse(function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)}):o.push(a),Gf[r.path]){case Gf.weights:l=Jl;break;case Gf.rotation:l=Ql;break;case Gf.translation:case Gf.scale:l=ec;break;default:if(1===n.itemSize)l=Jl;else l=ec}const c=void 0!==i.interpolation?Hf[i.interpolation]:me,h=this._getArrayFromAccessor(n);for(let u=0,d=o.length;u<d;u++){const t=new l(o[u]+"."+Gf[r.path],e.array,h,c);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(t),s.push(t)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=Qf(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*t;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof Ql?Uf:Df)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function nm(t,e,n){const i=e.attributes,r=[];function s(e,i){return n.getDependency("accessor",e).then(function(e){t.setAttribute(i,e)})}for(const a in i){const e=Vf[a]||a.toLowerCase();e in t.attributes||r.push(s(i[a],e))}if(void 0!==e.indices&&!t.index){const i=n.getDependency("accessor",e.indices).then(function(e){t.setIndex(e)});r.push(i)}return bn.workingColorSpace!==we&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${bn.workingColorSpace}" not supported.`),Zf(t,e),function(t,e,n){const i=e.attributes,r=new Bn;if(void 0===i.POSITION)return;{const t=n.json.accessors[i.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new fn(e[0],e[1],e[2]),new fn(s[0],s[1],s[2])),t.normalized){const e=Qf(Ff[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new fn,e=new fn;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,a=i.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),i.normalized){const t=Qf(Ff[i.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const a=new ni;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=a}(t,e,n),Promise.all(r).then(function(){return void 0!==e.targets?function(t,e,n){let i=!1,r=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const t=e[c];if(void 0!==t.POSITION&&(i=!0),void 0!==t.NORMAL&&(r=!0),void 0!==t.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(t);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const h=e[c];if(i){const e=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):t.attributes.position;a.push(e)}if(r){const e=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):t.attributes.normal;o.push(e)}if(s){const e=void 0!==h.COLOR_0?n.getDependency("accessor",h.COLOR_0):t.attributes.color;l.push(e)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(e){const n=e[0],a=e[1],o=e[2];return i&&(t.morphAttributes.position=n),r&&(t.morphAttributes.normal=a),s&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t})}(t,e.targets,n):t})}function im(t){const{scene:n,camera:i,renderer:r,gpu:s,meshes:a,cartLights:o,materialCache:l,instancedMeshes:c,lodObjects:h}=t;return{clearScene:function(){const i=t.disposeMaterial,r=t.removeLight;e.info("๐งน Clearing 3D scene... meshes:",a.size,"lights:",o.size,"materials:",l.size);for(const[,t]of a)n.remove(t),t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(i):i(t.material));for(a.clear(),o.forEach((t,e)=>r(e)),o.clear(),l.forEach(i),l.clear();n.children.length>0;){const t=n.children[0];n.remove(t),t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(i):i(t.material))}n.add(new Cc(16777215,.5));const u=new Ac(16777215,.8);u.position.set(5,10,7.5),n.add(u),s.clearAnimatedMeshes&&s.clearAnimatedMeshes();for(const{mesh:t}of c.values())n.remove(t),t.geometry?.dispose(),t.material?.dispose();c.clear();for(const t of h.values()){n.remove(t);for(const{object:e}of t.levels)e.geometry?.dispose(),e.material?.dispose()}h.clear(),e.info("โ
Scene cleared completely")},setupScene:function(e={}){const n=e.camera??{};t.setCameraPosition(n.x??0,n.y??5,n.z??10),t.setCameraTarget(n.targetX??0,n.targetY??0,n.targetZ??0),n.fov&&t.setCameraFOV(n.fov);const i=e.light??{};if(i.direction){const e=i.direction;t.setLightDirection(e[0]??-.3,e[1]??-1,e[2]??-.5)}void 0!==i.color&&t.setLightColor(i.color),void 0!==i.ambient&&t.setAmbientLight(i.ambient),e.fog&&!1!==e.fog&&t.setFog(e.fog.color??0,e.fog.near??10,e.fog.far??50),e.skybox&&"function"==typeof globalThis.createSpaceSkybox&&globalThis.createSpaceSkybox(e.skybox),e.effects&&"function"==typeof globalThis.enableRetroEffects&&globalThis.enableRetroEffects("object"==typeof e.effects?e.effects:{})},raycastFromCamera:function(t,e){const n=new _h,s=new dn(t/r.domElement.clientWidth*2-1,-e/r.domElement.clientHeight*2+1);n.setFromCamera(s,i);const o=Array.from(a.values()).filter(t=>"Mesh"===t.type),l=n.intersectObjects(o);if(l.length>0)for(const[i,r]of a)if(r===l[0].object)return{meshId:i,point:l[0].point,distance:l[0].distance};return null},get3DStats:function(){return s.getStats()},enablePixelation:function(t=2){s.enablePixelation(t)},enableDithering:function(t=!0){s.enableDithering(t)}}}globalThis.THREE=Wp;class rm{constructor(t){this.spriteApi=t,this.opened=!1,this.scale=16,this.brush={r:255,g:255,b:255,a:255},this._buildUI()}_buildUI(){const t=document.createElement("div");t.style.position="fixed",t.style.inset="0",t.style.display="none",t.style.background="rgba(0,0,0,0.8)",t.style.zIndex="9999",t.style.placeItems="center",t.style.gridTemplateRows="auto auto",t.style.padding="16px";const e=document.createElement("div");e.style.background="#151822",e.style.border="1px solid #1f2433",e.style.borderRadius="12px",e.style.padding="12px",e.style.display="grid",e.style.gap="8px",e.style.color="#dcdfe4";const n=document.createElement("div");n.textContent="Sprite Editor",n.style.fontWeight="700";const i=document.createElement("div");i.textContent="Paint directly on the sprite sheet. Save applies to the running cart.",i.style.fontSize="12px",i.style.opacity="0.7";const r=document.createElement("canvas");r.style.background="#000",r.style.borderRadius="8px",r.style.imageRendering="pixelated",this.canvas=r;const s=document.createElement("input");s.type="color",s.value="#ffffff",s.addEventListener("input",()=>{const t=s.value.replace("#",""),e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);this.brush.r=e,this.brush.g=n,this.brush.b=i});const a=document.createElement("input");a.type="range",a.min="0",a.max="255",a.value="255",a.addEventListener("input",()=>{this.brush.a=parseInt(a.value,10)});const o=document.createElement("select");[8,12,16,20,24,32].forEach(t=>{const e=document.createElement("option");e.value=String(t),e.textContent=t+"x",t===this.scale&&(e.selected=!0),o.appendChild(e)}),o.addEventListener("change",()=>{this.scale=parseInt(o.value,10),this._resizeCanvas(),this._redraw()});const l=document.createElement("button");l.textContent="Save to runtime",l.addEventListener("click",async()=>{await this.applyToRuntime()});const c=document.createElement("button");c.textContent="Close",c.addEventListener("click",()=>this.close()),e.appendChild(n),e.appendChild(i),e.appendChild(((t=[])=>{const e=document.createElement("div");return e.style.display="flex",e.style.gap="8px",e.style.alignItems="center",t.forEach(t=>e.appendChild(t)),e})([document.createTextNode("Zoom"),o,document.createTextNode("Color"),s,document.createTextNode("Alpha"),a,l,c])),e.appendChild(r),t.appendChild(e),document.body.appendChild(t),this.wrap=t;let h=!1;const u=t=>{if(!h)return;const e=r.getBoundingClientRect(),n=Math.floor((t.clientX-e.left)/this.scale),i=Math.floor((t.clientY-e.top)/this.scale);this._plot(n,i,this.brush)};r.addEventListener("mousedown",t=>{h=!0,u(t)}),window.addEventListener("mousemove",u),window.addEventListener("mouseup",()=>{h=!1})}async open(){const t=this.spriteApi.getSpriteSheetImage?.();t?(await this._loadImage(t),this.opened=!0,this.wrap.style.display="grid"):alert("Sprite sheet not loaded in this cart.")}close(){this.opened=!1,this.wrap.style.display="none"}async _loadImage(t){this.img=t,this.sheetW=t.naturalWidth,this.sheetH=t.naturalHeight,this._resizeCanvas();const e=this.canvas.getContext("2d");e.imageSmoothingEnabled=!1,e.drawImage(t,0,0),this._redraw()}_resizeCanvas(){this.canvas.width=this.sheetW*this.scale,this.canvas.height=this.sheetH*this.scale,this.canvas.style.width=this.canvas.width+"px",this.canvas.style.height=this.canvas.height+"px"}_plot(t,e,{r:n,g:i,b:r,a:s}){if(t<0||e<0||t>=this.sheetW||e>=this.sheetH)return;const a=this.canvas.getContext("2d"),o=a.getImageData(t,e,1,1);o.data[0]=n,o.data[1]=i,o.data[2]=r,o.data[3]=s,a.putImageData(o,t,e),a.imageSmoothingEnabled=!1,a.drawImage(this.canvas,t,e,1,1,t*this.scale,e*this.scale,this.scale,this.scale)}_redraw(){const t=this.canvas.getContext("2d");t.imageSmoothingEnabled=!1,t.drawImage(this.img,0,0),t.save(),t.scale(this.scale,this.scale),t.globalAlpha=.2,t.strokeStyle="#3a3f55",t.lineWidth=1/this.scale;for(let e=0;e<=this.sheetW;e+=8)t.beginPath(),t.moveTo(e,0),t.lineTo(e,this.sheetH),t.stroke();for(let e=0;e<=this.sheetH;e+=8)t.beginPath(),t.moveTo(0,e),t.lineTo(this.sheetW,e),t.stroke();t.restore()}async applyToRuntime(){const t=this.canvas.toDataURL("image/png");await this.spriteApi.applySpriteSheetDataURL(t),alert("Sprite sheet applied to runtime.")}}const sm=new class{constructor(){this.active=!1,this.value="",this.maxLen=128,this.placeholder="",this._build()}_build(){const t=document.createElement("input");t.type="text",t.autocomplete="off",t.spellcheck=!1,t.style.position="fixed",t.style.left="50%",t.style.top="10px",t.style.transform="translateX(-50%)",t.style.zIndex="9998",t.style.fontSize="14px",t.style.padding="6px 10px",t.style.borderRadius="8px",t.style.border="1px solid #2a324a",t.style.background="#202538",t.style.color="#dcdfe4",t.style.display="none",document.body.appendChild(t),t.addEventListener("input",()=>{t.value.length>this.maxLen&&(t.value=t.value.slice(0,this.maxLen)),this.value=t.value}),this.el=t}start(t={}){this.active=!0,this.value=t.value||"",this.maxLen=t.maxLen||128,this.placeholder=t.placeholder||"",this.el.placeholder=this.placeholder,this.el.value=this.value,this.el.style.display="block",this.el.focus(),this.el.selectionStart=this.el.selectionEnd=this.el.value.length}stop(){return this.active=!1,this.el.style.display="none",this.el.blur(),this.value}get(){return this.value}};const am=new class{constructor(){this.ctx=null,this.master=null,this.channels=8,this.gains=[]}_ensure(){if(this.ctx)return;const t=new(window.AudioContext||window.webkitAudioContext);this.ctx=t,this.master=t.createGain(),this.master.gain.value=.4,this.master.connect(t.destination);for(let e=0;e<this.channels;e++){const e=t.createGain();e.gain.value=0,e.connect(this.master),this.gains.push(e)}}setVolume(t){this._ensure(),this.master.gain.value=Math.max(0,Math.min(1,t))}sfx(t={}){this._ensure();const e=this.ctx,{wave:n="square",freq:i=440,dur:r=.2,vol:s=.5,sweep:a=0}=t,o=this.gains[Math.floor(Math.random()*this.channels)],l=e.currentTime,c=Math.max(0,Math.min(1,s));if(o.gain.cancelScheduledValues(l),o.gain.setValueAtTime(0,l),o.gain.linearRampToValueAtTime(c,l+.005),o.gain.linearRampToValueAtTime(1e-4,l+r),"noise"===n){const t=16384,n=e.createBuffer(1,t,e.sampleRate),i=n.getChannelData(0);for(let e=0;e<t;e++)i[e]=2*Math.random()-1;const s=e.createBufferSource();return s.buffer=n,s.connect(o),s.start(l),void s.stop(l+r)}const h=e.createOscillator();h.type=n,h.frequency.setValueAtTime(i,l),0!==a&&h.frequency.linearRampToValueAtTime(Math.max(1,i+a*r),l+r),h.connect(o),h.start(l),h.stop(l+r)}},om={0:{wave:"square",freq:880,dur:.1,vol:.4},1:{wave:"sine",freq:220,dur:.3,vol:.3,sweep:-100},2:{wave:"noise",dur:.2,vol:.3},jump:{wave:"square",freq:300,dur:.12,vol:.4,sweep:200},land:{wave:"noise",dur:.08,vol:.3},coin:{wave:"sine",freq:1046,dur:.15,vol:.5,sweep:400},powerup:{wave:"sine",freq:440,dur:.4,vol:.5,sweep:880},explosion:{wave:"noise",dur:.4,vol:.8},laser:{wave:"square",freq:1200,dur:.1,vol:.4,sweep:-800},hit:{wave:"square",freq:200,dur:.15,vol:.5,sweep:-100},death:{wave:"sawtooth",freq:440,dur:.6,vol:.5,sweep:-400},select:{wave:"sine",freq:660,dur:.08,vol:.3},confirm:{wave:"sine",freq:880,dur:.12,vol:.3,sweep:220},error:{wave:"square",freq:180,dur:.3,vol:.4,sweep:-30},blip:{wave:"square",freq:440,dur:.06,vol:.3}};const lm={0:12,1:13,2:4,3:5,4:6,5:7,6:8,7:9,8:13,9:12,12:0,13:3,14:1,15:2},cm={0:"ArrowLeft",1:"ArrowRight",2:"ArrowUp",3:"ArrowDown",4:"KeyZ",5:"KeyX",6:"KeyC",7:"KeyV",8:"KeyA",9:"KeyS",10:"KeyQ",11:"KeyW",12:"Enter",13:"Space"};const hm=new class{constructor(){this.keys=new Map,this.prev=new Map,this.mouse={x:0,y:0,down:!1,prevDown:!1},this.uiCallbacks={setMousePosition:null,setMouseButton:null},this.gamepadButtons=new Map,this.gamepadPrev=new Map,this.gamepadAxes={leftX:0,leftY:0,rightX:0,rightY:0},this.gamepadDeadzone=.15,"undefined"!=typeof window&&(window.addEventListener("keydown",t=>{this.keys.set(t.code,!0)}),window.addEventListener("keyup",t=>{this.keys.set(t.code,!1)}),window.addEventListener("blur",()=>{this.keys.clear()}),window.addEventListener("mousemove",t=>{const e=document.querySelector("canvas");if(e){const n=e.getBoundingClientRect();this.mouse.x=Math.floor((t.clientX-n.left)/n.width*640),this.mouse.y=Math.floor((t.clientY-n.top)/n.height*360),this.uiCallbacks.setMousePosition&&this.uiCallbacks.setMousePosition(this.mouse.x,this.mouse.y)}}),window.addEventListener("mousedown",t=>{this.mouse.down=!0,this.uiCallbacks.setMouseButton&&this.uiCallbacks.setMouseButton(!0)}),window.addEventListener("mouseup",t=>{this.mouse.down=!1,this.uiCallbacks.setMouseButton&&this.uiCallbacks.setMouseButton(!1)}),window.addEventListener("gamepadconnected",t=>{}),window.addEventListener("gamepaddisconnected",t=>{this.gamepadButtons.clear(),this.gamepadPrev.clear()}))}pollGamepad(){const t=(navigator.getGamepads?navigator.getGamepads():[])[0];t&&(t.buttons.forEach((t,e)=>{const n=lm[e];void 0!==n&&this.gamepadButtons.set(n,t.pressed)}),t.axes.length>=4&&(this.gamepadAxes.leftX=Math.abs(t.axes[0])>this.gamepadDeadzone?t.axes[0]:0,this.gamepadAxes.leftY=Math.abs(t.axes[1])>this.gamepadDeadzone?t.axes[1]:0,this.gamepadAxes.rightX=Math.abs(t.axes[2])>this.gamepadDeadzone?t.axes[2]:0,this.gamepadAxes.rightY=Math.abs(t.axes[3])>this.gamepadDeadzone?t.axes[3]:0))}connectUI(t,e){this.uiCallbacks.setMousePosition=t,this.uiCallbacks.setMouseButton=e}step(){this.prev=new Map(this.keys),this.mouse.prevDown=this.mouse.down,this.gamepadPrev=new Map(this.gamepadButtons),this.pollGamepad()}btn(t){return!!this.keys.get(cm[0|t]||"")||!!this.gamepadButtons.get(0|t)}btnp(t){const e=cm[0|t]||"",n=!!this.keys.get(e)&&!this.prev.get(e),i=!!this.gamepadButtons.get(0|t)&&!this.gamepadPrev.get(0|t);return n||i}key(t){return!!this.keys.get(t)}keyp(t){return!!this.keys.get(t)&&!this.prev.get(t)}getGamepadAxis(t){return this.gamepadAxes[t]||0}isGamepadConnected(){const t=navigator.getGamepads?navigator.getGamepads():[];return null!==t[0]&&void 0!==t[0]}isKeyDown(t){return" "===t&&(t="Space"),1===t.length&&(t="Key"+t.toUpperCase()),!!this.keys.get(t)}isKeyPressed(t){return" "===t&&(t="Space"),1===t.length&&(t="Key"+t.toUpperCase()),!!this.keys.get(t)&&!this.prev.get(t)}};class um{constructor(){this.screens=new Map,this.currentScreen=null,this.defaultScreen=null,this._tr=null}addScreen(t,e){if("function"==typeof e){const n=e;this.screens.set(t,new n)}else this.screens.set(t,e);return this.defaultScreen||(this.defaultScreen=t),this}switchTo(t,n={}){const i=this.screens.get(t);if(!i)return e.warn("Screen '"+t+"' not found"),!1;if(this.currentScreen){const t=this.screens.get(this.currentScreen);t&&"function"==typeof t.exit&&t.exit()}return this.currentScreen=t,"function"==typeof i.enter&&i.enter(n),!0}transitionTo(t,n="fade",i=.4,r={}){if(this._tr&&this._tr.active)return;const s=this.screens.get(t);s?(this._tr={active:!0,type:n,duration:i,progress:0,fromName:this.currentScreen,toName:t,data:r,onEnd:null},"function"==typeof s.enter&&s.enter(r)):e.warn("Screen '"+t+"' not found")}onTransitionEnd(t){this._tr&&(this._tr.onEnd=t)}start(t=null){this.switchTo(t||this.defaultScreen)}update(t){if(this._tr&&this._tr.active){this._tr.progress+=t/this._tr.duration,this._tr.progress>=1&&(this._tr.progress=1,this._finishTransition());const e=this._tr&&this._tr.fromName?this.screens.get(this._tr.fromName):null,n=this._tr?this.screens.get(this._tr.toName):null;return e&&"function"==typeof e.update&&e.update(t),void(n&&"function"==typeof n.update&&n.update(t))}if(this.currentScreen){const e=this.screens.get(this.currentScreen);e&&"function"==typeof e.update&&e.update(t)}}_finishTransition(){const t=this._tr;if(t.fromName){const e=this.screens.get(t.fromName);e&&"function"==typeof e.exit&&e.exit()}this.currentScreen=t.toName,this._tr=null,"function"==typeof t.onEnd&&t.onEnd()}draw(){if(this._tr&&this._tr.active)this._drawTransition();else if(this.currentScreen){const t=this.screens.get(this.currentScreen);t&&"function"==typeof t.draw&&t.draw()}}_drawTransition(){const{type:t,progress:e,fromName:n,toName:i}=this._tr,r=n?this.screens.get(n):null,s=this.screens.get(i),a=Math.max(0,Math.min(1,e)),o=a*a*(3-2*a);if("fade"===t){const t=a<.5?Math.round(510*o):0;if(a<.5)r&&"function"==typeof r.draw&&r.draw(),t>0&&"function"==typeof globalThis.rect&&globalThis.rect(0,0,640,360,globalThis.rgba8(0,0,0,Math.min(255,t)),!0);else{s&&"function"==typeof s.draw&&s.draw();const t=Math.round(510*(1-o));t>0&&"function"==typeof globalThis.rect&&globalThis.rect(0,0,640,360,globalThis.rgba8(0,0,0,Math.min(255,t)),!0)}}else if("slide-left"===t||"slide-right"===t){const e="slide-left"===t?-1:1,n=Math.round(640*o),i="function"==typeof globalThis.setCamera?globalThis.setCamera:null;r&&"function"==typeof r.draw&&(i&&i(e*n,0),r.draw()),s&&"function"==typeof s.draw&&(i&&i(e*n-640*e,0),s.draw()),i&&i(0,0)}else if("wipe"===t){if(s&&"function"==typeof s.draw&&s.draw(),r&&"function"==typeof r.draw){const t=Math.round(640*o);"function"==typeof globalThis.setCamera&&globalThis.setCamera(t,0),r.draw(),"function"==typeof globalThis.setCamera&&globalThis.setCamera(0,0)}}else s&&"function"==typeof s.draw&&s.draw()}getCurrentScreen(){return this.currentScreen}getCurrentScreenObject(){return this.currentScreen?this.screens.get(this.currentScreen):null}isTransitioning(){return!(!this._tr||!this._tr.active)}reset(){if(this.currentScreen){const t=this.screens.get(this.currentScreen);t&&"function"==typeof t.exit&&t.exit()}this.screens=new Map,this.currentScreen=null,this.defaultScreen=null,this._tr=null}}class dm{constructor(){this.data={}}enter(t={}){this.data={...this.data,...t}}exit(){}update(t){}draw(){}}const pm={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"};class fm{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const mm=new Tc(-1,1,1,-1,0,1);const gm=new class extends Er{constructor(){super(),this.setAttribute("position",new _r([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _r([0,2,0,0,2,0],2))}};class vm{constructor(t){this._mesh=new Br(gm,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,mm)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class _m extends fm{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof jr?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Wr.clone(t.uniforms),this.material=new jr({name:void 0!==t.name?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new vm(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class xm extends fm{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){const i=t.getContext(),r=t.state;let s,a;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0),this.inverse?(s=0,a=1):(s=1,a=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),r.buffers.stencil.setFunc(i.ALWAYS,s,4294967295),r.buffers.stencil.setClear(a),r.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(i.EQUAL,1,4294967295),r.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),r.buffers.stencil.setLocked(!0)}}class ym extends fm{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class Mm{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),void 0===e){const n=t.getSize(new dn);this._width=n.width,this._height=n.height,(e=new Un(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ft})).texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new _m(pm),this.copyPass.material.blending=0,this.clock=new qc}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let n=!1;for(let i=0,r=this.passes.length;i<r;i++){const e=this.passes[i];if(!1!==e.enabled){if(e.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),e.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),e.needsSwap){if(n){const e=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),n.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==xm&&(e instanceof xm?n=!0:e instanceof ym&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new dn);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,i)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class bm extends fm{constructor(t,e,n=null,i=null,r=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new ir}render(t,e,n){const i=t.autoClear;let r,s;t.autoClear=!1,null!==this.overrideMaterial&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),null!==this.clearColor&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),null!==this.clearAlpha&&(r=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),1==this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),!0===this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),null!==this.clearColor&&t.setClearColor(this._oldClearColor),null!==this.clearAlpha&&t.setClearAlpha(r),null!==this.overrideMaterial&&(this.scene.overrideMaterial=s),t.autoClear=i}}const Sm={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new ir(0)},defaultOpacity:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec3 defaultColor;\n\t\tuniform float defaultOpacity;\n\t\tuniform float luminosityThreshold;\n\t\tuniform float smoothWidth;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\t\t\tfloat v = luminance( texel.xyz );\n\n\t\t\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n\t\t\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n\t\t\tgl_FragColor = mix( outputColor, texel, alpha );\n\n\t\t}"};class wm extends fm{constructor(t,e=1,n,i){super(),this.strength=e,this.radius=n,this.threshold=i,this.resolution=void 0!==t?new dn(t.x,t.y):new dn(256,256),this.clearColor=new ir(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let r=Math.round(this.resolution.x/2),s=Math.round(this.resolution.y/2);this.renderTargetBright=new Un(r,s,{type:ft}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let l=0;l<this.nMips;l++){const t=new Un(r,s,{type:ft});t.texture.name="UnrealBloomPass.h"+l,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);const e=new Un(r,s,{type:ft});e.texture.name="UnrealBloomPass.v"+l,e.texture.generateMipmaps=!1,this.renderTargetsVertical.push(e),r=Math.round(r/2),s=Math.round(s/2)}const a=Sm;this.highPassUniforms=Wr.clone(a.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new jr({uniforms:this.highPassUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader}),this.separableBlurMaterials=[];const o=[6,10,14,18,22];r=Math.round(this.resolution.x/2),s=Math.round(this.resolution.y/2);for(let l=0;l<this.nMips;l++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(o[l])),this.separableBlurMaterials[l].uniforms.invSize.value=new dn(1/r,1/s),r=Math.round(r/2),s=Math.round(s/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=e,this.compositeMaterial.uniforms.bloomRadius.value=.1;this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new fn(1,1,1),new fn(1,1,1),new fn(1,1,1),new fn(1,1,1),new fn(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=Wr.clone(pm.uniforms),this.blendMaterial=new jr({uniforms:this.copyUniforms,vertexShader:pm.vertexShader,fragmentShader:pm.fragmentShader,premultipliedAlpha:!0,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new ir,this._oldClearAlpha=1,this._basic=new or,this._fsQuad=new vm(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose();for(let t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(t,e){let n=Math.round(t/2),i=Math.round(e/2);this.renderTargetBright.setSize(n,i);for(let r=0;r<this.nMips;r++)this.renderTargetsHorizontal[r].setSize(n,i),this.renderTargetsVertical[r].setSize(n,i),this.separableBlurMaterials[r].uniforms.invSize.value=new dn(1/n,1/i),n=Math.round(n/2),i=Math.round(i/2)}render(t,e,n,i,r){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();const s=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),r&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=n.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let a=this.renderTargetBright;for(let o=0;o<this.nMips;o++)this._fsQuad.material=this.separableBlurMaterials[o],this.separableBlurMaterials[o].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[o].uniforms.direction.value=wm.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[o]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[o].uniforms.colorTexture.value=this.renderTargetsHorizontal[o].texture,this.separableBlurMaterials[o].uniforms.direction.value=wm.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[o]),t.clear(),this._fsQuad.render(t),a=this.renderTargetsVertical[o];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,r&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(n),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=s}_getSeparableBlurMaterial(t){const e=[],n=t/3;for(let i=0;i<t;i++)e.push(.39894*Math.exp(-.5*i*i/(n*n))/n);return new jr({defines:{KERNEL_RADIUS:t},uniforms:{colorTexture:{value:null},invSize:{value:new dn(.5,.5)},direction:{value:new dn(.5,.5)},gaussianCoefficients:{value:e}},vertexShader:"\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\n\t\t\t\t\tfor ( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\t\t\tfloat x = float( i );\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += ( sample1 + sample2 ) * w;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tgl_FragColor = vec4( diffuseSum, 1.0 );\n\n\t\t\t\t}"})}_getCompositeMaterial(t){return new jr({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor( const in float factor ) {\n\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix( factor, mirrorFactor, bloomRadius );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t// 3.0 for backwards compatibility with previous alpha-based intensity\n\t\t\t\t\tvec3 bloom = 3.0 * bloomStrength * (\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +\n\t\t\t\t\t\tlerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb\n\t\t\t\t\t);\n\n\t\t\t\t\tfloat bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );\n\t\t\t\t\tgl_FragColor = vec4( bloom, bloomAlpha );\n\n\t\t\t\t}"})}}wm.BlurDirectionX=new dn(1,0),wm.BlurDirectionY=new dn(0,1);const Tm={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new dn(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\n\t\t}"},Em={uniforms:{tDiffuse:{value:null},amount:{value:.002}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float amount;\n varying vec2 vUv;\n void main() {\n vec2 dir = vUv - 0.5;\n float dist = length(dir);\n vec2 offset = normalize(dir) * dist * amount;\n float r = texture2D(tDiffuse, vUv + offset).r;\n float g = texture2D(tDiffuse, vUv).g;\n float b = texture2D(tDiffuse, vUv - offset).b;\n gl_FragColor = vec4(r, g, b, 1.0);\n }\n "},Am={uniforms:{tDiffuse:{value:null},intensity:{value:0},time:{value:0}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float intensity;\n uniform float time;\n varying vec2 vUv;\n\n float rand(vec2 co) {\n return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = vUv;\n\n // Scanline displacement โ horizontal bands shift left/right\n float scanJitter = step(0.99 - intensity * 0.3, rand(vec2(time * 1.3, floor(uv.y * 40.0))))\n * (rand(vec2(time, floor(uv.y * 40.0))) - 0.5) * intensity * 0.15;\n uv.x += scanJitter;\n\n // Block glitch โ large rectangular regions shift\n float blockY = floor(uv.y * 8.0);\n float blockShift = step(0.97 - intensity * 0.15, rand(vec2(blockY, time * 0.7)))\n * (rand(vec2(blockY + 1.0, time)) - 0.5) * intensity * 0.1;\n uv.x += blockShift;\n\n // RGB channel split\n float rgbShift = intensity * 0.012;\n float r = texture2D(tDiffuse, vec2(uv.x + rgbShift, uv.y + rgbShift * 0.5)).r;\n float g = texture2D(tDiffuse, uv).g;\n float b = texture2D(tDiffuse, vec2(uv.x - rgbShift, uv.y - rgbShift * 0.3)).b;\n\n // Color corruption โ random bright pixels\n float noise = step(0.995 - intensity * 0.05, rand(uv + time)) * intensity;\n\n gl_FragColor = vec4(r + noise, g, b + noise * 0.5, 1.0);\n }\n "},Cm={uniforms:{tDiffuse:{value:null},darkness:{value:1.5},offset:{value:.95}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float darkness;\n uniform float offset;\n varying vec2 vUv;\n void main() {\n vec4 texel = texture2D(tDiffuse, vUv);\n vec2 uv = (vUv - vec2(0.5)) * vec2(offset);\n float vignette = 1.0 - dot(uv, uv) * darkness;\n gl_FragColor = vec4(texel.rgb * clamp(vignette, 0.0, 1.0), texel.a);\n }\n "};class Rm{constructor(t){this.canvas=t,this.button=null,this.isFullscreen=!1,this.createButton(),this.attachListeners()}createButton(){this.button=document.createElement("button"),this.button.id="nova64-fullscreen-btn",this.button.innerHTML=this.getExpandIcon(),this.button.title="Toggle Fullscreen (ESC to exit)",Object.assign(this.button.style,{position:"fixed",bottom:"20px",right:"20px",width:"48px",height:"48px",borderRadius:"8px",border:"2px solid #00ffff",background:"rgba(21, 24, 34, 0.9)",color:"#00ffff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",fontWeight:"bold",zIndex:"9999",boxShadow:"0 0 20px rgba(0, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.5)",transition:"all 0.3s ease",backdropFilter:"blur(10px)"}),this.button.addEventListener("mouseenter",()=>{this.button.style.background="rgba(0, 255, 255, 0.2)",this.button.style.boxShadow="0 0 30px rgba(0, 255, 255, 0.6), 0 4px 16px rgba(0, 0, 0, 0.6)",this.button.style.transform="scale(1.1)"}),this.button.addEventListener("mouseleave",()=>{this.button.style.background="rgba(21, 24, 34, 0.9)",this.button.style.boxShadow="0 0 20px rgba(0, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.5)",this.button.style.transform="scale(1)"}),document.body.appendChild(this.button)}getExpandIcon(){return'\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/>\n </svg>\n '}getCompressIcon(){return'\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"/>\n </svg>\n '}attachListeners(){this.button.addEventListener("click",()=>{this.toggleFullscreen()}),document.addEventListener("keydown",t=>{"Escape"===t.key&&this.isFullscreen&&this.exitFullscreen()}),document.addEventListener("fullscreenchange",()=>{this.handleFullscreenChange()}),document.addEventListener("webkitfullscreenchange",()=>{this.handleFullscreenChange()}),document.addEventListener("mozfullscreenchange",()=>{this.handleFullscreenChange()}),document.addEventListener("MSFullscreenChange",()=>{this.handleFullscreenChange()})}toggleFullscreen(){this.isFullscreen?this.exitFullscreen():this.enterFullscreen()}enterFullscreen(){const t=this.canvas;t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.msRequestFullscreen(),this.isFullscreen=!0,this.updateButton()}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),this.isFullscreen=!1,this.updateButton()}handleFullscreenChange(){const t=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);this.isFullscreen=t,this.updateButton()}updateButton(){this.isFullscreen?(this.button.innerHTML=this.getCompressIcon(),this.button.title="Exit Fullscreen (ESC)"):(this.button.innerHTML=this.getExpandIcon(),this.button.title="Toggle Fullscreen (ESC to exit)")}destroy(){this.button&&this.button.parentNode&&this.button.parentNode.removeChild(this.button)}}const Pm={},Im=function(t,e,n){let i=Promise.resolve();if(e&&e.length>0){const t=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),s=r?.nonce||r?.getAttribute("nonce");i=Promise.allSettled(e.map(e=>{if(e=function(t,e){return new URL(t,e).href}(e,n),e in Pm)return;Pm[e]=!0;const i=e.endsWith(".css"),r=i?'[rel="stylesheet"]':"";if(!!n)for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.href===e&&(!i||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${e}"]${r}`))return;const a=document.createElement("link");return a.rel=i?"stylesheet":"modulepreload",i||(a.as="script"),a.crossOrigin="",a.href=e,s&&a.setAttribute("nonce",s),document.head.appendChild(a),i?new Promise((t,n)=>{a.addEventListener("load",t),a.addEventListener("error",()=>n(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}function r(t){const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=t,window.dispatchEvent(e),!e.defaultPrevented)throw t}return i.then(e=>{for(const t of e||[])"rejected"===t.status&&r(t.reason);return t().catch(r)})};let Lm;function Dm(t){return Lm(t)}Lm=function(t){let e;const n=new Set,i=(t,i=!1)=>{const r="function"==typeof t?t(e):t,s=i?r:Object.assign({},e,r);if(s!==e){const t=e;e=s,n.forEach(n=>n(e,t))}},r=()=>e,s={setState:i,getState:r,subscribe:t=>(n.add(t),()=>n.delete(t)),destroy:()=>n.clear()};return e="function"==typeof t?t(i,r,s):t||{},s},async function(){try{const t=await Im(()=>import("./vanilla-Dcuy32gi.js"),[],import.meta.url);Lm=t.createStore,e.info("โ
Nova64 Store: using Zustand/vanilla")}catch{Lm=function(t){let e;const n=new Set,i=(t,i=!1)=>{const r="function"==typeof t?t(e):t,s=i?r:Object.assign({},e,r);if(s!==e){const t=e;e=s,n.forEach(n=>n(e,t))}},r=()=>e,s={setState:i,getState:r,subscribe:t=>(n.add(t),()=>n.delete(t)),destroy:()=>n.clear()};return e="function"==typeof t?t(i,r,s):t,s},e.info("โน๏ธ Nova64 Store: using built-in store polyfill (run pnpm install to enable Zustand)")}}();const Nm=Lm({gameState:"start",score:0,lives:3,level:1,time:0,paused:!1,playerX:0,playerY:0});function Um(t){if("bigint"==typeof t)return{r:Number(t>>48n&0xffffn)/257,g:Number(t>>32n&0xffffn)/257,b:Number(t>>16n&0xffffn)/257,a:Number(0xffffn&t)/257};const e=BigInt(Math.floor(t));return{r:Number(e>>48n&0xffffn)/257,g:Number(e>>32n&0xffffn)/257,b:Number(e>>16n&0xffffn)/257,a:Number(0xffffn&e)/257}}function Om(t,e,n){const i=Um(t),r=Um(e);return tf(i.r+(r.r-i.r)*n,i.g+(r.g-i.g)*n,i.b+(r.b-i.b)*n,i.a+(r.a-i.a)*n)}function Fm(t,e){const{r:n,g:i,b:r,a:s}=Um(t);return tf(Math.min(255,n*e),Math.min(255,i*e),Math.min(255,r*e),s)}function Bm(t,e=255){return tf(t>>16&255,t>>8&255,255&t,e)}function zm(t,e=1,n=.5,i=255){t=(t%360+360)%360;const r=(1-Math.abs(2*n-1))*e,s=r*(1-Math.abs(t/60%2-1)),a=n-r/2;let o,l,c;return t<60?(o=r,l=s,c=0):t<120?(o=s,l=r,c=0):t<180?(o=0,l=r,c=s):t<240?(o=0,l=s,c=r):t<300?(o=s,l=0,c=r):(o=r,l=0,c=s),tf(Math.round(255*(o+a)),Math.round(255*(l+a)),Math.round(255*(c+a)),i)}function km(t,e,n){return t+(e-t)*n}function Vm(t,e=0,n=1){return t<e?e:t>n?n:t}function Gm(t,e){return t+Math.random()*(e-t)}function Hm(t,e){return t+Math.random()*(e-t+1)|0}function Wm(t,e,n,i){const r=n-t,s=i-e;return Math.sqrt(r*r+s*s)}function jm(t,e,n,i,r,s){const a=i-t,o=r-e,l=s-n;return Math.sqrt(a*a+o*o+l*l)}function Xm(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)}function qm(t,e=1){return.5*Math.sin(t*e*Math.PI*2)+.5}function Ym(t){return t*Math.PI/180}function Zm(t){return 180*t/Math.PI}const Km={black:tf(0,0,0),white:tf(255,255,255),red:tf(220,30,30),green:tf(30,200,60),blue:tf(30,80,220),yellow:tf(255,220,0),cyan:tf(0,220,220),magenta:tf(200,0,200),orange:tf(255,140,0),purple:tf(120,0,200),teal:tf(0,160,160),brown:tf(140,80,30),grey:tf(128,128,128),darkGrey:tf(60,60,60),lightGrey:tf(200,200,200),sky:tf(70,130,200),gold:tf(255,210,50),silver:tf(192,192,210)};function Jm(t={}){return{mag:0,x:0,y:0,decay:t.decay??4,maxMag:t.maxMag??20}}function $m(t,e){t.mag=Math.min(t.mag+e,t.maxMag)}function Qm(t,e){t.mag>.01?(t.x=(Math.random()-.5)*t.mag*1.5,t.y=(Math.random()-.5)*t.mag*1.5,t.mag-=t.decay*e):(t.mag=0,t.x=0,t.y=0)}function tg(t){return[t.x,t.y]}function eg(t){return{remaining:0,duration:t}}function ng(t){return!(t.remaining>0)&&(t.remaining=t.duration,!0)}function ig(t){return t.remaining<=0}function rg(t){return t.duration<=0?1:Math.max(0,1-t.remaining/t.duration)}function sg(t,e){t.remaining>0&&(t.remaining=Math.max(0,t.remaining-e))}function ag(t){const e={};for(const[n,i]of Object.entries(t))e[n]=eg(i);return e}function og(t,e){for(const n in t)sg(t[n],e)}function lg(t={}){return{invulnTimer:0,invulnDuration:t.invulnDuration??.8,blinkRate:t.blinkRate??25,flashTimer:0}}function cg(t){return!(t.invulnTimer>0)&&(t.invulnTimer=t.invulnDuration,t.flashTimer=.1,!0)}function hg(t){return t.invulnTimer>0}function ug(t,e){return t.invulnTimer<=0||Math.sin(e*t.blinkRate)>0}function dg(t){return t.flashTimer>0}function pg(t,e){t.invulnTimer>0&&(t.invulnTimer=Math.max(0,t.invulnTimer-e)),t.flashTimer>0&&(t.flashTimer=Math.max(0,t.flashTimer-e))}function fg(t={}){return{wave:0,timer:t.initialDelay??t.waveInterval??10,waveInterval:t.waveInterval??10,baseCount:t.baseCount??3,countGrowth:t.countGrowth??1,maxCount:t.maxCount??20,spawnFn:t.spawnFn??null,active:!0,totalSpawned:0}}function mg(t,e){if(t.active&&(t.timer-=e,t.timer<=0)){t.wave++,t.timer=t.waveInterval;const e=Math.min(t.baseCount+(t.wave-1)*t.countGrowth,t.maxCount);if(t.spawnFn)for(let n=0;n<e;n++)t.spawnFn(t.wave,n,e),t.totalSpawned++}}function gg(t){t.timer=0}function vg(t){return t.wave}function _g(t=100,e){const n=e??(()=>({})),i=[];for(let r=0;r<t;r++){const t=n();t._poolAlive=!1,i.push(t)}return{items:i,spawn(t){for(let e=0;e<i.length;e++)if(!i[e]._poolAlive)return i[e]._poolAlive=!0,t&&t(i[e]),i[e];return null},forEach(t){for(let e=0;e<i.length;e++){if(!i[e]._poolAlive)continue;!1===t(i[e],e)&&(i[e]._poolAlive=!1)}},kill(t){t._poolAlive=!1},recycle(){for(let t=0;t<i.length;t++)i[t]._poolAlive=!1},get count(){let t=0;for(let e=0;e<i.length;e++)i[e]._poolAlive&&t++;return t}}}function xg(){const t=[];return{spawn(e,n,i,r={}){const s=void 0!==r.z;t.push({text:String(e),x:n,y:i,z:r.z,vx:r.vx??0,vy:r.vy??(s?r.riseSpeed??2:-(r.riseSpeed??30)),vz:r.vz??0,timer:r.duration??1,maxTimer:r.duration??1,color:r.color??16777215,scale:r.scale??1})},update(e){for(let n=t.length-1;n>=0;n--){const i=t[n];i.x+=i.vx*e,i.y+=i.vy*e,void 0!==i.z&&(i.z+=i.vz*e),i.timer-=e,i.timer<=0&&t.splice(n,1)}},getTexts:()=>t,clear(){t.length=0},get count(){return t.length}}}function yg(t){let e=t,n=0;const i={};return{on(t,e){return i[t]=e,this},switchTo(t){i[e]?.exit&&i[e].exit(),e=t,n=0,i[e]?.enter&&i[e].enter()},update(t){n+=t,i[e]?.update&&i[e].update(t,n)},getState:()=>e,getElapsed:()=>n,is:t=>e===t}}function Mg(t,e={}){return{elapsed:0,duration:t,loop:e.loop??!1,onComplete:e.onComplete??null,done:!1,update(t){this.done&&!this.loop||(this.elapsed+=t,this.elapsed>=this.duration&&(this.loop?this.elapsed-=this.duration:(this.elapsed=this.duration,this.done=!0),this.onComplete&&this.onComplete()))},progress(){return Math.min(1,this.elapsed/this.duration)},reset(){this.elapsed=0,this.done=!1}}}globalThis.novaLogger=e;const bg=document.getElementById("screen");let Sg;globalThis.fullscreenButton=new Rm(bg);try{Sg=new Xp(bg,640,360),console.log("โ
Using Three.js renderer - Nintendo 64/PlayStation GPU mode")}catch(ov){throw console.error("โ Three.js renderer failed to initialize:",ov),new Error("Fantasy console requires 3D GPU support (Three.js)")}const wg=function(t){const e=t.getFramebuffer(),n={x:0,y:0};function i(t,e){n.x=0|t,n.y=0|e}function r(){return n}function s(t){return"bigint"==typeof t||"number"==typeof t?Qp(t):{r:65535,g:65535,b:65535,a:65535}}function a(t){const{r:n,g:i,b:r,a:s}="bigint"==typeof t?Qp(t):{r:0,g:0,b:0,a:65535};e.fill(n,i,r,s)}function o(t,i,r){const{r:a,g:o,b:l,a:c}=s(r);e.pset((0|t)-n.x,(0|i)-n.y,a,o,l,c)}function l(t,i,r,a,o){const{r:l,g:c,b:h,a:u}=s(o);t=(0|t)-n.x,i=(0|i)-n.y,r=(0|r)-n.x,a=(0|a)-n.y;let d=Math.abs(r-t),p=t<r?1:-1,f=-Math.abs(a-i),m=i<a?1:-1,g=d+f;for(;t>=0&&i>=0&&t<e.width&&i<e.height&&e.pset(t,i,l,c,h,u),t!==r||i!==a;){const e=2*g;e>=f&&(g+=f,t+=p),e<=d&&(g+=d,i+=m)}}function c(t,i,r,a,o,l=!1){const{r:c,g:h,b:u,a:d}=s(o);t=(0|t)-n.x,i=(0|i)-n.y,r|=0,a|=0;const p=Math.max(0,t),f=Math.max(0,i),m=Math.min(e.width,t+r),g=Math.min(e.height,i+a);if(l)for(let n=f;n<g;n++)for(let t=p;t<m;t++)e.pset(t,n,c,h,u,d);else{for(let t=p;t<m;t++)i>=0&&i<e.height&&e.pset(t,i,c,h,u,d),i+a-1>=0&&i+a-1<e.height&&e.pset(t,i+a-1,c,h,u,d);for(let n=f;n<g;n++)t>=0&&t<e.width&&e.pset(t,n,c,h,u,d),t+r-1>=0&&t+r-1<e.width&&e.pset(t+r-1,n,c,h,u,d)}}function h(t,i,r,a,o=!1){const{r:l,g:c,b:h,a:u}=s(a);if(t=(0|t)-n.x,i=(0|i)-n.y,r|=0,o)for(let n=-r;n<=r;n++){const s=Math.floor(Math.sqrt(r*r-n*n));for(let r=t-s;r<=t+s;r++){const t=i+n;r>=0&&r<e.width&&t>=0&&t<e.height&&e.pset(r,t,l,c,h,u)}}else{let n=r,s=0,a=0;for(;n>=s;){const r=[[t+n,i+s],[t+s,i+n],[t-s,i+n],[t-n,i+s],[t-n,i-s],[t-s,i-n],[t+s,i-n],[t+n,i-s]];for(const[t,n]of r)t>=0&&t<e.width&&n>=0&&n<e.height&&e.pset(t,n,l,c,h,u);a<=0&&(s+=1,a+=2*s+1),a>0&&(n-=1,a-=2*n+1)}}}function u(t,e,n,i,r){c(t,e,n,i,r,!0)}function d(t,i,r,s=tf(255,255,255,255),a=1){Jp.draw(e,t,(0|i)-n.x,(0|r)-n.y,s,a)}return{exposeTo(t){Object.assign(t,{cls:a,pset:o,line:l,rect:c,rectfill:u,circle:h,print:d,packRGBA64:$p,rgba8:tf,setCamera:i,getCamera:r})}}}(Sg),Tg=function(t){const e={sheet:null,map:null,tileSize:8};let n={x:0,y:0};function i(){return e.sheet?.image||null}async function r(n,i=8){e.sheet=await async function(t,e=8){const n=await nf(t);return new ef(n,n.naturalWidth,e)}(n,i),e.tileSize=i,t.updateTextureForImage&&t.updateTextureForImage(e.sheet.image)}async function s(t){e.map=await async function(t){const e=await fetch(t);if(!e.ok)throw new Error("Failed to load tilemap: "+t);return await e.json()}(t),globalThis.__nova_map=e.map}async function a(n){const i=await nf(n);e.sheet?(e.sheet.image=i,e.sheet.sheetWidth=i.naturalWidth,e.sheet.cols=Math.floor(i.naturalWidth/e.tileSize)):e.sheet={image:i,sheetWidth:i.naturalWidth,tileSize:8,cols:Math.floor(i.naturalWidth/8)},t.updateTextureForImage&&t.updateTextureForImage(i)}function o(i,r,s,{flipX:a=!1,flipY:o=!1,scale:l=1,parallax:c=1}={}){const h=e.tileSize;if(!e.sheet)return;const u=Math.floor(e.sheet.sheetWidth/h),d=i%u*h,p=Math.floor(i/u)*h,f=(0|r)-Math.floor(n.x*c),m=(0|s)-Math.floor(n.y*c);t.supportsSpriteBatch&&t.supportsSpriteBatch()&&t.queueSprite(e.sheet.image,d,p,h,h,f,m,l)}function l(t,i,r,s,a,l,{scale:c=1,parallax:h=1}={}){if(!e.map)return;const u=e.tileSize,{width:d,height:p,data:f}=e.map,m=a-Math.floor(n.x*h),g=l-Math.floor(n.y*h);for(let e=0;e<s;e++)for(let n=0;n<r;n++){const r=t+n,s=i+e;if(r<0||s<0||r>=d||s>=p)continue;o(f[s*d+r],m+n*u*c,g+e*u*c,{scale:c,parallax:h})}}return{exposeTo(t){Object.assign(t,{spr:o,mapDraw:l,loadSprites:r,loadMap:s,getSpriteSheetImage:i,applySpriteSheetDataURL:a})},setCameraRef(t){n=t},getSpriteSheetImage:i,applySpriteSheetDataURL:a}}(Sg),Eg=function(t){if(!t.getScene)return{exposeTo:()=>{}};const n=t.getScene(),i=t.getCamera(),r=t.getRenderer(),s={scene:n,camera:i,renderer:r,gpu:t,meshes:new Map,mixers:new Map,modelAnimations:new Map,materialCache:new Map,cartLights:new Map,instancedMeshes:new Map,lodObjects:new Map,counters:{mesh:0,light:0,instance:0,lod:0}};return Object.assign(s,function({gpu:t,materialCache:e}){function n(t){return JSON.stringify({material:t.material||"standard",color:t.color||16777215,emissive:t.emissive||0,metalness:t.metalness,roughness:t.roughness,transparent:t.transparent,opacity:t.opacity,wireframe:t.wireframe})}return{getMaterialKey:n,getCachedMaterial:function(i){const r=n(i);if(e.has(r))return e.get(r);const s=t.createN64Material(i);return e.set(r,s),s},disposeMaterial:function(t){["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","lightMap","envMap"].forEach(e=>{t[e]?.dispose&&t[e].dispose()}),t.dispose()}}}(s)),Object.assign(s,function({scene:t,gpu:n,meshes:i,mixers:r,modelAnimations:s,counters:a,getCachedMaterial:o}){function l(r,s,o=[0,0,0]){if(!r||!s)return e.error("createMesh: geometry and material are required"),null;let l;r.type&&!r.isBufferGeometry?l={type:"Mesh",geometry:r,material:s,position:{x:0,y:0,z:0,set(t,e,n){this.x=t,this.y=e,this.z=n}},rotation:{x:0,y:0,z:0,set(t,e,n){this.x=t,this.y=e,this.z=n}},scale:{x:1,y:1,z:1,set(t,e,n){this.x=t,this.y=e,this.z=n},setScalar(t){this.x=t,this.y=t,this.z=t}},castShadow:!0,receiveShadow:!0}:(l=new Br(r,s),l.castShadow=!0,l.receiveShadow=!0),Array.isArray(o)&&o.length>=3?l.position.set(o[0],o[1],o[2]):"object"==typeof o&&void 0!==o.x?l.position.set(o.x,o.y||0,o.z||0):l.position.set(0,0,0),t.add&&t.add(l),s?.userData?.animated&&n.registerAnimatedMesh&&n.registerAnimatedMesh(l);const c=++a.mesh;return i.set(c,l),c}function c(e){const n=i.get(e);n&&(t.remove(n),n.geometry?.dispose(),n.material?.map&&n.material.map.dispose(),n.material?.dispose(),i.delete(e),r.delete(e),s.delete(e))}function h(t=1,i=16777215,r=[0,0,0],s={}){try{return("number"!=typeof t||t<=0)&&(e.warn("createCube: invalid size, using default"),t=1),"number"!=typeof i&&(e.warn("createCube: invalid color, using white"),i=16777215),l(n.createBoxGeometry(t,t,t),o({color:i,...s}),r)}catch(ov){return e.error("createCube failed:",ov),null}}return{createMesh:l,destroyMesh:c,getMesh:function(t){return i.get(t)},removeMesh:c,createCube:h,createAdvancedCube:function(t=1,i={},r=[0,0,0]){try{return("number"!=typeof t||t<=0)&&(t=1),l(n.createBoxGeometry(t,t,t),o(i),r)}catch(ov){return e.error("createAdvancedCube failed:",ov),null}},createSphere:function(t=1,i=16777215,r=[0,0,0],s=8,a={}){try{return("number"!=typeof t||t<=0)&&(e.warn("createSphere: invalid radius, using default"),t=1),("number"!=typeof s||s<3)&&(e.warn("createSphere: invalid segments, using default"),s=8),l(n.createSphereGeometry(t,s),o({color:i,...a}),r)}catch(ov){return e.error("createSphere failed:",ov),null}},createAdvancedSphere:function(t=1,i={},r=[0,0,0],s=16){try{return("number"!=typeof t||t<=0)&&(t=1),("number"!=typeof s||s<3)&&(s=16),l(n.createSphereGeometry(t,s),o(i),r)}catch(ov){return e.error("createAdvancedSphere failed:",ov),null}},createPlane:function(t=1,i=1,r=16777215,s=[0,0,0]){try{return("number"!=typeof t||t<=0)&&(e.warn("createPlane: invalid width, using default"),t=1),("number"!=typeof i||i<=0)&&(e.warn("createPlane: invalid height, using default"),i=1),l(n.createPlaneGeometry(t,i),o({color:r}),s)}catch(ov){return e.error("createPlane failed:",ov),null}},createCylinder:function(t=1,i=1,r=1,s=16777215,a=[0,0,0],c={}){try{return l(n.createCylinderGeometry?n.createCylinderGeometry(t,i,r,c.segments||16):n.createBoxGeometry(t,r,t),o({...c,color:s}),a)}catch(ov){return e.error("createCylinder err",ov),h(2*t,s,a)}},createTorus:function(t=1,i=.3,r=16777215,s=[0,0,0],a={}){try{return l(new bl(t,i,a.radialSegments||8,a.tubularSegments||16),n.createN64Material({color:r,...a}),s)}catch(ov){return e.error("createTorus failed:",ov),null}},createCone:function(t=1,i=2,r=16777215,s=[0,0,0],a={}){try{return l(n.createConeGeometry(t,i,a.segments||16),o({color:r,...a}),s)}catch(ov){return e.error("createCone failed:",ov),null}},createCapsule:function(t=.5,i=1,r=16777215,s=[0,0,0],a={}){try{return l(n.createCapsuleGeometry(t,i,a.segments||8),o({color:r,...a}),s)}catch(ov){return e.error("createCapsule failed:",ov),null}}}}(s)),Object.assign(s,function({getMesh:t}){return{setPosition:function(n,i,r,s){try{const a=t(n);return a?(a.position.set("number"==typeof i?i:0,"number"==typeof r?r:0,"number"==typeof s?s:0),!0):(e.warn(`setPosition: mesh with id ${n} not found`),!1)}catch(ov){return e.error("setPosition failed:",ov),!1}},setRotation:function(n,i,r,s){try{const a=t(n);return a?(a.rotation.set("number"==typeof i?i:0,"number"==typeof r?r:0,"number"==typeof s?s:0),!0):(e.warn(`setRotation: mesh with id ${n} not found`),!1)}catch(ov){return e.error("setRotation failed:",ov),!1}},setScale:function(n,i,r,s){try{const a=t(n);return a?(i="number"==typeof i&&i>0?i:1,void 0===r?a.scale.setScalar(i):a.scale.set(i,"number"==typeof r&&r>0?r:1,"number"==typeof s&&s>0?s:1),!0):(e.warn(`setScale: mesh with id ${n} not found`),!1)}catch(ov){return e.error("setScale failed:",ov),!1}},getPosition:function(e){const n=t(e);return n?[n.position.x,n.position.y,n.position.z]:null},getRotation:function(e){const n=t(e);return n?[n.rotation.x,n.rotation.y,n.rotation.z]:null},rotateMesh:function(n,i,r,s){try{const a=t(n);return a?(a.rotation.x+="number"==typeof i?i:0,a.rotation.y+="number"==typeof r?r:0,a.rotation.z+="number"==typeof s?s:0,!0):(e.warn(`rotateMesh: mesh with id ${n} not found`),!1)}catch(ov){return e.error("rotateMesh failed:",ov),!1}},moveMesh:function(e,n,i,r){const s=t(e);s&&(s.position.x+=n,s.position.y+=i,s.position.z+=r)},setFlatShading:function(e,n=!0){const i=t(e);return!!i&&(i.material&&(i.material.flatShading=n,i.material.needsUpdate=!0),!0)},setMeshVisible:function(e,n){const i=t(e);return!!i&&(i.visible=n,!0)},setMeshOpacity:function(e,n){const i=t(e);return!!i&&(i.material&&(i.material.transparent=n<1,i.material.opacity=n,i.material.needsUpdate=!0),!0)},setCastShadow:function(e,n){const i=t(e);return!!i&&(i.castShadow=n,!0)},setReceiveShadow:function(e,n){const i=t(e);return!!i&&(i.receiveShadow=n,!0)}}}(s)),Object.assign(s,function({scene:t,camera:e,gpu:n}){return{setCameraPosition:function(t,e,i){n.setCameraPosition(t,e,i)},setCameraTarget:function(t,e,i){n.setCameraTarget(t,e,i)},setCameraFOV:function(t){n.setCameraFOV(t)},setCameraLookAt:function(t){Array.isArray(t)&&t.length>=3?e.lookAt(e.position.x+t[0],e.position.y+t[1],e.position.z+t[2]):"object"==typeof t&&void 0!==t.x&&e.lookAt(e.position.x+t.x,e.position.y+t.y,e.position.z+t.z)},setFog:function(t,e=10,i=50){n.setFog(t,e,i)},clearFog:function(){t&&(t.fog=null)},setLightDirection:function(t,e,i){n.setLightDirection(t,e,i)},setLightColor:function(t){n.setLightColor&&n.setLightColor(t)},setAmbientLight:function(t,e){n.setAmbientLight&&n.setAmbientLight(t,e)},setDirectionalLight:function(e,n=16777215,i=1){t.children.filter(t=>"DirectionalLight"===t.type).forEach(e=>t.remove(e));const r=new Ac(n,i);Array.isArray(e)&&e.length>=3?r.position.set(e[0],e[1],e[2]):r.position.set(1,2,1),t.add(r)}}}(s)),Object.assign(s,function({scene:t,cartLights:e,counters:n}){return{createPointLight:function(i=16777215,r=2,s=20,a=0,o=0,l=0){const c=new wc(i,r,s);c.position.set(a,o,l),t.add(c);const h=++n.light;return e.set(h,c),h},setPointLightPosition:function(t,n,i,r){const s=e.get(t);return!!s&&(s.position.set(n,i,r),!0)},setPointLightColor:function(t,n){const i=e.get(t);return!!i&&(i.color.setHex(n),!0)},removeLight:function(n){const i=e.get(n);return!!i&&(t.remove(i),i.shadow?.map&&i.shadow.map.dispose(),i.dispose&&i.dispose(),e.delete(n),!0)}}}(s)),Object.assign(s,function({scene:t,gpu:e,meshes:n,mixers:i,modelAnimations:r,counters:s}){return{loadModel:async function(a,o=[0,0,0],l=1){return new Promise((c,h)=>{(new sf).load(a,a=>{const h=a.scene;h.position.set(...o),h.scale.setScalar(l),h.traverse(t=>{t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0,t.material&&(t.material=e.createN64Material({color:t.material.color,texture:t.material.map})))}),t.add(h);const u=++s.mesh;if(n.set(u,h),a.animations?.length>0){const t=new fh(h);i.set(u,t),r.set(u,a.animations),t.clipAction(a.animations[0]).play()}c(u)},void 0,h)})},playAnimation:function(t,e=0,n=!0,s=1){const a=i.get(t),o=r.get(t);if(!a||!o)return;const l="number"==typeof e?o[e]:nc.findByName(o,e);if(l){a.stopAllAction();const t=a.clipAction(l);t.setLoop(n?pe:de),t.timeScale=s,t.play()}},updateAnimations:function(t){i.forEach(e=>e.update(t))},loadTexture:function(t){return new Promise((e,n)=>{(new fc).load(t,t=>{t.magFilter=et,t.minFilter=et,t.generateMipmaps=!1,e(t)},void 0,n)})}}}(s)),Object.assign(s,function({scene:t,camera:e,gpu:n,instancedMeshes:i,lodObjects:r,counters:s,getCachedMaterial:a}){const o=new Bi;return{createInstancedMesh:function(e="cube",r=100,o=16777215,l={}){let c;switch(e){case"sphere":c=n.createSphereGeometry(l.size||1,l.segments||6);break;case"plane":c=n.createPlaneGeometry(l.width||1,l.height||1);break;case"cylinder":c=n.createCylinderGeometry(l.size||.5,l.size||.5,l.height||2,8);break;default:c=n.createBoxGeometry(l.size||1,l.size||1,l.size||1)}const h=a({color:o,...l}),u=new $s(c,h,r);u.castShadow=u.receiveShadow=!0,u.instanceMatrix.setUsage(Fe),t.add(u);const d=++s.instance;return i.set(d,{mesh:u,count:r}),d},setInstanceTransform:function(t,e,n=0,r=0,s=0,a=0,l=0,c=0,h=1,u=1,d=1){const p=i.get(t);return!(!p||e<0||e>=p.count||(o.position.set(n,r,s),o.rotation.set(a,l,c),o.scale.set(h,u,d),o.updateMatrix(),p.mesh.setMatrixAt(e,o.matrix),0))},setInstanceColor:function(t,e,n){const r=i.get(t);return!!r&&(r.mesh.setColorAt(e,new ir(n)),r.mesh.instanceColor&&(r.mesh.instanceColor.needsUpdate=!0),!0)},finalizeInstances:function(t){const e=i.get(t);if(!e)return!1;e.mesh.instanceMatrix.needsUpdate=!0;try{e.mesh.computeBoundingSphere()}catch{}return!0},removeInstancedMesh:function(e){const n=i.get(e);return!!n&&(t.remove(n.mesh),n.mesh.geometry?.dispose(),n.mesh.material?.dispose(),i.delete(e),!0)},createLODMesh:function(e=[],i=[0,0,0]){const o=new Cs;for(const{shape:t="cube",size:r=1,color:s=16777215,distance:c=0,options:h={}}of e){let e;switch(t){case"sphere":e=n.createSphereGeometry(r,h.segments||8);break;case"plane":e=n.createPlaneGeometry(r,h.height||r);break;case"cylinder":e=n.createCylinderGeometry(.5*r,.5*r,h.height||2*r,h.segments||8);break;default:e=n.createBoxGeometry(r,r,r)}const i=a({color:s,...h}),l=new Br(e,i);l.castShadow=l.receiveShadow=!0,o.addLevel(l,c)}Array.isArray(i)&&i.length>=3&&o.position.set(i[0],i[1],i[2]),t.add(o);const l=++s.lod;return r.set(l,o),l},setLODPosition:function(t,e,n,i){const s=r.get(t);return!!s&&(s.position.set(e,n,i),!0)},removeLODMesh:function(e){const n=r.get(e);if(!n)return!1;t.remove(n);for(const{object:t}of n.levels)t.geometry?.dispose(),t.material?.dispose();return r.delete(e),!0},updateLODs:function(){for(const t of r.values())t.update(e)}}}(s)),Object.assign(s,function({meshes:t}){const e=new fc;function n(t){if(!t?.material)return;if(t.material.isMeshStandardMaterial)return;const e=t.material,n=new Pl({color:e.color?.clone()??new ir(16777215),map:e.map??null,metalness:0,roughness:.6,transparent:e.transparent??!1,opacity:e.opacity??1});e.dispose(),t.material=n}return{loadNormalMap:function(t){return new Promise((n,i)=>{e.load(t,t=>{t.wrapS=t.wrapT=$,n(t)},void 0,t=>i(t))})},setNormalMap:function(e,i){const r=t.get(e);return!!r&&(n(r),r.material.normalMap=i,r.material.needsUpdate=!0,!0)},setPBRMaps:function(e,i={}){const r=t.get(e);if(!r)return!1;n(r);const s=r.material;return i.normalMap&&(s.normalMap=i.normalMap),i.roughnessMap&&(s.roughnessMap=i.roughnessMap),i.aoMap&&(s.aoMap=i.aoMap),void 0!==i.metalness&&(s.metalness=i.metalness),void 0!==i.roughness&&(s.roughness=i.roughness),s.needsUpdate=!0,!0},setPBRProperties:function(e,n={}){const i=t.get(e);if(!i)return!1;const r=i.material;return i.material=new Pl({color:void 0!==n.color?new ir(n.color):r.color?.clone()??new ir(16777215),map:r.map??null,metalness:void 0!==n.metalness?Math.max(0,Math.min(1,n.metalness)):r.metalness??0,roughness:void 0!==n.roughness?Math.max(0,Math.min(1,n.roughness)):r.roughness??.6,envMapIntensity:n.envMapIntensity??r.envMapIntensity??1,emissive:r.emissive?.clone()??new ir(0),emissiveIntensity:r.emissiveIntensity??0,transparent:r.transparent??!1,opacity:r.opacity??1,side:r.side??0}),i.material.needsUpdate=!0,!0}}}(s)),Object.assign(s,function({scene:t,counters:e}){const n=new Map;let i=0;const r=new Bi,s=new ir;function a(t,e={}){if(0===t.freeList.length)return;const n=13*t.freeList.pop(),{pool:i,emitter:r}=t,s=e.x??r.x,a=e.y??r.y,o=e.z??r.z,l=Math.random()*Math.PI*2,c=Math.random()*(e.spread??r.spread),h=Math.cos(c),u=Math.sin(c),d=r.minSpeed+Math.random()*(r.maxSpeed-r.minSpeed),p=e.vx??u*Math.cos(l)*d,f=e.vy??h*d,m=e.vz??u*Math.sin(l)*d,g=r.minLife+Math.random()*(r.maxLife-r.minLife),v=r.minSize+Math.random()*(r.maxSize-r.minSize);i[n+0]=s,i[n+1]=a,i[n+2]=o,i[n+3]=p,i[n+4]=f,i[n+5]=m,i[n+6]=0,i[n+7]=g>0?g:1;const _=t.config.startColor;i[n+8]=e.r??_.r,i[n+9]=e.g??_.g,i[n+10]=e.b??_.b,i[n+11]=v,i[n+12]=1,t.activeCount++}return{createParticleSystem:function(s=200,a={}){const{shape:o="sphere",size:l=.15,segments:c=4,color:h=16755200,emissive:u=16737792,emissiveIntensity:d=2,gravity:p=-9.8,drag:f=.95,emitterX:m=0,emitterY:g=0,emitterZ:v=0,emitRate:_=20,minLife:x=.8,maxLife:y=2,minSpeed:M=2,maxSpeed:b=8,spread:S=Math.PI,minSize:w=.05,maxSize:T=.3,startColor:E=h,endColor:A=0}=a;let C;C="cube"===o?new kr(l,l,l):new yl(l,c,c),new or({color:h,vertexColors:!1}).emissive=new ir(u);const R=new Pl({color:h,emissive:new ir(u),emissiveIntensity:d,roughness:.8,metalness:0}),P=new $s(C,R,s);P.instanceMatrix.setUsage(Fe),P.castShadow=!1,P.receiveShadow=!1,r.position.set(0,-9999,0),r.scale.set(0,0,0),r.updateMatrix();for(let t=0;t<s;t++)P.setMatrixAt(t,r.matrix);P.instanceMatrix.needsUpdate=!0,P.instanceColor=new Ws(new Float32Array(3*s),3),t.add(P);const I=new Float32Array(13*s),L=++i;return n.set(L,{mesh:P,pool:I,maxParticles:s,freeList:Array.from({length:s},(t,e)=>e),activeCount:0,emitAccum:0,emitter:{x:m,y:g,z:v,emitRate:_,minLife:x,maxLife:y,minSpeed:M,maxSpeed:b,spread:S,minSize:w,maxSize:T},config:{gravity:p,drag:f,startColor:new ir(E),endColor:new ir(A)}}),e.particle=(e.particle||0)+1,L},setParticleEmitter:function(t,e={}){const i=n.get(t);i&&Object.assign(i.emitter,e)},emitParticle:function(t,e={}){const i=n.get(t);i&&a(i,e)},burstParticles:function(t,e=10,i={}){const r=n.get(t);if(r)for(let n=0;n<e;n++)a(r,i)},updateParticles:function(t){n.forEach(e=>{const{pool:n,maxParticles:i,mesh:o,config:l,emitter:c}=e;for(e.emitAccum+=c.emitRate*t;e.emitAccum>=1&&e.freeList.length>0;)a(e),e.emitAccum-=1;let h=!1;for(let a=0;a<i;a++){const i=13*a;if(0===n[i+12])continue;n[i+6]+=t;const c=n[i+6],u=n[i+7];if(c>=u){n[i+12]=0,e.freeList.push(a),e.activeCount--,r.position.set(0,-9999,0),r.scale.set(0,0,0),r.updateMatrix(),o.setMatrixAt(a,r.matrix),h=!0;continue}n[i+3]*=l.drag,n[i+5]*=l.drag,n[i+4]+=l.gravity*t,n[i+0]+=n[i+3]*t,n[i+1]+=n[i+4]*t,n[i+2]+=n[i+5]*t;const d=c/u,p=n[i+8]*(1-d)+l.endColor.r*d,f=n[i+9]*(1-d)+l.endColor.g*d,m=n[i+10]*(1-d)+l.endColor.b*d;s.setRGB(p,f,m),o.setColorAt(a,s);const g=n[i+11]*(1-.8*d);r.position.set(n[i+0],n[i+1],n[i+2]),r.scale.set(g,g,g),r.updateMatrix(),o.setMatrixAt(a,r.matrix),h=!0}h&&(o.instanceMatrix.needsUpdate=!0,o.instanceColor&&(o.instanceColor.needsUpdate=!0))})},removeParticleSystem:function(e){const i=n.get(e);return!!i&&(t.remove(i.mesh),i.mesh.geometry?.dispose(),i.mesh.material?.dispose(),n.delete(e),!0)},getParticleStats:function(t){const e=n.get(t);return e?{active:e.activeCount,max:e.maxParticles,free:e.freeList.length}:null}}}(s)),Object.assign(s,im(s)),{exposeTo(t){Object.assign(t,{createCube:s.createCube,createSphere:s.createSphere,createCylinder:s.createCylinder,createPlane:s.createPlane,createAdvancedCube:s.createAdvancedCube,createAdvancedSphere:s.createAdvancedSphere,createTorus:s.createTorus,createCone:s.createCone,createCapsule:s.createCapsule,destroyMesh:s.destroyMesh,removeMesh:s.removeMesh,loadModel:s.loadModel,playAnimation:s.playAnimation,updateAnimations:s.updateAnimations,loadTexture:s.loadTexture,setPosition:s.setPosition,setRotation:s.setRotation,setScale:s.setScale,getPosition:s.getPosition,getRotation:s.getRotation,rotateMesh:s.rotateMesh,moveMesh:s.moveMesh,setFlatShading:s.setFlatShading,setMeshVisible:s.setMeshVisible,setMeshOpacity:s.setMeshOpacity,setCastShadow:s.setCastShadow,setReceiveShadow:s.setReceiveShadow,setCameraPosition:s.setCameraPosition,setCameraTarget:s.setCameraTarget,setCameraLookAt:s.setCameraLookAt,setCameraFOV:s.setCameraFOV,setFog:s.setFog,clearFog:s.clearFog,setLightDirection:s.setLightDirection,setLightColor:s.setLightColor,setAmbientLight:s.setAmbientLight,setDirectionalLight:s.setDirectionalLight,clearScene:s.clearScene,enablePixelation:s.enablePixelation,enableDithering:s.enableDithering,createPointLight:s.createPointLight,setPointLightPosition:s.setPointLightPosition,setPointLightColor:s.setPointLightColor,removeLight:s.removeLight,createInstancedMesh:s.createInstancedMesh,setInstanceTransform:s.setInstanceTransform,setInstanceColor:s.setInstanceColor,finalizeInstances:s.finalizeInstances,removeInstancedMesh:s.removeInstancedMesh,createLODMesh:s.createLODMesh,setLODPosition:s.setLODPosition,removeLODMesh:s.removeLODMesh,updateLODs:s.updateLODs,loadNormalMap:s.loadNormalMap,setNormalMap:s.setNormalMap,setPBRMaps:s.setPBRMaps,setPBRProperties:s.setPBRProperties,createParticleSystem:s.createParticleSystem,setParticleEmitter:s.setParticleEmitter,emitParticle:s.emitParticle,burstParticles:s.burstParticles,updateParticles:s.updateParticles,removeParticleSystem:s.removeParticleSystem,getParticleStats:s.getParticleStats,raycastFromCamera:s.raycastFromCamera,get3DStats:s.get3DStats,setupScene:s.setupScene,getScene:()=>n,getCamera:()=>i,getRenderer:()=>r,getMesh:s.getMesh})}}}(Sg),Ag=function(t){const e=new rm(t);return{exposeTo(t){Object.assign(t,{openSpriteEditor:()=>e.open(),closeSpriteEditor:()=>e.close()})},open:()=>e.open()}}(Tg),Cg=function(){const t=new Set;let e=500,n=8,i=(t,e)=>!1;function r(t){e=t}function s(t){n=0|t}function a(t){i=t}const o=a;function l(e,n,i,r,s={}){const a=Object.assign({x:e,y:n,w:i,h:r,vx:0,vy:0,restitution:0,friction:.9,onGround:!1},s);return t.add(a),a}function c(e){t.delete(e)}function h(t,r){t.vy+=e*r;let s=t.x+t.vx*r,a=t.y+t.vy*r;t.onGround=!1;const o=Math.sign(t.vx);if(0!==o){const e=o>0?s+t.w:s,r=Math.floor(t.y/n),a=Math.floor((t.y+t.h-1)/n);for(let l=r;l<=a;l++){const r=Math.floor(e/n);if(i(r,l)){s=o>0?r*n-t.w-.01:(r+1)*n+.01,t.vx=-t.vx*t.restitution;break}}}const l=Math.sign(t.vy);if(0!==l){const e=l>0?a+t.h:a,r=Math.floor(s/n),o=Math.floor((s+t.w-1)/n);for(let s=r;s<=o;s++){const r=Math.floor(e/n);if(i(s,r)){l>0?(a=r*n-t.h-.01,t.onGround=!0):a=(r+1)*n+.01,t.vy=-t.vy*t.restitution;break}}}t.onGround&&(t.vx*=t.friction),t.x=s,t.y=a}function u(e){for(const n of t)h(n,e)}return{exposeTo(t){Object.assign(t,{createBody:l,destroyBody:c,stepPhysics:u,setGravity:r,setTileSize:s,setTileSolidFn:a,setCollisionMap:o})}}}(),Rg={exposeTo(t){Object.assign(t,{startTextInput:t=>sm.start(t||{}),stopTextInput:()=>sm.stop(),getTextInput:()=>sm.get()})}},Pg={exposeTo(t){Object.assign(t,{sfx:(t,e)=>{if("number"==typeof t||"string"==typeof t){const n=om[t];n&&am.sfx(Object.assign({},n,e||{}))}else am.sfx(t||{})},setVolume:t=>am.setVolume(t)})}},Ig={exposeTo(t){Object.assign(t,{btn:t=>hm.btn(t),btnp:t=>hm.btnp(t),key:t=>hm.key(t),keyp:t=>hm.keyp(t),isKeyDown:t=>hm.isKeyDown(t),isKeyPressed:t=>hm.isKeyPressed(t),mouseX:()=>hm.mouse.x,mouseY:()=>hm.mouse.y,mouseDown:()=>hm.mouse.down,mousePressed:()=>hm.mouse.down&&!hm.mouse.prevDown,gamepadAxis:t=>hm.getGamepadAxis(t),gamepadConnected:()=>hm.isGamepadConnected(),leftStickX:()=>hm.getGamepadAxis("leftX"),leftStickY:()=>hm.getGamepadAxis("leftY"),rightStickX:()=>hm.getGamepadAxis("rightX"),rightStickY:()=>hm.getGamepadAxis("rightY")})},step(){hm.step()},connectUI(t,e){hm.connectUI(t,e)}},Lg=function(t="nova64"){function e(e){return t+":"+e}function n(t,n){try{return localStorage.setItem(e(t),JSON.stringify(n)),!0}catch(ov){return!1}}function i(t,n=null){try{const i=localStorage.getItem(e(t));return i?JSON.parse(i):n}catch(ov){return n}}function r(t){try{localStorage.removeItem(e(t))}catch(ov){}}const s=n,a=i,o=r;return{exposeTo(t){Object.assign(t,{saveData:s,loadData:a,deleteData:o,saveJSON:n,loadJSON:i,remove:r})}}}("nova64"),Dg=function(){const t=new um;return{manager:t,exposeTo(e){e.ScreenManager=um,e.Screen=dm,e.screens=t,e.addScreen=(e,n)=>t.addScreen(e,n),e.switchToScreen=(e,n)=>t.switchTo(e,n),e.switchScreen=(e,n)=>t.switchTo(e,n),e.transitionTo=(e,n,i,r)=>t.transitionTo(e,n,i,r),e.onTransitionEnd=e=>t.onTransitionEnd(e),e.isTransitioning=()=>t.isTransitioning(),e.getCurrentScreen=()=>t.getCurrentScreen(),e.startScreens=e=>t.start(e)}}}(),Ng=function(t){let e=null,n=null,i=1,r=!1;function s(i={}){const{starCount:r=1e3,starSize:s=2,nebulae:a=!0,nebulaColor:o=4465322}=i;h();const l=new Er,u=[],d=[];for(let t=0;t<r;t++){const t=500+500*Math.random(),e=Math.random()*Math.PI*2,n=Math.acos(2*Math.random()-1);u.push(t*Math.sin(n)*Math.cos(e),t*Math.sin(n)*Math.sin(e),t*Math.cos(n));const i=Math.random();i<.7?d.push(1,1,1):i<.85?d.push(.7,.8,1):i<.95?d.push(1,1,.7):d.push(1,.7,.6)}return l.setAttribute("position",new _r(u,3)),l.setAttribute("color",new _r(d,3)),n=new Ya(l,new Ha({size:s,vertexColors:!0,transparent:!0,opacity:.8,sizeAttenuation:!0})),t.scene.add(n),a&&(e=c(1297,o)),{starField:n,skyboxMesh:e}}function a(t=1731240,n=16026720){h(),e=c(t,n)}function o(e=0){h(),t.scene.background=new ir(e)}function l(e){return new Promise((n,i)=>{if(!Array.isArray(e)||6!==e.length)return void i(new Error("createImageSkybox: requires exactly 6 face URLs [+X, -X, +Y, -Y, +Z, -Z]"));h();(new pc).load(e,e=>{e.colorSpace=Se,t.scene.background=e;try{const n=new xu(t.renderer);n.compileCubemapShader(),t.scene.environment=n.fromCubemap(e).texture,n.dispose()}catch(i){}n(e)},void 0,t=>i(t))})}function c(e,n){const i=new yl(800,32,32),r=new jr({uniforms:{topColor:{value:new ir(e)},bottomColor:{value:new ir(n)}},vertexShader:"\n varying vec3 vWorldPosition;\n void main() {\n vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform vec3 topColor;\n uniform vec3 bottomColor;\n varying vec3 vWorldPosition;\n void main() {\n float h = normalize(vWorldPosition).y;\n gl_FragColor = vec4(mix(bottomColor, topColor, max(h * 0.5 + 0.5, 0.0)), 1.0);\n }",side:1,depthWrite:!1}),s=new Br(i,r);return t.scene.add(s),s}function h(){e&&(t.scene.remove(e),e.geometry?.dispose(),e.material?.dispose(),e=null),n&&(t.scene.remove(n),n.geometry?.dispose(),n.material?.dispose(),n=null),t.scene.background instanceof ir&&(t.scene.background=null)}function u(t){n&&(n.rotation.y+=.01*t*i)}function d(t){i=t}function p(t=1){r=!0,i=t}function f(){r=!1}function m(){h()}return{_tick:function(t){r&&u(t)},exposeTo(t){Object.assign(t,{createSpaceSkybox:s,createGradientSkybox:a,createSolidSkybox:o,createImageSkybox:l,animateSkybox:u,setSkyboxSpeed:d,enableSkyboxAutoAnimate:p,disableSkyboxAutoAnimate:f,clearSkybox:m})}}}(Sg),Ug=function(t){if(!t.getScene||!t.getCamera||!t.getRenderer)return{exposeTo:()=>{}};const n=t.getScene(),i=t.getCamera(),r=t.getRenderer();let s=null,a=null,o=null,l=null,c=null,h=null,u=null,d=!1,p=0;const f=new Map;function m(){s||(s=new Mm(r),a=new bm(n,i),s.addPass(a),d=!0)}function g(t=1,e=.5,n=.6){return m(),o&&s.removePass(o),o=new wm(new dn(window.innerWidth,window.innerHeight),t,e,n),s.addPass(o),!0}function v(){o&&s&&(s.removePass(o),o=null)}function _(t){o&&(o.strength=t)}function x(t){o&&(o.radius=t)}function y(t){o&&(o.threshold=t)}function M(){if(m(),l)return;l=new _m(Tm);const t=r.getPixelRatio();l.material.uniforms.resolution.value.x=1/(window.innerWidth*t),l.material.uniforms.resolution.value.y=1/(window.innerHeight*t),s.addPass(l)}function b(){l&&s&&(s.removePass(l),l=null)}function S(t=.002){m(),c?c.uniforms.amount.value=t:(c=new _m(Em),c.uniforms.amount.value=t,s.addPass(c))}function w(){c&&s&&(s.removePass(c),c=null)}function T(t=1,e=.9){if(m(),h)return h.uniforms.darkness.value=t,void(h.uniforms.offset.value=e);h=new _m(Cm),h.uniforms.darkness.value=t,h.uniforms.offset.value=e,s.addPass(h)}function E(){h&&s&&(s.removePass(h),h=null)}function A(t=.5){m(),u?u.uniforms.intensity.value=Math.max(0,Math.min(1,t)):(u=new _m(Am),u.uniforms.intensity.value=Math.max(0,Math.min(1,t)),s.addPass(u))}function C(){u&&s&&(s.removePass(u),u=null)}function R(t){u&&(u.uniforms.intensity.value=Math.max(0,Math.min(1,t)))}const P={uniforms:{time:{value:0},color:{value:new ir(65535)},scanlineSpeed:{value:2},glitchAmount:{value:.1},opacity:{value:.8}},vertexShader:"\n varying vec2 vUv;\n varying vec3 vPosition;\n \n void main() {\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float time;\n uniform vec3 color;\n uniform float scanlineSpeed;\n uniform float glitchAmount;\n uniform float opacity;\n \n varying vec2 vUv;\n varying vec3 vPosition;\n \n void main() {\n // Scanlines\n float scanline = sin(vUv.y * 100.0 + time * scanlineSpeed) * 0.5 + 0.5;\n \n // Glitch effect\n float glitch = step(0.95, sin(time * 10.0 + vUv.y * 50.0)) * glitchAmount;\n \n // Edge glow\n float edge = 1.0 - abs(vUv.x - 0.5) * 2.0;\n edge = pow(edge, 3.0);\n \n // Combine effects\n vec3 finalColor = color * (scanline * 0.5 + 0.5) + vec3(edge * 0.3);\n finalColor += vec3(glitch);\n \n gl_FragColor = vec4(finalColor, opacity);\n }\n "},I={uniforms:{time:{value:0},hitPosition:{value:new fn(0,0,0)},hitStrength:{value:0},color:{value:new ir(65535)},opacity:{value:.6}},vertexShader:"\n varying vec2 vUv;\n varying vec3 vNormal;\n varying vec3 vPosition;\n \n void main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n vPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float time;\n uniform vec3 hitPosition;\n uniform float hitStrength;\n uniform vec3 color;\n uniform float opacity;\n \n varying vec2 vUv;\n varying vec3 vNormal;\n varying vec3 vPosition;\n \n void main() {\n // Fresnel effect\n vec3 viewDirection = normalize(cameraPosition - vPosition);\n float fresnel = pow(1.0 - dot(viewDirection, vNormal), 3.0);\n \n // Hexagon pattern\n vec2 hexUv = vUv * 20.0;\n float hexPattern = abs(sin(hexUv.x * 3.14159) * sin(hexUv.y * 3.14159));\n hexPattern = step(0.5, hexPattern);\n \n // Hit ripple\n float distToHit = length(vPosition - hitPosition);\n float ripple = sin(distToHit * 5.0 - time * 10.0) * 0.5 + 0.5;\n ripple *= smoothstep(2.0, 0.0, distToHit) * hitStrength;\n \n // Pulsing energy\n float pulse = sin(time * 2.0) * 0.2 + 0.8;\n \n // Combine effects\n vec3 finalColor = color * (fresnel + hexPattern * 0.3 + ripple) * pulse;\n float finalOpacity = opacity * (fresnel * 0.5 + 0.5 + ripple);\n \n gl_FragColor = vec4(finalColor, finalOpacity);\n }\n "},L={uniforms:{time:{value:0},color:{value:new ir(35071)},waveSpeed:{value:1},waveHeight:{value:.5},transparency:{value:.7}},vertexShader:"\n uniform float time;\n uniform float waveSpeed;\n uniform float waveHeight;\n \n varying vec2 vUv;\n varying vec3 vNormal;\n varying float vElevation;\n \n void main() {\n vUv = uv;\n vNormal = normal;\n \n // Wave displacement\n vec3 pos = position;\n float wave1 = sin(pos.x * 2.0 + time * waveSpeed) * waveHeight;\n float wave2 = sin(pos.z * 3.0 + time * waveSpeed * 1.5) * waveHeight * 0.5;\n pos.y += wave1 + wave2;\n vElevation = wave1 + wave2;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n }\n ",fragmentShader:"\n uniform float time;\n uniform vec3 color;\n uniform float transparency;\n \n varying vec2 vUv;\n varying vec3 vNormal;\n varying float vElevation;\n \n void main() {\n // Foam on wave peaks\n float foam = smoothstep(0.3, 0.5, vElevation);\n \n // Caustics pattern\n vec2 causticsUv = vUv * 10.0 + time * 0.1;\n float caustics = abs(sin(causticsUv.x * 3.14159) * sin(causticsUv.y * 3.14159));\n \n // Depth fade\n float depth = vUv.y;\n vec3 deepColor = color * 0.5;\n vec3 shallowColor = color * 1.5;\n vec3 finalColor = mix(deepColor, shallowColor, depth);\n \n // Add foam and caustics\n finalColor += vec3(foam * 0.5);\n finalColor += vec3(caustics * 0.2);\n \n gl_FragColor = vec4(finalColor, transparency);\n }\n "},D={uniforms:{time:{value:0},color1:{value:new ir(16729088)},color2:{value:new ir(16776960)},intensity:{value:1},speed:{value:2}},vertexShader:"\n varying vec2 vUv;\n varying vec3 vPosition;\n \n void main() {\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float time;\n uniform vec3 color1;\n uniform vec3 color2;\n uniform float intensity;\n uniform float speed;\n \n varying vec2 vUv;\n varying vec3 vPosition;\n \n // Noise function\n float random(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);\n }\n \n float noise(vec2 st) {\n vec2 i = floor(st);\n vec2 f = fract(st);\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y;\n }\n \n void main() {\n vec2 uv = vUv;\n \n // Multiple layers of noise for fire effect\n float n1 = noise(uv * 5.0 + time * speed);\n float n2 = noise(uv * 10.0 + time * speed * 1.5);\n float n3 = noise(uv * 20.0 + time * speed * 2.0);\n \n // Combine noise layers\n float firePattern = n1 * 0.5 + n2 * 0.3 + n3 * 0.2;\n \n // Vertical gradient (fire rises)\n float gradient = 1.0 - uv.y;\n firePattern *= gradient;\n \n // Color mixing\n vec3 fireColor = mix(color1, color2, firePattern);\n \n // Intensity and flickering\n float flicker = sin(time * 10.0) * 0.1 + 0.9;\n fireColor *= intensity * flicker;\n \n // Alpha based on pattern\n float alpha = firePattern * intensity;\n \n gl_FragColor = vec4(fireColor, alpha);\n }\n "};function N(t,n={}){let i;switch(t){case"holographic":i=P;break;case"shield":i=I;break;case"water":i=L;break;case"fire":i=D;break;default:return e.warn(`Unknown shader: ${t}`),null}const r={...i.uniforms};for(const e in n)r[e]&&(r[e].value=n[e]);const s=new jr({uniforms:r,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,transparent:!0,side:2}),a=`shader_${Date.now()}_${Math.random()}`;return f.set(a,s),{id:a,material:s}}function U(t,e,n){const i=f.get(t);return!(!i||!i.uniforms[e])&&(i.uniforms[e].value=n,!0)}function O(t,e={}){const{color:i=16777215,size:r=.1,speed:s=1,lifetime:a=2,spread:o=1,gravity:l=-1}=e,c=new Er,h=new Float32Array(3*t),u=new Float32Array(3*t),d=new Float32Array(t);for(let n=0;n<t;n++){const t=3*n;h[t]=(Math.random()-.5)*o,h[t+1]=(Math.random()-.5)*o,h[t+2]=(Math.random()-.5)*o,u[t]=(Math.random()-.5)*s,u[t+1]=Math.random()*s,u[t+2]=(Math.random()-.5)*s,d[n]=Math.random()*a}c.setAttribute("position",new mr(h,3)),c.setAttribute("velocity",new mr(u,3)),c.setAttribute("lifetime",new mr(d,1));const p=new Ha({color:i,size:r,transparent:!0,opacity:.8,blending:2}),f=new Ya(c,p);return f.userData.velocities=u,f.userData.lifetimes=d,f.userData.maxLifetime=a,f.userData.gravity=l,f.userData.speed=s,f.userData.spread=o,n.add(f),f}function F(t,e){if(!t||!t.geometry)return;const n=t.geometry.attributes.position.array,i=t.userData.velocities,r=t.userData.lifetimes,s=t.userData.maxLifetime,a=t.userData.gravity,o=t.userData.speed,l=t.userData.spread;for(let c=0;c<n.length;c+=3){const t=c/3;r[t]-=e,r[t]<=0?(n[c]=(Math.random()-.5)*l,n[c+1]=0,n[c+2]=(Math.random()-.5)*l,i[c]=(Math.random()-.5)*o,i[c+1]=Math.random()*o,i[c+2]=(Math.random()-.5)*o,r[t]=s):(n[c]+=i[c]*e,n[c+1]+=i[c+1]*e,n[c+2]+=i[c+2]*e,i[c+1]+=a*e)}t.geometry.attributes.position.needsUpdate=!0}function B(t={}){const e=void 0!==t.pixelation?t.pixelation:1;!1!==e&&"function"==typeof globalThis.enablePixelation&&globalThis.enablePixelation(e);const n=void 0===t.dithering||t.dithering;!1!==n&&"function"==typeof globalThis.enableDithering&&globalThis.enableDithering(n);const i=void 0!==t.bloom?t.bloom:{};if(!1!==i){const t="object"==typeof i?i:{};g(t.strength??1,t.radius??.4,t.threshold??.6)}!1!==(void 0===t.fxaa||t.fxaa)&&M();const r=void 0!==t.vignette?t.vignette:{};if(!1!==r){const t="object"==typeof r?r:{};T(t.darkness??1.3,t.offset??.9)}const s=void 0!==t.chromatic&&t.chromatic;return!1!==s&&S("number"==typeof s?s:.002),!0}function z(){v(),b(),E(),w(),"function"==typeof globalThis.enablePixelation&&globalThis.enablePixelation(0),"function"==typeof globalThis.enableDithering&&globalThis.enableDithering(!1)}function k(){d&&s?s.render():r.render(n,i)}function V(t){!function(t){f.forEach(e=>{e.uniforms.time&&(e.uniforms.time.value+=t)})}(t),u&&(p+=t,u.uniforms.time.value=p)}return{exposeTo(t){Object.assign(t,{enableBloom:g,disableBloom:v,setBloomStrength:_,setBloomRadius:x,setBloomThreshold:y,enableFXAA:M,disableFXAA:b,enableChromaticAberration:S,disableChromaticAberration:w,enableVignette:T,disableVignette:E,enableGlitch:A,disableGlitch:C,setGlitchIntensity:R,enableRetroEffects:B,disableRetroEffects:z,createShaderMaterial:N,updateShaderUniform:U,createParticleSystem:O,updateParticles:F,isEffectsEnabled:()=>d,renderEffects:k})},update(t){V(t)},render(){k()}}}(Sg),Og=function(t){const e=16,n=64,i={AIR:0,GRASS:1,DIRT:2,STONE:3,SAND:4,WATER:5,WOOD:6,LEAVES:7,COBBLESTONE:8,PLANKS:9,GLASS:10,BRICK:11,SNOW:12,ICE:13,BEDROCK:14},r={[i.GRASS]:5622835,[i.DIRT]:10053188,[i.STONE]:11184810,[i.SAND]:16768392,[i.WATER]:2263261,[i.WOOD]:7816226,[i.LEAVES]:1140258,[i.COBBLESTONE]:6715272,[i.PLANKS]:14527061,[i.GLASS]:13434879,[i.BRICK]:13386803,[i.SNOW]:15658751,[i.ICE]:10083839,[i.BEDROCK]:3355443},s=new Map,a=new Map;let o=Math.floor(5e4*Math.random());function l(t,e){const n=43758.5453*Math.sin(12.9898*t+78.233*e);return n-Math.floor(n)}function c(t,e){return(l(t-1,e-1)+l(t+1,e-1)+l(t-1,e+1)+l(t+1,e+1))/16+(l(t-1,e)+l(t+1,e)+l(t,e-1)+l(t,e+1))/8+l(t,e)/4}function h(t,e){const n=Math.floor(t),i=t-n,r=Math.floor(e),s=e-r;return(c(n,r)*(1-i)+c(n+1,r)*i)*(1-s)+(c(n,r+1)*(1-i)+c(n+1,r+1)*i)*s}function u(t,e,n=4,i=.5){let r=0,s=1,a=1,o=0;for(let l=0;l<n;l++)r+=h(t*s*.01,e*s*.01)*a,o+=a,a*=i,s*=2;return r/o}class d{constructor(t,e){this.chunkX=t,this.chunkZ=e,this.blocks=new Uint8Array(16384),this.dirty=!0}getBlock(t,r,s){if(t<0||t>=e||r<0||r>=n||s<0||s>=e)return i.AIR;const a=t+s*e+r*e*e;return this.blocks[a]}setBlock(t,i,r,s){if(t<0||t>=e||i<0||i>=n||r<0||r>=e)return;const a=t+r*e+i*e*e;this.blocks[a]=s,this.dirty=!0}}function p(t,r){const a=`${t},${r}`;if(!s.has(a)){const l=new d(t,r);!function(t){const r=t.chunkX*e,s=t.chunkZ*e,a=[];for(let l=0;l<e;l++)for(let c=0;c<e;c++){const e=r+l,h=s+c,d=u(.5*e+o,.5*h+o,2,.5),p=u(.3*e+1e3+o,.3*h+1e3+o,2,.5);let f=20,m=32,g=i.GRASS,v=i.DIRT,_=0,x=30;d<.2?(g=i.SNOW,v=i.ICE,f=6,m=33,_=0):d<.35&&p>.5?(g=i.COBBLESTONE,v=i.STONE,f=18,m=34,_=.06):d>.7&&p<.25?(g=i.SAND,v=i.SAND,f=4,m=31,_=0):d>.6&&p>.6?(g=i.LEAVES,v=i.DIRT,f=22,m=28,_=.15):p<.3?(g=i.DIRT,v=i.SAND,f=5,m=33,_=.005):d>.4&&p>.4?(g=i.GRASS,v=i.DIRT,f=14,m=32,_=.08):d<.35?(g=i.SNOW,v=i.STONE,f=35,m=30,_=.02):(g=i.GRASS,v=i.DIRT,f=6,m=32,_=.015);const y=Math.floor(u(e,h,4,.5)*f+m);for(let r=0;r<n;r++)if(0===r?t.setBlock(l,r,c,i.BEDROCK):r<y-3?t.setBlock(l,r,c,i.STONE):r<y-1?t.setBlock(l,r,c,v):r===y-1?t.setBlock(l,r,c,g):r<x&&r>=y&&t.setBlock(l,r,c,i.WATER),r>0&&r<y-5){u(.5*e,.5*r,.5*h,3)>.6&&t.setBlock(l,r,c,i.AIR)}if(y>x&&_>0){const t=43758.5453*Math.sin(12.9898*e+78.233*h);t-Math.floor(t)<_&&l>2&&l<13&&c>2&&c<13&&a.push({x:l,y:y,z:c})}}for(const o of a){const r=4+Math.floor(3*Math.abs(Math.sin(7*o.x+13*o.z)));for(let e=0;e<r;e++)t.setBlock(o.x,o.y+e,o.z,i.WOOD);const s=o.y+r;for(let a=-2;a<=2;a++)for(let r=-2;r<=2;r++)for(let l=-2;l<=2;l++)if(Math.abs(a)+Math.abs(r)+Math.abs(l)<4){const c=o.x+a,h=s+r,u=o.z+l;c>=0&&c<e&&u>=0&&u<e&&h<n&&t.setBlock(c,h,u,i.LEAVES)}}}(l),s.set(a,l)}return s.get(a)}function f(t){const a=new Er,o=[],l=[],c=[],h=[],u=[];let d=0;const p=[[0,0,1],[0,0,-1],[1,0,0],[-1,0,0],[0,1,0],[0,-1,0]],f=[[0,0,1],[0,0,-1],[1,0,0],[-1,0,0],[0,1,0],[0,-1,0]];function m(r,a,o,l){const c=r+l[0],h=a+l[1],u=o+l[2];if(c>=0&&c<e&&h>=0&&h<n&&u>=0&&u<e){const e=t.getBlock(c,h,u);return e===i.AIR||e===i.WATER}if(c<0||c>=e||u<0||u>=e){const n=function(t,e){const n=`${t},${e}`;return s.get(n)||null}(t.chunkX+Math.floor(c/e),t.chunkZ+Math.floor(u/e));if(!n)return!0;const r=(c%e+e)%e,a=(u%e+e)%e,o=n.getBlock(r,h,a);return o===i.AIR||o===i.WATER}return h<0||h>=n}function g(n,i,s,a,p,m){const g=new ir(r[m]||16777215),v=[.9,.9,.85,.85,1,.7][p];g.multiplyScalar(v);const _=f[p];let x;x=0===p?[[n,i,s+1],[n+1,i,s+1],[n+1,i+1,s+1],[n,i+1,s+1]]:1===p?[[n+1,i,s],[n,i,s],[n,i+1,s],[n+1,i+1,s]]:2===p?[[n+1,i,s+1],[n+1,i,s],[n+1,i+1,s],[n+1,i+1,s+1]]:3===p?[[n,i,s],[n,i,s+1],[n,i+1,s+1],[n,i+1,s]]:4===p?[[n,i+1,s+1],[n+1,i+1,s+1],[n+1,i+1,s],[n,i+1,s]]:[[n,i,s],[n+1,i,s],[n+1,i,s+1],[n,i,s+1]];const y=t.chunkX*e,M=t.chunkZ*e;for(let t=0;t<4;t++)o.push(x[t][0]+y,x[t][1],x[t][2]+M),l.push(_[0],_[1],_[2]),c.push(g.r,g.g,g.b);h.push(0,1,1,1,1,0,0,0);const b=d;u.push(b,b+1,b+2),u.push(b,b+2,b+3),d+=4}for(let r=0;r<n;r++)for(let n=0;n<e;n++)for(let s=0;s<e;s++){const e=t.getBlock(s,r,n);if(e!==i.AIR)for(let t=0;t<6;t++)m(s,r,n,p[t])&&g(s,r,n,0,t,e)}return o.length>0&&(a.setAttribute("position",new _r(o,3)),a.setAttribute("normal",new _r(l,3)),a.setAttribute("color",new _r(c,3)),a.setAttribute("uv",new _r(h,2)),a.setIndex(u),a.computeBoundingSphere()),a}function m(e){if(!e.dirty)return;const n=`${e.chunkX},${e.chunkZ}`;if(a.has(n)){const e=a.get(n);t.scene.remove(e),e.geometry.dispose(),a.delete(n)}const i=f(e);if(i.attributes.position){const e=window.VOXEL_MATERIAL||new Pl({vertexColors:!0,flatShading:!0,roughness:.8,metalness:.1}),r=new Br(i,e);r.castShadow=!0,r.receiveShadow=!0,t.scene.add(r),a.set(n,r)}e.dirty=!1}function g(t,n){return{chunkX:Math.floor(t/e),chunkZ:Math.floor(n/e),localX:(t%e+e)%e,localZ:(n%e+e)%e}}function v(t,e,r){if(e<0||e>=n)return i.AIR;const{chunkX:s,chunkZ:a,localX:o,localZ:l}=g(t,r);return p(s,a).getBlock(o,e,l)}function _(t,e,i,r){if(e<0||e>=n)return;const{chunkX:s,chunkZ:a,localX:o,localZ:l}=g(t,i);p(s,a).setBlock(o,e,l,r),0===o&&(p(s-1,a).dirty=!0),15===o&&(p(s+1,a).dirty=!0),0===l&&(p(s,a-1).dirty=!0),15===l&&(p(s,a+1).dirty=!0)}function x(n,i){const r=Math.floor(n/e),o=Math.floor(i/e);for(let t=-4;t<=4;t++)for(let e=-4;e<=4;e++){m(p(r+t,o+e))}const l=[];for(const[e,c]of a.entries()){const[n,i]=e.split(",").map(Number),a=Math.abs(n-r),h=Math.abs(i-o);(a>5||h>5)&&(t.scene.remove(c),c.geometry.dispose(),c.material.dispose(),l.push(e),s.delete(e))}l.forEach(t=>a.delete(t))}function y(){for(const e of a.values())t.scene.remove(e),e.geometry.dispose(),e.material.dispose();a.clear(),s.clear(),o+=5e3+Math.floor(1e4*Math.random())}function M(t,e,n=10){const r=.1,s={x:t[0],y:t[1],z:t[2]},a=e[0],o=e[1],l=e[2];for(let c=0;c<n/r;c++){s.x+=a*r,s.y+=o*r,s.z+=l*r;const t=Math.floor(s.x),e=Math.floor(s.y),n=Math.floor(s.z),h=v(t,e,n);if(h!==i.AIR&&h!==i.WATER)return{hit:!0,position:[t,e,n],blockType:h,distance:c*r}}return{hit:!1}}function b(t,e){const n=Math.floor(t[0]-e),r=Math.floor(t[0]+e),s=Math.floor(t[1]),a=Math.floor(t[1]+2*e),o=Math.floor(t[2]-e),l=Math.floor(t[2]+e);for(let c=n;c<=r;c++)for(let t=s;t<=a;t++)for(let e=o;e<=l;e++){const n=v(c,t,e);if(n!==i.AIR&&n!==i.WATER)return!0}return!1}function S(t,e,n){const r=4+Math.floor(3*Math.random());for(let a=0;a<r;a++)_(t,e+a,n,i.WOOD);const s=e+r;for(let a=-2;a<=2;a++)for(let e=-2;e<=2;e++)for(let r=-2;r<=2;r++)Math.abs(a)+Math.abs(e)+Math.abs(r)<4&&_(t+a,s+e,n+r,i.LEAVES)}return{BLOCK_TYPES:i,CHUNK_SIZE:e,CHUNK_HEIGHT:n,updateChunks:x,getBlock:v,setBlock:_,raycastBlock:M,checkCollision:b,placeTree:S,resetWorld:y,exposeTo:function(t){t.BLOCK_TYPES=i,t.updateVoxelWorld=x,t.getVoxelBlock=v,t.setVoxelBlock=_,t.raycastVoxelBlock=M,t.checkVoxelCollision=b,t.placeVoxelTree=S,t.resetVoxelWorld=y}}}(Sg),Fg={exposeTo(t){t.createGameStore=Dm,t.novaStore=Nm},tick(t){const e=Nm.getState();e.paused||Nm.setState({time:e.time+t})},reset(){Nm.setState({gameState:"start",score:0,lives:3,level:1,time:0,paused:!1,playerX:0,playerY:0},!0)}},Bg=function(t){const e=t.getFramebuffer(),n=e.width,i=e.height;function r(t,r,s,a,o,l){if(t<0||r<0||t>=n||r>=i)return;if(l>=255)return void e.pset(t,r,257*s,257*a,257*o,65535);const c=4*(r*n+t),h=e.pixels,u=l/255,d=1-u;h[c]=257*Math.round(s*u+h[c]/257*d),h[c+1]=257*Math.round(a*u+h[c+1]/257*d),h[c+2]=257*Math.round(o*u+h[c+2]/257*d),h[c+3]=65535}function s(t,e,n){const i=Um(n);r(0|t,0|e,i.r,i.g,i.b,i.a)}function a(t,e,s,a,o,l,c="v"){t|=0,e|=0,s|=0,a|=0;const h=Um(o),u=Um(l),d=Math.max(0,t),p=Math.max(0,e),f=Math.min(n,t+s),m=Math.min(i,e+a);for(let n=p;n<m;n++)for(let i=d;i<f;i++){let o;o="h"===c?s>0?(i-t)/s:0:"d"===c?s+a>0?(i-t+(n-e))/(s+a):0:a>0?(n-e)/a:0,o=Math.max(0,Math.min(1,o)),r(i,n,h.r+(u.r-h.r)*o|0,h.g+(u.g-h.g)*o|0,h.b+(u.b-h.b)*o|0,h.a+(u.a-h.a)*o|0)}}function o(t,e,s,a,o){t|=0,e|=0,s|=0;const l=Um(a),c=Um(o),h=Math.max(0,t-s),u=Math.max(0,e-s),d=Math.min(n,t+s),p=Math.min(i,e+s),f=s*s;for(let n=u;n<p;n++)for(let i=h;i<d;i++){const a=i-t,o=n-e,h=a*a+o*o;if(h>f)continue;const u=Math.sqrt(h)/s;r(i,n,l.r+(c.r-l.r)*u|0,l.g+(c.g-l.g)*u|0,l.b+(c.b-l.b)*u|0,l.a+(c.a-l.a)*u|0)}}function l(t,e,n,i,s,a,o=!0){t|=0,e|=0,n|=0,i|=0,s=Math.min(0|s,Math.min(n,i)>>1);const{r:l,g:c,b:h,a:u}=Um(a);if(o){for(let o=e+s;o<e+i-s;o++)for(let e=t;e<t+n;e++)r(e,o,l,c,h,u);for(let i=e;i<e+s;i++)for(let e=t+s;e<t+n-s;e++)r(e,i,l,c,h,u);for(let o=e+i-s;o<e+i;o++)for(let e=t+s;e<t+n-s;e++)r(e,o,l,c,h,u);const a=[[t+s,e+s],[t+n-s-1,e+s],[t+s,e+i-s-1],[t+n-s-1,e+i-s-1]];for(const[t,e]of a)for(let n=-s;n<=s;n++)for(let i=-s;i<=s;i++)i*i+n*n<=s*s&&r(t+i,e+n,l,c,h,u)}else{for(let o=t+s;o<t+n-s;o++)r(o,e,l,c,h,u),r(o,e+i-1,l,c,h,u);for(let o=e+s;o<e+i-s;o++)r(t,o,l,c,h,u),r(t+n-1,o,l,c,h,u);const a=[[t+s,e+s,-1,-1],[t+n-s-1,e+s,1,-1],[t+s,e+i-s-1,-1,1],[t+n-s-1,e+i-s-1,1,1]];for(const[t,e,n,i]of a)for(let a=0;a<=90;a+=1){const o=a*Math.PI/180;r(t+n*Math.cos(o)*s|0,e+i*Math.sin(o)*s|0,l,c,h,u)}}}function c(t,e,s=!0){if(t.length<3)return;const{r:a,g:o,b:l,a:c}=Um(e);if(s){const e=Math.max(0,0|Math.min(...t.map(t=>t[1]))),s=Math.min(i-1,0|Math.max(...t.map(t=>t[1])));for(let i=e;i<=s;i++){const e=[],s=t.length;for(let n=0;n<s;n++){const[r,a]=t[n],[o,l]=t[(n+1)%s];if(a<=i&&i<l||l<=i&&i<a){const t=(i-a)/(l-a);e.push(r+t*(o-r))}}e.sort((t,e)=>t-e);for(let t=0;t+1<e.length;t+=2){const s=Math.max(0,0|e[t]),h=Math.min(n-1,0|e[t+1]);for(let t=s;t<=h;t++)r(t,i,a,o,l,c)}}}else{const e=t.length;for(let n=0;n<e;n++){const[i,s]=t[n],[h,u]=t[(n+1)%e];let d=Math.abs(h-i),p=-Math.abs(u-s),f=i<h?1:-1,m=s<u?1:-1,g=d+p,v=0|i,_=0|s;for(;r(v,_,a,o,l,c),v!==(0|h)||_!==(0|u);){const t=2*g;t>=p&&(g+=p,v+=f),t<=d&&(g+=d,_+=m)}}}}function h(t,e,n,i,r,s,a,o=!0){c([[t,e],[n,i],[r,s]],a,o)}function u(t,e,n,i,r,s=!0){c([[t,e-i],[t+n,e],[t,e+i],[t-n,e]],r,s)}function d(t,e,n,i,r){"function"==typeof globalThis.print&&globalThis.print(t,e,n,i,r)}function p(t,e=1){const n=Math.max(1,Math.round(e));return{width:6*t.length*n,height:7*n}}function f(t,e,n,i,r=1){d(t,e-p(t,r).width/2|0,n,i,r)}function m(t,e,n,i,r=1){d(t,e-p(t,r).width|0,n,i,r)}function g(t,e,n,i,r,s=1){const a=[[-1,-1],[0,-1],[1,-1],[-1,0],[1,0],[-1,1],[0,1],[1,1]];for(const[o,l]of a)d(t,e+o,n+l,r,s);d(t,e,n,i,s)}function v(t,e,n,i,r,s=1){g(t,e-p(t,s).width/2|0,n,i,r,s)}function _(t,e,n,i,r,s={}){const a=s.frequency??3,o=s.minAlpha??120,l=s.scale??1,c=Math.floor((.5*Math.sin(r*a)+.5)*(255-o)+o),{r:h,g:u,b:d}=Um(i),p=tf(h,u,d,c);s.glowColor?v(t,e,n,p,s.glowColor,l):f(t,e,n,p,l)}function x(t=80,r=2){const s=e.pixels,a=(255-t)/255;for(let e=0;e<i;e+=r)for(let t=0;t<n;t++){const i=4*(e*n+t);s[i]=s[i]*a|0,s[i+1]=s[i+1]*a|0,s[i+2]=s[i+2]*a|0}}function y(t,e,s,a,o=40,l=0){t|=0,e|=0,s|=0,a|=0;let c=12345|l;const h=Math.max(0,t),u=Math.max(0,e),d=Math.min(n,t+s),p=Math.min(i,e+a);for(let n=u;n<p;n++)for(let t=h;t<d;t++){c=1664525*c+1013904223&4294967295;const e=c>>>16&255;r(t,n,e,e,e,e/255*o|0)}}function M(t,e,r,a,o,l,c=8){t|=0,e|=0,r|=0,a|=0,c|=0;const h=Math.max(0,t),u=Math.max(0,e),d=Math.min(n,t+r),p=Math.min(i,e+a);for(let n=u;n<p;n++)for(let i=h;i<d;i++){s(i,n,0===(((i-t)/c|0)+((n-e)/c|0))%2?o:l)}}function b(t,e,n,i,s,a,o,l){if(s=Math.max(0,Math.min(1,s)),void 0!==o){const s=Um(o);for(let a=e;a<e+i;a++)for(let e=t;e<t+n;e++)r(e,a,s.r,s.g,s.b,s.a)}const c=n*s|0,h=Um(a);for(let u=e;u<e+i;u++)for(let e=t;e<t+c;e++)r(e,u,h.r,h.g,h.b,h.a);if(void 0!==l){const s=Um(l);for(let a=t;a<t+n;a++)r(a,e,s.r,s.g,s.b,s.a),r(a,e+i-1,s.r,s.g,s.b,s.a);for(let a=e;a<e+i;a++)r(t,a,s.r,s.g,s.b,s.a),r(t+n-1,a,s.r,s.g,s.b,s.a)}}function S(t,e,n,i,r,s,a={}){const o=s>0?r/s:0;b(t,e,n,i,o,o<(a.dangerThreshold??.25)?a.dangerColor??tf(220,40,40):a.barColor??tf(50,220,80),a.backgroundColor??tf(30,30,30,200),a.borderColor??tf(200,200,200,180))}function w(t,e,n,i,s,a,o=2){const l=Um(s),c=Um(a);for(let h=0;h<o;h++){for(let i=t+h;i<t+n-h;i++)r(i,e+h,l.r,l.g,l.b,l.a);for(let n=e+h;n<e+i-h;n++)r(t+h,n,l.r,l.g,l.b,l.a);for(let s=t+h;s<t+n-h;s++)r(s,e+i-1-h,c.r,c.g,c.b,c.a);for(let s=e+h;s<e+i-h;s++)r(t+n-1-h,s,c.r,c.g,c.b,c.a)}}function T(t,e,n,i,r,s,a=!0){const o=[];for(let l=0;l<2*r;l++){const s=l*Math.PI/r-Math.PI/2,a=l%2==0?n:i;o.push([t+Math.cos(s)*a,e+Math.sin(s)*a])}c(o,s,a)}function E(t,e,s,a,o,l,c,h=2){const{r:u,g:d,b:p,a:f}=Um(c);for(let m=t;m<t+s&&m<n;m++){const n=e+Math.sin((m-t)*o+l)*a|0;for(let t=-h>>1;t<=h>>1;t++){const e=n+t;e>=0&&e<i&&r(m,e,u,d,p,f)}}}function A(t,e,s,a,o){const{r:l,g:c,b:h,a:u}=Um(o),d=360*s;for(let p=0;p<d;p++){const s=p/180*Math.PI,o=p/360*a,d=t+Math.cos(s)*o|0,f=e+Math.sin(s)*o|0;d>=0&&d<n&&f>=0&&f<i&&r(d,f,l,c,h,u)}}function C(t,e,n,i,s={}){const a=s.bgColor??tf(10,10,30,200),o=s.borderLight??tf(180,180,220,255),l=s.borderDark??tf(30,30,60,255),c=Um(a);for(let h=e+2;h<e+i-2;h++)for(let e=t+2;e<t+n-2;e++)r(e,h,c.r,c.g,c.b,c.a);if(w(t,e,n,i,o,l,2),s.title){const i=s.titleColor??tf(255,255,255,255),r=s.padding??6;f(s.title,t+n/2,e+r,i)}}function R(t={}){return{x:t.x??n-90,y:t.y??10,width:t.width??80,height:t.height??80,bgColor:t.bgColor??tf(0,0,0,180),borderLight:void 0!==t.borderLight?t.borderLight:tf(150,150,150),borderDark:void 0!==t.borderDark?t.borderDark:tf(50,50,50),shape:t.shape??"rect",follow:t.follow??null,worldW:t.worldW??100,worldH:t.worldH??100,tileW:t.tileW??0,tileH:t.tileH??0,tileScale:t.tileScale??2,tiles:t.tiles??null,fogOfWar:t.fogOfWar??0,entities:t.entities??[],player:t.player??null,sweep:t.sweep??null,gridLines:t.gridLines??0,gridColor:t.gridColor??tf(40,60,40,120)}}function P(t,e,n,i,r){const s=t-n,a=e-i;return s*s+a*a<=r*r}function I(t,e,n,i,s){let a,o=0;"number"==typeof t?(a=R({x:t,y:e,width:n,height:n,worldW:100,worldH:100,bgColor:s}),Array.isArray(i)&&(a.entities=i.map(t=>({x:t.x,y:t.y,color:t.color??tf(255,255,255),size:2})),i.length>0&&(a.worldW=i[0].worldW??100,a.worldH=i[0].worldH??100))):(a=t,o=e??0);const{x:l,y:c,width:h,height:u,shape:d}=a,p=l+h/2,f=c+u/2,m="circle"===d,g=Math.min(h,u)/2,v=Um(a.bgColor);for(let x=c;x<c+u;x++)for(let t=l;t<l+h;t++)m&&!P(t,x,p,f,g)||r(t,x,v.r,v.g,v.b,v.a);if(a.tiles&&a.tileW>0&&a.tileH>0){const t=a.tileScale,e="function"==typeof a.tiles,n=a.follow?Math.floor(a.follow.x):0,i=a.follow?Math.floor(a.follow.y):0;for(let s=0;s<a.tileH;s++)for(let o=0;o<a.tileW;o++){if(a.fogOfWar>0&&a.follow){if(Math.abs(o-n)+Math.abs(s-i)>a.fogOfWar)continue}const h=e?a.tiles(o,s):a.tiles[s]?a.tiles[s][o]:null;if(!h)continue;const u=Um(h),d=l+o*t,v=c+s*t;for(let e=0;e<t;e++)for(let n=0;n<t;n++){const t=d+n,i=v+e;m&&!P(t,i,p,f,g)||r(t,i,u.r,u.g,u.b,u.a)}}}if(a.gridLines>0){const t=Um(a.gridColor);for(let e=1;e<a.gridLines;e++){const n=l+h/a.gridLines*e|0;for(let e=c;e<c+u;e++)m&&!P(n,e,p,f,g)||r(n,e,t.r,t.g,t.b,t.a);const i=c+u/a.gridLines*e|0;for(let e=l;e<l+h;e++)m&&!P(e,i,p,f,g)||r(e,i,t.r,t.g,t.b,t.a)}}if(a.sweep){const t=o*(a.sweep.speed??2),e=Um(a.sweep.color??tf(0,255,0,100)),n=Math.cos(t)*g,i=Math.sin(t)*g,s=0|Math.max(Math.abs(n),Math.abs(i));if(s>0)for(let a=0;a<=s;a++){const t=a/s,o=p+n*t|0,d=f+i*t|0;o<l||o>=l+h||d<c||d>=c+u||(m&&!P(o,d,p,f,g)||r(o,d,e.r,e.g,e.b,e.a))}}function _(t,e){if(a.tiles&&a.tileW>0)return[l+t*a.tileScale|0,c+e*a.tileScale|0];let n,i;return a.follow?(n=.5+(t-a.follow.x)/a.worldW,i=.5+(e-a.follow.y)/a.worldH):(n=t/a.worldW,i=e/a.worldH),[l+n*h|0,c+i*u|0]}for(const x of a.entities){const[t,e]=_(x.x,x.y),n=x.size??2;if(t<l-n||t>=l+h+n||e<c-n||e>=c+u+n)continue;const i=Um(x.color??tf(255,255,255)),s=n/2|0;for(let a=-s;a<n-s;a++)for(let o=-s;o<n-s;o++){const n=t+o,s=e+a;n<l||n>=l+h||s<c||s>=c+u||(m&&!P(n,s,p,f,g)||r(n,s,i.r,i.g,i.b,i.a))}}if(a.player){if(!(!1!==a.player.blink)||Math.sin(8*o)>0){const[t,e]=_(a.player.x,a.player.y),n=Um(a.player.color??tf(50,150,255)),i=a.player.size??3,s=i/2|0;for(let a=-s;a<i-s;a++)for(let o=-s;o<i-s;o++){const i=t+o,s=e+a;i<l||i>=l+h||s<c||s>=c+u||(m&&!P(i,s,p,f,g)||r(i,s,n.r,n.g,n.b,n.a))}}}if(null!==a.borderLight)if(m){const t=Um(a.borderLight),e=(g-1)*(g-1),n=g*g;for(let i=c;i<c+u;i++)for(let s=l;s<l+h;s++){const a=s-p,o=i-f,l=a*a+o*o;l>=e&&l<=n&&r(s,i,t.r,t.g,t.b,t.a)}}else w(l,c,h,u,a.borderLight,a.borderDark,1)}function L(t,e,n,i,r,s=1,a=640){d(t,a-i*n%(a+p(t,s).width)|0,e,r,s)}function D(t,e=0,n=0){const i=t.getTexts();for(const r of i){const t=Math.min(255,Math.floor(r.timer/r.maxTimer*255)),i=r.color>>16&255,s=r.color>>8&255,a=255&r.color;d(r.text,r.x+e|0,r.y+n|0,tf(i,s,a,t),r.scale)}}function N(t,e){const n=t.getTexts();for(const i of n){const[t,n]=e(i.x,i.y,i.z??0),r=Math.min(255,Math.floor(i.timer/i.maxTimer*255)),s=i.color>>16&255,a=i.color>>8&255,o=255&i.color;d(i.text,0|t,0|n,tf(s,a,o,r),i.scale)}}function U(t,e){a(0,0,n,i,t,e,"v")}function O(t){const{r:e,g:s,b:a,a:o}=Um(t);for(let l=0;l<i;l++)for(let t=0;t<n;t++)r(t,l,e,s,a,o)}function F(t,e,n=8,i=4294967295,r="cross"){if("cross"===r||"dot"===r){for(let r=t-n;r<=t+n;r++)s(r,e,i);for(let r=e-n;r<=e+n;r++)s(t,r,i)}if("circle"===r){const r=Math.max(32,4*n);for(let a=0;a<r;a++){const o=a/r*Math.PI*2;s(Math.round(t+Math.cos(o)*n),Math.round(e+Math.sin(o)*n),i)}}"dot"===r&&(s(t-1,e,i),s(t+1,e,i),s(t,e-1,i),s(t,e+1,i))}return{exposeTo(t){Object.assign(t,{colorLerp:Om,colorMix:Fm,hexColor:Bm,hslColor:zm,n64Palette:Km,lerp:km,clamp:Vm,randRange:Gm,randInt:Hm,dist:Wm,dist3d:jm,remap:Xm,pulse:qm,deg2rad:Ym,rad2deg:Zm,drawGradient:a,drawRadialGradient:o,drawSkyGradient:U,drawFlash:O,drawRoundedRect:l,poly:c,drawTriangle:h,drawDiamond:u,drawStarburst:T,drawWave:E,drawSpiral:A,drawCheckerboard:M,measureText:p,printCentered:f,printRight:m,drawGlowText:g,drawGlowTextCentered:v,drawPulsingText:_,drawScanlines:x,drawNoise:y,drawProgressBar:b,drawHealthBar:S,drawPixelBorder:w,drawPanel:C,drawCrosshair:F,createMinimap:R,drawMinimap:I,drawFloatingTexts:D,drawFloatingTexts3D:N,scrollingText:L})}}}(Sg),zg=function(t){function e(){t&&t.scene&&t.scene.traverse(t=>{t.isMesh&&t.material&&(t.material.flatShading=!0,t.material.needsUpdate=!0)})}function n(){const t=globalThis;"function"==typeof t.disableBloom&&t.disableBloom(),"function"==typeof t.enableFXAA&&t.enableFXAA(),"function"==typeof t.disableVignette&&t.disableVignette(),"function"==typeof t.disableChromaticAberration&&t.disableChromaticAberration(),e()}function i(){const t=globalThis;"function"==typeof t.enableBloom&&t.enableBloom(.8,.6,.4),"function"==typeof t.enableVignette&&t.enableVignette(2,.75),"function"==typeof t.enableChromaticAberration&&t.enableChromaticAberration(),"function"==typeof t.enableFXAA&&t.enableFXAA(),e()}function r(){const t=globalThis;"function"==typeof t.disableChromaticAberration&&t.disableChromaticAberration(),"function"==typeof t.enableBloom&&t.enableBloom(.4,.3,.7),"function"==typeof t.enableVignette&&t.enableVignette(.8,.95),"function"==typeof t.enableFXAA&&t.enableFXAA(),e()}function s(){const e=globalThis;"function"==typeof e.disableBloom&&e.disableBloom(),"function"==typeof e.disableVignette&&e.disableVignette(),"function"==typeof e.disableChromaticAberration&&e.disableChromaticAberration(),t&&t.scene&&t.scene.traverse(t=>{t.isMesh&&t.material&&(t.material.flatShading=!1,t.material.needsUpdate=!0)})}return{exposeTo(t){Object.assign(t,{enableN64Mode:n,enablePSXMode:i,enableLowPolyMode:r,disablePresetMode:s})}}}(Sg),kg=function(t){const e=t.getFramebuffer(),n=2*Math.PI,i=Math.PI/2,r=Math.PI/4;let s=0;function a(t,n,i){const[r,s]=function(t,e){return[M.a*t+M.c*e+M.tx,M.b*t+M.d*e+M.ty]}(t,n),a=Math.round(r),l=Math.round(s);if(a<0||l<0||a>=e.width||l>=e.height)return;const{r:c,g:h,b:u,a:d}=o(i);e.pset(a,l,c,h,u,d)}function o(t){if("bigint"==typeof t)return{r:Number(t>>48n&0xffffn),g:Number(t>>32n&0xffffn),b:Number(t>>16n&0xffffn),a:Number(0xffffn&t)};const e=BigInt(Math.floor(t));return{r:Number(e>>48n&0xffffn),g:Number(e>>32n&0xffffn),b:Number(e>>16n&0xffffn),a:Number(0xffffn&e)}}let l=new Uint8Array(512),c=4,h=.5;function u(t){const e=new Uint8Array(256);for(let i=0;i<256;i++)e[i]=i;let n=0|t;for(let i=255;i>0;i--){n=1664525*n+1013904223&2147483647;const t=n%(i+1);[e[i],e[t]]=[e[t],e[i]]}for(let i=0;i<512;i++)l[i]=e[255&i]}u(0);const d=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]];function p(t){return t*t*t*(t*(6*t-15)+10)}function f(t,e,n){const i=255&Math.floor(t),r=255&Math.floor(e),s=255&Math.floor(n),a=t-Math.floor(t),o=e-Math.floor(e),c=n-Math.floor(n),h=p(a),u=p(o),f=p(c),g=l[i]+r,v=l[g]+s,_=l[g+1]+s,x=l[i+1]+r,y=l[x]+s,M=l[x+1]+s,b=(t,e,n,i)=>{const r=d[t%12];return r[0]*e+r[1]*n+r[2]*i};return m(m(m(b(l[v],a,o,c),b(l[y],a-1,o,c),h),m(b(l[_],a,o-1,c),b(l[M],a-1,o-1,c),h),u),m(m(b(l[v+1],a,o,c-1),b(l[y+1],a-1,o,c-1),h),m(b(l[_+1],a,o-1,c-1),b(l[M+1],a-1,o-1,c-1),h),u),f)}function m(t,e,n){return t+(e-t)*n}function g(t,e=0,n=0){let i=0,r=1,s=1,a=0;for(let o=0;o<c;o++)i+=f(t*s,e*s,n*s)*r,a+=r,r*=h,s*=2;return.5*(i/a+1)}function v(t){u(t)}function _(t=4,e=.5){c=Math.max(1,Math.min(8,t)),h=Math.max(0,Math.min(1,e))}function x(t,e,n=.02,i=0,r=0){const s=new Float32Array(t*e);for(let a=0;a<e;a++)for(let e=0;e<t;e++)s[a*t+e]=g((e+i)*n,(a+r)*n);return s}let y=[],M={a:1,b:0,c:0,d:1,tx:0,ty:0};function b(){y.push({...M})}function S(){y.length>0&&(M=y.pop())}function w(t,e){M.tx+=M.a*t+M.c*e,M.ty+=M.b*t+M.d*e}function T(t){const e=Math.cos(t),n=Math.sin(t),{a:i,b:r,c:s,d:a}=M;M.a=i*e+s*n,M.b=r*e+a*n,M.c=i*-n+s*e,M.d=r*-n+a*e}function E(t,e){void 0===e&&(e=t),M.a*=t,M.b*=t,M.c*=e,M.d*=e}function A(){M={a:1,b:0,c:0,d:1,tx:0,ty:0},y=[]}function C(t,e,i,r,s,o=!0){if(void 0===r&&(r=i),o)for(let n=-r;n<=r;n++){const o=Math.sqrt(Math.max(0,1-n*n/(r*r)))*i;for(let i=-Math.ceil(o);i<=Math.ceil(o);i++)a(t+i,e+n,s)}else{const o=Math.max(32,Math.ceil(4*Math.max(i,r)));for(let l=0;l<o;l++){const c=l/o*n;a(Math.round(t+Math.cos(c)*i),Math.round(e+Math.sin(c)*r),s)}}}function R(t,e,n,i,r,s,o,l=!1){const c=Math.max(32,Math.ceil(4*Math.max(n,i))),h=s-r;if(l)for(let a=0;a<c;a++){const s=r+a/c*h,l=r+(a+1)/c*h;P(t,e,t+Math.cos(s)*n,e+Math.sin(s)*i,t+Math.cos(l)*n,e+Math.sin(l)*i,o)}else for(let u=0;u<=c;u++){const s=r+u/c*h;a(Math.round(t+Math.cos(s)*n),Math.round(e+Math.sin(s)*i),o)}}function P(t,e,n,i,r,s,o){let l=[{x:t,y:e},{x:n,y:i},{x:r,y:s}];l.sort((t,e)=>t.y-e.y);const[c,h,u]=l,d=u.y-c.y;if(!(d<1))for(let p=Math.ceil(c.y);p<=Math.floor(u.y);p++){const t=p>h.y||h.y===c.y,e=t?u.y-h.y:h.y-c.y;if(e<.5)continue;const n=(p-c.y)/d,i=t?(p-h.y)/e:(p-c.y)/e;let r=c.x+(u.x-c.x)*n,s=t?h.x+(u.x-h.x)*i:c.x+(h.x-c.x)*i;r>s&&([r,s]=[s,r]);for(let l=Math.ceil(r);l<=Math.floor(s);l++)a(l,p,o)}}function I(t,e,n,i,r,s,a,o,l,c=60){let h=t,u=e;for(let d=1;d<=c;d++){const p=d/c,f=p*p,m=f*p,g=1-p,v=g*g,_=v*g,x=_*t+3*v*p*n+3*g*f*r+m*a,y=_*e+3*v*p*i+3*g*f*s+m*o;D(h,u,x,y,l),h=x,u=y}}function L(t,e,n,i,r,s,a,o=40){let l=t,c=e;for(let h=1;h<=o;h++){const u=h/o,d=1-u,p=d*d*t+2*d*u*n+u*u*r,f=d*d*e+2*d*u*i+u*u*s;D(l,c,p,f,a),l=p,c=f}}function D(t,e,n,i,r){t=Math.round(t),e=Math.round(e),n=Math.round(n),i=Math.round(i);const s=Math.abs(n-t),o=Math.abs(i-e),l=t<n?1:-1,c=e<i?1:-1;let h=s-o;for(;a(t,e,r),t!==n||e!==i;){const n=2*h;n>-o&&(h-=o,t+=l),n<s&&(h+=s,e+=c)}}let N="rgb",U=[255,255,255,255];function O(t,e=255,n,i,r){N=t.toLowerCase(),U=void 0===n?[e,e,e,e]:[e,n||e,i||e,r||255]}function F(t,e,n,i){void 0===i&&(i=U[3]);const r=t/U[0],s=e/U[1],a=n/U[2],o=i/U[3];if("hsb"===N||"hsv"===N){const t=(360*r+360)%360,e=Math.max(0,Math.min(1,s)),n=Math.max(0,Math.min(1,a)),i=n*e,l=i*(1-Math.abs(t/60%2-1)),c=n-i;let h,u,d;return[h,u,d]=t<60?[i,l,0]:t<120?[l,i,0]:t<180?[0,i,l]:t<240?[0,l,i]:t<300?[l,0,i]:[i,0,l],tf(255*(h+c),255*(u+c),255*(d+c),255*o)}return tf(255*r,255*s,255*a,255*o)}function B(t,e=1,n=1,i=255){t=(t%360+360)%360;const r=n*e,s=r*(1-Math.abs(t/60%2-1)),a=n-r;let o,l,c;return[o,l,c]=t<60?[r,s,0]:t<120?[s,r,0]:t<180?[0,r,s]:t<240?[0,s,r]:t<300?[s,0,r]:[r,0,s],tf(255*(o+a),255*(l+a),255*(c+a),i)}function z(t,e,n){const i=o(t),r=o(e);return function(t,e,n,i){return BigInt(Math.round(t))<<48n|BigInt(Math.round(e))<<32n|BigInt(Math.round(n))<<16n|BigInt(Math.round(i))}(i.r+(r.r-i.r)*n,i.g+(r.g-i.g)*n,i.b+(r.b-i.b)*n,i.a+(r.a-i.a)*n)}const k={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInElastic:t=>0===t?0:1===t?1:-Math.pow(2,10*t-10)*Math.sin((10*t-10.75)*(2*Math.PI/3)),easeOutElastic:t=>0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin((10*t-.75)*(2*Math.PI/3))+1,easeOutBounce:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375};function V(t,e="easeInOutQuad"){return(k[e]||k.linear)(Math.max(0,Math.min(1,t)))}function G(t,e,n){const i=Math.max(0,Math.min(1,(n-t)/(e-t)));return i*i*(3-2*i)}function H(t,e,i=.06,r=0){const s=new Float32Array(t*e);for(let a=0;a<e;a++)for(let e=0;e<t;e++){const o=g(e*i,a*i,r);s[a*t+e]=o*n*2}return s}return{_advanceFrame:function(){s++},exposeTo(t){Object.assign(t,{TWO_PI:n,HALF_PI:i,QUARTER_PI:r,noise:g,noiseSeed:v,noiseDetail:_,noiseMap:x,ellipse:C,arc:R,bezier:I,quadCurve:L,pushMatrix:b,popMatrix:S,translate:w,rotate:T,scale2d:E,resetMatrix:A,colorMode:O,color:F,hsb:B,lerpColor:z,ease:V,smoothstep:G,flowField:H}),Object.defineProperty(t,"frameCount",{get:()=>s,configurable:!0})}}}(Sg),Vg={exposeTo(t){Object.assign(t,{createShake:Jm,triggerShake:$m,updateShake:Qm,getShakeOffset:tg,createCooldown:eg,useCooldown:ng,cooldownReady:ig,cooldownProgress:rg,updateCooldown:sg,createCooldownSet:ag,updateCooldowns:og,createHitState:lg,triggerHit:cg,isInvulnerable:hg,isVisible:ug,isFlashing:dg,updateHitState:pg,createSpawner:fg,updateSpawner:mg,triggerWave:gg,getSpawnerWave:vg,createPool:_g,createFloatingTextSystem:xg,createStateMachine:yg,createTimer:Mg})}};let Gg;const Hg={};wg.exposeTo(Hg),Tg.exposeTo(Hg),Eg.exposeTo(Hg),Ag.exposeTo(Hg),Cg.exposeTo(Hg),Rg.exposeTo(Hg),Object.assign(Hg,{aabb:function(t,e,n,i,r,s,a,o){return t<r+a&&t+n>r&&e<s+o&&e+i>s},circleCollision:function(t,e,n,i,r,s){const a=t-i,o=e-r;return a*a+o*o<=(n+s)*(n+s)},raycastTilemap:function(t,e,n,i,r,s,a){let o=0;const l=Math.sign(n)||1,c=Math.sign(i)||1,h=0!==n?1/n:1e9,u=0!==i?1/i:1e9;let d=Math.floor(t/s),p=Math.floor(e/s);const f=(t,e,n)=>((n>0?(Math.floor(t/s)+1)*s:Math.floor(t/s)*s)-t)*(0!==e?1/e:1e9);let m=f(t,n,l),g=f(e,i,c);const v=Math.abs(s*h),_=Math.abs(s*u);if(a(d,p))return{hit:!0,tx:d,ty:p,t:0,x:t,y:e};for(;o<=r;){m<g?(o=m,m+=v,d+=l):(o=g,g+=_,p+=c);const r=t+n*o,s=e+i*o;if(a(d,p))return{hit:!0,tx:d,ty:p,t:o,x:r,y:s}}return{hit:!1}}}),Pg.exposeTo(Hg),Ig.exposeTo(Hg),Lg.exposeTo(Hg),Dg.exposeTo(Hg),Ng.exposeTo(Hg),Ug.exposeTo(Hg),Og.exposeTo(Hg),Fg.exposeTo(Hg),Bg.exposeTo(Hg),zg.exposeTo(Hg),kg.exposeTo(Hg),Vg.exposeTo(Hg),Gg=function(t,e){const n={tiny:{size:1,spacing:1},small:{size:1,spacing:2},normal:{size:2,spacing:1},large:{size:3,spacing:1},huge:{size:4,spacing:2}},i=e.rgba8,r={primary:i(0,120,255,255),secondary:i(100,100,255,255),success:i(0,255,100,255),warning:i(255,200,0,255),danger:i(255,50,50,255),dark:i(20,20,30,255),light:i(240,240,250,255),white:i(255,255,255,255),black:i(0,0,0,255),transparent:i(0,0,0,0)},s={g:e,fonts:n,state:{currentFont:"normal",textAlign:"left",textBaseline:"top"},mouse:{x:0,y:0,down:!1,pressed:!1},colors:r,panels:[],buttons:[]},a=function({g:t,fonts:e,state:n,colors:i}){function r(){return e[n.currentFont]}function s(t,e=1){const n=r(),i=6*e*n.size,s=8*e*n.size;return{width:t.length*i,height:s}}function a(e,a,o,l=i.white,c=1){const h=c*r().size,u=s(e,c);let d=a;"center"===n.textAlign?d=a-u.width/2:"right"===n.textAlign&&(d=a-u.width);let p=o;"middle"===n.textBaseline?p=o-u.height/2:"bottom"===n.textBaseline&&(p=o-u.height),t.print(e,Math.floor(d),Math.floor(p),l,h)}return{setFont:function(t){e[t]&&(n.currentFont=t)},getFont:r,setTextAlign:function(t){n.textAlign=t},setTextBaseline:function(t){n.textBaseline=t},measureText:s,drawText:a,drawTextShadow:function(t,e,n,r=i.white,s=i.black,o=2,l=1){a(t,e+o,n+o,s,l),a(t,e,n,r,l)},drawTextOutline:function(t,e,n,r=i.white,s=i.black,o=1){for(let i=-1;i<=1;i++)for(let r=-1;r<=1;r++)0===i&&0===r||a(t,e+i,n+r,s,o);a(t,e,n,r,o)}}}(s);Object.assign(s,a);const o=function({g:t,colors:e,panels:n,state:i,drawText:r,setTextAlign:s}){function a(e){if(!e.visible)return;const{x:n,y:a,width:o,height:l}=e;if(e.shadow){const i=e.shadowOffset;t.rect(n+i,a+i,o,l,t.rgba8(0,0,0,100),!0)}if(e.gradient){const i=20,r=Qp(e.bgColor),s=Qp(e.gradientColor),c=Math.floor(r.r/257),h=Math.floor(r.g/257),u=Math.floor(r.b/257),d=Math.floor(r.a/257),p=Math.floor(s.r/257),f=Math.floor(s.g/257),m=Math.floor(s.b/257);for(let e=0;e<i;e++){const r=e/i,s=Math.floor(l/i),g=Math.floor(c+(p-c)*r),v=Math.floor(h+(f-h)*r),_=Math.floor(u+(m-u)*r);t.rect(n,a+e*s,o,s,t.rgba8(g,v,_,d),!0)}}else t.rect(n,a,o,l,e.bgColor,!0);if(e.cornerRadius>0){const i=e.cornerRadius;t.rect(n,a,i,i,e.bgColor,!0),t.rect(n+o-i,a,i,i,e.bgColor,!0),t.rect(n,a+l-i,i,i,e.bgColor,!0),t.rect(n+o-i,a+l-i,i,i,e.bgColor,!0)}if(e.borderWidth>0)for(let i=0;i<e.borderWidth;i++)t.rect(n+i,a+i,o-2*i,l-2*i,e.borderColor,!1);if(e.title){const l=20;t.rect(n,a-l,o,l,e.titleBgColor,!0),t.rect(n,a-l,o,l,e.borderColor,!1);const c=i.textAlign;s("center"),r(e.title,n+o/2,a-l+4,e.titleColor,1),s(c)}}return{createPanel:function(i,r,s,a,o={}){const l={id:`panel_${Date.now()}_${Math.random()}`,x:i,y:r,width:s,height:a,bgColor:o.bgColor||t.rgba8(0,0,0,200),borderColor:o.borderColor||e.primary,borderWidth:void 0!==o.borderWidth?o.borderWidth:2,cornerRadius:o.cornerRadius||0,shadow:o.shadow||!1,shadowOffset:o.shadowOffset||4,title:o.title||null,titleColor:o.titleColor||e.white,titleBgColor:o.titleBgColor||e.primary,padding:o.padding||10,visible:void 0===o.visible||o.visible,gradient:o.gradient||!1,gradientColor:o.gradientColor||t.rgba8(0,0,50,200)};return n.push(l),l},drawPanel:a,drawAllPanels:function(){n.forEach(t=>a(t))},removePanel:function(t){const e=n.indexOf(t);e>=0&&n.splice(e,1)},clearPanels:function(){n.length=0}}}(s);Object.assign(s,o);const l=function({g:t,colors:e,buttons:n,mouse:i,state:r,drawText:s,setTextAlign:a,setTextBaseline:o}){function l(t){if(!t.enabled||!t.visible)return t.hovered=!1,t.pressed=!1,!1;const e=i.x>=t.x&&i.x<=t.x+t.width&&i.y>=t.y&&i.y<=t.y+t.height;return t.hovered=e,t.pressed=e&&i.down,!(!e||!i.pressed||(t.callback&&t.callback(),0))}function c(e){if(!e.visible)return;const{x:n,y:i,width:l,height:c}=e;let h=e.normalColor;if(e.enabled?e.pressed?h=e.pressedColor:e.hovered&&(h=e.hoverColor):h=e.disabledColor,t.rect(n,i,l,c,h,!0),e.borderWidth>0){const r=e.hovered?e.hoverColor:e.borderColor;for(let s=0;s<e.borderWidth;s++)t.rect(n+s,i+s,l-2*s,c-2*s,r,!1)}e.pressed&&t.rect(n+2,i+2,l-4,c-4,t.rgba8(255,255,255,50),!0);const u=r.textAlign,d=r.textBaseline;a("center"),o("middle");const p=e.pressed?i+c/2+1:i+c/2;s(e.text,n+l/2,p,e.textColor,1),a(u),o(d)}return{createButton:function(i,r,s,a,o,l,c={}){const h={id:`button_${Date.now()}_${Math.random()}`,x:i,y:r,width:s,height:a,text:o,callback:l,enabled:void 0===c.enabled||c.enabled,visible:void 0===c.visible||c.visible,normalColor:c.normalColor||e.primary,hoverColor:c.hoverColor||t.rgba8(50,150,255,255),pressedColor:c.pressedColor||t.rgba8(0,80,200,255),disabledColor:c.disabledColor||t.rgba8(100,100,100,255),textColor:c.textColor||e.white,borderColor:c.borderColor||e.white,borderWidth:void 0!==c.borderWidth?c.borderWidth:2,hovered:!1,pressed:!1,rounded:c.rounded||!1,icon:c.icon||null};return n.push(h),h},updateButton:l,drawButton:c,updateAllButtons:function(){let t=!1;return n.forEach(e=>{l(e)&&(t=!0)}),i.pressed=!1,t},drawAllButtons:function(){n.forEach(t=>c(t))},removeButton:function(t){const e=n.indexOf(t);e>=0&&n.splice(e,1)},clearButtons:function(){n.length=0}}}(s);Object.assign(s,l);const c=function({g:t,colors:e,mouse:n,state:i,drawTextOutline:r,setTextAlign:s,setTextBaseline:a}){return{drawProgressBar:function(n,o,l,c,h,u,d={}){const p=d.bgColor||t.rgba8(50,50,50,255),f=d.fillColor||e.success,m=d.borderColor||e.white,g=void 0===d.showText||d.showText,v=d.textColor||e.white;t.rect(n,o,l,c,p,!0);const _=Math.floor(h/u*l);if(_>0&&t.rect(n,o,_,c,f,!0),t.rect(n,o,l,c,m,!1),g){const t=`${Math.floor(h)}/${Math.floor(u)}`,d=i.textAlign,p=i.textBaseline;s("center"),a("middle"),r(t,n+l/2,o+c/2,v,e.black,1),s(d),a(p)}},drawRoundedRect:function(e,n,i,r,s,a,o=!0){0!==s?(t.rect(e+s,n,i-2*s,r,a,o),t.rect(e,n+s,s,r-2*s,a,o),t.rect(e+i-s,n+s,s,r-2*s,a,o),t.circle(e+s,n+s,s,a,o),t.circle(e+i-s,n+s,s,a,o),t.circle(e+s,n+r-s,s,a,o),t.circle(e+i-s,n+r-s,s,a,o)):t.rect(e,n,i,r,a,o)},drawGradientRect:function(e,n,i,r,s,a,o=!0){const l=o?r:i,c=Qp(s),h=Qp(a),u=Math.floor(c.r/257),d=Math.floor(c.g/257),p=Math.floor(c.b/257),f=Math.floor(c.a/257),m=Math.floor(h.r/257),g=Math.floor(h.g/257),v=Math.floor(h.b/257),_=Math.floor(h.a/257);for(let x=0;x<l;x++){const s=x/l,a=Math.floor(u+(m-u)*s),c=Math.floor(d+(g-d)*s),h=Math.floor(p+(v-p)*s),y=Math.floor(f+(_-f)*s),M=t.rgba8(a,c,h,y);o?t.rect(e,n+x,i,1,M,!0):t.rect(e+x,n,1,r,M,!0)}},centerX:function(t,e=640){return Math.floor((e-t)/2)},centerY:function(t,e=360){return Math.floor((e-t)/2)},grid:function(t,e,n,i,r=0,s=0){const a=[];for(let o=0;o<e;o++)for(let e=0;e<t;e++)a.push({x:e*(n+r),y:o*(i+s),width:n,height:i,col:e,row:o});return a},setMousePosition:function(t,e){n.x=t,n.y=e},setMouseButton:function(t){n.pressed=t&&!n.down,n.down=t},getMousePosition:function(){return{x:n.x,y:n.y}},isMouseDown:function(){return n.down},isMousePressed:function(){return n.pressed}}}(s);return Object.assign(s,c),{setMousePosition:s.setMousePosition,setMouseButton:s.setMouseButton,exposeTo(t){Object.assign(t,{setFont:s.setFont,getFont:s.getFont,setTextAlign:s.setTextAlign,setTextBaseline:s.setTextBaseline,measureText:s.measureText,drawText:s.drawText,drawTextShadow:s.drawTextShadow,drawTextOutline:s.drawTextOutline,createPanel:s.createPanel,drawPanel:s.drawPanel,drawAllPanels:s.drawAllPanels,removePanel:s.removePanel,clearPanels:s.clearPanels,createButton:s.createButton,updateButton:s.updateButton,drawButton:s.drawButton,updateAllButtons:s.updateAllButtons,drawAllButtons:s.drawAllButtons,removeButton:s.removeButton,clearButtons:s.clearButtons,uiProgressBar:s.drawProgressBar,drawRoundedRect:s.drawRoundedRect,drawGradientRect:s.drawGradientRect,centerX:s.centerX,centerY:s.centerY,grid:s.grid,setMousePosition:s.setMousePosition,setMouseButton:s.setMouseButton,getMousePosition:s.getMousePosition,isMouseDown:s.isMouseDown,isMousePressed:s.isMousePressed,uiColors:r,uiFonts:n})}}}(0,Hg),Gg.exposeTo(Hg),Ig.connectUI(Gg.setMousePosition,Gg.setMouseButton),Object.assign(globalThis,Hg),Hg.getCamera&&Tg.setCameraRef(Hg.getCamera());const Wg=new class{constructor(t){this.gpu=t,this.cart=null,this._loadGeneration=0}async loadCart(t){const n=++this._loadGeneration;e.info(`๐งน Clearing previous scene before loading new cart... (gen=${n})`),this.cart=null,"function"==typeof globalThis.clearButtons&&globalThis.clearButtons(),"function"==typeof globalThis.clearPanels&&globalThis.clearPanels(),globalThis.screens&&"function"==typeof globalThis.screens.reset&&globalThis.screens.reset(),"function"==typeof globalThis.clearScene&&globalThis.clearScene(),"function"==typeof globalThis.clearSkybox&&globalThis.clearSkybox(),"function"==typeof globalThis.setCameraPosition&&globalThis.setCameraPosition(0,5,10),"function"==typeof globalThis.setCameraTarget&&globalThis.setCameraTarget(0,0,0),"function"==typeof globalThis.setFog&&globalThis.setFog(8900331,50,200),e.info("โ
Scene cleared, loading new cart:",t);const i=await import(t+"?t="+Date.now());if(n===this._loadGeneration){"function"==typeof globalThis.clearScene&&globalThis.clearScene(),"function"==typeof globalThis.clearSkybox&&globalThis.clearSkybox(),"function"==typeof globalThis.clearButtons&&globalThis.clearButtons(),"function"==typeof globalThis.clearPanels&&globalThis.clearPanels(),this.cart={init:i.init||(()=>{}),update:i.update||(()=>{}),draw:i.draw||(()=>{})};try{if(await this.cart.init(),n!==this._loadGeneration)return e.warn(`โ ๏ธ loadCart(${t}) superseded during init (gen ${n} vs ${this._loadGeneration}), aborting.`),void(this.cart=null);e.info("โ
Cart init() complete:",t)}catch(ov){e.error("โ Cart init() threw:",ov.message,ov.stack)}}else e.warn(`โ ๏ธ loadCart(${t}) superseded by a newer load (gen ${n} vs ${this._loadGeneration}), aborting.`)}}(Sg);let jg=!1,Xg=!1,qg=document.getElementById("stats");async function Yg(t){await Wg.loadCart(t)}let Zg=performance.now(),Kg=0,Jg=0,$g=0,Qg=0;function tv(){const t=performance.now(),e=Math.min(.1,(t-Zg)/1e3);if(Qg=e,Zg=t,!jg||Xg){const t=performance.now();if(Fg.tick(e),Ng._tick(e),kg._advanceFrame(),Ug.update(e),Wg.cart&&Wg.cart.update)try{"function"==typeof globalThis.updateAnimations&&globalThis.updateAnimations(e),Wg.cart.update(e)}catch(ov){console.error("โ Cart update() error:",ov.message)}Dg.manager.update(e);const n=performance.now();Kg=n-t,Sg.beginFrame();const i=performance.now();if(Wg.cart&&Wg.cart.draw)try{Wg.cart.draw()}catch(ov){console.error("โ Cart draw() error:",ov.message,ov.stack)}Dg.manager.draw();const r=performance.now();Jg=r-i;try{Sg.endFrame()}catch(ov){console.error("โ gpu.endFrame() error:",ov.message,ov.stack)}Ig.step()}Xg&&(Xg=!1),$g=Math.round(1e3/(performance.now()-t));let n=`3D GPU (Three.js) โข fps: ${$g}, update: ${Kg.toFixed(2)}ms, draw: ${Jg.toFixed(2)}ms`;if("function"==typeof get3DStats){const t=get3DStats();t.render&&(n+=` โข triangles: ${t.render.triangles}, calls: ${t.render.calls}`)}qg.textContent=n,requestAnimationFrame(tv)}globalThis.getDeltaTime=()=>Qg,globalThis.getFPS=()=>$g,function(){const t=document.getElementById("cart"),e=document.getElementById("pause"),n=document.getElementById("step"),i=document.getElementById("shot");t.addEventListener("change",async()=>{jg=!1,e.textContent="Pause",await Yg(t.value)}),e.addEventListener("click",()=>{jg=!jg,e.textContent=jg?"Resume":"Pause"}),n.addEventListener("click",()=>{Xg=!0}),i.addEventListener("click",()=>{const t=bg.toDataURL("image/png"),e=document.createElement("a");e.href=t,e.download="nova64.png",e.click()})}();const ev=new URLSearchParams(window.location.search),nv=ev.get("game"),iv=ev.get("path"),rv=ev.get("demo"),sv={"space-harrier":"/examples/space-harrier-3d/code.js",fzero:"/examples/f-zero-nova-3d/code.js",knight:"/examples/strider-demo-3d/code.js",cyberpunk:"/examples/cyberpunk-city-3d/code.js",strider:"/examples/strider-demo-3d/code.js",demoscene:"/examples/demoscene/code.js","space-combat":"/examples/star-fox-nova-3d/code.js",minecraft:"/examples/minecraft-demo/code.js",boids:"/examples/boids-flocking/code.js","game-of-life":"/examples/game-of-life-3d/code.js",nature:"/examples/nature-explorer-3d/code.js",dungeon:"/examples/dungeon-crawler-3d/code.js",wizardry:"/examples/wizardry-3d/code.js"},av={"hello-world":"/examples/hello-world/code.js","crystal-cathedral-3d":"/examples/crystal-cathedral-3d/code.js","f-zero-nova-3d":"/examples/f-zero-nova-3d/code.js","star-fox-nova-3d":"/examples/star-fox-nova-3d/code.js","minecraft-demo":"/examples/minecraft-demo/code.js","super-plumber-64":"/examples/super-plumber-64/code.js","cyberpunk-city-3d":"/examples/cyberpunk-city-3d/code.js","strider-demo-3d":"/examples/strider-demo-3d/code.js",demoscene:"/examples/demoscene/code.js","space-harrier-3d":"/examples/space-harrier-3d/code.js","hello-3d":"/examples/hello-3d/code.js","mystical-realm-3d":"/examples/mystical-realm-3d/code.js","physics-demo-3d":"/examples/physics-demo-3d/code.js","shooter-demo-3d":"/examples/shooter-demo-3d/code.js","hello-skybox":"/examples/hello-skybox/code.js","fps-demo-3d":"/examples/fps-demo-3d/code.js","adventure-comic-3d":"/examples/adventure-comic-3d/code.js","input-showcase":"/examples/input-showcase/code.js","audio-lab":"/examples/audio-lab/code.js","storage-quest":"/examples/storage-quest/code.js","instancing-demo":"/examples/instancing-demo/code.js","particles-demo":"/examples/particles-demo/code.js","screen-demo":"/examples/screen-demo/code.js","ui-demo":"/examples/ui-demo/code.js","wing-commander-space":"/examples/wing-commander-space/code.js","space-combat-3d":"/examples/space-combat-3d/code.js","model-viewer-3d":"/examples/model-viewer-3d/code.js","3d-advanced":"/examples/3d-advanced/code.js","pbr-showcase":"/examples/pbr-showcase/code.js","generative-art":"/examples/generative-art/code.js","boids-flocking":"/examples/boids-flocking/code.js","game-of-life-3d":"/examples/game-of-life-3d/code.js","nature-explorer-3d":"/examples/nature-explorer-3d/code.js","dungeon-crawler-3d":"/examples/dungeon-crawler-3d/code.js","wizardry-3d":"/examples/wizardry-3d/code.js"};(async()=>{let t=document.getElementById("cart")?.value||"/examples/space-harrier-3d/code.js";iv?t=iv:rv&&av[rv]?t=av[rv]:rv?t=`/examples/${rv}/code.js`:nv&&sv[nv]&&(t=sv[nv]),console.log(`๐ฎ Loading game: ${t}`),await Yg(t),requestAnimationFrame(tv)})(),window.addEventListener("message",t=>{if(t.data&&"EXECUTE_CODE"===t.data.type){console.log("๐ฎ Game Studio: Executing code..."),console.log("๐ Code to execute:",t.data.code.substring(0,200)+"..."),console.log("๐ง Available APIs:",{api:typeof wg,iApi:typeof Ig,threeDApi_instance:typeof Eg});try{console.log("โธ๏ธ Pausing game..."),jg=!0,console.log("๐งน Clearing 3D scene..."),Eg&&"function"==typeof Eg.clearScene?(Eg.clearScene(),console.log("โ
Scene cleared")):console.warn("โ ๏ธ clearScene not available");const e=t.data.code;console.log("๐จ Creating game function...");const n=new Function("cls","pset","pget","rectfill","rect","circfill","circ","line","print","btn","btnp","rgba8","spr","map","mset","mget","rect3d","cube3d","sphere3d","cylinder3d","cone3d","model3d","light3d","setCamera","lookAt","fog3d","clearScene","updateModel","createSpaceSkybox","animateSkybox","clearSkybox","bloom","chromaticAberration","vignette","scanlines","crt","glitch","createVoxelEngine","voxelSet","voxelGet","voxelClear","voxelRender","console","Math","Date","Array","Object","String","Number",e+'\n; return { update: typeof update !== "undefined" ? update : null, draw: typeof draw !== "undefined" ? draw : null, render: typeof render !== "undefined" ? render : null };');console.log("๐ Executing game function...");const i=n(wg.cls,wg.pset,wg.pget,wg.rectfill,wg.rect,wg.circfill,wg.circ,wg.line,wg.print,Ig.btn,Ig.btnp,wg.rgba8,Tg.spr,Tg.map,Tg.mset,Tg.mget,Eg.rect3d,Eg.cube3d,Eg.sphere3d,Eg.cylinder3d,Eg.cone3d,Eg.model3d,Eg.light3d,Eg.setCamera,Eg.lookAt,Eg.fog3d,Eg.clearScene,Eg.updateModel,Hg.createSpaceSkybox,Hg.animateSkybox,Hg.clearSkybox,Ug.bloom,Ug.chromaticAberration,Ug.vignette,Ug.scanlines,Ug.crt,Ug.glitch,Og.createVoxelEngine,Og.voxelSet,Og.voxelGet,Og.voxelClear,Og.voxelRender,console,Math,Date,Array,Object,String,Number);console.log("๐ Game functions:",i),i.update||i.draw||i.render?(console.log("๐ Replacing cart functions..."),Wg.cart||(Wg.cart={}),i.update&&(Wg.cart.update=i.update,console.log("โ
Replaced update function")),i.draw?(Wg.cart.draw=i.draw,console.log("โ
Replaced draw function")):i.render&&(Wg.cart.draw=i.render,console.log("โ
Replaced draw function (from render)"))):console.log("โน๏ธ No update/draw functions found in code"),console.log("โถ๏ธ Resuming game loop..."),jg=!1,console.log("โ
Game Studio: Code executed successfully!"),t.source&&t.source.postMessage({type:"EXECUTE_SUCCESS"},t.origin)}catch(e){console.error("โ Game Studio: Error executing code:",e),console.error("Stack trace:",e.stack),t.source&&t.source.postMessage({type:"EXECUTE_ERROR",error:e.message},t.origin)}}});
|
|
14
|
+
//# sourceMappingURL=console-CY_kygm3.js.map
|