tinker-gomoku 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,50 @@
|
|
|
1
|
-
var Vu=Object.defineProperty;var Wu=(i,t,e)=>t in i?Vu(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var ur=(i,t,e)=>Wu(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=e(r);fetch(r.href,s)}})();function Rl(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Bs={exports:{}},zs={exports:{}};(function(i,t){t=function(e){return e===void 0},i.exports=t})(zs,zs.exports);var nr=zs.exports;(function(i,t){var e=nr;t=function(n,r,s){return e(s)&&(s=r,r=void 0),!e(r)&&n<r?r:n>s?s:n},i.exports=t})(Bs,Bs.exports);var Xu=Bs.exports;const Hn=Rl(Xu);class qu{constructor(){ur(this,"enabled",!0);ur(this,"loadStarted",!1);ur(this,"turnAudio",new Audio("sound/turn.mp3"));this.turnAudio.preload="auto",this.turnAudio.volume=.7}setEnabled(t){this.enabled=t}unlock(){this.loadStarted||(this.loadStarted=!0,this.turnAudio.load())}play(){this.enabled&&(this.turnAudio.currentTime=0,this.turnAudio.play().catch(()=>{}))}}const ge=15,kr=ge*ge,qe=0,Ke=1,Cl=2,Pl=[[1,0],[0,1],[1,1],[1,-1]];function yn(i,t){return i*ge+t}function Gr(i,t){return i>=0&&i<ge&&t>=0&&t<ge}function Da(){return new Uint8Array(kr)}function Ua(i){return i===Ke?Cl:Ke}function Yu(i){for(const t of i)if(t===qe)return!1;return!0}function Zu(i,t,e){const n=i[yn(t,e)];if(n===qe)return null;for(const[r,s]of Pl){const o=[[t,e]];for(let a=1;a<ge;a++){const c=t+r*a,l=e+s*a;if(!Gr(c,l)||i[yn(c,l)]!==n)break;o.push([c,l])}for(let a=1;a<ge;a++){const c=t-r*a,l=e-s*a;if(!Gr(c,l)||i[yn(c,l)]!==n)break;o.unshift([c,l])}if(o.length>=5)return o}return null}const Sn={five:1e7,"4-open":2e5,"4-closed":12e3,"3-open":9e3,"3-closed":800,"2-open":600,"2-closed":90,"1-open":40,"1-closed":6};function Hs(i,t,e,n){let r=0;for(const[s,o]of Pl){let a=1,c=0;for(const u of[1,-1])for(let h=1;h<5;h++){const f=t+s*h*u,d=e+o*h*u;if(!Gr(f,d))break;const g=i[yn(f,d)];if(g===n){a++;continue}g===qe&&c++;break}if(a>=5){r+=Sn.five;continue}const l=c>=2?"open":c===1?"closed":"blocked";r+=Sn[`${a}-${l}`]??0}return r}function Ll(i,t,e){const n=new Uint8Array(kr),r=[];let s=!1;for(let o=0;o<kr;o++){if(i[o]===qe)continue;s=!0;const a=Math.floor(o/ge),c=o%ge;for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++){const h=a+l,f=c+u;if(!Gr(h,f))continue;const d=yn(h,f);if(i[d]!==qe||n[d])continue;n[d]=1;const g=Hs(i,h,f,e),v=Hs(i,h,f,Ua(e));r.push({row:h,column:f,cell:d,attack:g,defense:v,weight:g+v*.95})}}if(!s){const o=Math.floor(ge/2);return[{row:o,column:o,cell:yn(o,o),attack:0,defense:0,weight:0}]}return r.sort((o,a)=>a.weight-o.weight),r.slice(0,t)}function vc(i,t){let e=0;for(let n=0;n<kr;n++){const r=i[n];if(r===qe)continue;const s=Math.floor(n/ge),o=n%ge;i[n]=qe;const a=Hs(i,s,o,r);i[n]=r,e+=r===t?a:-a*1.15}return e}function ks(i,t,e,n,r,s){if(e===0)return vc(i,t);const o=s?t:Ua(t),a=Ll(i,6,o);if(a.length===0)return vc(i,t);if(s){let l=-1/0;for(const u of a){i[u.cell]=o;const h=u.attack>=Sn.five?9e6+e*1e3:ks(i,t,e-1,n,r,!1);if(i[u.cell]=qe,l=Math.max(l,h),n=Math.max(n,l),r<=n)break}return l}let c=1/0;for(const l of a){i[l.cell]=o;const u=l.attack>=Sn.five?-9e6-e*1e3:ks(i,t,e-1,n,r,!0);if(i[l.cell]=qe,c=Math.min(c,u),r=Math.min(r,c),r<=n)break}return c}function Ju(i,t,e){const n=Ll(i,e==="easy"?14:12,t);if(n.length===0)return null;const r=n.find(u=>u.attack>=Sn.five);if(r)return r;const s=n.find(u=>u.defense>=Sn.five);if(s)return s;if(e==="easy"){const u=n.map(h=>({move:h,score:h.attack*.9+h.defense*.45+Math.random()*900}));return u.sort((h,f)=>f.score-h.score),u[0].move}if(e==="normal"){const u=n.map(h=>({move:h,score:h.attack*1.05+h.defense+Math.random()*60}));return u.sort((h,f)=>f.score-h.score),u[0].move}const o=n.find(u=>u.attack>=Sn["4-open"]);if(o)return o;const a=n.find(u=>u.defense>=Sn["4-open"]);if(a)return a;let c=n[0],l=-1/0;for(const u of n.slice(0,8)){i[u.cell]=t;const h=ks(i,t,2,-1/0,1/0,!1)+u.weight*.02;i[u.cell]=qe,h>l&&(l=h,c=u)}return c}function Ku(i="pvp",t="normal"){return{board:Da(),mode:i,difficulty:t,phase:"menu",turn:Ke,cursor:{row:7,column:7},sound:!0}}function ju(i,t,e){document.querySelectorAll("[data-mode]").forEach(h=>{h.addEventListener("click",()=>{e.setMode(h.dataset.mode)})}),document.querySelectorAll("[data-difficulty]").forEach(h=>{h.addEventListener("click",()=>{e.setDifficulty(h.dataset.difficulty)})}),t.startButton.addEventListener("click",e.startMatch),t.againButton.addEventListener("click",e.startMatch),t.menuButton.addEventListener("click",e.openMenu),t.resultMenuButton.addEventListener("click",e.openMenu),t.soundButton.addEventListener("click",e.toggleSound),document.querySelectorAll("[data-direction]").forEach(h=>{h.addEventListener("click",()=>{const f=h.dataset.direction;f==="up"&&e.moveCursor(-1,0),f==="down"&&e.moveCursor(1,0),f==="left"&&e.moveCursor(0,-1),f==="right"&&e.moveCursor(0,1)})}),document.querySelector('[data-action="place"]').addEventListener("click",()=>{const h=e.getCursor();e.placeStone(h.row,h.column)}),window.addEventListener("keydown",h=>{if(h.key==="Escape"){e.getPhase()!=="menu"&&e.openMenu();return}if(h.key.toLowerCase()==="r"&&e.getPhase()!=="menu"){e.startMatch();return}if(e.getPhase()!=="play"&&e.getPhase()!=="thinking")return;const d={ArrowUp:[-1,0],w:[-1,0],ArrowDown:[1,0],s:[1,0],ArrowLeft:[0,-1],a:[0,-1],ArrowRight:[0,1],d:[0,1]}[h.key];if(d)h.preventDefault(),e.moveCursor(d[0],d[1]);else if(h.key===" "||h.key==="Enter"){h.preventDefault();const g=e.getCursor();e.placeStone(g.row,g.column)}});let n=null,r=0,s=0,o=null;const a=h=>{if(h.pointerId===n){n=null,o=null,i.renderer.domElement.style.cursor="grab";try{i.renderer.domElement.releasePointerCapture(h.pointerId)}catch{}}};i.renderer.domElement.addEventListener("pointerdown",h=>{e.unlockAudio();const f=i.pickCell(h.clientX,h.clientY);if(h.button===0&&f&&e.getPhase()==="play"){e.setCursor(f.row,f.column),e.placeStone(f.row,f.column);return}(h.button===0||h.button===2)&&(n=h.pointerId,r=h.clientX,s=h.clientY,o=h.button===2?"pan":"rotate",i.renderer.domElement.style.cursor="grabbing",i.renderer.domElement.setPointerCapture(h.pointerId),h.preventDefault())}),i.renderer.domElement.addEventListener("pointermove",h=>{if(h.pointerId===n){const d=h.clientX-r,g=h.clientY-s;o==="pan"?i.pan(d,g):i.orbit(d,g),r=h.clientX,s=h.clientY,h.preventDefault();return}if(e.getPhase()!=="play")return;const f=i.pickCell(h.clientX,h.clientY);f&&e.setCursor(f.row,f.column)}),i.renderer.domElement.addEventListener("pointerup",a),i.renderer.domElement.addEventListener("pointercancel",a),i.renderer.domElement.addEventListener("contextmenu",h=>h.preventDefault());let c=0,l=!1;return{pollGamepad:()=>{var b,T;const h=(b=navigator.getGamepads)==null?void 0:b.call(navigator)[0];if(!h||e.getPhase()==="menu"||e.getPhase()==="over")return;const f=.55,d=h.axes[0]??0,g=h.axes[1]??0,v=Math.abs(d)>Math.abs(g)?d>f?[0,1]:d<-f?[0,-1]:null:g>f?[1,0]:g<-f?[-1,0]:null,m=performance.now();v&&m-c>180&&(e.moveCursor(v[0],v[1]),c=m);const p=!!((T=h.buttons[0])!=null&&T.pressed);if(p&&!l){const S=e.getCursor();e.placeStone(S.row,S.column)}l=p}}}/**
|
|
1
|
+
var Dh=Object.defineProperty;var Uh=(i,t,e)=>t in i?Dh(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var ee=(i,t,e)=>Uh(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=e(r);fetch(r.href,s)}})();function nn(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var eo={exports:{}},no={exports:{}};(function(i,t){t=function(e){return e===void 0},i.exports=t})(no,no.exports);var Bi=no.exports;(function(i,t){var e=Bi;t=function(n,r,s){return e(s)&&(s=r,r=void 0),!e(r)&&n<r?r:n>s?s:n},i.exports=t})(eo,eo.exports);var Ih=eo.exports;const An=nn(Ih);class Nh{constructor(){ee(this,"enabled",!0);ee(this,"loadStarted",!1);ee(this,"turnAudio",new Audio("sound/turn.mp3"));this.turnAudio.preload="auto",this.turnAudio.volume=.7}setEnabled(t){this.enabled=t}unlock(){this.loadStarted||(this.loadStarted=!0,this.turnAudio.load())}play(){this.enabled&&(this.turnAudio.currentTime=0,this.turnAudio.play().catch(()=>{}))}}var io={exports:{}},ro={exports:{}},so={exports:{}},oo={exports:{}};(function(i,t){var e=Object.prototype.toString;t=function(n){return e.call(n)},i.exports=t})(oo,oo.exports);var Qn=oo.exports;(function(i,t){var e=Qn;t=function(n){return e(n)==="[object Number]"},i.exports=t})(so,so.exports);var cc=so.exports,ao={exports:{}};(function(i,t){var e=Qn;t=function(n){var r=e(n);return r==="[object Function]"||r==="[object GeneratorFunction]"||r==="[object AsyncFunction]"},i.exports=t})(ao,ao.exports);var ti=ao.exports;(function(i,t){var e=cc,n=ti,r=Math.pow(2,53)-1;t=function(s){if(!s)return!1;var o=s.length;return e(o)&&o>=0&&o<=r&&!n(s)},i.exports=t})(ro,ro.exports);var hr=ro.exports,co={exports:{}},lo={exports:{}};(function(i,t){var e=Object.prototype.hasOwnProperty;t=function(n,r){return e.call(n,r)},i.exports=t})(lo,lo.exports);var lc=lo.exports;(function(i,t){var e=lc;Object.keys?t=Object.keys:t=function(n){var r=[];for(var s in n)e(n,s)&&r.push(s);return r},i.exports=t})(co,co.exports);var Ln=co.exports,uo={exports:{}};(function(i,t){var e=Bi;t=function(n,r,s){if(e(r))return n;switch(s??3){case 1:return function(o){return n.call(r,o)};case 3:return function(o,a,c){return n.call(r,o,a,c)};case 4:return function(o,a,c,l){return n.call(r,o,a,c,l)}}return function(){return n.apply(r,arguments)}},i.exports=t})(uo,uo.exports);var pu=uo.exports;(function(i,t){var e=hr,n=Ln,r=pu;t=function(s,o,a){o=r(o,a);var c,l;if(e(s))for(c=0,l=s.length;c<l;c++)o(s[c],c,s);else{var u=n(s);for(c=0,l=u.length;c<l;c++)o(s[u[c]],u[c],s)}return s},i.exports=t})(io,io.exports);var fr=io.exports;const Fh=nn(fr),Le=15,Oh=Le*Le,uc=0,Ze=1,mu=2,Bh=[[1,0],[0,1],[1,1],[1,-1]];function $i(i,t){return i*Le+t}function $c(i,t){return i>=0&&i<Le&&t>=0&&t<Le}function hc(){return new Uint8Array(Oh)}function zh(i){return i===Ze?mu:Ze}function Hh(i){for(const t of i)if(t===uc)return!1;return!0}function kh(i,t,e){const n=i[$i(t,e)];if(n===uc)return null;for(const[r,s]of Bh){const o=[[t,e]];for(let a=1;a<Le;a++){const c=t+r*a,l=e+s*a;if(!$c(c,l)||i[$i(c,l)]!==n)break;o.push([c,l])}for(let a=1;a<Le;a++){const c=t-r*a,l=e-s*a;if(!$c(c,l)||i[$i(c,l)]!==n)break;o.unshift([c,l])}if(o.length>=5)return o}return null}var ho={exports:{}},fo={exports:{}},po={exports:{}};(function(i,t){t=function(e){var n=typeof e;return!!e&&(n==="function"||n==="object")},i.exports=t})(po,po.exports);var ei=po.exports,mo={exports:{}};(function(i,t){var e=Qn;Array.isArray?t=Array.isArray:t=function(n){return e(n)==="[object Array]"},i.exports=t})(mo,mo.exports);var zi=mo.exports,go={exports:{}},_o={exports:{}},vo={exports:{}};(function(i,t){var e=Bi,n=fr;t=function(r,s){return function(o){return n(arguments,function(a,c){if(c!==0){var l=r(a);n(l,function(u){(!s||e(o[u]))&&(o[u]=a[u])})}}),o}},i.exports=t})(vo,vo.exports);var fc=vo.exports;(function(i,t){var e=Ln,n=fc;t=n(e),i.exports=t})(_o,_o.exports);var Vh=_o.exports,xo={exports:{}};(function(i,t){var e=Ln;t=function(n,r){var s=e(r),o=s.length;if(n==null)return!o;n=Object(n);for(var a=0;a<o;a++){var c=s[a];if(r[c]!==n[c]||!(c in n))return!1}return!0},i.exports=t})(xo,xo.exports);var Gh=xo.exports;(function(i,t){var e=Vh,n=Gh;t=function(r){return r=e({},r),function(s){return n(s,r)}},i.exports=t})(go,go.exports);var Wh=go.exports,Mo={exports:{}};(function(i,t){t=function(e){return e},i.exports=t})(Mo,Mo.exports);var Xh=Mo.exports,So={exports:{}},Eo={exports:{}},yo={exports:{}};(function(i,t){var e=lc,n=zi;t=function(o,a){if(n(o))return o;if(a&&e(a,o))return[o];var c=[];return o.replace(r,function(l,u,h,f){c.push(h?f.replace(s,"$1"):u||l)}),c};var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g;i.exports=t})(yo,yo.exports);var qh=yo.exports;(function(i,t){var e=Bi,n=qh;t=function(r,s){s=n(s,r);var o;for(o=s.shift();!e(o);){if(r=r[o],r==null)return;o=s.shift()}return r},i.exports=t})(Eo,Eo.exports);var gu=Eo.exports;(function(i,t){var e=zi,n=gu;t=function(s){return e(s)?function(o){return n(o,s)}:r(s)};function r(s){return function(o){return o==null?void 0:o[s]}}i.exports=t})(So,So.exports);var _u=So.exports;(function(i,t){var e=ti,n=ei,r=zi,s=pu,o=Wh,a=Xh,c=_u;t=function(l,u,h){return l==null?a:e(l)?s(l,u,h):n(l)&&!r(l)?o(l):c(l)},i.exports=t})(fo,fo.exports);var us=fo.exports;(function(i,t){var e=us,n=hr,r=Ln;t=function(s,o,a){o=e(o,a);for(var c=!n(s)&&r(s),l=(c||s).length,u=0;u<l;u++){var h=c?c[u]:u;if(o(s[h],h,s))return!0}return!1},i.exports=t})(ho,ho.exports);var Yh=ho.exports;const Kh=nn(Yh);var To={exports:{}},Ao={exports:{}},bo={exports:{}};(function(i,t){var e=us,n=Ln,r=hr;t=function(s,o,a){o=e(o,a);for(var c=!r(s)&&n(s),l=(c||s).length,u=Array(l),h=0;h<l;h++){var f=c?c[h]:h;u[h]=o(s[f],f,s)}return u},i.exports=t})(bo,bo.exports);var hs=bo.exports;const Ai=nn(hs);(function(i,t){var e=hs,n=_u;t=function(r,s){return e(r,n(s))},i.exports=t})(Ao,Ao.exports);var Zh=Ao.exports;(function(i,t){var e=us,n=Zh,r=hs,s=Bi;t=function(o,a,c){a=e(a,c);var l=0;return n(r(o,function(u,h){return{val:u,idx:l++,criteria:a(u,h,o)}}).sort(function(u,h){var f=u.criteria,d=h.criteria;if(f!==d){if(f>d||s(f))return 1;if(f<d||s(d))return-1}return u.idx-h.idx}),"val")},i.exports=t})(To,To.exports);var $h=To.exports;const vu=nn($h);var wo={exports:{}};(function(i,t){var e=us,n=fr;t=function(r,s,o){var a=[];return s=e(s,o),n(r,function(c,l,u){s(c,l,u)&&a.push(c)}),a},i.exports=t})(wo,wo.exports);var dc=wo.exports;const pc=nn(dc);function Ro(i){return i===Ze?1:-1}const Yr={pointsLimit:20,rootPointsLimit:32,deepPointsLimit:12,inLineDistance:5};function Jc(i,t){return[Math.floor(i/t),i%t]}function Mr(i,t,e){return i*e+t}function Jh(i,t,e){const n=Yr.inLineDistance,[r,s]=Jc(i,e),[o,a]=Jc(t,e);return r===o&&Math.abs(s-a)<n||s===a&&Math.abs(r-o)<n||Math.abs(r-o)===Math.abs(s-a)&&Math.abs(r-o)<n}function jc(i,t,e){return Kh(t,n=>Jh(i,n,e))}const nt={FIVE:5,BLOCK_FIVE:50,FOUR:4,FOUR_FOUR:44,FOUR_THREE:43,THREE_THREE:33,BLOCK_FOUR:40,THREE:3,BLOCK_THREE:30,TWO_TWO:22,TWO:2,NONE:0},Qc=(i,t,e,n,r,s)=>{const o=-s;let a=0,c=0,l=0,u=0,h=0,f=0,d=0;for(let g=1;g<=5;g++){const v=t+g*n+1,m=e+g*r+1,p=i[v][m];if(p===2||p===o||(p===s&&(l++,h=0,c&&(a+=c,c=0),a===0?(f++,d++):a===1&&d++),u++,p===0&&(c++,h++),h>=2))break}return a||(d=0),{selfCount:l,totalLength:u,noEmptySelfCount:f,oneEmptySelfCount:d,innerEmptyCount:a,sideEmptyCount:h}},jh=(i,t,e,n,r,s)=>{if(i[t+n+1][e+r+1]===0&&i[t-n+1][e-r+1]===0&&i[t+2*n+1][e+2*r+1]===0&&i[t-2*n+1][e-2*r+1]===0)return[nt.NONE,1];let o=nt.NONE;const a=Qc(i,t,e,-n,-r,s),c=Qc(i,t,e,n,r,s),l=a.selfCount+c.selfCount+1,u=a.totalLength+c.totalLength+1,h=a.noEmptySelfCount+c.noEmptySelfCount+1,f=Math.max(a.oneEmptySelfCount+c.noEmptySelfCount,a.noEmptySelfCount+c.oneEmptySelfCount)+1,d=c.sideEmptyCount,g=a.sideEmptyCount;if(u<5)return[o,l];if(h>=5)return d>0&&g>0?[nt.FIVE,l]:[nt.BLOCK_FIVE,l];if(h===4){if((d>=1||c.oneEmptySelfCount>c.noEmptySelfCount)&&(g>=1||a.oneEmptySelfCount>a.noEmptySelfCount))return[nt.FOUR,l];if(!(d===0&&g===0))return[nt.BLOCK_FOUR,l]}return f===4?[nt.BLOCK_FOUR,l]:h===3?d>=2&&g>=1||d>=1&&g>=2?[nt.THREE,l]:[nt.BLOCK_THREE,l]:f===3?d>=1&&g>=1?[nt.THREE,l]:[nt.BLOCK_THREE,l]:((h===2||f===2)&&u>5&&(o=nt.TWO),[o,l])},ri=i=>i===nt.FIVE||i===nt.BLOCK_FIVE,Sr=i=>i===nt.FOUR||i===nt.BLOCK_FOUR,Ss=(i,t,e,n)=>{const r=n?[n]:[1,-1],s=[];for(const o of r)for(const a of[0,1,2,3]){const c=i[o][a][t][e];c>0&&s.push(c)}return s},Oe=1e7,xu=1e5,Qh=xu/2,Mu=1500,ts=1e3,tf=150,ef=200,nf=100,rf=15,sf=10,tl=[[0,1],[1,0],[1,1],[1,-1]],of=()=>{const i={};for(const t of Object.keys(nt))i[nt[t]]=new Set;return i},af=(i,t,e)=>vu([...i],n=>-e(n)*1e6+n).slice(0,t),el=(i,t)=>i===0?0:t===0?1:i===t?2:3;class cf{constructor(t=15){ee(this,"size");ee(this,"board");ee(this,"blackScores");ee(this,"whiteScores");ee(this,"shapeCache");ee(this,"activePoints");ee(this,"history",[]);this.size=t,this.board=Array.from({length:t+2},(e,n)=>Array.from({length:t+2},(r,s)=>n===0||s===0||n===t+1||s===t+1?2:0)),this.blackScores=Array.from({length:t},()=>Array.from({length:t},()=>0)),this.whiteScores=Array.from({length:t},()=>Array.from({length:t},()=>0)),this.initPoints()}move(t,e,n){for(const r of[0,1,2,3])this.shapeCache[n][r][t][e]=nt.NONE,this.shapeCache[-n][r][t][e]=nt.NONE;this.activePoints[n].delete(Mr(t,e,this.size)),this.activePoints[-n].delete(Mr(t,e,this.size)),this.blackScores[t][e]=0,this.whiteScores[t][e]=0,this.board[t+1][e+1]=n,this.updatePoint(t,e),this.history.push([Mr(t,e,this.size),n])}undo(t,e){this.board[t+1][e+1]=0,this.updatePoint(t,e),this.history.pop()}initPoints(){this.shapeCache={1:{},[-1]:{}};for(const t of[1,-1])for(const e of[0,1,2,3])this.shapeCache[t][e]=Array.from({length:this.size},()=>Array.from({length:this.size},()=>nt.NONE));this.activePoints={1:new Set,[-1]:new Set}}getPoints(t,e,n,r){const s=e%2===0?t:-t,o=of(),a=this.history.slice(-4).map(([c])=>c);for(const c of[t,-t])for(const l of this.activePoints[c]){const u=Math.floor(l/this.size),h=l%this.size;let f=0,d=0,g=0;for(const v of[0,1,2,3]){const m=this.shapeCache[c][v][u][h];if(!m||r&&(c===s&&!Sr(m)&&!ri(m)||c===-s&&ri(m)))continue;if(n){if(e%2===0){if(e===0&&c!==s||m!==nt.THREE&&!Sr(m)&&!ri(m)||m===nt.THREE&&c!==s||e>0&&(m===nt.THREE&&Ss(this.shapeCache,u,h,c).length===1||m===nt.BLOCK_FOUR&&Ss(this.shapeCache,u,h,c).length===1))continue}else if(m!==nt.THREE&&!Sr(m)&&!ri(m)||m===nt.THREE&&c===-s||e>1&&(m===nt.BLOCK_FOUR&&Ss(this.shapeCache,u,h).length===1||m===nt.BLOCK_FOUR&&!jc(l,a,this.size)))continue}if(r&&!Sr(m)&&!ri(m)||e>2&&(m===nt.TWO||m===nt.TWO_TWO||m===nt.BLOCK_THREE)&&!jc(l,a,this.size))continue;o[m].add(l),m===nt.FOUR?f++:m===nt.BLOCK_FOUR?d++:m===nt.THREE&&g++;let p;f>=2?p=nt.FOUR_FOUR:d&&g?p=nt.FOUR_THREE:g>=2&&(p=nt.THREE_THREE),p&&o[p].add(l)}}return o}updatePoint(t,e){this.updateSinglePoint(t,e,1),this.updateSinglePoint(t,e,-1);for(const[n,r]of tl)for(const s of[1,-1])for(let o=1;o<=5;o++){let a=!1;for(const c of[1,-1]){const l=t+s*o*n+1,u=e+s*o*r+1;if(this.board[l][u]===2){a=!0;break}this.board[l][u]!==-c&&this.board[l][u]===0&&this.updateSinglePoint(l-1,u-1,c,[s*n,s*r])}if(a)break}}updateSinglePoint(t,e,n,r){if(this.board[t+1][e+1]!==0)return;this.board[t+1][e+1]=n;const s=r?[r]:tl,o=this.shapeCache[n];for(const[d,g]of s)o[el(d,g)][t][e]=nt.NONE;for(const[d,g]of s){const v=el(d,g),[m]=jh(this.board,t,e,d,g,n);o[v][t][e]=m||nt.NONE}let a=0,c=0,l=0,u=0;for(const d of[0,1,2,3]){let g=o[d][t][e];g&&(g===nt.BLOCK_FOUR?c++:g===nt.THREE?l++:g===nt.TWO&&u++,c>=2?g=nt.FOUR_FOUR:c&&l?g=nt.FOUR_THREE:l>=2?g=nt.THREE_THREE:u>=2&&(g=nt.TWO_TWO),a+=lf(g))}this.board[t+1][e+1]=0;const h=Mr(t,e,this.size);return[0,1,2,3].some(d=>o[d][t][e]!==nt.NONE)?this.activePoints[n].add(h):this.activePoints[n].delete(h),n===1?this.blackScores[t][e]=a:this.whiteScores[t][e]=a,a}evaluate(t){let e=0,n=0;for(let r=0;r<this.blackScores.length;r++)for(let s=0;s<this.blackScores[r].length;s++)e+=this.blackScores[r][s],n+=this.whiteScores[r][s];return t===1?e-n:n-e}hasThreatAtLeast(t){for(const e of[1,-1]){const n=e===1?this.blackScores:this.whiteScores;for(const r of this.activePoints[e]){const s=Math.floor(r/this.size),o=r%this.size;if(n[s][o]>=t)return!0}}return!1}getMoves(t,e,n=!1,r=!1){return Array.from(this.getMovePositions(t,e,n,r)).map(s=>[Math.floor(s/this.size),s%this.size])}getMovePositions(t,e,n=!1,r=!1){const s=this.getPoints(t,e,n,r),o=t===1?this.blackScores:this.whiteScores,a=t===1?this.whiteScores:this.blackScores,c=R=>{const E=Math.floor(R/this.size),_=R%this.size;return o[E][_]*2+a[E][_]},l=R=>[...R].sort((E,_)=>c(_)-c(E)||E-_),u=(...R)=>new Set(R.flatMap(l)),h=(R,E)=>{const _=Math.floor(R/this.size),w=R%this.size;return[0,1,2,3].map(B=>this.shapeCache[E][B][_][w])},f=(R,E,_)=>{const w=h(R,E);return _===nt.FIVE?w.some(ri):_===nt.FOUR_FOUR?w.filter(B=>B===nt.FOUR).length>=2:_===nt.FOUR_THREE?w.includes(nt.BLOCK_FOUR)&&w.includes(nt.THREE):_===nt.THREE_THREE?w.filter(B=>B===nt.THREE).length>=2:w.includes(_)},d=(R,E,_)=>pc([...R],w=>f(w,E,_)),g=(R,E)=>[d(R,t,E),d(R,-t,E)],v=new Set([...s[nt.FIVE],...s[nt.BLOCK_FIVE]]);if(v.size){const[R,E]=g(v,nt.FIVE);return u(R,E)}const m=s[nt.FOUR],p=s[nt.BLOCK_FOUR];if(r||m.size){const[R,E]=g(m,nt.FOUR),[_,w]=g(p,nt.BLOCK_FOUR);return u(R,E,_,w)}const A=s[nt.FOUR_FOUR];if(A.size){const[R,E]=g(A,nt.FOUR_FOUR),[_,w]=g(p,nt.BLOCK_FOUR);return u(R,E,_,w)}const y=s[nt.THREE],S=s[nt.FOUR_THREE];if(S.size){const[R,E]=g(S,nt.FOUR_THREE),[_,w]=g(p,nt.BLOCK_FOUR),[B,F]=g(y,nt.THREE);return u(R,E,_,w,B,F)}const L=s[nt.THREE_THREE];if(L.size){const[R,E]=g(L,nt.THREE_THREE),[_,w]=g(p,nt.BLOCK_FOUR),[B,F]=g(y,nt.THREE);return u(R,E,_,w,B,F)}if(n){const[R,E]=g(p,nt.BLOCK_FOUR),[_,w]=g(y,nt.THREE);return u(R,E,_,w)}const P=new Set([...s[nt.BLOCK_FOUR],...s[nt.THREE],...s[nt.BLOCK_THREE],...s[nt.TWO_TWO],...s[nt.TWO]]),C=e===0?Yr.rootPointsLimit:e>=3?Yr.deepPointsLimit:Yr.pointsLimit;return new Set(af(P,C,c))}}const lf=i=>{switch(i){case nt.FIVE:return xu;case nt.BLOCK_FIVE:return Mu;case nt.FOUR:case nt.FOUR_FOUR:case nt.FOUR_THREE:return ts;case nt.BLOCK_FOUR:return tf;case nt.THREE:return nf;case nt.THREE_THREE:return Qh/10;case nt.BLOCK_THREE:return rf;case nt.TWO:return sf;case nt.TWO_TWO:return ef/10;default:return 0}};let Co=class{constructor(t=1e6){ee(this,"capacity");ee(this,"cache",[]);ee(this,"map",new Map);ee(this,"nextEviction",0);this.capacity=t}get(t){return this.map.get(t)??null}put(t,e){if(this.map.has(t)){this.map.set(t,e);return}if(this.cache.length<this.capacity)this.cache.push(t);else{const n=this.cache[this.nextEviction];this.map.delete(n),this.cache[this.nextEviction]=t,this.nextEviction=(this.nextEviction+1)%this.capacity}this.map.set(t,e)}};class uf{constructor(t){ee(this,"zobristTable");ee(this,"hash",0n);this.size=t,this.zobristTable=this.initializeZobristTable(t)}randomBitString(t){let e="0b";for(let n=0;n<t;n++)e+=Math.round(Math.random()).toString();return e}initializeZobristTable(t){const e=[];for(let n=0;n<t;n++){e[n]=[];for(let r=0;r<t;r++)e[n][r]={1:BigInt(this.randomBitString(64)),[-1]:BigInt(this.randomBitString(64))}}return e}togglePiece(t,e,n){this.hash^=this.zobristTable[t][e][n]}getHash(){return this.hash}}const hf=[[1,0],[0,1],[1,1],[1,-1]],ff=[-1,1];class df{constructor(t=15,e=1){ee(this,"size");ee(this,"board");ee(this,"firstRole");ee(this,"role");ee(this,"history",[]);ee(this,"emptyCount");ee(this,"winner",0);ee(this,"zobrist");ee(this,"evaluateCache",new Co);ee(this,"valuableMovesCache",new Co);ee(this,"evaluator");this.size=t,this.board=Array.from({length:t},()=>Array.from({length:t},()=>0)),this.firstRole=e,this.role=e,this.emptyCount=t*t,this.zobrist=new uf(t),this.evaluator=new cf(t)}isGameOver(){return this.winner!==0||this.emptyCount===0}getWinner(){return this.winner}hasFiveAt(t,e,n){for(const[r,s]of hf){let o=1;for(const a of ff)for(let c=1;c<5;c++){const l=t+a*c*r,u=e+a*c*s;if(l<0||l>=this.size||u<0||u>=this.size||this.board[l][u]!==n)break;o++}if(o>=5)return!0}return!1}put(t,e,n){const r=n??this.role;return this.board[t][e]!==0?!1:(this.board[t][e]=r,this.history.push({i:t,j:e,role:r,previousRole:this.role}),this.zobrist.togglePiece(t,e,r),this.evaluator.move(t,e,r),this.emptyCount--,this.winner=this.hasFiveAt(t,e,r)?r:0,this.role=-r,!0)}undo(){const t=this.history.pop();return t?(this.board[t.i][t.j]=0,this.role=t.previousRole,this.zobrist.togglePiece(t.i,t.j,t.role),this.evaluator.undo(t.i,t.j),this.emptyCount++,this.winner=0,!0):!1}getValuableMoves(t,e=0,n=!1,r=!1){const s=this.hash(),o=this.valuableMovesCache.get(s);if(o&&o.role===t&&o.depth===e&&o.onlyThree===n&&o.onlyFour===r)return o.moves;const a=this.evaluator.getMoves(t,e,n,r);if(!n&&!r){const c=Math.floor(this.size/2);this.board[c][c]===0&&a.push([c,c])}return this.valuableMovesCache.put(s,{role:t,moves:a,depth:e,onlyThree:n,onlyFour:r}),a}hash(){return this.zobrist.getHash()}evaluate(t){const e=this.hash(),n=this.evaluateCache.get(e);if((n==null?void 0:n.role)===t)return n.score;const r=this.getWinner(),s=r!==0?Oe*r*t:this.evaluator.evaluate(t);return this.evaluateCache.put(e,{role:t,score:s}),s}}var Po={exports:{}},Lo={exports:{}};(function(i,t){var e=/^\s+/;t=function(n,r){if(r==null)return n.trimLeft?n.trimLeft():n.replace(e,"");for(var s=0,o=n.length,a=r.length,c=!0,l,u;c&&s<o;)for(c=!1,l=-1,u=n.charAt(s);++l<a;)if(u===r[l]){c=!0,s++;break}return s>=o?"":n.substr(s,o)},i.exports=t})(Lo,Lo.exports);var pf=Lo.exports,Do={exports:{}};(function(i,t){t=function(e,n){if(n==null){if(e.trimRight)return e.trimRight();n=` \r
|
|
2
|
+
\f\v`}for(var r=e.length-1,s=n.length,o=!0,a,c;o&&r>=0;)for(o=!1,a=-1,c=e.charAt(r);++a<s;)if(c===n[a]){o=!0,r--;break}return r>=0?e.substring(0,r+1):""},i.exports=t})(Do,Do.exports);var mf=Do.exports;(function(i,t){var e=pf,n=mf;t=function(r,s){return s==null&&r.trim?r.trim():e(n(r,s),s)},i.exports=t})(Po,Po.exports);var gf=Po.exports;const _f=nn(gf);var Uo={exports:{}};(function(i,t){var e=dc;t=function(n){return e(n,function(r){return!!r})},i.exports=t})(Uo,Uo.exports);var vf=Uo.exports;const xf=nn(vf);var Io={exports:{}},No={exports:{}},Fo={exports:{}};(function(i,t){var e=Qn;t=function(n){return e(n)==="[object String]"},i.exports=t})(Fo,Fo.exports);var fs=Fo.exports;(function(i,t){var e=cc,n=ei,r=ti,s=fs;t=function(o){if(e(o))return o;if(n(o)){var a=r(o.valueOf)?o.valueOf():o;o=n(a)?a+"":a}return s(o)?+o:o===0?o:+o},i.exports=t})(No,No.exports);var Mf=No.exports;(function(i,t){var e=Mf;t=function(n){return n?(n=e(n),n-n%1):n===0?n:0},i.exports=t})(Io,Io.exports);var Sf=Io.exports;const Oo=nn(Sf),Ef=`# Gomoku opening lines for the computer opponent.
|
|
3
|
+
# Each line is a sequence of row,column moves on a 15x15 board. Black plays first.
|
|
4
|
+
|
|
5
|
+
7,7 6,6
|
|
6
|
+
7,7 7,8 6,8
|
|
7
|
+
7,7 8,7 10,10 9,9 9,7
|
|
8
|
+
7,7 8,7 10,7 10,8 8,9
|
|
9
|
+
7,7 8,7 10,8 8,9 6,9
|
|
10
|
+
7,7 8,7 8,10 6,8 8,5
|
|
11
|
+
7,7 8,8 5,10 8,6 8,10
|
|
12
|
+
7,7 8,8 6,10 6,8 7,5
|
|
13
|
+
7,7 8,8 7,10 6,9 5,6
|
|
14
|
+
7,7 8,8 8,9
|
|
15
|
+
7,7 8,8 9,10 8,10 5,11
|
|
16
|
+
7,7 8,9 6,8
|
|
17
|
+
7,7 9,9 6,8
|
|
18
|
+
7,7 6,8 8,8
|
|
19
|
+
7,7 8,8 6,6
|
|
20
|
+
6,7 5,7
|
|
21
|
+
7,7 4,6
|
|
22
|
+
1,6 4,6 6,4 6,1 2,3
|
|
23
|
+
1,11 2,8 4,7
|
|
24
|
+
1,13 3,11 5,13 3,9 5,10 3,12 3,10
|
|
25
|
+
4,2 5,2 5,5 4,4 2,3 7,4
|
|
26
|
+
5,0 7,0 0,1 4,1 4,3 7,4
|
|
27
|
+
5,0 7,0 9,0 7,1 8,3 9,4
|
|
28
|
+
5,5 4,5 4,7 3,6 1,8 4,4
|
|
29
|
+
5,5 4,5 7,5 3,6 5,7 5,4
|
|
30
|
+
5,5 4,6
|
|
31
|
+
6,13 5,6 2,11 3,12 5,8 4,9
|
|
32
|
+
11,3 6,12 9,8 6,3 5,12 8,3 11,6
|
|
33
|
+
11,4 12,8 13,1 10,4 8,5 9,5 10,6 8,6
|
|
34
|
+
11,10 12,8 12,5 11,4 9,3 10,7 10,6 9,5 9,6 8,6 7,7 7,5
|
|
35
|
+
2,12 3,13 4,14 5,14 6,13 7,12 6,11 4,10 3,10 6,10 5,8
|
|
36
|
+
0,12 2,14 0,11 3,14 0,10 4,14 5,14 0,9 2,12 4,10 4,12 5,10 0,14
|
|
37
|
+
2,14 3,14 2,13 3,13 2,12 3,12 8,14 7,14 8,13 7,13 8,12 7,12 3,10
|
|
38
|
+
7,10 5,8 4,7 3,6 4,6 5,6 6,6 7,6 7,4 9,6 11,8 10,7 9,8 8,8 8,5 6,9 7,9 8,9 10,8 7,11 8,7 7,3 2,6 12,8 8,11 4,8
|
|
39
|
+
`,Bo=(i,t)=>`${i},${t}`,yf=i=>xf(Ai(i.split(/\s+/),t=>{const e=t.match(/^(\d+),(\d+)$/);return e?[Oo(e[1]),Oo(e[2])]:void 0})),Tf=pc(Ai(Ef.split(/\r?\n/),i=>yf(_f(i.replace(/#.*/,"")))),i=>i.length>0),zo=new Map;for(const i of Tf)for(let t=0;t<i.length;t++){const e=Ai(i.slice(0,t),([o,a])=>Bo(o,a)).join(" "),n=i[t];if(!n)continue;const r=Bo(n[0],n[1]),s=zo.get(e)??new Map;s.set(r,(s.get(r)??0)+1),zo.set(e,s)}function Su(i){const t=Ai(i.history,({i:n,j:r})=>Bo(n,r)).join(" "),e=zo.get(t);return e?vu(pc(Ai([...e.entries()],([n,r])=>{const[s,o]=Ai(n.split(","),Oo);return{move:[s,o],weight:r}}),({move:[n,r]})=>i.board[n][r]===0),({weight:n,move:[r,s]})=>-n*1e4+r*15+s):[]}function Af(i){var t;return((t=Su(i)[0])==null?void 0:t.move)??null}const Ji=1e9,bf=6,wf=2,Er=2,Rf=3,Ho=Symbol("search-timeout"),ke={EXACT:"exact",LOWER:"lower",UPPER:"upper"};let es=new WeakMap;const Cf=i=>{let t=es.get(i);return t||(t=new Co,es.set(i,t)),t},Pf=i=>{i?es.delete(i):es=new WeakMap},Lf=(i,t)=>`${i?1:0}:${t?1:0}`,Eu=(i,t,e)=>i<=t?ke.UPPER:i>=e?ke.LOWER:ke.EXACT,Df=i=>Math.abs(i)>=Oe?Math.sign(i)*Oe:i,ns=(i,t,[e,n])=>{const r=t===1?i.evaluator.blackScores:i.evaluator.whiteScores,s=t===1?i.evaluator.whiteScores:i.evaluator.blackScores;return r[e][n]*2+s[e][n]},nl=(i,t)=>i&&t&&i[0]===t[0]&&i[1]===t[1],rr=(i,[t,e])=>t*i+e,Uf=(i,t,e,n,r)=>e!==0||!i.openingBookRanks?0:i.openingBookRanks[rr(t.size,r)]-i.openingBookRanks[rr(t.size,n)],il=(i,t,e,n)=>{var s;const r=rr(n,e);if(i.useKillers){const o=(s=i.killers)==null?void 0:s[t];if(r===(o==null?void 0:o[0]))return 768;if(r===(o==null?void 0:o[1]))return 512}return i.useHistory?i.history[r]:0},If=(i,t,e,n,r)=>{var o;if(!i.experimentalMoveOrdering)return;const s=rr(r,n);if(i.useKillers){const a=((o=i.killers)==null?void 0:o[t])??[];s!==a[0]&&(i.killers[t]=[s,a[0]??s])}i.useHistory&&(i.history[s]=An(i.history[s]+e**2,0,255))},is=(i,t)=>i.evaluator.hasThreatAtLeast(t),yu=(i,t,e,n,r,s,o,a)=>{const c=r,l=s;if(o.deadline&&performance.now()>=o.deadline)throw Ho;const u=i.evaluate(t);if(!n||i.isGameOver())return{score:u,flag:ke.EXACT};const h=is(i,Mu);if(!h&&(!a||!is(i,ts)))return{score:u,flag:ke.EXACT};let f=i.getValuableMoves(t,e,!h,h);if(!h){const m=f.length>Er&&ns(i,t,f[Er-1])===ns(i,t,f[Er])?Rf:Er;f=f.slice(0,m)}if(!f.length)return{score:u,flag:ke.EXACT};let d=-Ji;for(const v of f){if(!i.put(v[0],v[1],t))continue;let m;try{m=yu(i,-t,e+1,n-1,-s,-r,o,a).score}finally{i.undo()}if(d=Math.max(d,-m),r=Math.max(r,d),r>=s||r>=Oe)break}const g=d===-Ji?u:d;return{score:g,flag:Eu(g,c,l)}},Tu=(i=!1,t=!1)=>{const e=!i&&!t,n=(r,s,o,a,c,l,u,h=!1)=>{if(u.deadline&&performance.now()>=u.deadline)throw Ho;if(a>=o||r.isGameOver()){const _=!r.isGameOver()&&e&&!u.disableQuiescence?yu(r,s,a,wf,c,l,u,o<=2):{score:r.evaluate(s),flag:ke.EXACT},{score:w}=_;return{score:Math.abs(w)>=Oe?Math.sign(w)*(Oe+o-a):w,move:null,pv:[],flag:_.flag}}const f=Cf(r),d=r.hash(),g=c,v=l,m=o-a,p=Lf(i,t),A=f.get(d);if(!u.disableTt&&!u.disableTtCutoffs&&A&&A.role===s&&A.mode===p&&A.depth>=m){if(A.flag===ke.EXACT)return{score:A.score,move:A.move,pv:A.pv,flag:A.flag};if(!u.exactTtOnly&&A.flag===ke.LOWER&&(c=Math.max(c,A.score)),!u.exactTtOnly&&A.flag===ke.UPPER&&(l=Math.min(l,A.score)),c>=l)return{score:A.score,move:A.move,pv:A.pv,flag:A.flag}}const y=[...r.getValuableMoves(s,a,i||a>bf,t)];if(!y.length)return{score:r.evaluate(s),move:null,pv:[],flag:ke.EXACT};const S=(_,w)=>{if(nl(_,A==null?void 0:A.move))return-1;if(nl(w,A==null?void 0:A.move))return 1;const B=ns(r,s,_),F=ns(r,s,w);if(B!==F)return F-B;const k=Uf(u,r,a,_,w);return k||(u.experimentalMoveOrdering?il(u,a,w,r.size)-il(u,a,_,r.size):0)};y.sort(S);let L=-Ji,P=null,C=[],R=0;for(const _ of y){if(!r.put(_[0],_[1],s))continue;let w;try{if(u.experimentalPvs&&a===0&&R>0){const F=n(r,-s,o,a+1,-c-1,-c,u,!0),k=-F.score;w=k>c&&k<l?n(r,-s,o,a+1,-l,-c,u,!1):F}else w=n(r,-s,o,a+1,-l,-c,u,h)}finally{r.undo()}R++;const B=-w.score;if(B>L&&(L=B,P=_,C=[_,...w.pv]),c=Math.max(c,L),c>=l||c>=Oe){If(u,a,m,_,r.size);break}}if(!P)return{score:r.evaluate(s),move:null,pv:[],flag:ke.EXACT};const E=Eu(L,g,v);return!u.disableTt&&!h&&f.put(d,{depth:m,score:L,move:P,pv:C,role:s,mode:p,flag:E}),{score:L,move:P,pv:C,flag:E}};return(r,s,o=4,a={})=>{let c=null,l=0;const u=!a.timeLimitMs&&!a.deadline,h=!i&&!t&&a.experimentalPvs!==!1&&a.disablePvs!==!0&&(u||a.experimentalPvs===!0),f=a.experimentalMoveOrderingMode??(a.experimentalMoveOrdering===!0?"combined":a.disableMoveOrdering===!0?null:"killer"),d=!i&&!t&&a.disableOpeningBook!==!0?Su(r):[],g=d.length?new Uint16Array(r.size*r.size):null;d.forEach(({move:p},A)=>{g[rr(r.size,p)]=d.length-A});const v={deadline:a.deadline??(a.timeLimitMs?performance.now()+a.timeLimitMs:0),experimentalPvs:h,disableTtCutoffs:a.disableTtCutoffs===!0,exactTtOnly:a.exactTtOnly===!0||h,disableTt:a.disableTt===!0,disableQuiescence:a.disableQuiescence===!0,experimentalMoveOrdering:!!f,useKillers:f==="killer"||f==="combined",useHistory:f==="history"||f==="combined",killers:f?[]:null,history:f?new Uint16Array(r.size*r.size):null,openingBookRanks:g},m=o<2?o:2;for(let p=m;p<=o;p+=2){let A;try{A=n(r,s,p,0,-Ji,Ji,v)}catch(y){if(y===Ho)break;throw y}if((A.move||r.isGameOver())&&(c=A,l=p),A.score>=Oe)break}if(!c){const p=r.getValuableMoves(s,0,i,t)[0]??null;return[r.evaluate(s),p,p?[p]:[],0]}return[Df(c.score),c.move,c.pv,l]}},rl=Tu(),Gi=Tu(!0),Nf=(i,t,e=4,n=!0,r={})=>{if(r.disableOpeningBook!==!0&&!is(i,ts)){const y=Af(i);if(y)return[i.evaluate(t),y,[y],0]}if(!n||!is(i,ts))return rl(i,t,e,r);const s=performance.now(),o=Number(r.timeLimitMs)||0,a=y=>o?{...r,timeLimitMs:0,deadline:s+o*y}:r,c=e+8;let[l,u,h,f]=Gi(i,t,c,a(.35));if(l>=Oe)return[l,u,h,f];const[d,g]=Gi(i,-t,c,a(.6));if(d>=Oe&&g&&i.board[g[0]][g[1]]===0){i.put(g[0],g[1],t);let y;try{y=Gi(i,-t,c,a(.75))}finally{i.undo()}if(y[0]<Oe)return[i.evaluate(t),g,[g,...y[2]],f]}if([l,u,h,f]=rl(i,t,e,a(.9)),!u)return[l,u,h,f];if(!i.put(u[0],u[1],t))return[l,u,h,f];let v;try{v=Gi(i,-t,c,a(1))}finally{i.undo()}const[m,p,A]=v;if(l<Oe&&m===Oe&&A.length>h.length){const[,,y]=Gi(i,-t,c,a(1));if(A.length<=y.length&&p)return[l,p,A,f]}return[l,u,h,f]},Ff={easy:2,normal:4,hard:6},Of={hard:3e3};function Bf(i){const t=i.length>0?Ro(i[0].stone):1,e=new df(Le,t);return Fh(i,({row:n,column:r,stone:s})=>{e.put(n,r,Ro(s))}),e}function zf(i,t,e){const n=Bf(i),r=Ro(t);if(n.role!==r)return null;Pf(n);const s=Ff[e],o=e!=="easy",a=Of[e],[,c]=Nf(n,r,s,o,{timeLimitMs:a});return c?{row:c[0],column:c[1]}:null}function Hf(i="pvp",t="normal"){return{board:hc(),history:[],mode:i,difficulty:t,phase:"menu",turn:Ze,cursor:{row:7,column:7},sound:!0}}function kf(i,t,e){document.querySelectorAll("[data-mode]").forEach(h=>{h.addEventListener("click",()=>{e.setMode(h.dataset.mode)})}),document.querySelectorAll("[data-difficulty]").forEach(h=>{h.addEventListener("click",()=>{e.setDifficulty(h.dataset.difficulty)})}),t.startButton.addEventListener("click",e.startMatch),t.againButton.addEventListener("click",e.startMatch),t.menuButton.addEventListener("click",e.openMenu),t.resultMenuButton.addEventListener("click",e.openMenu),t.soundButton.addEventListener("click",e.toggleSound),document.querySelectorAll("[data-direction]").forEach(h=>{h.addEventListener("click",()=>{const f=h.dataset.direction;f==="up"&&e.moveCursor(-1,0),f==="down"&&e.moveCursor(1,0),f==="left"&&e.moveCursor(0,-1),f==="right"&&e.moveCursor(0,1)})}),document.querySelector('[data-action="place"]').addEventListener("click",()=>{const h=e.getCursor();e.placeStone(h.row,h.column)}),window.addEventListener("keydown",h=>{if(h.key==="Escape"){e.getPhase()!=="menu"&&e.openMenu();return}if(h.key.toLowerCase()==="r"&&e.getPhase()!=="menu"){e.startMatch();return}if(e.getPhase()!=="play"&&e.getPhase()!=="thinking")return;const d={ArrowUp:[-1,0],w:[-1,0],ArrowDown:[1,0],s:[1,0],ArrowLeft:[0,-1],a:[0,-1],ArrowRight:[0,1],d:[0,1]}[h.key];if(d)h.preventDefault(),e.moveCursor(d[0],d[1]);else if(h.key===" "||h.key==="Enter"){h.preventDefault();const g=e.getCursor();e.placeStone(g.row,g.column)}});let n=null,r=0,s=0,o=null;const a=h=>{if(h.pointerId===n){n=null,o=null,i.renderer.domElement.style.cursor="grab";try{i.renderer.domElement.releasePointerCapture(h.pointerId)}catch{}}};i.renderer.domElement.addEventListener("pointerdown",h=>{e.unlockAudio();const f=i.pickCell(h.clientX,h.clientY);if(h.button===0&&f&&e.getPhase()==="play"){e.setCursor(f.row,f.column),e.placeStone(f.row,f.column);return}(h.button===0||h.button===2)&&(n=h.pointerId,r=h.clientX,s=h.clientY,o=h.button===2?"pan":"rotate",i.renderer.domElement.style.cursor="grabbing",i.renderer.domElement.setPointerCapture(h.pointerId),h.preventDefault())}),i.renderer.domElement.addEventListener("pointermove",h=>{if(h.pointerId===n){const d=h.clientX-r,g=h.clientY-s;o==="pan"?i.pan(d,g):i.orbit(d,g),r=h.clientX,s=h.clientY,h.preventDefault();return}if(e.getPhase()!=="play")return;const f=i.pickCell(h.clientX,h.clientY);f&&e.setCursor(f.row,f.column)}),i.renderer.domElement.addEventListener("pointerup",a),i.renderer.domElement.addEventListener("pointercancel",a),i.renderer.domElement.addEventListener("contextmenu",h=>h.preventDefault());let c=0,l=!1;return{pollGamepad:()=>{var A,y;const h=(A=navigator.getGamepads)==null?void 0:A.call(navigator)[0];if(!h||e.getPhase()==="menu"||e.getPhase()==="over")return;const f=.55,d=h.axes[0]??0,g=h.axes[1]??0,v=Math.abs(d)>Math.abs(g)?d>f?[0,1]:d<-f?[0,-1]:null:g>f?[1,0]:g<-f?[-1,0]:null,m=performance.now();v&&m-c>180&&(e.moveCursor(v[0],v[1]),c=m);const p=!!((y=h.buttons[0])!=null&&y.pressed);if(p&&!l){const S=e.getCursor();e.placeStone(S.row,S.column)}l=p}}}/**
|
|
2
40
|
* @license
|
|
3
41
|
* Copyright 2010-2024 Three.js Authors
|
|
4
42
|
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/const Ia="172",$u=0,xc=1,Qu=2,Dl=1,Ul=2,an=3,bn=0,Ce=1,Ze=2,En=0,Mi=1,Mc=2,Sc=3,yc=4,th=5,On=100,eh=101,nh=102,ih=103,rh=104,sh=200,oh=201,ah=202,ch=203,Gs=204,Vs=205,lh=206,uh=207,hh=208,fh=209,dh=210,ph=211,mh=212,gh=213,_h=214,Ws=0,Xs=1,qs=2,Ti=3,Ys=4,Zs=5,Js=6,Ks=7,Il=0,vh=1,xh=2,Tn=0,Mh=1,Sh=2,yh=3,Nl=4,Eh=5,Th=6,Ah=7,Fl=300,Ai=301,bi=302,js=303,$s=304,Jr=306,wi=1e3,kn=1001,Qs=1002,Xe=1003,bh=1004,hr=1005,Je=1006,ss=1007,Gn=1008,fn=1009,Ol=1010,Bl=1011,Ki=1012,Na=1013,qn=1014,ln=1015,ir=1016,Fa=1017,Oa=1018,Ri=1020,zl=35902,Hl=1021,kl=1022,We=1023,Gl=1024,Vl=1025,Si=1026,Ci=1027,Wl=1028,Ba=1029,Xl=1030,za=1031,Ha=1033,Nr=33776,Fr=33777,Or=33778,Br=33779,to=35840,eo=35841,no=35842,io=35843,ro=36196,so=37492,oo=37496,ao=37808,co=37809,lo=37810,uo=37811,ho=37812,fo=37813,po=37814,mo=37815,go=37816,_o=37817,vo=37818,xo=37819,Mo=37820,So=37821,zr=36492,yo=36494,Eo=36495,ql=36283,To=36284,Ao=36285,bo=36286,wh=3200,Rh=3201,Yl=0,Ch=1,Mn="",we="srgb",Pi="srgb-linear",Vr="linear",te="srgb",ti=7680,Ec=519,Ph=512,Lh=513,Dh=514,Zl=515,Uh=516,Ih=517,Nh=518,Fh=519,Tc=35044,Ac="300 es",un=2e3,Wr=2001;class Di{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const r=this._listeners[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,t);t.target=null}}}const Me=["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 bc=1234567;const Wi=Math.PI/180,ji=180/Math.PI;function Kn(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Me[i&255]+Me[i>>8&255]+Me[i>>16&255]+Me[i>>24&255]+"-"+Me[t&255]+Me[t>>8&255]+"-"+Me[t>>16&15|64]+Me[t>>24&255]+"-"+Me[e&63|128]+Me[e>>8&255]+"-"+Me[e>>16&255]+Me[e>>24&255]+Me[n&255]+Me[n>>8&255]+Me[n>>16&255]+Me[n>>24&255]).toLowerCase()}function Gt(i,t,e){return Math.max(t,Math.min(e,i))}function ka(i,t){return(i%t+t)%t}function Oh(i,t,e,n,r){return n+(i-t)*(r-n)/(e-t)}function Bh(i,t,e){return i!==t?(e-i)/(t-i):0}function Xi(i,t,e){return(1-e)*i+e*t}function zh(i,t,e,n){return Xi(i,t,1-Math.exp(-e*n))}function Hh(i,t=1){return t-Math.abs(ka(i,t*2)-t)}function kh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Gh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Vh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Wh(i,t){return i+Math.random()*(t-i)}function Xh(i){return i*(.5-Math.random())}function qh(i){i!==void 0&&(bc=i);let t=bc+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Yh(i){return i*Wi}function Zh(i){return i*ji}function Jh(i){return(i&i-1)===0&&i!==0}function Kh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function jh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function $h(i,t,e,n,r){const s=Math.cos,o=Math.sin,a=s(e/2),c=o(e/2),l=s((t+n)/2),u=o((t+n)/2),h=s((t-n)/2),f=o((t-n)/2),d=s((n-t)/2),g=o((n-t)/2);switch(r){case"XYX":i.set(a*u,c*h,c*f,a*l);break;case"YZY":i.set(c*f,a*u,c*h,a*l);break;case"ZXZ":i.set(c*h,c*f,a*u,a*l);break;case"XZX":i.set(a*u,c*g,c*d,a*l);break;case"YXY":i.set(c*d,a*u,c*g,a*l);break;case"ZYZ":i.set(c*g,c*d,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function pi(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Te(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Qh={DEG2RAD:Wi,RAD2DEG:ji,generateUUID:Kn,clamp:Gt,euclideanModulo:ka,mapLinear:Oh,inverseLerp:Bh,lerp:Xi,damp:zh,pingpong:Hh,smoothstep:kh,smootherstep:Gh,randInt:Vh,randFloat:Wh,randFloatSpread:Xh,seededRandom:qh,degToRad:Yh,radToDeg:Zh,isPowerOfTwo:Jh,ceilPowerOfTwo:Kh,floorPowerOfTwo:jh,setQuaternionFromProperEuler:$h,normalize:Te,denormalize:pi};class at{constructor(t=0,e=0){at.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,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(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(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Gt(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),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*r+t.x,this.y=s*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zt{constructor(t,e,n,r,s,o,a,c,l){zt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,c,l)}set(t,e,n,r,s,o,a,c,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[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,r=e.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],g=n[8],v=r[0],m=r[3],p=r[6],b=r[1],T=r[4],S=r[7],L=r[2],C=r[5],R=r[8];return s[0]=o*v+a*b+c*L,s[3]=o*m+a*T+c*C,s[6]=o*p+a*S+c*R,s[1]=l*v+u*b+h*L,s[4]=l*m+u*T+h*C,s[7]=l*p+u*S+h*R,s[2]=f*v+d*b+g*L,s[5]=f*m+d*T+g*C,s[8]=f*p+d*S+g*R,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],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*s*u+n*a*c+r*s*l-r*o*c}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=u*o-a*l,f=a*c-u*s,d=l*s-o*c,g=e*h+n*f+r*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return t[0]=h*v,t[1]=(r*l-u*n)*v,t[2]=(a*n-r*o)*v,t[3]=f*v,t[4]=(u*e-r*c)*v,t[5]=(r*s-a*e)*v,t[6]=d*v,t[7]=(n*c-l*e)*v,t[8]=(o*e-n*s)*v,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,r,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(os.makeScale(t,e)),this}rotate(t){return this.premultiply(os.makeRotation(-t)),this}translate(t,e){return this.premultiply(os.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 r=0;r<9;r++)if(e[r]!==n[r])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 os=new zt;function Jl(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function $i(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function tf(){const i=$i("canvas");return i.style.display="block",i}const wc={};function mi(i){i in wc||(wc[i]=!0,console.warn(i))}function ef(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}function nf(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function rf(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const Rc=new zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Cc=new zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function sf(){const i={enabled:!0,workingColorSpace:Pi,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===te&&(r.r=hn(r.r),r.g=hn(r.g),r.b=hn(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===te&&(r.r=yi(r.r),r.g=yi(r.g),r.b=yi(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Mn?Vr:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Pi]:{primaries:t,whitePoint:n,transfer:Vr,toXYZ:Rc,fromXYZ:Cc,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:we},outputColorSpaceConfig:{drawingBufferColorSpace:we}},[we]:{primaries:t,whitePoint:n,transfer:te,toXYZ:Rc,fromXYZ:Cc,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:we}}}),i}const Kt=sf();function hn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function yi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ei;class of{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ei===void 0&&(ei=$i("canvas")),ei.width=t.width,ei.height=t.height;const n=ei.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=ei}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=$i("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=hn(s[o]/255)*255;return n.putImageData(r,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(hn(e[n]/255)*255):e[n]=hn(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let af=0;class Kl{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:af++}),this.uuid=Kn(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(as(r[o].image)):s.push(as(r[o]))}else s=as(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function as(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?of.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let cf=0;class ye extends Di{constructor(t=ye.DEFAULT_IMAGE,e=ye.DEFAULT_MAPPING,n=kn,r=kn,s=Je,o=Gn,a=We,c=fn,l=ye.DEFAULT_ANISOTROPY,u=Mn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:cf++}),this.uuid=Kn(),this.name="",this.source=new Kl(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new at(0,0),this.repeat=new at(1,1),this.center=new at(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new zt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Fl)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case wi:t.x=t.x-Math.floor(t.x);break;case kn:t.x=t.x<0?0:1;break;case Qs:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case wi:t.y=t.y-Math.floor(t.y);break;case kn:t.y=t.y<0?0:1;break;case Qs:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ye.DEFAULT_IMAGE=null;ye.DEFAULT_MAPPING=Fl;ye.DEFAULT_ANISOTROPY=1;class ee{constructor(t=0,e=0,n=0,r=1){ee.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}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,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*s,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,r,s;const c=t.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],g=c[9],v=c[2],m=c[6],p=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(g+m)<.1&&Math.abs(l+d+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const T=(l+1)/2,S=(d+1)/2,L=(p+1)/2,C=(u+f)/4,R=(h+v)/4,D=(g+m)/4;return T>S&&T>L?T<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(T),r=C/n,s=R/n):S>L?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=C/r,s=D/r):L<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),n=R/s,r=D/s),this.set(n,r,s,e),this}let b=Math.sqrt((m-g)*(m-g)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(h-v)/b,this.z=(f-u)/b,this.w=Math.acos((l+d+p-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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this.w=Gt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this.w=Gt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(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 lf extends Di{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ee(0,0,t,e),this.scissorTest=!1,this.viewport=new ee(0,0,t,e);const r={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Je,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ye(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;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}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(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 r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n;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 n=0,r=t.textures.length;n<r;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const e=Object.assign({},t.texture.image);return this.texture.source=new Kl(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Yn extends lf{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class jl extends ye{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class uf extends ye{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class rr{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,o,a){let c=n[r+0],l=n[r+1],u=n[r+2],h=n[r+3];const f=s[o+0],d=s[o+1],g=s[o+2],v=s[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=f,t[e+1]=d,t[e+2]=g,t[e+3]=v;return}if(h!==v||c!==f||l!==d||u!==g){let m=1-a;const p=c*f+l*d+u*g+h*v,b=p>=0?1:-1,T=1-p*p;if(T>Number.EPSILON){const L=Math.sqrt(T),C=Math.atan2(L,p*b);m=Math.sin(m*C)/L,a=Math.sin(a*C)/L}const S=a*b;if(c=c*m+f*S,l=l*m+d*S,u=u*m+g*S,h=h*m+v*S,m===1-a){const L=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=L,l*=L,u*=L,h*=L}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,r,s,o){const a=n[r],c=n[r+1],l=n[r+2],u=n[r+3],h=s[o],f=s[o+1],d=s[o+2],g=s[o+3];return t[e]=a*g+u*h+c*d-l*f,t[e+1]=c*g+u*f+l*h-a*d,t[e+2]=l*g+u*d+a*f-c*h,t[e+3]=u*g-a*h-c*f-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,r){return this._x=t,this._y=e,this._z=n,this._w=r,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,r=t._y,s=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(r/2),h=a(s/2),f=c(n/2),d=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=f*u*h+l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h-f*d*g;break;case"YXZ":this._x=f*u*h+l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h+f*d*g;break;case"ZXY":this._x=f*u*h-l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h-f*d*g;break;case"ZYX":this._x=f*u*h-l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h+f*d*g;break;case"YZX":this._x=f*u*h+l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h-f*d*g;break;case"XZY":this._x=f*u*h-l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h+f*d*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],f=n+a+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(o-r)*d}else if(n>a&&n>h){const d=2*Math.sqrt(1+n-a-h);this._w=(u-c)/d,this._x=.25*d,this._y=(r+o)/d,this._z=(s+l)/d}else if(a>h){const d=2*Math.sqrt(1+a-n-h);this._w=(s-l)/d,this._x=(r+o)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-a);this._w=(o-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(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(Gt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,s=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-r*a,this._w=o*u-n*a-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,r=this._y,s=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const d=1-e;return this._w=d*o+e*this._w,this._x=d*n+e*this._x,this._y=d*r+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=r*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*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 P{constructor(t=0,e=0,n=0){P.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(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(Pc.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Pc.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*r-a*n),u=2*(a*e-s*r),h=2*(s*n-o*e);return this.x=e+c*l+o*h-a*u,this.y=n+c*u+a*l-s*h,this.z=r+c*h+s*u-o*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,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(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,r=t.y,s=t.z,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-n*c,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return cs.copy(this).projectOnVector(t),this.sub(cs)}reflect(t){return this.sub(cs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Gt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}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 r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*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(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,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 cs=new P,Pc=new rr;class sr{constructor(t=new P(1/0,1/0,1/0),e=new P(-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(He.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(He.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=He.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(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,He):He.fromBufferAttribute(s,o),He.applyMatrix4(t.matrixWorld),this.expandByPoint(He);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),fr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),fr.copy(n.boundingBox)),fr.applyMatrix4(t.matrixWorld),this.union(fr)}const r=t.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,He),He.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(Bi),dr.subVectors(this.max,Bi),ni.subVectors(t.a,Bi),ii.subVectors(t.b,Bi),ri.subVectors(t.c,Bi),dn.subVectors(ii,ni),pn.subVectors(ri,ii),Pn.subVectors(ni,ri);let e=[0,-dn.z,dn.y,0,-pn.z,pn.y,0,-Pn.z,Pn.y,dn.z,0,-dn.x,pn.z,0,-pn.x,Pn.z,0,-Pn.x,-dn.y,dn.x,0,-pn.y,pn.x,0,-Pn.y,Pn.x,0];return!ls(e,ni,ii,ri,dr)||(e=[1,0,0,0,1,0,0,0,1],!ls(e,ni,ii,ri,dr))?!1:(pr.crossVectors(dn,pn),e=[pr.x,pr.y,pr.z],ls(e,ni,ii,ri,dr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,He).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(He).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(en[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),en[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),en[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),en[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),en[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),en[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),en[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),en[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(en),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const en=[new P,new P,new P,new P,new P,new P,new P,new P],He=new P,fr=new sr,ni=new P,ii=new P,ri=new P,dn=new P,pn=new P,Pn=new P,Bi=new P,dr=new P,pr=new P,Ln=new P;function ls(i,t,e,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){Ln.fromArray(i,s);const a=r.x*Math.abs(Ln.x)+r.y*Math.abs(Ln.y)+r.z*Math.abs(Ln.z),c=t.dot(Ln),l=e.dot(Ln),u=n.dot(Ln);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const hf=new sr,zi=new P,us=new P;class Ga{constructor(t=new P,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;e!==void 0?n.copy(e):hf.setFromPoints(t).getCenter(n);let r=0;for(let s=0,o=t.length;s<o;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),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;zi.subVectors(t,this.center);const e=zi.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(zi,r/n),this.radius+=r}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(us.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(zi.copy(t.center).add(us)),this.expandByPoint(zi.copy(t.center).sub(us))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const nn=new P,hs=new P,mr=new P,mn=new P,fs=new P,gr=new P,ds=new P;class $l{constructor(t=new P,e=new P(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,nn)),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=nn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(nn.copy(this.origin).addScaledVector(this.direction,e),nn.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){hs.copy(t).add(e).multiplyScalar(.5),mr.copy(e).sub(t).normalize(),mn.copy(this.origin).sub(hs);const s=t.distanceTo(e)*.5,o=-this.direction.dot(mr),a=mn.dot(this.direction),c=-mn.dot(mr),l=mn.lengthSq(),u=Math.abs(1-o*o);let h,f,d,g;if(u>0)if(h=o*c-a,f=o*a-c,g=s*u,h>=0)if(f>=-g)if(f<=g){const v=1/u;h*=v,f*=v,d=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f<=-g?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=g?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(hs).addScaledVector(mr,f),d}intersectSphere(t,e){nn.subVectors(t.center,this.origin);const n=nn.dot(this.direction),r=nn.dot(nn)-n*n,s=t.radius*t.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,s,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,r=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,r=(t.min.x-f.x)*l),u>=0?(s=(t.min.y-f.y)*u,o=(t.max.y-f.y)*u):(s=(t.max.y-f.y)*u,o=(t.min.y-f.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(t.min.z-f.z)*h,c=(t.max.z-f.z)*h):(a=(t.max.z-f.z)*h,c=(t.min.z-f.z)*h),n>c||a>r)||((a>n||n!==n)&&(n=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,nn)!==null}intersectTriangle(t,e,n,r,s){fs.subVectors(e,t),gr.subVectors(n,t),ds.crossVectors(fs,gr);let o=this.direction.dot(ds),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;mn.subVectors(this.origin,t);const c=a*this.direction.dot(gr.crossVectors(mn,gr));if(c<0)return null;const l=a*this.direction.dot(fs.cross(mn));if(l<0||c+l>o)return null;const u=-a*mn.dot(ds);return u<0?null:this.at(u/o,s)}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 re{constructor(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m){re.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m)}set(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=r,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=f,p[3]=d,p[7]=g,p[11]=v,p[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 re().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 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){const e=this.elements,n=t.elements,r=1/si.setFromMatrixColumn(t,0).length(),s=1/si.setFromMatrixColumn(t,1).length(),o=1/si.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,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,r=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){const f=o*u,d=o*h,g=a*u,v=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=d+g*l,e[5]=f-v*l,e[9]=-a*c,e[2]=v-f*l,e[6]=g+d*l,e[10]=o*c}else if(t.order==="YXZ"){const f=c*u,d=c*h,g=l*u,v=l*h;e[0]=f+v*a,e[4]=g*a-d,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=d*a-g,e[6]=v+f*a,e[10]=o*c}else if(t.order==="ZXY"){const f=c*u,d=c*h,g=l*u,v=l*h;e[0]=f-v*a,e[4]=-o*h,e[8]=g+d*a,e[1]=d+g*a,e[5]=o*u,e[9]=v-f*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const f=o*u,d=o*h,g=a*u,v=a*h;e[0]=c*u,e[4]=g*l-d,e[8]=f*l+v,e[1]=c*h,e[5]=v*l+f,e[9]=d*l-g,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const f=o*c,d=o*l,g=a*c,v=a*l;e[0]=c*u,e[4]=v-f*h,e[8]=g*h+d,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=d*h+g,e[10]=f-v*h}else if(t.order==="XZY"){const f=o*c,d=o*l,g=a*c,v=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=f*h+v,e[5]=o*u,e[9]=d*h-g,e[2]=g*h-d,e[6]=a*u,e[10]=v*h+f}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(ff,t,df)}lookAt(t,e,n){const r=this.elements;return De.subVectors(t,e),De.lengthSq()===0&&(De.z=1),De.normalize(),gn.crossVectors(n,De),gn.lengthSq()===0&&(Math.abs(n.z)===1?De.x+=1e-4:De.z+=1e-4,De.normalize(),gn.crossVectors(n,De)),gn.normalize(),_r.crossVectors(De,gn),r[0]=gn.x,r[4]=_r.x,r[8]=De.x,r[1]=gn.y,r[5]=_r.y,r[9]=De.y,r[2]=gn.z,r[6]=_r.z,r[10]=De.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],g=n[2],v=n[6],m=n[10],p=n[14],b=n[3],T=n[7],S=n[11],L=n[15],C=r[0],R=r[4],D=r[8],y=r[12],M=r[1],w=r[5],H=r[9],O=r[13],V=r[2],X=r[6],G=r[10],K=r[14],k=r[3],ct=r[7],pt=r[11],Mt=r[15];return s[0]=o*C+a*M+c*V+l*k,s[4]=o*R+a*w+c*X+l*ct,s[8]=o*D+a*H+c*G+l*pt,s[12]=o*y+a*O+c*K+l*Mt,s[1]=u*C+h*M+f*V+d*k,s[5]=u*R+h*w+f*X+d*ct,s[9]=u*D+h*H+f*G+d*pt,s[13]=u*y+h*O+f*K+d*Mt,s[2]=g*C+v*M+m*V+p*k,s[6]=g*R+v*w+m*X+p*ct,s[10]=g*D+v*H+m*G+p*pt,s[14]=g*y+v*O+m*K+p*Mt,s[3]=b*C+T*M+S*V+L*k,s[7]=b*R+T*w+S*X+L*ct,s[11]=b*D+T*H+S*G+L*pt,s[15]=b*y+T*O+S*K+L*Mt,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],r=t[8],s=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],f=t[10],d=t[14],g=t[3],v=t[7],m=t[11],p=t[15];return g*(+s*c*h-r*l*h-s*a*f+n*l*f+r*a*d-n*c*d)+v*(+e*c*d-e*l*f+s*o*f-r*o*d+r*l*u-s*c*u)+m*(+e*l*h-e*a*d-s*o*h+n*o*d+s*a*u-n*l*u)+p*(-r*a*u-e*c*h+e*a*f+r*o*h-n*o*f+n*c*u)}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 r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],d=t[11],g=t[12],v=t[13],m=t[14],p=t[15],b=h*m*l-v*f*l+v*c*d-a*m*d-h*c*p+a*f*p,T=g*f*l-u*m*l-g*c*d+o*m*d+u*c*p-o*f*p,S=u*v*l-g*h*l+g*a*d-o*v*d-u*a*p+o*h*p,L=g*h*c-u*v*c-g*a*f+o*v*f+u*a*m-o*h*m,C=e*b+n*T+r*S+s*L;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/C;return t[0]=b*R,t[1]=(v*f*s-h*m*s-v*r*d+n*m*d+h*r*p-n*f*p)*R,t[2]=(a*m*s-v*c*s+v*r*l-n*m*l-a*r*p+n*c*p)*R,t[3]=(h*c*s-a*f*s-h*r*l+n*f*l+a*r*d-n*c*d)*R,t[4]=T*R,t[5]=(u*m*s-g*f*s+g*r*d-e*m*d-u*r*p+e*f*p)*R,t[6]=(g*c*s-o*m*s-g*r*l+e*m*l+o*r*p-e*c*p)*R,t[7]=(o*f*s-u*c*s+u*r*l-e*f*l-o*r*d+e*c*d)*R,t[8]=S*R,t[9]=(g*h*s-u*v*s-g*n*d+e*v*d+u*n*p-e*h*p)*R,t[10]=(o*v*s-g*a*s+g*n*l-e*v*l-o*n*p+e*a*p)*R,t[11]=(u*a*s-o*h*s-u*n*l+e*h*l+o*n*d-e*a*d)*R,t[12]=L*R,t[13]=(u*v*r-g*h*r+g*n*f-e*v*f-u*n*m+e*h*m)*R,t[14]=(g*a*r-o*v*r-g*n*c+e*v*c+o*n*m-e*a*m)*R,t[15]=(o*h*r-u*a*r+u*n*c-e*h*c-o*n*f+e*a*f)*R,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,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],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}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),r=Math.sin(e),s=1-n,o=t.x,a=t.y,c=t.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+n,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+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,r,s,o){return this.set(1,n,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,o=e._y,a=e._z,c=e._w,l=s+s,u=o+o,h=a+a,f=s*l,d=s*u,g=s*h,v=o*u,m=o*h,p=a*h,b=c*l,T=c*u,S=c*h,L=n.x,C=n.y,R=n.z;return r[0]=(1-(v+p))*L,r[1]=(d+S)*L,r[2]=(g-T)*L,r[3]=0,r[4]=(d-S)*C,r[5]=(1-(f+p))*C,r[6]=(m+b)*C,r[7]=0,r[8]=(g+T)*R,r[9]=(m-b)*R,r[10]=(1-(f+v))*R,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let s=si.set(r[0],r[1],r[2]).length();const o=si.set(r[4],r[5],r[6]).length(),a=si.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],ke.copy(this);const l=1/s,u=1/o,h=1/a;return ke.elements[0]*=l,ke.elements[1]*=l,ke.elements[2]*=l,ke.elements[4]*=u,ke.elements[5]*=u,ke.elements[6]*=u,ke.elements[8]*=h,ke.elements[9]*=h,ke.elements[10]*=h,e.setFromRotationMatrix(ke),n.x=s,n.y=o,n.z=a,this}makePerspective(t,e,n,r,s,o,a=un){const c=this.elements,l=2*s/(e-t),u=2*s/(n-r),h=(e+t)/(e-t),f=(n+r)/(n-r);let d,g;if(a===un)d=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===Wr)d=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,s,o,a=un){const c=this.elements,l=1/(e-t),u=1/(n-r),h=1/(o-s),f=(e+t)*l,d=(n+r)*u;let g,v;if(a===un)g=(o+s)*h,v=-2*h;else if(a===Wr)g=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=v,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])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 si=new P,ke=new re,ff=new P(0,0,0),df=new P(1,1,1),gn=new P,_r=new P,De=new P,Lc=new re,Dc=new rr;class $e{constructor(t=0,e=0,n=0,r=$e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}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,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,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 r=t.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],h=r[2],f=r[6],d=r[10];switch(e){case"XYZ":this._y=Math.asin(Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Lc.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Lc,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Dc.setFromEuler(this),this.setFromQuaternion(Dc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}$e.DEFAULT_ORDER="XYZ";class Va{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let pf=0;const Uc=new P,oi=new rr,rn=new re,vr=new P,Hi=new P,mf=new P,gf=new rr,Ic=new P(1,0,0),Nc=new P(0,1,0),Fc=new P(0,0,1),Oc={type:"added"},_f={type:"removed"},ai={type:"childadded",child:null},ps={type:"childremoved",child:null};class ve extends Di{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:pf++}),this.uuid=Kn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ve.DEFAULT_UP.clone();const t=new P,e=new $e,n=new rr,r=new P(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new re},normalMatrix:{value:new zt}}),this.matrix=new re,this.matrixWorld=new re,this.matrixAutoUpdate=ve.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Va,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return oi.setFromAxisAngle(t,e),this.quaternion.multiply(oi),this}rotateOnWorldAxis(t,e){return oi.setFromAxisAngle(t,e),this.quaternion.premultiply(oi),this}rotateX(t){return this.rotateOnAxis(Ic,t)}rotateY(t){return this.rotateOnAxis(Nc,t)}rotateZ(t){return this.rotateOnAxis(Fc,t)}translateOnAxis(t,e){return Uc.copy(t).applyQuaternion(this.quaternion),this.position.add(Uc.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ic,t)}translateY(t){return this.translateOnAxis(Nc,t)}translateZ(t){return this.translateOnAxis(Fc,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(rn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?vr.copy(t):vr.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Hi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rn.lookAt(Hi,vr,this.up):rn.lookAt(vr,Hi,this.up),this.quaternion.setFromRotationMatrix(rn),r&&(rn.extractRotation(r.matrixWorld),oi.setFromRotationMatrix(rn),this.quaternion.premultiply(oi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Oc),ai.child=t,this.dispatchEvent(ai),ai.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(_f),ps.child=t,this.dispatchEvent(ps),ps.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),rn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),rn.multiply(t.parent.matrixWorld)),t.applyMatrix4(rn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Oc),ai.child=t,this.dispatchEvent(ai),ai.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,r=this.children.length;n<r;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].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(Hi,t,mf),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hi,gf,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,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];s(t.shapes,h)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(t.materials,this.material[c]));r.material=a}else r.material=s(t.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];r.animations.push(s(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),l=o(t.textures),u=o(t.images),h=o(t.shapes),f=o(t.skeletons),d=o(t.animations),g=o(t.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),g.length>0&&(n.nodes=g)}return n.object=r,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const r=t.children[n];this.add(r.clone())}return this}}ve.DEFAULT_UP=new P(0,1,0);ve.DEFAULT_MATRIX_AUTO_UPDATE=!0;ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ge=new P,sn=new P,ms=new P,on=new P,ci=new P,li=new P,Bc=new P,gs=new P,_s=new P,vs=new P,xs=new ee,Ms=new ee,Ss=new ee;class Ve{constructor(t=new P,e=new P,n=new P){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Ge.subVectors(t,e),r.cross(Ge);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){Ge.subVectors(r,e),sn.subVectors(n,e),ms.subVectors(t,e);const o=Ge.dot(Ge),a=Ge.dot(sn),c=Ge.dot(ms),l=sn.dot(sn),u=sn.dot(ms),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;const f=1/h,d=(l*c-a*u)*f,g=(o*u-a*c)*f;return s.set(1-d-g,g,d)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,on)===null?!1:on.x>=0&&on.y>=0&&on.x+on.y<=1}static getInterpolation(t,e,n,r,s,o,a,c){return this.getBarycoord(t,e,n,r,on)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,on.x),c.addScaledVector(o,on.y),c.addScaledVector(a,on.z),c)}static getInterpolatedAttribute(t,e,n,r,s,o){return xs.setScalar(0),Ms.setScalar(0),Ss.setScalar(0),xs.fromBufferAttribute(t,e),Ms.fromBufferAttribute(t,n),Ss.fromBufferAttribute(t,r),o.setScalar(0),o.addScaledVector(xs,s.x),o.addScaledVector(Ms,s.y),o.addScaledVector(Ss,s.z),o}static isFrontFacing(t,e,n,r){return Ge.subVectors(n,e),sn.subVectors(t,e),Ge.cross(sn).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),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 Ge.subVectors(this.c,this.b),sn.subVectors(this.a,this.b),Ge.cross(sn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ve.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ve.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,r,s){return Ve.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}containsPoint(t){return Ve.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ve.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,s=this.c;let o,a;ci.subVectors(r,n),li.subVectors(s,n),gs.subVectors(t,n);const c=ci.dot(gs),l=li.dot(gs);if(c<=0&&l<=0)return e.copy(n);_s.subVectors(t,r);const u=ci.dot(_s),h=li.dot(_s);if(u>=0&&h<=u)return e.copy(r);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),e.copy(n).addScaledVector(ci,o);vs.subVectors(t,s);const d=ci.dot(vs),g=li.dot(vs);if(g>=0&&d<=g)return e.copy(s);const v=d*l-c*g;if(v<=0&&l>=0&&g<=0)return a=l/(l-g),e.copy(n).addScaledVector(li,a);const m=u*g-d*h;if(m<=0&&h-u>=0&&d-g>=0)return Bc.subVectors(s,r),a=(h-u)/(h-u+(d-g)),e.copy(r).addScaledVector(Bc,a);const p=1/(m+v+f);return o=v*p,a=f*p,e.copy(n).addScaledVector(ci,o).addScaledVector(li,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Ql={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},_n={h:0,s:0,l:0},xr={h:0,s:0,l:0};function ys(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Wt{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(e===void 0&&n===void 0){const r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=we){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,r=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.toWorkingColorSpace(this,r),this}setHSL(t,e,n,r=Kt.workingColorSpace){if(t=ka(t,1),e=Gt(e,0,1),n=Gt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=ys(o,s,t+1/3),this.g=ys(o,s,t),this.b=ys(o,s,t-1/3)}return Kt.toWorkingColorSpace(this,r),this}setStyle(t,e=we){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=we){const n=Ql[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=hn(t.r),this.g=hn(t.g),this.b=hn(t.b),this}copyLinearToSRGB(t){return this.r=yi(t.r),this.g=yi(t.g),this.b=yi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=we){return Kt.fromWorkingColorSpace(Se.copy(this),t),Math.round(Gt(Se.r*255,0,255))*65536+Math.round(Gt(Se.g*255,0,255))*256+Math.round(Gt(Se.b*255,0,255))}getHexString(t=we){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.fromWorkingColorSpace(Se.copy(this),e);const n=Se.r,r=Se.g,s=Se.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-n)/h+2;break;case s:c=(n-r)/h+4;break}c/=6}return t.h=c,t.s=l,t.l=u,t}getRGB(t,e=Kt.workingColorSpace){return Kt.fromWorkingColorSpace(Se.copy(this),e),t.r=Se.r,t.g=Se.g,t.b=Se.b,t}getStyle(t=we){Kt.fromWorkingColorSpace(Se.copy(this),t);const e=Se.r,n=Se.g,r=Se.b;return t!==we?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(t,e,n){return this.getHSL(_n),this.setHSL(_n.h+t,_n.s+e,_n.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(_n),t.getHSL(xr);const n=Xi(_n.h,xr.h,e),r=Xi(_n.s,xr.s,e),s=Xi(_n.l,xr.l,e);return this.setHSL(n,r,s),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,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,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 Se=new Wt;Wt.NAMES=Ql;let vf=0;class or extends Di{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:vf++}),this.uuid=Kn(),this.name="",this.type="Material",this.blending=Mi,this.side=bn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Gs,this.blendDst=Vs,this.blendEquation=On,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Wt(0,0,0),this.blendAlpha=0,this.depthFunc=Ti,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ec,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ti,this.stencilZFail=ti,this.stencilZPass=ti,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Mi&&(n.blending=this.blending),this.side!==bn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Gs&&(n.blendSrc=this.blendSrc),this.blendDst!==Vs&&(n.blendDst=this.blendDst),this.blendEquation!==On&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ti&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ec&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ti&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ti&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ti&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(e){const s=r(t.textures),o=r(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}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(e!==null){const r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Vn extends or{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Wt(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 $e,this.combine=Il,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 he=new P,Mr=new at;class je{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Tc,this.updateRanges=[],this.gpuType=ln,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Mr.fromBufferAttribute(this,e),Mr.applyMatrix3(t),this.setXY(e,Mr.x,Mr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix3(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix4(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyNormalMatrix(t),this.setXYZ(e,he.x,he.y,he.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.transformDirection(t),this.setXYZ(e,he.x,he.y,he.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=pi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Te(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=pi(e,this.array)),e}setX(t,e){return this.normalized&&(e=Te(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=pi(e,this.array)),e}setY(t,e){return this.normalized&&(e=Te(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=pi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Te(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=pi(e,this.array)),e}setW(t,e){return this.normalized&&(e=Te(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Te(e,this.array),n=Te(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=Te(e,this.array),n=Te(n,this.array),r=Te(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=Te(e,this.array),n=Te(n,this.array),r=Te(r,this.array),s=Te(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,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!==Tc&&(t.usage=this.usage),t}}class tu extends je{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class eu extends je{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class ne extends je{constructor(t,e,n){super(new Float32Array(t),e,n)}}let xf=0;const Oe=new re,Es=new ve,ui=new P,Ue=new sr,ki=new sr,pe=new P;class Pe extends Di{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:xf++}),this.uuid=Kn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Jl(t)?eu:tu)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,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 this.attributes[t]!==void 0}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;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new zt().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Oe.makeRotationFromQuaternion(t),this.applyMatrix4(Oe),this}rotateX(t){return Oe.makeRotationX(t),this.applyMatrix4(Oe),this}rotateY(t){return Oe.makeRotationY(t),this.applyMatrix4(Oe),this}rotateZ(t){return Oe.makeRotationZ(t),this.applyMatrix4(Oe),this}translate(t,e,n){return Oe.makeTranslation(t,e,n),this.applyMatrix4(Oe),this}scale(t,e,n){return Oe.makeScale(t,e,n),this.applyMatrix4(Oe),this}lookAt(t){return Es.lookAt(t),Es.updateMatrix(),this.applyMatrix4(Es.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ui).negate(),this.translate(ui.x,ui.y,ui.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let r=0,s=t.length;r<s;r++){const o=t[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new ne(n,3))}else{const n=Math.min(t.length,e.count);for(let r=0;r<n;r++){const s=t[r];e.setXYZ(r,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const s=e[n];Ue.setFromBufferAttribute(s),this.morphTargetsRelative?(pe.addVectors(this.boundingBox.min,Ue.min),this.boundingBox.expandByPoint(pe),pe.addVectors(this.boundingBox.max,Ue.max),this.boundingBox.expandByPoint(pe)):(this.boundingBox.expandByPoint(Ue.min),this.boundingBox.expandByPoint(Ue.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ga);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(t){const n=this.boundingSphere.center;if(Ue.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];ki.setFromBufferAttribute(a),this.morphTargetsRelative?(pe.addVectors(Ue.min,ki.min),Ue.expandByPoint(pe),pe.addVectors(Ue.max,ki.max),Ue.expandByPoint(pe)):(Ue.expandByPoint(ki.min),Ue.expandByPoint(ki.max))}Ue.getCenter(n);let r=0;for(let s=0,o=t.count;s<o;s++)pe.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(pe));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)pe.fromBufferAttribute(a,l),c&&(ui.fromBufferAttribute(t,l),pe.add(ui)),r=Math.max(r,n.distanceToSquared(pe))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,r=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new je(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let D=0;D<n.count;D++)a[D]=new P,c[D]=new P;const l=new P,u=new P,h=new P,f=new at,d=new at,g=new at,v=new P,m=new P;function p(D,y,M){l.fromBufferAttribute(n,D),u.fromBufferAttribute(n,y),h.fromBufferAttribute(n,M),f.fromBufferAttribute(s,D),d.fromBufferAttribute(s,y),g.fromBufferAttribute(s,M),u.sub(l),h.sub(l),d.sub(f),g.sub(f);const w=1/(d.x*g.y-g.x*d.y);isFinite(w)&&(v.copy(u).multiplyScalar(g.y).addScaledVector(h,-d.y).multiplyScalar(w),m.copy(h).multiplyScalar(d.x).addScaledVector(u,-g.x).multiplyScalar(w),a[D].add(v),a[y].add(v),a[M].add(v),c[D].add(m),c[y].add(m),c[M].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let D=0,y=b.length;D<y;++D){const M=b[D],w=M.start,H=M.count;for(let O=w,V=w+H;O<V;O+=3)p(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const T=new P,S=new P,L=new P,C=new P;function R(D){L.fromBufferAttribute(r,D),C.copy(L);const y=a[D];T.copy(y),T.sub(L.multiplyScalar(L.dot(y))).normalize(),S.crossVectors(C,y);const w=S.dot(c[D])<0?-1:1;o.setXYZW(D,T.x,T.y,T.z,w)}for(let D=0,y=b.length;D<y;++D){const M=b[D],w=M.start,H=M.count;for(let O=w,V=w+H;O<V;O+=3)R(t.getX(O+0)),R(t.getX(O+1)),R(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new je(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const r=new P,s=new P,o=new P,a=new P,c=new P,l=new P,u=new P,h=new P;if(t)for(let f=0,d=t.count;f<d;f+=3){const g=t.getX(f+0),v=t.getX(f+1),m=t.getX(f+2);r.fromBufferAttribute(e,g),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,m),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),a.add(u),c.add(u),l.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,d=e.count;f<d;f+=3)r.fromBufferAttribute(e,f+0),s.fromBufferAttribute(e,f+1),o.fromBufferAttribute(e,f+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)pe.fromBufferAttribute(t,e),pe.normalize(),t.setXYZ(e,pe.x,pe.y,pe.z)}toNonIndexed(){function t(a,c){const l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u);let d=0,g=0;for(let v=0,m=c.length;v<m;v++){a.isInterleavedBufferAttribute?d=c[v]*a.data.stride+a.offset:d=c[v]*u;for(let p=0;p<u;p++)f[g++]=l[d++]}return new je(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Pe,n=this.index.array,r=this.attributes;for(const a in r){const c=r[a],l=t(c,n);e.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){const f=l[u],d=t(f,n);c.push(d)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){const d=l[h];u.push(d.toJSON(t.data))}u.length>0&&(r[c]=u,s=!0)}s&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const r=t.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(e))}const s=t.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f<d;f++)u.push(h[f].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const zc=new re,Dn=new $l,Sr=new Ga,Hc=new P,yr=new P,Er=new P,Tr=new P,Ts=new P,Ar=new P,kc=new P,br=new P;class le extends ve{constructor(t=new Pe,e=new Vn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const a=this.morphTargetInfluences;if(s&&a){Ar.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],h=s[c];u!==0&&(Ts.fromBufferAttribute(h,t),o?Ar.addScaledVector(Ts,u):Ar.addScaledVector(Ts.sub(e),u))}e.add(Ar)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Sr.copy(n.boundingSphere),Sr.applyMatrix4(s),Dn.copy(t.ray).recast(t.near),!(Sr.containsPoint(Dn.origin)===!1&&(Dn.intersectSphere(Sr,Hc)===null||Dn.origin.distanceToSquared(Hc)>(t.far-t.near)**2))&&(zc.copy(s).invert(),Dn.copy(t.ray).applyMatrix4(zc),!(n.boundingBox!==null&&Dn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Dn)))}_computeIntersections(t,e,n){let r;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){const m=f[g],p=o[m.materialIndex],b=Math.max(m.start,d.start),T=Math.min(a.count,Math.min(m.start+m.count,d.start+d.count));for(let S=b,L=T;S<L;S+=3){const C=a.getX(S),R=a.getX(S+1),D=a.getX(S+2);r=wr(this,p,t,n,l,u,h,C,R,D),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(a.count,d.start+d.count);for(let m=g,p=v;m<p;m+=3){const b=a.getX(m),T=a.getX(m+1),S=a.getX(m+2);r=wr(this,o,t,n,l,u,h,b,T,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){const m=f[g],p=o[m.materialIndex],b=Math.max(m.start,d.start),T=Math.min(c.count,Math.min(m.start+m.count,d.start+d.count));for(let S=b,L=T;S<L;S+=3){const C=S,R=S+1,D=S+2;r=wr(this,p,t,n,l,u,h,C,R,D),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(c.count,d.start+d.count);for(let m=g,p=v;m<p;m+=3){const b=m,T=m+1,S=m+2;r=wr(this,o,t,n,l,u,h,b,T,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}}}function Mf(i,t,e,n,r,s,o,a){let c;if(t.side===Ce?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,t.side===bn,a),c===null)return null;br.copy(a),br.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(br);return l<e.near||l>e.far?null:{distance:l,point:br.clone(),object:i}}function wr(i,t,e,n,r,s,o,a,c,l){i.getVertexPosition(a,yr),i.getVertexPosition(c,Er),i.getVertexPosition(l,Tr);const u=Mf(i,t,e,n,yr,Er,Tr,kc);if(u){const h=new P;Ve.getBarycoord(kc,yr,Er,Tr,h),r&&(u.uv=Ve.getInterpolatedAttribute(r,a,c,l,h,new at)),s&&(u.uv1=Ve.getInterpolatedAttribute(s,a,c,l,h,new at)),o&&(u.normal=Ve.getInterpolatedAttribute(o,a,c,l,h,new P),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:c,c:l,normal:new P,materialIndex:0};Ve.getNormal(yr,Er,Tr,f.normal),u.face=f,u.barycoord=h}return u}class Zn extends Pe{constructor(t=1,e=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],u=[],h=[];let f=0,d=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new ne(l,3)),this.setAttribute("normal",new ne(u,3)),this.setAttribute("uv",new ne(h,2));function g(v,m,p,b,T,S,L,C,R,D,y){const M=S/R,w=L/D,H=S/2,O=L/2,V=C/2,X=R+1,G=D+1;let K=0,k=0;const ct=new P;for(let pt=0;pt<G;pt++){const Mt=pt*w-O;for(let Ft=0;Ft<X;Ft++){const Zt=Ft*M-H;ct[v]=Zt*b,ct[m]=Mt*T,ct[p]=V,l.push(ct.x,ct.y,ct.z),ct[v]=0,ct[m]=0,ct[p]=C>0?1:-1,u.push(ct.x,ct.y,ct.z),h.push(Ft/R),h.push(1-pt/D),K+=1}}for(let pt=0;pt<D;pt++)for(let Mt=0;Mt<R;Mt++){const Ft=f+Mt+X*pt,Zt=f+Mt+X*(pt+1),Y=f+(Mt+1)+X*(pt+1),st=f+(Mt+1)+X*pt;c.push(Ft,Zt,st),c.push(Zt,Y,st),k+=6}a.addGroup(d,k,y),d+=k,f+=K}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Li(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone():Array.isArray(r)?t[e][n]=r.slice():t[e][n]=r}}return t}function Ae(i){const t={};for(let e=0;e<i.length;e++){const n=Li(i[e]);for(const r in n)t[r]=n[r]}return t}function Sf(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function nu(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Kt.workingColorSpace}const yf={clone:Li,merge:Ae};var Ef=`void main() {
|
|
43
|
+
*/const mc="172",Vf=0,sl=1,Gf=2,Au=1,bu=2,hn=3,Cn=0,Pe=1,je=2,bn=0,bi=1,ol=2,al=3,cl=4,Wf=5,kn=100,Xf=101,qf=102,Yf=103,Kf=104,Zf=200,$f=201,Jf=202,jf=203,ko=204,Vo=205,Qf=206,td=207,ed=208,nd=209,id=210,rd=211,sd=212,od=213,ad=214,Go=0,Wo=1,Xo=2,Pi=3,qo=4,Yo=5,Ko=6,Zo=7,wu=0,cd=1,ld=2,wn=0,ud=1,hd=2,fd=3,Ru=4,dd=5,pd=6,md=7,Cu=300,Li=301,Di=302,$o=303,Jo=304,ds=306,Ui=1e3,Wn=1001,jo=1002,$e=1003,gd=1004,yr=1005,Qe=1006,Es=1007,Xn=1008,gn=1009,Pu=1010,Lu=1011,sr=1012,gc=1013,Zn=1014,dn=1015,dr=1016,_c=1017,vc=1018,Ii=1020,Du=35902,Uu=1021,Iu=1022,Ke=1023,Nu=1024,Fu=1025,wi=1026,Ni=1027,Ou=1028,xc=1029,Bu=1030,Mc=1031,Sc=1033,Kr=33776,Zr=33777,$r=33778,Jr=33779,Qo=35840,ta=35841,ea=35842,na=35843,ia=36196,ra=37492,sa=37496,oa=37808,aa=37809,ca=37810,la=37811,ua=37812,ha=37813,fa=37814,da=37815,pa=37816,ma=37817,ga=37818,_a=37819,va=37820,xa=37821,jr=36492,Ma=36494,Sa=36495,zu=36283,Ea=36284,ya=36285,Ta=36286,_d=3200,vd=3201,Hu=0,xd=1,Tn="",Re="srgb",Fi="srgb-linear",rs="linear",ne="srgb",si=7680,ll=519,Md=512,Sd=513,Ed=514,ku=515,yd=516,Td=517,Ad=518,bd=519,ul=35044,hl="300 es",pn=2e3,ss=2001;class Hi{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const r=this._listeners[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,t);t.target=null}}}const Se=["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 fl=1234567;const ji=Math.PI/180,or=180/Math.PI;function ni(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Se[i&255]+Se[i>>8&255]+Se[i>>16&255]+Se[i>>24&255]+"-"+Se[t&255]+Se[t>>8&255]+"-"+Se[t>>16&15|64]+Se[t>>24&255]+"-"+Se[e&63|128]+Se[e>>8&255]+"-"+Se[e>>16&255]+Se[e>>24&255]+Se[n&255]+Se[n>>8&255]+Se[n>>16&255]+Se[n>>24&255]).toLowerCase()}function Gt(i,t,e){return Math.max(t,Math.min(e,i))}function Ec(i,t){return(i%t+t)%t}function wd(i,t,e,n,r){return n+(i-t)*(r-n)/(e-t)}function Rd(i,t,e){return i!==t?(e-i)/(t-i):0}function Qi(i,t,e){return(1-e)*i+e*t}function Cd(i,t,e,n){return Qi(i,t,1-Math.exp(-e*n))}function Pd(i,t=1){return t-Math.abs(Ec(i,t*2)-t)}function Ld(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Dd(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Ud(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Id(i,t){return i+Math.random()*(t-i)}function Nd(i){return i*(.5-Math.random())}function Fd(i){i!==void 0&&(fl=i);let t=fl+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Od(i){return i*ji}function Bd(i){return i*or}function zd(i){return(i&i-1)===0&&i!==0}function Hd(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function kd(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Vd(i,t,e,n,r){const s=Math.cos,o=Math.sin,a=s(e/2),c=o(e/2),l=s((t+n)/2),u=o((t+n)/2),h=s((t-n)/2),f=o((t-n)/2),d=s((n-t)/2),g=o((n-t)/2);switch(r){case"XYX":i.set(a*u,c*h,c*f,a*l);break;case"YZY":i.set(c*f,a*u,c*h,a*l);break;case"ZXZ":i.set(c*h,c*f,a*u,a*l);break;case"XZX":i.set(a*u,c*g,c*d,a*l);break;case"YXY":i.set(c*d,a*u,c*g,a*l);break;case"ZYZ":i.set(c*g,c*d,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function xi(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Ae(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Gd={DEG2RAD:ji,RAD2DEG:or,generateUUID:ni,clamp:Gt,euclideanModulo:Ec,mapLinear:wd,inverseLerp:Rd,lerp:Qi,damp:Cd,pingpong:Pd,smoothstep:Ld,smootherstep:Dd,randInt:Ud,randFloat:Id,randFloatSpread:Nd,seededRandom:Fd,degToRad:Od,radToDeg:Bd,isPowerOfTwo:zd,ceilPowerOfTwo:Hd,floorPowerOfTwo:kd,setQuaternionFromProperEuler:Vd,normalize:Ae,denormalize:xi};class ct{constructor(t=0,e=0){ct.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,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(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(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Gt(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),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*r+t.x,this.y=s*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ht{constructor(t,e,n,r,s,o,a,c,l){Ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,c,l)}set(t,e,n,r,s,o,a,c,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[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,r=e.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],g=n[8],v=r[0],m=r[3],p=r[6],A=r[1],y=r[4],S=r[7],L=r[2],P=r[5],C=r[8];return s[0]=o*v+a*A+c*L,s[3]=o*m+a*y+c*P,s[6]=o*p+a*S+c*C,s[1]=l*v+u*A+h*L,s[4]=l*m+u*y+h*P,s[7]=l*p+u*S+h*C,s[2]=f*v+d*A+g*L,s[5]=f*m+d*y+g*P,s[8]=f*p+d*S+g*C,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],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*s*u+n*a*c+r*s*l-r*o*c}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=u*o-a*l,f=a*c-u*s,d=l*s-o*c,g=e*h+n*f+r*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return t[0]=h*v,t[1]=(r*l-u*n)*v,t[2]=(a*n-r*o)*v,t[3]=f*v,t[4]=(u*e-r*c)*v,t[5]=(r*s-a*e)*v,t[6]=d*v,t[7]=(n*c-l*e)*v,t[8]=(o*e-n*s)*v,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,r,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ys.makeScale(t,e)),this}rotate(t){return this.premultiply(ys.makeRotation(-t)),this}translate(t,e){return this.premultiply(ys.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 r=0;r<9;r++)if(e[r]!==n[r])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 ys=new Ht;function Vu(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ar(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Wd(){const i=ar("canvas");return i.style.display="block",i}const dl={};function Mi(i){i in dl||(dl[i]=!0,console.warn(i))}function Xd(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}function qd(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function Yd(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const pl=new Ht().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ml=new Ht().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Kd(){const i={enabled:!0,workingColorSpace:Fi,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===ne&&(r.r=mn(r.r),r.g=mn(r.g),r.b=mn(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===ne&&(r.r=Ri(r.r),r.g=Ri(r.g),r.b=Ri(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Tn?rs:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Fi]:{primaries:t,whitePoint:n,transfer:rs,toXYZ:pl,fromXYZ:ml,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Re},outputColorSpaceConfig:{drawingBufferColorSpace:Re}},[Re]:{primaries:t,whitePoint:n,transfer:ne,toXYZ:pl,fromXYZ:ml,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Re}}}),i}const Jt=Kd();function mn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ri(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let oi;class Zd{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{oi===void 0&&(oi=ar("canvas")),oi.width=t.width,oi.height=t.height;const n=oi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=oi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=ar("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=mn(s[o]/255)*255;return n.putImageData(r,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(mn(e[n]/255)*255):e[n]=mn(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let $d=0;class Gu{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:$d++}),this.uuid=ni(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Ts(r[o].image)):s.push(Ts(r[o]))}else s=Ts(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function Ts(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Zd.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Jd=0;class ye extends Hi{constructor(t=ye.DEFAULT_IMAGE,e=ye.DEFAULT_MAPPING,n=Wn,r=Wn,s=Qe,o=Xn,a=Ke,c=gn,l=ye.DEFAULT_ANISOTROPY,u=Tn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Jd++}),this.uuid=ni(),this.name="",this.source=new Gu(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new ct(0,0),this.repeat=new ct(1,1),this.center=new ct(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ht,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Cu)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ui:t.x=t.x-Math.floor(t.x);break;case Wn:t.x=t.x<0?0:1;break;case jo:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Ui:t.y=t.y-Math.floor(t.y);break;case Wn:t.y=t.y<0?0:1;break;case jo:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ye.DEFAULT_IMAGE=null;ye.DEFAULT_MAPPING=Cu;ye.DEFAULT_ANISOTROPY=1;class ie{constructor(t=0,e=0,n=0,r=1){ie.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}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,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*s,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,r,s;const c=t.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],g=c[9],v=c[2],m=c[6],p=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(g+m)<.1&&Math.abs(l+d+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const y=(l+1)/2,S=(d+1)/2,L=(p+1)/2,P=(u+f)/4,C=(h+v)/4,R=(g+m)/4;return y>S&&y>L?y<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(y),r=P/n,s=C/n):S>L?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=P/r,s=R/r):L<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),n=C/s,r=R/s),this.set(n,r,s,e),this}let A=Math.sqrt((m-g)*(m-g)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(A)<.001&&(A=1),this.x=(m-g)/A,this.y=(h-v)/A,this.z=(f-u)/A,this.w=Math.acos((l+d+p-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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this.w=Gt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this.w=Gt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(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 jd extends Hi{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ie(0,0,t,e),this.scissorTest=!1,this.viewport=new ie(0,0,t,e);const r={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Qe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ye(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;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}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(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 r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n;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 n=0,r=t.textures.length;n<r;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const e=Object.assign({},t.texture.image);return this.texture.source=new Gu(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $n extends jd{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Wu extends ye{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=$e,this.minFilter=$e,this.wrapR=Wn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Qd extends ye{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=$e,this.minFilter=$e,this.wrapR=Wn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class pr{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,o,a){let c=n[r+0],l=n[r+1],u=n[r+2],h=n[r+3];const f=s[o+0],d=s[o+1],g=s[o+2],v=s[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=f,t[e+1]=d,t[e+2]=g,t[e+3]=v;return}if(h!==v||c!==f||l!==d||u!==g){let m=1-a;const p=c*f+l*d+u*g+h*v,A=p>=0?1:-1,y=1-p*p;if(y>Number.EPSILON){const L=Math.sqrt(y),P=Math.atan2(L,p*A);m=Math.sin(m*P)/L,a=Math.sin(a*P)/L}const S=a*A;if(c=c*m+f*S,l=l*m+d*S,u=u*m+g*S,h=h*m+v*S,m===1-a){const L=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=L,l*=L,u*=L,h*=L}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,r,s,o){const a=n[r],c=n[r+1],l=n[r+2],u=n[r+3],h=s[o],f=s[o+1],d=s[o+2],g=s[o+3];return t[e]=a*g+u*h+c*d-l*f,t[e+1]=c*g+u*f+l*h-a*d,t[e+2]=l*g+u*d+a*f-c*h,t[e+3]=u*g-a*h-c*f-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,r){return this._x=t,this._y=e,this._z=n,this._w=r,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,r=t._y,s=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(r/2),h=a(s/2),f=c(n/2),d=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=f*u*h+l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h-f*d*g;break;case"YXZ":this._x=f*u*h+l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h+f*d*g;break;case"ZXY":this._x=f*u*h-l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h-f*d*g;break;case"ZYX":this._x=f*u*h-l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h+f*d*g;break;case"YZX":this._x=f*u*h+l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h-f*d*g;break;case"XZY":this._x=f*u*h-l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h+f*d*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],f=n+a+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(o-r)*d}else if(n>a&&n>h){const d=2*Math.sqrt(1+n-a-h);this._w=(u-c)/d,this._x=.25*d,this._y=(r+o)/d,this._z=(s+l)/d}else if(a>h){const d=2*Math.sqrt(1+a-n-h);this._w=(s-l)/d,this._x=(r+o)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-a);this._w=(o-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(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(Gt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,s=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-r*a,this._w=o*u-n*a-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,r=this._y,s=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const d=1-e;return this._w=d*o+e*this._w,this._x=d*n+e*this._x,this._y=d*r+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=r*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*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 D{constructor(t=0,e=0,n=0){D.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(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(gl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(gl.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*r-a*n),u=2*(a*e-s*r),h=2*(s*n-o*e);return this.x=e+c*l+o*h-a*u,this.y=n+c*u+a*l-s*h,this.z=r+c*h+s*u-o*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,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,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=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(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,r=t.y,s=t.z,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-n*c,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return As.copy(this).projectOnVector(t),this.sub(As)}reflect(t){return this.sub(As.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Gt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}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 r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*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(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,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 As=new D,gl=new pr;class mr{constructor(t=new D(1/0,1/0,1/0),e=new D(-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(We.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(We.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=We.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(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,We):We.fromBufferAttribute(s,o),We.applyMatrix4(t.matrixWorld),this.expandByPoint(We);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Tr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Tr.copy(n.boundingBox)),Tr.applyMatrix4(t.matrixWorld),this.union(Tr)}const r=t.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,We),We.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(Wi),Ar.subVectors(this.max,Wi),ai.subVectors(t.a,Wi),ci.subVectors(t.b,Wi),li.subVectors(t.c,Wi),_n.subVectors(ci,ai),vn.subVectors(li,ci),In.subVectors(ai,li);let e=[0,-_n.z,_n.y,0,-vn.z,vn.y,0,-In.z,In.y,_n.z,0,-_n.x,vn.z,0,-vn.x,In.z,0,-In.x,-_n.y,_n.x,0,-vn.y,vn.x,0,-In.y,In.x,0];return!bs(e,ai,ci,li,Ar)||(e=[1,0,0,0,1,0,0,0,1],!bs(e,ai,ci,li,Ar))?!1:(br.crossVectors(_n,vn),e=[br.x,br.y,br.z],bs(e,ai,ci,li,Ar))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,We).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(We).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(on[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),on[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),on[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),on[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),on[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),on[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),on[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),on[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(on),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const on=[new D,new D,new D,new D,new D,new D,new D,new D],We=new D,Tr=new mr,ai=new D,ci=new D,li=new D,_n=new D,vn=new D,In=new D,Wi=new D,Ar=new D,br=new D,Nn=new D;function bs(i,t,e,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){Nn.fromArray(i,s);const a=r.x*Math.abs(Nn.x)+r.y*Math.abs(Nn.y)+r.z*Math.abs(Nn.z),c=t.dot(Nn),l=e.dot(Nn),u=n.dot(Nn);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const tp=new mr,Xi=new D,ws=new D;class yc{constructor(t=new D,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;e!==void 0?n.copy(e):tp.setFromPoints(t).getCenter(n);let r=0;for(let s=0,o=t.length;s<o;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),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;Xi.subVectors(t,this.center);const e=Xi.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(Xi,r/n),this.radius+=r}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ws.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Xi.copy(t.center).add(ws)),this.expandByPoint(Xi.copy(t.center).sub(ws))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const an=new D,Rs=new D,wr=new D,xn=new D,Cs=new D,Rr=new D,Ps=new D;class Xu{constructor(t=new D,e=new D(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,an)),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=an.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(an.copy(this.origin).addScaledVector(this.direction,e),an.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){Rs.copy(t).add(e).multiplyScalar(.5),wr.copy(e).sub(t).normalize(),xn.copy(this.origin).sub(Rs);const s=t.distanceTo(e)*.5,o=-this.direction.dot(wr),a=xn.dot(this.direction),c=-xn.dot(wr),l=xn.lengthSq(),u=Math.abs(1-o*o);let h,f,d,g;if(u>0)if(h=o*c-a,f=o*a-c,g=s*u,h>=0)if(f>=-g)if(f<=g){const v=1/u;h*=v,f*=v,d=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f<=-g?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=g?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Rs).addScaledVector(wr,f),d}intersectSphere(t,e){an.subVectors(t.center,this.origin);const n=an.dot(this.direction),r=an.dot(an)-n*n,s=t.radius*t.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,s,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,r=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,r=(t.min.x-f.x)*l),u>=0?(s=(t.min.y-f.y)*u,o=(t.max.y-f.y)*u):(s=(t.max.y-f.y)*u,o=(t.min.y-f.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(t.min.z-f.z)*h,c=(t.max.z-f.z)*h):(a=(t.max.z-f.z)*h,c=(t.min.z-f.z)*h),n>c||a>r)||((a>n||n!==n)&&(n=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,an)!==null}intersectTriangle(t,e,n,r,s){Cs.subVectors(e,t),Rr.subVectors(n,t),Ps.crossVectors(Cs,Rr);let o=this.direction.dot(Ps),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;xn.subVectors(this.origin,t);const c=a*this.direction.dot(Rr.crossVectors(xn,Rr));if(c<0)return null;const l=a*this.direction.dot(Cs.cross(xn));if(l<0||c+l>o)return null;const u=-a*xn.dot(Ps);return u<0?null:this.at(u/o,s)}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 oe{constructor(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m){oe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m)}set(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=r,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=f,p[3]=d,p[7]=g,p[11]=v,p[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 oe().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 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){const e=this.elements,n=t.elements,r=1/ui.setFromMatrixColumn(t,0).length(),s=1/ui.setFromMatrixColumn(t,1).length(),o=1/ui.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,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,r=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){const f=o*u,d=o*h,g=a*u,v=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=d+g*l,e[5]=f-v*l,e[9]=-a*c,e[2]=v-f*l,e[6]=g+d*l,e[10]=o*c}else if(t.order==="YXZ"){const f=c*u,d=c*h,g=l*u,v=l*h;e[0]=f+v*a,e[4]=g*a-d,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=d*a-g,e[6]=v+f*a,e[10]=o*c}else if(t.order==="ZXY"){const f=c*u,d=c*h,g=l*u,v=l*h;e[0]=f-v*a,e[4]=-o*h,e[8]=g+d*a,e[1]=d+g*a,e[5]=o*u,e[9]=v-f*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const f=o*u,d=o*h,g=a*u,v=a*h;e[0]=c*u,e[4]=g*l-d,e[8]=f*l+v,e[1]=c*h,e[5]=v*l+f,e[9]=d*l-g,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const f=o*c,d=o*l,g=a*c,v=a*l;e[0]=c*u,e[4]=v-f*h,e[8]=g*h+d,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=d*h+g,e[10]=f-v*h}else if(t.order==="XZY"){const f=o*c,d=o*l,g=a*c,v=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=f*h+v,e[5]=o*u,e[9]=d*h-g,e[2]=g*h-d,e[6]=a*u,e[10]=v*h+f}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(ep,t,np)}lookAt(t,e,n){const r=this.elements;return Ie.subVectors(t,e),Ie.lengthSq()===0&&(Ie.z=1),Ie.normalize(),Mn.crossVectors(n,Ie),Mn.lengthSq()===0&&(Math.abs(n.z)===1?Ie.x+=1e-4:Ie.z+=1e-4,Ie.normalize(),Mn.crossVectors(n,Ie)),Mn.normalize(),Cr.crossVectors(Ie,Mn),r[0]=Mn.x,r[4]=Cr.x,r[8]=Ie.x,r[1]=Mn.y,r[5]=Cr.y,r[9]=Ie.y,r[2]=Mn.z,r[6]=Cr.z,r[10]=Ie.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],g=n[2],v=n[6],m=n[10],p=n[14],A=n[3],y=n[7],S=n[11],L=n[15],P=r[0],C=r[4],R=r[8],E=r[12],_=r[1],w=r[5],B=r[9],F=r[13],k=r[2],X=r[6],G=r[10],$=r[14],V=r[3],lt=r[7],mt=r[11],St=r[15];return s[0]=o*P+a*_+c*k+l*V,s[4]=o*C+a*w+c*X+l*lt,s[8]=o*R+a*B+c*G+l*mt,s[12]=o*E+a*F+c*$+l*St,s[1]=u*P+h*_+f*k+d*V,s[5]=u*C+h*w+f*X+d*lt,s[9]=u*R+h*B+f*G+d*mt,s[13]=u*E+h*F+f*$+d*St,s[2]=g*P+v*_+m*k+p*V,s[6]=g*C+v*w+m*X+p*lt,s[10]=g*R+v*B+m*G+p*mt,s[14]=g*E+v*F+m*$+p*St,s[3]=A*P+y*_+S*k+L*V,s[7]=A*C+y*w+S*X+L*lt,s[11]=A*R+y*B+S*G+L*mt,s[15]=A*E+y*F+S*$+L*St,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],r=t[8],s=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],f=t[10],d=t[14],g=t[3],v=t[7],m=t[11],p=t[15];return g*(+s*c*h-r*l*h-s*a*f+n*l*f+r*a*d-n*c*d)+v*(+e*c*d-e*l*f+s*o*f-r*o*d+r*l*u-s*c*u)+m*(+e*l*h-e*a*d-s*o*h+n*o*d+s*a*u-n*l*u)+p*(-r*a*u-e*c*h+e*a*f+r*o*h-n*o*f+n*c*u)}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 r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],d=t[11],g=t[12],v=t[13],m=t[14],p=t[15],A=h*m*l-v*f*l+v*c*d-a*m*d-h*c*p+a*f*p,y=g*f*l-u*m*l-g*c*d+o*m*d+u*c*p-o*f*p,S=u*v*l-g*h*l+g*a*d-o*v*d-u*a*p+o*h*p,L=g*h*c-u*v*c-g*a*f+o*v*f+u*a*m-o*h*m,P=e*A+n*y+r*S+s*L;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return t[0]=A*C,t[1]=(v*f*s-h*m*s-v*r*d+n*m*d+h*r*p-n*f*p)*C,t[2]=(a*m*s-v*c*s+v*r*l-n*m*l-a*r*p+n*c*p)*C,t[3]=(h*c*s-a*f*s-h*r*l+n*f*l+a*r*d-n*c*d)*C,t[4]=y*C,t[5]=(u*m*s-g*f*s+g*r*d-e*m*d-u*r*p+e*f*p)*C,t[6]=(g*c*s-o*m*s-g*r*l+e*m*l+o*r*p-e*c*p)*C,t[7]=(o*f*s-u*c*s+u*r*l-e*f*l-o*r*d+e*c*d)*C,t[8]=S*C,t[9]=(g*h*s-u*v*s-g*n*d+e*v*d+u*n*p-e*h*p)*C,t[10]=(o*v*s-g*a*s+g*n*l-e*v*l-o*n*p+e*a*p)*C,t[11]=(u*a*s-o*h*s-u*n*l+e*h*l+o*n*d-e*a*d)*C,t[12]=L*C,t[13]=(u*v*r-g*h*r+g*n*f-e*v*f-u*n*m+e*h*m)*C,t[14]=(g*a*r-o*v*r-g*n*c+e*v*c+o*n*m-e*a*m)*C,t[15]=(o*h*r-u*a*r+u*n*c-e*h*c-o*n*f+e*a*f)*C,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,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],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}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),r=Math.sin(e),s=1-n,o=t.x,a=t.y,c=t.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+n,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+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,r,s,o){return this.set(1,n,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,o=e._y,a=e._z,c=e._w,l=s+s,u=o+o,h=a+a,f=s*l,d=s*u,g=s*h,v=o*u,m=o*h,p=a*h,A=c*l,y=c*u,S=c*h,L=n.x,P=n.y,C=n.z;return r[0]=(1-(v+p))*L,r[1]=(d+S)*L,r[2]=(g-y)*L,r[3]=0,r[4]=(d-S)*P,r[5]=(1-(f+p))*P,r[6]=(m+A)*P,r[7]=0,r[8]=(g+y)*C,r[9]=(m-A)*C,r[10]=(1-(f+v))*C,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let s=ui.set(r[0],r[1],r[2]).length();const o=ui.set(r[4],r[5],r[6]).length(),a=ui.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Xe.copy(this);const l=1/s,u=1/o,h=1/a;return Xe.elements[0]*=l,Xe.elements[1]*=l,Xe.elements[2]*=l,Xe.elements[4]*=u,Xe.elements[5]*=u,Xe.elements[6]*=u,Xe.elements[8]*=h,Xe.elements[9]*=h,Xe.elements[10]*=h,e.setFromRotationMatrix(Xe),n.x=s,n.y=o,n.z=a,this}makePerspective(t,e,n,r,s,o,a=pn){const c=this.elements,l=2*s/(e-t),u=2*s/(n-r),h=(e+t)/(e-t),f=(n+r)/(n-r);let d,g;if(a===pn)d=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===ss)d=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,s,o,a=pn){const c=this.elements,l=1/(e-t),u=1/(n-r),h=1/(o-s),f=(e+t)*l,d=(n+r)*u;let g,v;if(a===pn)g=(o+s)*h,v=-2*h;else if(a===ss)g=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=v,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])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 ui=new D,Xe=new oe,ep=new D(0,0,0),np=new D(1,1,1),Mn=new D,Cr=new D,Ie=new D,_l=new oe,vl=new pr;class en{constructor(t=0,e=0,n=0,r=en.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}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,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,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 r=t.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],h=r[2],f=r[6],d=r[10];switch(e){case"XYZ":this._y=Math.asin(Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return _l.makeRotationFromQuaternion(t),this.setFromRotationMatrix(_l,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return vl.setFromEuler(this),this.setFromQuaternion(vl,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}en.DEFAULT_ORDER="XYZ";class Tc{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let ip=0;const xl=new D,hi=new pr,cn=new oe,Pr=new D,qi=new D,rp=new D,sp=new pr,Ml=new D(1,0,0),Sl=new D(0,1,0),El=new D(0,0,1),yl={type:"added"},op={type:"removed"},fi={type:"childadded",child:null},Ls={type:"childremoved",child:null};class xe extends Hi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ip++}),this.uuid=ni(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=xe.DEFAULT_UP.clone();const t=new D,e=new en,n=new pr,r=new D(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new oe},normalMatrix:{value:new Ht}}),this.matrix=new oe,this.matrixWorld=new oe,this.matrixAutoUpdate=xe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=xe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Tc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return hi.setFromAxisAngle(t,e),this.quaternion.multiply(hi),this}rotateOnWorldAxis(t,e){return hi.setFromAxisAngle(t,e),this.quaternion.premultiply(hi),this}rotateX(t){return this.rotateOnAxis(Ml,t)}rotateY(t){return this.rotateOnAxis(Sl,t)}rotateZ(t){return this.rotateOnAxis(El,t)}translateOnAxis(t,e){return xl.copy(t).applyQuaternion(this.quaternion),this.position.add(xl.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ml,t)}translateY(t){return this.translateOnAxis(Sl,t)}translateZ(t){return this.translateOnAxis(El,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(cn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Pr.copy(t):Pr.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),qi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?cn.lookAt(qi,Pr,this.up):cn.lookAt(Pr,qi,this.up),this.quaternion.setFromRotationMatrix(cn),r&&(cn.extractRotation(r.matrixWorld),hi.setFromRotationMatrix(cn),this.quaternion.premultiply(hi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(yl),fi.child=t,this.dispatchEvent(fi),fi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(op),Ls.child=t,this.dispatchEvent(Ls),Ls.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),cn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),cn.multiply(t.parent.matrixWorld)),t.applyMatrix4(cn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(yl),fi.child=t,this.dispatchEvent(fi),fi.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,r=this.children.length;n<r;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].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(qi,t,rp),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qi,sp,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,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];s(t.shapes,h)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(t.materials,this.material[c]));r.material=a}else r.material=s(t.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];r.animations.push(s(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),l=o(t.textures),u=o(t.images),h=o(t.shapes),f=o(t.skeletons),d=o(t.animations),g=o(t.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),g.length>0&&(n.nodes=g)}return n.object=r,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const r=t.children[n];this.add(r.clone())}return this}}xe.DEFAULT_UP=new D(0,1,0);xe.DEFAULT_MATRIX_AUTO_UPDATE=!0;xe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qe=new D,ln=new D,Ds=new D,un=new D,di=new D,pi=new D,Tl=new D,Us=new D,Is=new D,Ns=new D,Fs=new ie,Os=new ie,Bs=new ie;class Ye{constructor(t=new D,e=new D,n=new D){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),qe.subVectors(t,e),r.cross(qe);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){qe.subVectors(r,e),ln.subVectors(n,e),Ds.subVectors(t,e);const o=qe.dot(qe),a=qe.dot(ln),c=qe.dot(Ds),l=ln.dot(ln),u=ln.dot(Ds),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;const f=1/h,d=(l*c-a*u)*f,g=(o*u-a*c)*f;return s.set(1-d-g,g,d)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,un)===null?!1:un.x>=0&&un.y>=0&&un.x+un.y<=1}static getInterpolation(t,e,n,r,s,o,a,c){return this.getBarycoord(t,e,n,r,un)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,un.x),c.addScaledVector(o,un.y),c.addScaledVector(a,un.z),c)}static getInterpolatedAttribute(t,e,n,r,s,o){return Fs.setScalar(0),Os.setScalar(0),Bs.setScalar(0),Fs.fromBufferAttribute(t,e),Os.fromBufferAttribute(t,n),Bs.fromBufferAttribute(t,r),o.setScalar(0),o.addScaledVector(Fs,s.x),o.addScaledVector(Os,s.y),o.addScaledVector(Bs,s.z),o}static isFrontFacing(t,e,n,r){return qe.subVectors(n,e),ln.subVectors(t,e),qe.cross(ln).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),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 qe.subVectors(this.c,this.b),ln.subVectors(this.a,this.b),qe.cross(ln).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ye.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ye.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,r,s){return Ye.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}containsPoint(t){return Ye.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ye.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,s=this.c;let o,a;di.subVectors(r,n),pi.subVectors(s,n),Us.subVectors(t,n);const c=di.dot(Us),l=pi.dot(Us);if(c<=0&&l<=0)return e.copy(n);Is.subVectors(t,r);const u=di.dot(Is),h=pi.dot(Is);if(u>=0&&h<=u)return e.copy(r);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),e.copy(n).addScaledVector(di,o);Ns.subVectors(t,s);const d=di.dot(Ns),g=pi.dot(Ns);if(g>=0&&d<=g)return e.copy(s);const v=d*l-c*g;if(v<=0&&l>=0&&g<=0)return a=l/(l-g),e.copy(n).addScaledVector(pi,a);const m=u*g-d*h;if(m<=0&&h-u>=0&&d-g>=0)return Tl.subVectors(s,r),a=(h-u)/(h-u+(d-g)),e.copy(r).addScaledVector(Tl,a);const p=1/(m+v+f);return o=v*p,a=f*p,e.copy(n).addScaledVector(di,o).addScaledVector(pi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const qu={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},Sn={h:0,s:0,l:0},Lr={h:0,s:0,l:0};function zs(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Xt{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(e===void 0&&n===void 0){const r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Re){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Jt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,r=Jt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Jt.toWorkingColorSpace(this,r),this}setHSL(t,e,n,r=Jt.workingColorSpace){if(t=Ec(t,1),e=Gt(e,0,1),n=Gt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=zs(o,s,t+1/3),this.g=zs(o,s,t),this.b=zs(o,s,t-1/3)}return Jt.toWorkingColorSpace(this,r),this}setStyle(t,e=Re){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Re){const n=qu[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=mn(t.r),this.g=mn(t.g),this.b=mn(t.b),this}copyLinearToSRGB(t){return this.r=Ri(t.r),this.g=Ri(t.g),this.b=Ri(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Re){return Jt.fromWorkingColorSpace(Ee.copy(this),t),Math.round(Gt(Ee.r*255,0,255))*65536+Math.round(Gt(Ee.g*255,0,255))*256+Math.round(Gt(Ee.b*255,0,255))}getHexString(t=Re){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Jt.workingColorSpace){Jt.fromWorkingColorSpace(Ee.copy(this),e);const n=Ee.r,r=Ee.g,s=Ee.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-n)/h+2;break;case s:c=(n-r)/h+4;break}c/=6}return t.h=c,t.s=l,t.l=u,t}getRGB(t,e=Jt.workingColorSpace){return Jt.fromWorkingColorSpace(Ee.copy(this),e),t.r=Ee.r,t.g=Ee.g,t.b=Ee.b,t}getStyle(t=Re){Jt.fromWorkingColorSpace(Ee.copy(this),t);const e=Ee.r,n=Ee.g,r=Ee.b;return t!==Re?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(t,e,n){return this.getHSL(Sn),this.setHSL(Sn.h+t,Sn.s+e,Sn.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(Sn),t.getHSL(Lr);const n=Qi(Sn.h,Lr.h,e),r=Qi(Sn.s,Lr.s,e),s=Qi(Sn.l,Lr.l,e);return this.setHSL(n,r,s),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,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,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 Ee=new Xt;Xt.NAMES=qu;let ap=0;class gr extends Hi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ap++}),this.uuid=ni(),this.name="",this.type="Material",this.blending=bi,this.side=Cn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ko,this.blendDst=Vo,this.blendEquation=kn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Xt(0,0,0),this.blendAlpha=0,this.depthFunc=Pi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ll,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=si,this.stencilZFail=si,this.stencilZPass=si,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(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.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(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),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(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,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==bi&&(n.blending=this.blending),this.side!==Cn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==ko&&(n.blendSrc=this.blendSrc),this.blendDst!==Vo&&(n.blendDst=this.blendDst),this.blendEquation!==kn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Pi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ll&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==si&&(n.stencilFail=this.stencilFail),this.stencilZFail!==si&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==si&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(e){const s=r(t.textures),o=r(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}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(e!==null){const r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class qn extends gr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Xt(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 en,this.combine=wu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const de=new D,Dr=new ct;class tn{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=ul,this.updateRanges=[],this.gpuType=dn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Dr.fromBufferAttribute(this,e),Dr.applyMatrix3(t),this.setXY(e,Dr.x,Dr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)de.fromBufferAttribute(this,e),de.applyMatrix3(t),this.setXYZ(e,de.x,de.y,de.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)de.fromBufferAttribute(this,e),de.applyMatrix4(t),this.setXYZ(e,de.x,de.y,de.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)de.fromBufferAttribute(this,e),de.applyNormalMatrix(t),this.setXYZ(e,de.x,de.y,de.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)de.fromBufferAttribute(this,e),de.transformDirection(t),this.setXYZ(e,de.x,de.y,de.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=xi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Ae(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=xi(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ae(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=xi(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ae(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=xi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ae(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=xi(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ae(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ae(e,this.array),n=Ae(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=Ae(e,this.array),n=Ae(n,this.array),r=Ae(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=Ae(e,this.array),n=Ae(n,this.array),r=Ae(r,this.array),s=Ae(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,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!==ul&&(t.usage=this.usage),t}}class Yu extends tn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Ku extends tn{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class re extends tn{constructor(t,e,n){super(new Float32Array(t),e,n)}}let cp=0;const He=new oe,Hs=new xe,mi=new D,Ne=new mr,Yi=new mr,ge=new D;class De extends Hi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cp++}),this.uuid=ni(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Vu(t)?Ku:Yu)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,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 this.attributes[t]!==void 0}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;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ht().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return He.makeRotationFromQuaternion(t),this.applyMatrix4(He),this}rotateX(t){return He.makeRotationX(t),this.applyMatrix4(He),this}rotateY(t){return He.makeRotationY(t),this.applyMatrix4(He),this}rotateZ(t){return He.makeRotationZ(t),this.applyMatrix4(He),this}translate(t,e,n){return He.makeTranslation(t,e,n),this.applyMatrix4(He),this}scale(t,e,n){return He.makeScale(t,e,n),this.applyMatrix4(He),this}lookAt(t){return Hs.lookAt(t),Hs.updateMatrix(),this.applyMatrix4(Hs.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mi).negate(),this.translate(mi.x,mi.y,mi.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let r=0,s=t.length;r<s;r++){const o=t[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new re(n,3))}else{const n=Math.min(t.length,e.count);for(let r=0;r<n;r++){const s=t[r];e.setXYZ(r,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const s=e[n];Ne.setFromBufferAttribute(s),this.morphTargetsRelative?(ge.addVectors(this.boundingBox.min,Ne.min),this.boundingBox.expandByPoint(ge),ge.addVectors(this.boundingBox.max,Ne.max),this.boundingBox.expandByPoint(ge)):(this.boundingBox.expandByPoint(Ne.min),this.boundingBox.expandByPoint(Ne.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new yc);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const n=this.boundingSphere.center;if(Ne.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];Yi.setFromBufferAttribute(a),this.morphTargetsRelative?(ge.addVectors(Ne.min,Yi.min),Ne.expandByPoint(ge),ge.addVectors(Ne.max,Yi.max),Ne.expandByPoint(ge)):(Ne.expandByPoint(Yi.min),Ne.expandByPoint(Yi.max))}Ne.getCenter(n);let r=0;for(let s=0,o=t.count;s<o;s++)ge.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(ge));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)ge.fromBufferAttribute(a,l),c&&(mi.fromBufferAttribute(t,l),ge.add(mi)),r=Math.max(r,n.distanceToSquared(ge))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,r=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new tn(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let R=0;R<n.count;R++)a[R]=new D,c[R]=new D;const l=new D,u=new D,h=new D,f=new ct,d=new ct,g=new ct,v=new D,m=new D;function p(R,E,_){l.fromBufferAttribute(n,R),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,_),f.fromBufferAttribute(s,R),d.fromBufferAttribute(s,E),g.fromBufferAttribute(s,_),u.sub(l),h.sub(l),d.sub(f),g.sub(f);const w=1/(d.x*g.y-g.x*d.y);isFinite(w)&&(v.copy(u).multiplyScalar(g.y).addScaledVector(h,-d.y).multiplyScalar(w),m.copy(h).multiplyScalar(d.x).addScaledVector(u,-g.x).multiplyScalar(w),a[R].add(v),a[E].add(v),a[_].add(v),c[R].add(m),c[E].add(m),c[_].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let R=0,E=A.length;R<E;++R){const _=A[R],w=_.start,B=_.count;for(let F=w,k=w+B;F<k;F+=3)p(t.getX(F+0),t.getX(F+1),t.getX(F+2))}const y=new D,S=new D,L=new D,P=new D;function C(R){L.fromBufferAttribute(r,R),P.copy(L);const E=a[R];y.copy(E),y.sub(L.multiplyScalar(L.dot(E))).normalize(),S.crossVectors(P,E);const w=S.dot(c[R])<0?-1:1;o.setXYZW(R,y.x,y.y,y.z,w)}for(let R=0,E=A.length;R<E;++R){const _=A[R],w=_.start,B=_.count;for(let F=w,k=w+B;F<k;F+=3)C(t.getX(F+0)),C(t.getX(F+1)),C(t.getX(F+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new tn(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const r=new D,s=new D,o=new D,a=new D,c=new D,l=new D,u=new D,h=new D;if(t)for(let f=0,d=t.count;f<d;f+=3){const g=t.getX(f+0),v=t.getX(f+1),m=t.getX(f+2);r.fromBufferAttribute(e,g),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,m),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),a.add(u),c.add(u),l.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,d=e.count;f<d;f+=3)r.fromBufferAttribute(e,f+0),s.fromBufferAttribute(e,f+1),o.fromBufferAttribute(e,f+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ge.fromBufferAttribute(t,e),ge.normalize(),t.setXYZ(e,ge.x,ge.y,ge.z)}toNonIndexed(){function t(a,c){const l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u);let d=0,g=0;for(let v=0,m=c.length;v<m;v++){a.isInterleavedBufferAttribute?d=c[v]*a.data.stride+a.offset:d=c[v]*u;for(let p=0;p<u;p++)f[g++]=l[d++]}return new tn(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new De,n=this.index.array,r=this.attributes;for(const a in r){const c=r[a],l=t(c,n);e.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){const f=l[u],d=t(f,n);c.push(d)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){const d=l[h];u.push(d.toJSON(t.data))}u.length>0&&(r[c]=u,s=!0)}s&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const r=t.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(e))}const s=t.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f<d;f++)u.push(h[f].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Al=new oe,Fn=new Xu,Ur=new yc,bl=new D,Ir=new D,Nr=new D,Fr=new D,ks=new D,Or=new D,wl=new D,Br=new D;class he extends xe{constructor(t=new De,e=new qn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const a=this.morphTargetInfluences;if(s&&a){Or.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],h=s[c];u!==0&&(ks.fromBufferAttribute(h,t),o?Or.addScaledVector(ks,u):Or.addScaledVector(ks.sub(e),u))}e.add(Or)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ur.copy(n.boundingSphere),Ur.applyMatrix4(s),Fn.copy(t.ray).recast(t.near),!(Ur.containsPoint(Fn.origin)===!1&&(Fn.intersectSphere(Ur,bl)===null||Fn.origin.distanceToSquared(bl)>(t.far-t.near)**2))&&(Al.copy(s).invert(),Fn.copy(t.ray).applyMatrix4(Al),!(n.boundingBox!==null&&Fn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Fn)))}_computeIntersections(t,e,n){let r;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){const m=f[g],p=o[m.materialIndex],A=Math.max(m.start,d.start),y=Math.min(a.count,Math.min(m.start+m.count,d.start+d.count));for(let S=A,L=y;S<L;S+=3){const P=a.getX(S),C=a.getX(S+1),R=a.getX(S+2);r=zr(this,p,t,n,l,u,h,P,C,R),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(a.count,d.start+d.count);for(let m=g,p=v;m<p;m+=3){const A=a.getX(m),y=a.getX(m+1),S=a.getX(m+2);r=zr(this,o,t,n,l,u,h,A,y,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){const m=f[g],p=o[m.materialIndex],A=Math.max(m.start,d.start),y=Math.min(c.count,Math.min(m.start+m.count,d.start+d.count));for(let S=A,L=y;S<L;S+=3){const P=S,C=S+1,R=S+2;r=zr(this,p,t,n,l,u,h,P,C,R),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(c.count,d.start+d.count);for(let m=g,p=v;m<p;m+=3){const A=m,y=m+1,S=m+2;r=zr(this,o,t,n,l,u,h,A,y,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}}}function lp(i,t,e,n,r,s,o,a){let c;if(t.side===Pe?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,t.side===Cn,a),c===null)return null;Br.copy(a),Br.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Br);return l<e.near||l>e.far?null:{distance:l,point:Br.clone(),object:i}}function zr(i,t,e,n,r,s,o,a,c,l){i.getVertexPosition(a,Ir),i.getVertexPosition(c,Nr),i.getVertexPosition(l,Fr);const u=lp(i,t,e,n,Ir,Nr,Fr,wl);if(u){const h=new D;Ye.getBarycoord(wl,Ir,Nr,Fr,h),r&&(u.uv=Ye.getInterpolatedAttribute(r,a,c,l,h,new ct)),s&&(u.uv1=Ye.getInterpolatedAttribute(s,a,c,l,h,new ct)),o&&(u.normal=Ye.getInterpolatedAttribute(o,a,c,l,h,new D),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:c,c:l,normal:new D,materialIndex:0};Ye.getNormal(Ir,Nr,Fr,f.normal),u.face=f,u.barycoord=h}return u}class Jn extends De{constructor(t=1,e=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],u=[],h=[];let f=0,d=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new re(l,3)),this.setAttribute("normal",new re(u,3)),this.setAttribute("uv",new re(h,2));function g(v,m,p,A,y,S,L,P,C,R,E){const _=S/C,w=L/R,B=S/2,F=L/2,k=P/2,X=C+1,G=R+1;let $=0,V=0;const lt=new D;for(let mt=0;mt<G;mt++){const St=mt*w-F;for(let Ot=0;Ot<X;Ot++){const Zt=Ot*_-B;lt[v]=Zt*A,lt[m]=St*y,lt[p]=k,l.push(lt.x,lt.y,lt.z),lt[v]=0,lt[m]=0,lt[p]=P>0?1:-1,u.push(lt.x,lt.y,lt.z),h.push(Ot/C),h.push(1-mt/R),$+=1}}for(let mt=0;mt<R;mt++)for(let St=0;St<C;St++){const Ot=f+St+X*mt,Zt=f+St+X*(mt+1),Y=f+(St+1)+X*(mt+1),ot=f+(St+1)+X*mt;c.push(Ot,Zt,ot),c.push(Zt,Y,ot),V+=6}a.addGroup(d,V,E),d+=V,f+=$}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Oi(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone():Array.isArray(r)?t[e][n]=r.slice():t[e][n]=r}}return t}function be(i){const t={};for(let e=0;e<i.length;e++){const n=Oi(i[e]);for(const r in n)t[r]=n[r]}return t}function up(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Zu(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Jt.workingColorSpace}const hp={clone:Oi,merge:be};var fp=`void main() {
|
|
6
44
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
7
|
-
}`,
|
|
45
|
+
}`,dp=`void main() {
|
|
8
46
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
9
|
-
}`;class
|
|
47
|
+
}`;class Pn extends gr{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=fp,this.fragmentShader=dp,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Oi(t.uniforms),this.uniformsGroups=up(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}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?e.uniforms[r]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[r]={type:"m4",value:o.toArray()}:e.uniforms[r]={value:o}}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 r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class $u extends xe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new oe,this.projectionMatrix=new oe,this.projectionMatrixInverse=new oe,this.coordinateSystem=pn}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 En=new D,Rl=new ct,Cl=new ct;class Fe extends $u{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,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=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=or*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ji*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return or*2*Math.atan(Math.tan(ji*.5*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){En.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(En.x,En.y).multiplyScalar(-t/En.z),En.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(En.x,En.y).multiplyScalar(-t/En.z)}getViewSize(t,e){return this.getViewBounds(t,Rl,Cl),e.subVectors(Cl,Rl)}setViewOffset(t,e,n,r,s,o){this.aspect=t/e,this.view===null&&(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=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ji*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,e-=o.offsetY*n/l,r*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,e,e-n,t,this.far,this.coordinateSystem),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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const gi=-90,_i=1;class pp extends xe{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Fe(gi,_i,t,e);r.layers=this.layers,this.add(r);const s=new Fe(gi,_i,t,e);s.layers=this.layers,this.add(s);const o=new Fe(gi,_i,t,e);o.layers=this.layers,this.add(o);const a=new Fe(gi,_i,t,e);a.layers=this.layers,this.add(a);const c=new Fe(gi,_i,t,e);c.layers=this.layers,this.add(c);const l=new Fe(gi,_i,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,r,s,o,a,c]=e;for(const l of e)this.remove(l);if(t===pn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===ss)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,c,l,u]=this.children,h=t.getRenderTarget(),f=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,r),t.render(e,s),t.setRenderTarget(n,1,r),t.render(e,o),t.setRenderTarget(n,2,r),t.render(e,a),t.setRenderTarget(n,3,r),t.render(e,c),t.setRenderTarget(n,4,r),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,r),t.render(e,u),t.setRenderTarget(h,f,d),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Ju extends ye{constructor(t,e,n,r,s,o,a,c,l,u){t=t!==void 0?t:[],e=e!==void 0?e:Li,super(t,e,n,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class mp extends $n{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new Ju(r,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Qe}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:`
|
|
10
48
|
|
|
11
49
|
varying vec3 vWorldDirection;
|
|
12
50
|
|
|
@@ -41,13 +79,13 @@ var Vu=Object.defineProperty;var Wu=(i,t,e)=>t in i?Vu(i,t,{enumerable:!0,config
|
|
|
41
79
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
42
80
|
|
|
43
81
|
}
|
|
44
|
-
`},r=new Zn(5,5,5),s=new wn({name:"CubemapFromEquirect",uniforms:Li(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ce,blending:En});s.uniforms.tEquirect.value=e;const o=new le(r,s),a=e.minFilter;return e.minFilter===Gn&&(e.minFilter=Je),new Af(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,r){const s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,r);t.setRenderTarget(s)}}class Wa{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Wt(t),this.near=e,this.far=n}clone(){return new Wa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class wf extends ve{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 $e,this.environmentIntensity=1,this.environmentRotation=new $e,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(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),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const As=new P,Rf=new P,Cf=new zt;class xn{constructor(t=new P(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,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=As.subVectors(n,e).cross(Rf.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(As),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}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||Cf.getNormalMatrix(t),r=this.coplanarPoint(As).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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 Un=new Ga,Rr=new P;class Xa{constructor(t=new xn,e=new xn,n=new xn,r=new xn,s=new xn,o=new xn){this.planes=[t,e,n,r,s,o]}set(t,e,n,r,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),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=un){const n=this.planes,r=t.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],f=r[7],d=r[8],g=r[9],v=r[10],m=r[11],p=r[12],b=r[13],T=r[14],S=r[15];if(n[0].setComponents(c-s,f-l,m-d,S-p).normalize(),n[1].setComponents(c+s,f+l,m+d,S+p).normalize(),n[2].setComponents(c+o,f+u,m+g,S+b).normalize(),n[3].setComponents(c-o,f-u,m-g,S-b).normalize(),n[4].setComponents(c-a,f-h,m-v,S-T).normalize(),e===un)n[5].setComponents(c+a,f+h,m+v,S+T).normalize();else if(e===Wr)n[5].setComponents(a,h,v,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Un.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Un.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Un)}intersectsSprite(t){return Un.center.set(0,0,0),Un.radius=.7071067811865476,Un.applyMatrix4(t.matrixWorld),this.intersectsSphere(Un)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(Rr.x=r.normal.x>0?t.max.x:t.min.x,Rr.y=r.normal.y>0?t.max.y:t.min.y,Rr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Rr)<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)}}class Wn extends ve{constructor(){super(),this.isGroup=!0,this.type="Group"}}class su extends ye{constructor(t,e,n,r,s,o,a,c,l){super(t,e,n,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ou extends ye{constructor(t,e,n,r,s,o,a,c,l,u=Si){if(u!==Si&&u!==Ci)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Si&&(n=qn),n===void 0&&u===Ci&&(n=Ri),super(null,r,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Xe,this.minFilter=c!==void 0?c:Xe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class Qe{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}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,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let r=0;const s=n.length;let o;e?o=e:o=t*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=n[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===o)return r/(s-1);const u=n[r],f=n[r+1]-u,d=(o-u)/f;return(r+d)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),c=e||(o.isVector2?new at:new P);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new P,r=[],s=[],o=[],a=new P,c=new re;for(let d=0;d<=t;d++){const g=d/t;r[d]=this.getTangentAt(g,new P)}s[0]=new P,o[0]=new P;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),f=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let d=1;d<=t;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(Gt(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(a,g))}o[d].crossVectors(r[d],s[d])}if(e===!0){let d=Math.acos(Gt(s[0].dot(s[t]),-1,1));d/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(d=-d);for(let g=1;g<=t;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],d*g)),o[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class qa extends Qe{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(t,e=new at){const n=e,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const a=this.aStartAngle+t*s;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*u-d*h+this.aX,l=f*h+d*u+this.aY}return n.set(c,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 Pf extends qa{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Ya(){let i=0,t=0,e=0,n=0;function r(s,o,a,c){i=s,t=a,e=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let f=(o-s)/l-(a-s)/(l+u)+(a-o)/u,d=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,d*=u,r(o,a,f,d)},calc:function(s){const o=s*s,a=o*s;return i+t*s+e*o+n*a}}}const Cr=new P,bs=new Ya,ws=new Ya,Rs=new Ya;class Lf extends Qe{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new P){const n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(Cr.subVectors(r[0],r[1]).add(r[0]),l=Cr);const h=r[a%s],f=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Cr.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Cr),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(h),d),v=Math.pow(h.distanceToSquared(f),d),m=Math.pow(f.distanceToSquared(u),d);v<1e-4&&(v=1),g<1e-4&&(g=v),m<1e-4&&(m=v),bs.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,g,v,m),ws.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,g,v,m),Rs.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,g,v,m)}else this.curveType==="catmullrom"&&(bs.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),ws.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),Rs.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(bs.calc(c),ws.calc(c),Rs.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.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 r=this.points[e];t.points.push(r.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 r=t.points[e];this.points.push(new P().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Wc(i,t,e,n,r){const s=(n-t)*.5,o=(r-e)*.5,a=i*i,c=i*a;return(2*e-2*n+s+o)*c+(-3*e+3*n-2*s-o)*a+s*i+e}function Df(i,t){const e=1-i;return e*e*t}function Uf(i,t){return 2*(1-i)*i*t}function If(i,t){return i*i*t}function qi(i,t,e,n){return Df(i,t)+Uf(i,e)+If(i,n)}function Nf(i,t){const e=1-i;return e*e*e*t}function Ff(i,t){const e=1-i;return 3*e*e*i*t}function Of(i,t){return 3*(1-i)*i*i*t}function Bf(i,t){return i*i*i*t}function Yi(i,t,e,n,r){return Nf(i,t)+Ff(i,e)+Of(i,n)+Bf(i,r)}class au extends Qe{constructor(t=new at,e=new at,n=new at,r=new at){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new at){const n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Yi(t,r.x,s.x,o.x,a.x),Yi(t,r.y,s.y,o.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 zf extends Qe{constructor(t=new P,e=new P,n=new P,r=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new P){const n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Yi(t,r.x,s.x,o.x,a.x),Yi(t,r.y,s.y,o.y,a.y),Yi(t,r.z,s.z,o.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 cu extends Qe{constructor(t=new at,e=new at){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new at){const n=e;return t===1?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 at){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 Hf extends Qe{constructor(t=new P,e=new P){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new P){const n=e;return t===1?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 P){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 lu extends Qe{constructor(t=new at,e=new at,n=new at){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new at){const n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(qi(t,r.x,s.x,o.x),qi(t,r.y,s.y,o.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 kf extends Qe{constructor(t=new P,e=new P,n=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new P){const n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(qi(t,r.x,s.x,o.x),qi(t,r.y,s.y,o.y),qi(t,r.z,s.z,o.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 uu extends Qe{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new at){const n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(Wc(a,c.x,l.x,u.x,h.x),Wc(a,c.y,l.y,u.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(new at().fromArray(r))}return this}}var wo=Object.freeze({__proto__:null,ArcCurve:Pf,CatmullRomCurve3:Lf,CubicBezierCurve:au,CubicBezierCurve3:zf,EllipseCurve:qa,LineCurve:cu,LineCurve3:Hf,QuadraticBezierCurve:lu,QuadraticBezierCurve3:kf,SplineCurve:uu});class Gf extends Qe{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=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new wo[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const o=r[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,e)}s++}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,r=this.curves.length;n<r;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 r=0,s=this.curves;r<s.length;r++){const o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(e.push(u),n=u)}}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 r=t.curves[e];this.curves.push(r.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 r=this.curves[e];t.curves.push(r.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 r=t.curves[e];this.curves.push(new wo[r.type]().fromJSON(r))}return this}}class Xc extends Gf{constructor(t){super(),this.type="Path",this.currentPoint=new at,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 cu(this.currentPoint.clone(),new at(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){const s=new lu(this.currentPoint.clone(),new at(t,e),new at(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){const a=new au(this.currentPoint.clone(),new at(t,e),new at(n,r),new at(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new uu(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(t+a,e+c,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+l,e+u,n,r,s,o,a,c),this}absellipse(t,e,n,r,s,o,a,c){const l=new qa(t,e,n,r,s,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),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 Xr extends Pe{constructor(t=1,e=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const s=[],o=[],a=[],c=[],l=new P,u=new at;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=e;h++,f+=3){const d=n+h/e*r;l.x=t*Math.cos(d),l.y=t*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/t+1)/2,u.y=(o[f+1]/t+1)/2,c.push(u.x,u.y)}for(let h=1;h<=e;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new ne(o,3)),this.setAttribute("normal",new ne(a,3)),this.setAttribute("uv",new ne(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xr(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Za extends Pe{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],f=[],d=[];let g=0;const v=[],m=n/2;let p=0;b(),o===!1&&(t>0&&T(!0),e>0&&T(!1)),this.setIndex(u),this.setAttribute("position",new ne(h,3)),this.setAttribute("normal",new ne(f,3)),this.setAttribute("uv",new ne(d,2));function b(){const S=new P,L=new P;let C=0;const R=(e-t)/n;for(let D=0;D<=s;D++){const y=[],M=D/s,w=M*(e-t)+t;for(let H=0;H<=r;H++){const O=H/r,V=O*c+a,X=Math.sin(V),G=Math.cos(V);L.x=w*X,L.y=-M*n+m,L.z=w*G,h.push(L.x,L.y,L.z),S.set(X,R,G).normalize(),f.push(S.x,S.y,S.z),d.push(O,1-M),y.push(g++)}v.push(y)}for(let D=0;D<r;D++)for(let y=0;y<s;y++){const M=v[y][D],w=v[y+1][D],H=v[y+1][D+1],O=v[y][D+1];(t>0||y!==0)&&(u.push(M,w,O),C+=3),(e>0||y!==s-1)&&(u.push(w,H,O),C+=3)}l.addGroup(p,C,0),p+=C}function T(S){const L=g,C=new at,R=new P;let D=0;const y=S===!0?t:e,M=S===!0?1:-1;for(let H=1;H<=r;H++)h.push(0,m*M,0),f.push(0,M,0),d.push(.5,.5),g++;const w=g;for(let H=0;H<=r;H++){const V=H/r*c+a,X=Math.cos(V),G=Math.sin(V);R.x=y*G,R.y=m*M,R.z=y*X,h.push(R.x,R.y,R.z),f.push(0,M,0),C.x=X*.5+.5,C.y=G*.5*M+.5,d.push(C.x,C.y),g++}for(let H=0;H<r;H++){const O=L+H,V=w+H;S===!0?u.push(V,V+1,O):u.push(V+1,V,O),D+=3}l.addGroup(p,D,S===!0?1:2),p+=D}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Za(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ja extends Xc{constructor(t){super(t),this.uuid=Kn(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n<r;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 r=t.holes[e];this.holes.push(r.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 r=this.holes[e];t.holes.push(r.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 r=t.holes[e];this.holes.push(new Xc().fromJSON(r))}return this}}const Vf={triangulate:function(i,t,e=2){const n=t&&t.length,r=n?t[0]*e:i.length;let s=hu(i,0,r,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,f,d;if(n&&(s=Zf(i,t,s,e)),i.length>80*e){a=l=i[0],c=u=i[1];for(let g=e;g<r;g+=e)h=i[g],f=i[g+1],h<a&&(a=h),f<c&&(c=f),h>l&&(l=h),f>u&&(u=f);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return Qi(s,o,e,a,c,d,0),o}};function hu(i,t,e,n,r){let s,o;if(r===sd(i,t,e,n)>0)for(s=t;s<e;s+=n)o=qc(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=qc(s,i[s],i[s+1],o);return o&&Kr(o,o.next)&&(er(o),o=o.next),o}function Jn(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(Kr(e,e.next)||oe(e.prev,e,e.next)===0)){if(er(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Qi(i,t,e,n,r,s,o){if(!i)return;!o&&s&&Qf(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?Xf(i,n,r,s):Wf(i)){t.push(c.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),er(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=qf(Jn(i),t,e),Qi(i,t,e,n,r,s,2)):o===2&&Yf(i,t,e,n,r,s):Qi(Jn(i),t,e,n,r,s,1);break}}}function Wf(i){const t=i.prev,e=i,n=i.next;if(oe(t,e,n)>=0)return!1;const r=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,f=r>s?r>o?r:o:s>o?s:o,d=a>c?a>l?a:l:c>l?c:l;let g=n.next;for(;g!==t;){if(g.x>=u&&g.x<=f&&g.y>=h&&g.y<=d&&_i(r,a,s,c,o,l,g.x,g.y)&&oe(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Xf(i,t,e,n){const r=i.prev,s=i,o=i.next;if(oe(r,s,o)>=0)return!1;const a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,f=o.y,d=a<c?a<l?a:l:c<l?c:l,g=u<h?u<f?u:f:h<f?h:f,v=a>c?a>l?a:l:c>l?c:l,m=u>h?u>f?u:f:h>f?h:f,p=Ro(d,g,t,e,n),b=Ro(v,m,t,e,n);let T=i.prevZ,S=i.nextZ;for(;T&&T.z>=p&&S&&S.z<=b;){if(T.x>=d&&T.x<=v&&T.y>=g&&T.y<=m&&T!==r&&T!==o&&_i(a,u,c,h,l,f,T.x,T.y)&&oe(T.prev,T,T.next)>=0||(T=T.prevZ,S.x>=d&&S.x<=v&&S.y>=g&&S.y<=m&&S!==r&&S!==o&&_i(a,u,c,h,l,f,S.x,S.y)&&oe(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;T&&T.z>=p;){if(T.x>=d&&T.x<=v&&T.y>=g&&T.y<=m&&T!==r&&T!==o&&_i(a,u,c,h,l,f,T.x,T.y)&&oe(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;S&&S.z<=b;){if(S.x>=d&&S.x<=v&&S.y>=g&&S.y<=m&&S!==r&&S!==o&&_i(a,u,c,h,l,f,S.x,S.y)&&oe(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function qf(i,t,e){let n=i;do{const r=n.prev,s=n.next.next;!Kr(r,s)&&fu(r,n,n.next,s)&&tr(r,s)&&tr(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),er(n),er(n.next),n=i=s),n=n.next}while(n!==i);return Jn(n)}function Yf(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&nd(o,a)){let c=du(o,a);o=Jn(o,o.next),c=Jn(c,c.next),Qi(o,t,e,n,r,s,0),Qi(c,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function Zf(i,t,e,n){const r=[];let s,o,a,c,l;for(s=0,o=t.length;s<o;s++)a=t[s]*n,c=s<o-1?t[s+1]*n:i.length,l=hu(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(ed(l));for(r.sort(Jf),s=0;s<r.length;s++)e=Kf(r[s],e);return e}function Jf(i,t){return i.x-t.x}function Kf(i,t){const e=jf(i,t);if(!e)return t;const n=du(e,i);return Jn(n,n.next),Jn(e,e.next)}function jf(i,t){let e=t,n=-1/0,r;const s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){const f=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=s&&f>n&&(n=f,r=e.x<e.next.x?e:e.next,f===s))return r}e=e.next}while(e!==t);if(!r)return null;const a=r,c=r.x,l=r.y;let u=1/0,h;e=r;do s>=e.x&&e.x>=c&&s!==e.x&&_i(o<l?s:n,o,c,l,o<l?n:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),tr(e,i)&&(h<u||h===u&&(e.x>r.x||e.x===r.x&&$f(r,e)))&&(r=e,u=h)),e=e.next;while(e!==a);return r}function $f(i,t){return oe(i.prev,i,t.prev)<0&&oe(t.next,i,i.next)<0}function Qf(i,t,e,n){let r=i;do r.z===0&&(r.z=Ro(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,td(r)}function td(i){let t,e,n,r,s,o,a,c,l=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<l&&(a++,n=n.nextZ,!!n);t++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,l*=2}while(o>1);return i}function Ro(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function ed(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function _i(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function nd(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!id(i,t)&&(tr(i,t)&&tr(t,i)&&rd(i,t)&&(oe(i.prev,i,t.prev)||oe(i,t.prev,t))||Kr(i,t)&&oe(i.prev,i,i.next)>0&&oe(t.prev,t,t.next)>0)}function oe(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Kr(i,t){return i.x===t.x&&i.y===t.y}function fu(i,t,e,n){const r=Lr(oe(i,t,e)),s=Lr(oe(i,t,n)),o=Lr(oe(e,n,i)),a=Lr(oe(e,n,t));return!!(r!==s&&o!==a||r===0&&Pr(i,e,t)||s===0&&Pr(i,n,t)||o===0&&Pr(e,i,n)||a===0&&Pr(e,t,n))}function Pr(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Lr(i){return i>0?1:i<0?-1:0}function id(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&fu(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function tr(i,t){return oe(i.prev,i,i.next)<0?oe(i,t,i.next)>=0&&oe(i,i.prev,t)>=0:oe(i,t,i.prev)<0||oe(i,i.next,t)<0}function rd(i,t){let e=i,n=!1;const r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function du(i,t){const e=new Co(i.i,i.x,i.y),n=new Co(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function qc(i,t,e,n){const r=new Co(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function er(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Co(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sd(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}class An{static area(t){const e=t.length;let n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return An.area(t)<0}static triangulateShape(t,e){const n=[],r=[],s=[];Yc(t),Zc(n,t);let o=t.length;e.forEach(Yc);for(let c=0;c<e.length;c++)r.push(o),o+=e[c].length,Zc(n,e[c]);const a=Vf.triangulate(n,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}}function Yc(i){const t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function Zc(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}class Ka extends Pe{constructor(t=new Ja([new at(.5,.5),new at(-.5,.5),new at(-.5,-.5),new at(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,r=[],s=[];for(let a=0,c=t.length;a<c;a++){const l=t[a];o(l)}this.setAttribute("position",new ne(r,3)),this.setAttribute("uv",new ne(s,2)),this.computeVertexNormals();function o(a){const c=[],l=e.curveSegments!==void 0?e.curveSegments:12,u=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1;let f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,d=e.bevelThickness!==void 0?e.bevelThickness:.2,g=e.bevelSize!==void 0?e.bevelSize:d-.1,v=e.bevelOffset!==void 0?e.bevelOffset:0,m=e.bevelSegments!==void 0?e.bevelSegments:3;const p=e.extrudePath,b=e.UVGenerator!==void 0?e.UVGenerator:od;let T,S=!1,L,C,R,D;p&&(T=p.getSpacedPoints(u),S=!0,f=!1,L=p.computeFrenetFrames(u,!1),C=new P,R=new P,D=new P),f||(m=0,d=0,g=0,v=0);const y=a.extractPoints(l);let M=y.shape;const w=y.holes;if(!An.isClockWise(M)){M=M.reverse();for(let J=0,et=w.length;J<et;J++){const A=w[J];An.isClockWise(A)&&(w[J]=A.reverse())}}const O=An.triangulateShape(M,w),V=M;for(let J=0,et=w.length;J<et;J++){const A=w[J];M=M.concat(A)}function X(J,et,A){return et||console.error("THREE.ExtrudeGeometry: vec does not exist"),J.clone().addScaledVector(et,A)}const G=M.length,K=O.length;function k(J,et,A){let bt,nt,St;const ot=J.x-et.x,Dt=J.y-et.y,mt=A.x-J.x,E=A.y-J.y,_=ot*ot+Dt*Dt,F=ot*E-Dt*mt;if(Math.abs(F)>Number.EPSILON){const q=Math.sqrt(_),tt=Math.sqrt(mt*mt+E*E),Z=et.x-Dt/q,wt=et.y+ot/q,ht=A.x-E/tt,xt=A.y+mt/tt,Xt=((ht-Z)*E-(xt-wt)*mt)/(ot*E-Dt*mt);bt=Z+ot*Xt-J.x,nt=wt+Dt*Xt-J.y;const rt=bt*bt+nt*nt;if(rt<=2)return new at(bt,nt);St=Math.sqrt(rt/2)}else{let q=!1;ot>Number.EPSILON?mt>Number.EPSILON&&(q=!0):ot<-Number.EPSILON?mt<-Number.EPSILON&&(q=!0):Math.sign(Dt)===Math.sign(E)&&(q=!0),q?(bt=-Dt,nt=ot,St=Math.sqrt(_)):(bt=ot,nt=Dt,St=Math.sqrt(_/2))}return new at(bt/St,nt/St)}const ct=[];for(let J=0,et=V.length,A=et-1,bt=J+1;J<et;J++,A++,bt++)A===et&&(A=0),bt===et&&(bt=0),ct[J]=k(V[J],V[A],V[bt]);const pt=[];let Mt,Ft=ct.concat();for(let J=0,et=w.length;J<et;J++){const A=w[J];Mt=[];for(let bt=0,nt=A.length,St=nt-1,ot=bt+1;bt<nt;bt++,St++,ot++)St===nt&&(St=0),ot===nt&&(ot=0),Mt[bt]=k(A[bt],A[St],A[ot]);pt.push(Mt),Ft=Ft.concat(Mt)}for(let J=0;J<m;J++){const et=J/m,A=d*Math.cos(et*Math.PI/2),bt=g*Math.sin(et*Math.PI/2)+v;for(let nt=0,St=V.length;nt<St;nt++){const ot=X(V[nt],ct[nt],bt);j(ot.x,ot.y,-A)}for(let nt=0,St=w.length;nt<St;nt++){const ot=w[nt];Mt=pt[nt];for(let Dt=0,mt=ot.length;Dt<mt;Dt++){const E=X(ot[Dt],Mt[Dt],bt);j(E.x,E.y,-A)}}}const Zt=g+v;for(let J=0;J<G;J++){const et=f?X(M[J],Ft[J],Zt):M[J];S?(R.copy(L.normals[0]).multiplyScalar(et.x),C.copy(L.binormals[0]).multiplyScalar(et.y),D.copy(T[0]).add(R).add(C),j(D.x,D.y,D.z)):j(et.x,et.y,0)}for(let J=1;J<=u;J++)for(let et=0;et<G;et++){const A=f?X(M[et],Ft[et],Zt):M[et];S?(R.copy(L.normals[J]).multiplyScalar(A.x),C.copy(L.binormals[J]).multiplyScalar(A.y),D.copy(T[J]).add(R).add(C),j(D.x,D.y,D.z)):j(A.x,A.y,h/u*J)}for(let J=m-1;J>=0;J--){const et=J/m,A=d*Math.cos(et*Math.PI/2),bt=g*Math.sin(et*Math.PI/2)+v;for(let nt=0,St=V.length;nt<St;nt++){const ot=X(V[nt],ct[nt],bt);j(ot.x,ot.y,h+A)}for(let nt=0,St=w.length;nt<St;nt++){const ot=w[nt];Mt=pt[nt];for(let Dt=0,mt=ot.length;Dt<mt;Dt++){const E=X(ot[Dt],Mt[Dt],bt);S?j(E.x,E.y+T[u-1].y,T[u-1].x+A):j(E.x,E.y,h+A)}}}Y(),st();function Y(){const J=r.length/3;if(f){let et=0,A=G*et;for(let bt=0;bt<K;bt++){const nt=O[bt];ut(nt[2]+A,nt[1]+A,nt[0]+A)}et=u+m*2,A=G*et;for(let bt=0;bt<K;bt++){const nt=O[bt];ut(nt[0]+A,nt[1]+A,nt[2]+A)}}else{for(let et=0;et<K;et++){const A=O[et];ut(A[2],A[1],A[0])}for(let et=0;et<K;et++){const A=O[et];ut(A[0]+G*u,A[1]+G*u,A[2]+G*u)}}n.addGroup(J,r.length/3-J,0)}function st(){const J=r.length/3;let et=0;Q(V,et),et+=V.length;for(let A=0,bt=w.length;A<bt;A++){const nt=w[A];Q(nt,et),et+=nt.length}n.addGroup(J,r.length/3-J,1)}function Q(J,et){let A=J.length;for(;--A>=0;){const bt=A;let nt=A-1;nt<0&&(nt=J.length-1);for(let St=0,ot=u+m*2;St<ot;St++){const Dt=G*St,mt=G*(St+1),E=et+bt+Dt,_=et+nt+Dt,F=et+nt+mt,q=et+bt+mt;vt(E,_,F,q)}}}function j(J,et,A){c.push(J),c.push(et),c.push(A)}function ut(J,et,A){Rt(J),Rt(et),Rt(A);const bt=r.length/3,nt=b.generateTopUV(n,r,bt-3,bt-2,bt-1);Vt(nt[0]),Vt(nt[1]),Vt(nt[2])}function vt(J,et,A,bt){Rt(J),Rt(et),Rt(bt),Rt(et),Rt(A),Rt(bt);const nt=r.length/3,St=b.generateSideWallUV(n,r,nt-6,nt-3,nt-2,nt-1);Vt(St[0]),Vt(St[1]),Vt(St[3]),Vt(St[1]),Vt(St[2]),Vt(St[3])}function Rt(J){r.push(c[J*3+0]),r.push(c[J*3+1]),r.push(c[J*3+2])}function Vt(J){s.push(J.x),s.push(J.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return ad(e,n,t)}static fromJSON(t,e){const n=[];for(let s=0,o=t.shapes.length;s<o;s++){const a=e[t.shapes[s]];n.push(a)}const r=t.options.extrudePath;return r!==void 0&&(t.options.extrudePath=new wo[r.type]().fromJSON(r)),new Ka(n,t.options)}}const od={generateTopUV:function(i,t,e,n,r){const s=t[e*3],o=t[e*3+1],a=t[n*3],c=t[n*3+1],l=t[r*3],u=t[r*3+1];return[new at(s,o),new at(a,c),new at(l,u)]},generateSideWallUV:function(i,t,e,n,r,s){const o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[n*3],u=t[n*3+1],h=t[n*3+2],f=t[r*3],d=t[r*3+1],g=t[r*3+2],v=t[s*3],m=t[s*3+1],p=t[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new at(o,1-c),new at(l,1-h),new at(f,1-g),new at(v,1-p)]:[new at(a,1-c),new at(u,1-h),new at(d,1-g),new at(m,1-p)]}};function ad(i,t,e){if(e.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];e.shapes.push(s.uuid)}else e.shapes.push(i.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class ar extends Pe{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,o=e/2,a=Math.floor(n),c=Math.floor(r),l=a+1,u=c+1,h=t/a,f=e/c,d=[],g=[],v=[],m=[];for(let p=0;p<u;p++){const b=p*f-o;for(let T=0;T<l;T++){const S=T*h-s;g.push(S,-b,0),v.push(0,0,1),m.push(T/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let b=0;b<a;b++){const T=b+l*p,S=b+l*(p+1),L=b+1+l*(p+1),C=b+1+l*p;d.push(T,S,C),d.push(S,L,C)}this.setIndex(d),this.setAttribute("position",new ne(g,3)),this.setAttribute("normal",new ne(v,3)),this.setAttribute("uv",new ne(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ar(t.width,t.height,t.widthSegments,t.heightSegments)}}class qr extends Pe{constructor(t=.5,e=1,n=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:o},n=Math.max(3,n),r=Math.max(1,r);const a=[],c=[],l=[],u=[];let h=t;const f=(e-t)/r,d=new P,g=new at;for(let v=0;v<=r;v++){for(let m=0;m<=n;m++){const p=s+m/n*o;d.x=h*Math.cos(p),d.y=h*Math.sin(p),c.push(d.x,d.y,d.z),l.push(0,0,1),g.x=(d.x/e+1)/2,g.y=(d.y/e+1)/2,u.push(g.x,g.y)}h+=f}for(let v=0;v<r;v++){const m=v*(n+1);for(let p=0;p<n;p++){const b=p+m,T=b,S=b+n+1,L=b+n+2,C=b+1;a.push(T,S,C),a.push(S,L,C)}}this.setIndex(a),this.setAttribute("position",new ne(c,3)),this.setAttribute("normal",new ne(l,3)),this.setAttribute("uv",new ne(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qr(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class ja extends Pe{constructor(t=new Ja([new at(0,.5),new at(-.5,-.5),new at(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],r=[],s=[],o=[];let a=0,c=0;if(Array.isArray(t)===!1)l(t);else for(let u=0;u<t.length;u++)l(t[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new ne(r,3)),this.setAttribute("normal",new ne(s,3)),this.setAttribute("uv",new ne(o,2));function l(u){const h=r.length/3,f=u.extractPoints(e);let d=f.shape;const g=f.holes;An.isClockWise(d)===!1&&(d=d.reverse());for(let m=0,p=g.length;m<p;m++){const b=g[m];An.isClockWise(b)===!0&&(g[m]=b.reverse())}const v=An.triangulateShape(d,g);for(let m=0,p=g.length;m<p;m++){const b=g[m];d=d.concat(b)}for(let m=0,p=d.length;m<p;m++){const b=d[m];r.push(b.x,b.y,0),s.push(0,0,1),o.push(b.x,b.y)}for(let m=0,p=v.length;m<p;m++){const b=v[m],T=b[0]+h,S=b[1]+h,L=b[2]+h;n.push(T,S,L),c+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return cd(e,t)}static fromJSON(t,e){const n=[];for(let r=0,s=t.shapes.length;r<s;r++){const o=e[t.shapes[r]];n.push(o)}return new ja(n,t.curveSegments)}}function cd(i,t){if(t.shapes=[],Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const r=i[e];t.shapes.push(r.uuid)}else t.shapes.push(i.uuid);return t}class $a extends Pe{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new P,f=new P,d=[],g=[],v=[],m=[];for(let p=0;p<=n;p++){const b=[],T=p/n;let S=0;p===0&&o===0?S=.5/e:p===n&&c===Math.PI&&(S=-.5/e);for(let L=0;L<=e;L++){const C=L/e;h.x=-t*Math.cos(r+C*s)*Math.sin(o+T*a),h.y=t*Math.cos(o+T*a),h.z=t*Math.sin(r+C*s)*Math.sin(o+T*a),g.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),m.push(C+S,1-T),b.push(l++)}u.push(b)}for(let p=0;p<n;p++)for(let b=0;b<e;b++){const T=u[p][b+1],S=u[p][b],L=u[p+1][b],C=u[p+1][b+1];(p!==0||o>0)&&d.push(T,S,C),(p!==n-1||c<Math.PI)&&d.push(S,L,C)}this.setIndex(d),this.setAttribute("position",new ne(g,3)),this.setAttribute("normal",new ne(v,3)),this.setAttribute("uv",new ne(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $a(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Qa extends Pe{constructor(t=1,e=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],c=[],l=[],u=new P,h=new P,f=new P;for(let d=0;d<=n;d++)for(let g=0;g<=r;g++){const v=g/r*s,m=d/n*Math.PI*2;h.x=(t+e*Math.cos(m))*Math.cos(v),h.y=(t+e*Math.cos(m))*Math.sin(v),h.z=e*Math.sin(m),a.push(h.x,h.y,h.z),u.x=t*Math.cos(v),u.y=t*Math.sin(v),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(g/r),l.push(d/n)}for(let d=1;d<=n;d++)for(let g=1;g<=r;g++){const v=(r+1)*d+g-1,m=(r+1)*(d-1)+g-1,p=(r+1)*(d-1)+g,b=(r+1)*d+g;o.push(v,m,b),o.push(m,p,b)}this.setIndex(o),this.setAttribute("position",new ne(a,3)),this.setAttribute("normal",new ne(c,3)),this.setAttribute("uv",new ne(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Qa(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class gi extends or{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Wt(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 Wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yl,this.normalScale=new at(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 $e,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 Jc extends gi{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 at(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Wt(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 Wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Wt(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 ld extends or{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wh,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 ud extends or{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}}const Kc={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class hd{constructor(t,e,n){const r=this;let s=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){const d=l[h],g=l[h+1];if(d.global&&(d.lastIndex=0),d.test(u))return g}return null}}}const fd=new hd;class tc{constructor(t){this.manager=t!==void 0?t:fd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}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}}tc.DEFAULT_MATERIAL_NAME="__DEFAULT";class dd extends tc{constructor(t){super(t)}load(t,e,n,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Kc.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;const a=$i("img");function c(){u(),Kc.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(h){u(),r&&r(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class pd extends tc{constructor(t){super(t)}load(t,e,n,r){const s=new ye,o=new dd(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},n,r),s}}class ec extends ve{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Wt(t),this.intensity=e}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,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class md extends ec{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Wt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Cs=new re,jc=new P,$c=new P;class pu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new at(512,512),this.map=null,this.mapPass=null,this.matrix=new re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Xa,this._frameExtents=new at(1,1),this._viewportCount=1,this._viewports=[new ee(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;jc.setFromMatrixPosition(t.matrixWorld),e.position.copy(jc),$c.setFromMatrixPosition(t.target.matrixWorld),e.lookAt($c),e.updateMatrixWorld(),Cs.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cs),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cs)}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.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Qc=new re,Gi=new P,Ps=new P;class gd extends pu{constructor(){super(new Ie(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new at(4,2),this._viewportCount=6,this._viewports=[new ee(2,1,1,1),new ee(0,1,1,1),new ee(3,1,1,1),new ee(1,1,1,1),new ee(3,0,1,1),new ee(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Gi.setFromMatrixPosition(t.matrixWorld),n.position.copy(Gi),Ps.copy(n.position),Ps.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Ps),n.updateMatrixWorld(),r.makeTranslation(-Gi.x,-Gi.y,-Gi.z),Qc.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Qc)}}class _d extends ec{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new gd}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}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}}class mu extends iu{constructor(t=-1,e=1,n=1,r=-1,s=.1,o=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=r,this.near=s,this.far=o,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=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,s,o){this.view===null&&(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=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(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,r=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=r+e,c=r-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class vd extends pu{constructor(){super(new mu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xd extends ec{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.target=new ve,this.shadow=new vd}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Md extends Ie{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}const tl=new re;class Sd{constructor(t,e,n=0,r=1/0){this.ray=new $l(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new Va,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):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return tl.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(tl),this}intersectObject(t,e=!0,n=[]){return Po(t,this,n,e),n.sort(el),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)Po(t[r],this,n,e);return n.sort(el),n}}function el(i,t){return i.distance-t.distance}function Po(i,t,e,n){let r=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let o=0,a=s.length;o<a;o++)Po(s[o],t,e,!0)}}function nl(i,t,e,n){const r=yd(n);switch(e){case Hl:return i*t;case Gl:return i*t;case Vl:return i*t*2;case Wl:return i*t/r.components*r.byteLength;case Ba:return i*t/r.components*r.byteLength;case Xl:return i*t*2/r.components*r.byteLength;case za:return i*t*2/r.components*r.byteLength;case kl:return i*t*3/r.components*r.byteLength;case We:return i*t*4/r.components*r.byteLength;case Ha:return i*t*4/r.components*r.byteLength;case Nr:case Fr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Or:case Br:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case eo:case io:return Math.max(i,16)*Math.max(t,8)/4;case to:case no:return Math.max(i,8)*Math.max(t,8)/2;case ro:case so:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case oo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ao:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case co:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case lo:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case uo:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case ho:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case fo:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case po:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case mo:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case go:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case _o:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case vo:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case xo:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Mo:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case So:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case zr:case yo:case Eo:return Math.ceil(i/4)*Math.ceil(t/4)*16;case ql:case To:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Ao:case bo:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function yd(i){switch(i){case fn:case Ol:return{byteLength:1,components:1};case Ki:case Bl:case ir:return{byteLength:2,components:1};case Fa:case Oa:return{byteLength:2,components:4};case qn:case Na:case ln:return{byteLength:4,components:1};case zl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ia}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ia);/**
|
|
82
|
+
`},r=new Jn(5,5,5),s=new Pn({name:"CubemapFromEquirect",uniforms:Oi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pe,blending:bn});s.uniforms.tEquirect.value=e;const o=new he(r,s),a=e.minFilter;return e.minFilter===Xn&&(e.minFilter=Qe),new pp(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,r){const s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,r);t.setRenderTarget(s)}}class Ac{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Xt(t),this.near=e,this.far=n}clone(){return new Ac(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class gp extends xe{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 en,this.environmentIntensity=1,this.environmentRotation=new en,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(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),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Vs=new D,_p=new D,vp=new Ht;class yn{constructor(t=new D(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,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Vs.subVectors(n,e).cross(_p.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(Vs),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}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||vp.getNormalMatrix(t),r=this.coplanarPoint(Vs).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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 On=new yc,Hr=new D;class bc{constructor(t=new yn,e=new yn,n=new yn,r=new yn,s=new yn,o=new yn){this.planes=[t,e,n,r,s,o]}set(t,e,n,r,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),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=pn){const n=this.planes,r=t.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],f=r[7],d=r[8],g=r[9],v=r[10],m=r[11],p=r[12],A=r[13],y=r[14],S=r[15];if(n[0].setComponents(c-s,f-l,m-d,S-p).normalize(),n[1].setComponents(c+s,f+l,m+d,S+p).normalize(),n[2].setComponents(c+o,f+u,m+g,S+A).normalize(),n[3].setComponents(c-o,f-u,m-g,S-A).normalize(),n[4].setComponents(c-a,f-h,m-v,S-y).normalize(),e===pn)n[5].setComponents(c+a,f+h,m+v,S+y).normalize();else if(e===ss)n[5].setComponents(a,h,v,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),On.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),On.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(On)}intersectsSprite(t){return On.center.set(0,0,0),On.radius=.7071067811865476,On.applyMatrix4(t.matrixWorld),this.intersectsSphere(On)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(Hr.x=r.normal.x>0?t.max.x:t.min.x,Hr.y=r.normal.y>0?t.max.y:t.min.y,Hr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Hr)<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)}}class Yn extends xe{constructor(){super(),this.isGroup=!0,this.type="Group"}}class ju extends ye{constructor(t,e,n,r,s,o,a,c,l){super(t,e,n,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Qu extends ye{constructor(t,e,n,r,s,o,a,c,l,u=wi){if(u!==wi&&u!==Ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===wi&&(n=Zn),n===void 0&&u===Ni&&(n=Ii),super(null,r,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:$e,this.minFilter=c!==void 0?c:$e,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class rn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}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,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let r=0;const s=n.length;let o;e?o=e:o=t*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=n[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===o)return r/(s-1);const u=n[r],f=n[r+1]-u,d=(o-u)/f;return(r+d)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),c=e||(o.isVector2?new ct:new D);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new D,r=[],s=[],o=[],a=new D,c=new oe;for(let d=0;d<=t;d++){const g=d/t;r[d]=this.getTangentAt(g,new D)}s[0]=new D,o[0]=new D;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),f=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let d=1;d<=t;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(Gt(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(a,g))}o[d].crossVectors(r[d],s[d])}if(e===!0){let d=Math.acos(Gt(s[0].dot(s[t]),-1,1));d/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(d=-d);for(let g=1;g<=t;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],d*g)),o[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class wc extends rn{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(t,e=new ct){const n=e,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const a=this.aStartAngle+t*s;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*u-d*h+this.aX,l=f*h+d*u+this.aY}return n.set(c,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 xp extends wc{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Rc(){let i=0,t=0,e=0,n=0;function r(s,o,a,c){i=s,t=a,e=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let f=(o-s)/l-(a-s)/(l+u)+(a-o)/u,d=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,d*=u,r(o,a,f,d)},calc:function(s){const o=s*s,a=o*s;return i+t*s+e*o+n*a}}}const kr=new D,Gs=new Rc,Ws=new Rc,Xs=new Rc;class Mp extends rn{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new D){const n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(kr.subVectors(r[0],r[1]).add(r[0]),l=kr);const h=r[a%s],f=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(kr.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=kr),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(h),d),v=Math.pow(h.distanceToSquared(f),d),m=Math.pow(f.distanceToSquared(u),d);v<1e-4&&(v=1),g<1e-4&&(g=v),m<1e-4&&(m=v),Gs.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,g,v,m),Ws.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,g,v,m),Xs.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,g,v,m)}else this.curveType==="catmullrom"&&(Gs.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),Ws.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),Xs.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(Gs.calc(c),Ws.calc(c),Xs.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.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 r=this.points[e];t.points.push(r.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 r=t.points[e];this.points.push(new D().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Pl(i,t,e,n,r){const s=(n-t)*.5,o=(r-e)*.5,a=i*i,c=i*a;return(2*e-2*n+s+o)*c+(-3*e+3*n-2*s-o)*a+s*i+e}function Sp(i,t){const e=1-i;return e*e*t}function Ep(i,t){return 2*(1-i)*i*t}function yp(i,t){return i*i*t}function tr(i,t,e,n){return Sp(i,t)+Ep(i,e)+yp(i,n)}function Tp(i,t){const e=1-i;return e*e*e*t}function Ap(i,t){const e=1-i;return 3*e*e*i*t}function bp(i,t){return 3*(1-i)*i*i*t}function wp(i,t){return i*i*i*t}function er(i,t,e,n,r){return Tp(i,t)+Ap(i,e)+bp(i,n)+wp(i,r)}class th extends rn{constructor(t=new ct,e=new ct,n=new ct,r=new ct){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new ct){const n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(er(t,r.x,s.x,o.x,a.x),er(t,r.y,s.y,o.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 Rp extends rn{constructor(t=new D,e=new D,n=new D,r=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new D){const n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(er(t,r.x,s.x,o.x,a.x),er(t,r.y,s.y,o.y,a.y),er(t,r.z,s.z,o.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 eh extends rn{constructor(t=new ct,e=new ct){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ct){const n=e;return t===1?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 ct){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 Cp extends rn{constructor(t=new D,e=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new D){const n=e;return t===1?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 D){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 nh extends rn{constructor(t=new ct,e=new ct,n=new ct){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new ct){const n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(tr(t,r.x,s.x,o.x),tr(t,r.y,s.y,o.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 Pp extends rn{constructor(t=new D,e=new D,n=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new D){const n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(tr(t,r.x,s.x,o.x),tr(t,r.y,s.y,o.y),tr(t,r.z,s.z,o.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 ih extends rn{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ct){const n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(Pl(a,c.x,l.x,u.x,h.x),Pl(a,c.y,l.y,u.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(new ct().fromArray(r))}return this}}var Aa=Object.freeze({__proto__:null,ArcCurve:xp,CatmullRomCurve3:Mp,CubicBezierCurve:th,CubicBezierCurve3:Rp,EllipseCurve:wc,LineCurve:eh,LineCurve3:Cp,QuadraticBezierCurve:nh,QuadraticBezierCurve3:Pp,SplineCurve:ih});class Lp extends rn{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=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Aa[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const o=r[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,e)}s++}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,r=this.curves.length;n<r;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 r=0,s=this.curves;r<s.length;r++){const o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(e.push(u),n=u)}}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 r=t.curves[e];this.curves.push(r.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 r=this.curves[e];t.curves.push(r.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 r=t.curves[e];this.curves.push(new Aa[r.type]().fromJSON(r))}return this}}class Ll extends Lp{constructor(t){super(),this.type="Path",this.currentPoint=new ct,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 eh(this.currentPoint.clone(),new ct(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){const s=new nh(this.currentPoint.clone(),new ct(t,e),new ct(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){const a=new th(this.currentPoint.clone(),new ct(t,e),new ct(n,r),new ct(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new ih(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(t+a,e+c,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+l,e+u,n,r,s,o,a,c),this}absellipse(t,e,n,r,s,o,a,c){const l=new wc(t,e,n,r,s,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),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 os extends De{constructor(t=1,e=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const s=[],o=[],a=[],c=[],l=new D,u=new ct;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=e;h++,f+=3){const d=n+h/e*r;l.x=t*Math.cos(d),l.y=t*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/t+1)/2,u.y=(o[f+1]/t+1)/2,c.push(u.x,u.y)}for(let h=1;h<=e;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new re(o,3)),this.setAttribute("normal",new re(a,3)),this.setAttribute("uv",new re(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new os(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Cc extends De{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],f=[],d=[];let g=0;const v=[],m=n/2;let p=0;A(),o===!1&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new re(h,3)),this.setAttribute("normal",new re(f,3)),this.setAttribute("uv",new re(d,2));function A(){const S=new D,L=new D;let P=0;const C=(e-t)/n;for(let R=0;R<=s;R++){const E=[],_=R/s,w=_*(e-t)+t;for(let B=0;B<=r;B++){const F=B/r,k=F*c+a,X=Math.sin(k),G=Math.cos(k);L.x=w*X,L.y=-_*n+m,L.z=w*G,h.push(L.x,L.y,L.z),S.set(X,C,G).normalize(),f.push(S.x,S.y,S.z),d.push(F,1-_),E.push(g++)}v.push(E)}for(let R=0;R<r;R++)for(let E=0;E<s;E++){const _=v[E][R],w=v[E+1][R],B=v[E+1][R+1],F=v[E][R+1];(t>0||E!==0)&&(u.push(_,w,F),P+=3),(e>0||E!==s-1)&&(u.push(w,B,F),P+=3)}l.addGroup(p,P,0),p+=P}function y(S){const L=g,P=new ct,C=new D;let R=0;const E=S===!0?t:e,_=S===!0?1:-1;for(let B=1;B<=r;B++)h.push(0,m*_,0),f.push(0,_,0),d.push(.5,.5),g++;const w=g;for(let B=0;B<=r;B++){const k=B/r*c+a,X=Math.cos(k),G=Math.sin(k);C.x=E*G,C.y=m*_,C.z=E*X,h.push(C.x,C.y,C.z),f.push(0,_,0),P.x=X*.5+.5,P.y=G*.5*_+.5,d.push(P.x,P.y),g++}for(let B=0;B<r;B++){const F=L+B,k=w+B;S===!0?u.push(k,k+1,F):u.push(k+1,k,F),R+=3}l.addGroup(p,R,S===!0?1:2),p+=R}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Cc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Pc extends Ll{constructor(t){super(t),this.uuid=ni(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n<r;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 r=t.holes[e];this.holes.push(r.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 r=this.holes[e];t.holes.push(r.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 r=t.holes[e];this.holes.push(new Ll().fromJSON(r))}return this}}const Dp={triangulate:function(i,t,e=2){const n=t&&t.length,r=n?t[0]*e:i.length;let s=rh(i,0,r,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,f,d;if(n&&(s=Op(i,t,s,e)),i.length>80*e){a=l=i[0],c=u=i[1];for(let g=e;g<r;g+=e)h=i[g],f=i[g+1],h<a&&(a=h),f<c&&(c=f),h>l&&(l=h),f>u&&(u=f);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return cr(s,o,e,a,c,d,0),o}};function rh(i,t,e,n,r){let s,o;if(r===Kp(i,t,e,n)>0)for(s=t;s<e;s+=n)o=Dl(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=Dl(s,i[s],i[s+1],o);return o&&ps(o,o.next)&&(ur(o),o=o.next),o}function jn(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(ps(e,e.next)||ce(e.prev,e,e.next)===0)){if(ur(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function cr(i,t,e,n,r,s,o){if(!i)return;!o&&s&&Vp(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?Ip(i,n,r,s):Up(i)){t.push(c.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),ur(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=Np(jn(i),t,e),cr(i,t,e,n,r,s,2)):o===2&&Fp(i,t,e,n,r,s):cr(jn(i),t,e,n,r,s,1);break}}}function Up(i){const t=i.prev,e=i,n=i.next;if(ce(t,e,n)>=0)return!1;const r=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,f=r>s?r>o?r:o:s>o?s:o,d=a>c?a>l?a:l:c>l?c:l;let g=n.next;for(;g!==t;){if(g.x>=u&&g.x<=f&&g.y>=h&&g.y<=d&&Ei(r,a,s,c,o,l,g.x,g.y)&&ce(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Ip(i,t,e,n){const r=i.prev,s=i,o=i.next;if(ce(r,s,o)>=0)return!1;const a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,f=o.y,d=a<c?a<l?a:l:c<l?c:l,g=u<h?u<f?u:f:h<f?h:f,v=a>c?a>l?a:l:c>l?c:l,m=u>h?u>f?u:f:h>f?h:f,p=ba(d,g,t,e,n),A=ba(v,m,t,e,n);let y=i.prevZ,S=i.nextZ;for(;y&&y.z>=p&&S&&S.z<=A;){if(y.x>=d&&y.x<=v&&y.y>=g&&y.y<=m&&y!==r&&y!==o&&Ei(a,u,c,h,l,f,y.x,y.y)&&ce(y.prev,y,y.next)>=0||(y=y.prevZ,S.x>=d&&S.x<=v&&S.y>=g&&S.y<=m&&S!==r&&S!==o&&Ei(a,u,c,h,l,f,S.x,S.y)&&ce(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;y&&y.z>=p;){if(y.x>=d&&y.x<=v&&y.y>=g&&y.y<=m&&y!==r&&y!==o&&Ei(a,u,c,h,l,f,y.x,y.y)&&ce(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;S&&S.z<=A;){if(S.x>=d&&S.x<=v&&S.y>=g&&S.y<=m&&S!==r&&S!==o&&Ei(a,u,c,h,l,f,S.x,S.y)&&ce(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function Np(i,t,e){let n=i;do{const r=n.prev,s=n.next.next;!ps(r,s)&&sh(r,n,n.next,s)&&lr(r,s)&&lr(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),ur(n),ur(n.next),n=i=s),n=n.next}while(n!==i);return jn(n)}function Fp(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Xp(o,a)){let c=oh(o,a);o=jn(o,o.next),c=jn(c,c.next),cr(o,t,e,n,r,s,0),cr(c,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function Op(i,t,e,n){const r=[];let s,o,a,c,l;for(s=0,o=t.length;s<o;s++)a=t[s]*n,c=s<o-1?t[s+1]*n:i.length,l=rh(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(Wp(l));for(r.sort(Bp),s=0;s<r.length;s++)e=zp(r[s],e);return e}function Bp(i,t){return i.x-t.x}function zp(i,t){const e=Hp(i,t);if(!e)return t;const n=oh(e,i);return jn(n,n.next),jn(e,e.next)}function Hp(i,t){let e=t,n=-1/0,r;const s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){const f=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=s&&f>n&&(n=f,r=e.x<e.next.x?e:e.next,f===s))return r}e=e.next}while(e!==t);if(!r)return null;const a=r,c=r.x,l=r.y;let u=1/0,h;e=r;do s>=e.x&&e.x>=c&&s!==e.x&&Ei(o<l?s:n,o,c,l,o<l?n:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),lr(e,i)&&(h<u||h===u&&(e.x>r.x||e.x===r.x&&kp(r,e)))&&(r=e,u=h)),e=e.next;while(e!==a);return r}function kp(i,t){return ce(i.prev,i,t.prev)<0&&ce(t.next,i,i.next)<0}function Vp(i,t,e,n){let r=i;do r.z===0&&(r.z=ba(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Gp(r)}function Gp(i){let t,e,n,r,s,o,a,c,l=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<l&&(a++,n=n.nextZ,!!n);t++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,l*=2}while(o>1);return i}function ba(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Wp(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Ei(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function Xp(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!qp(i,t)&&(lr(i,t)&&lr(t,i)&&Yp(i,t)&&(ce(i.prev,i,t.prev)||ce(i,t.prev,t))||ps(i,t)&&ce(i.prev,i,i.next)>0&&ce(t.prev,t,t.next)>0)}function ce(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ps(i,t){return i.x===t.x&&i.y===t.y}function sh(i,t,e,n){const r=Gr(ce(i,t,e)),s=Gr(ce(i,t,n)),o=Gr(ce(e,n,i)),a=Gr(ce(e,n,t));return!!(r!==s&&o!==a||r===0&&Vr(i,e,t)||s===0&&Vr(i,n,t)||o===0&&Vr(e,i,n)||a===0&&Vr(e,t,n))}function Vr(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Gr(i){return i>0?1:i<0?-1:0}function qp(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&sh(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function lr(i,t){return ce(i.prev,i,i.next)<0?ce(i,t,i.next)>=0&&ce(i,i.prev,t)>=0:ce(i,t,i.prev)<0||ce(i,i.next,t)<0}function Yp(i,t){let e=i,n=!1;const r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function oh(i,t){const e=new wa(i.i,i.x,i.y),n=new wa(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function Dl(i,t,e,n){const r=new wa(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ur(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function wa(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Kp(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}class Rn{static area(t){const e=t.length;let n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return Rn.area(t)<0}static triangulateShape(t,e){const n=[],r=[],s=[];Ul(t),Il(n,t);let o=t.length;e.forEach(Ul);for(let c=0;c<e.length;c++)r.push(o),o+=e[c].length,Il(n,e[c]);const a=Dp.triangulate(n,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}}function Ul(i){const t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function Il(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}class Lc extends De{constructor(t=new Pc([new ct(.5,.5),new ct(-.5,.5),new ct(-.5,-.5),new ct(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,r=[],s=[];for(let a=0,c=t.length;a<c;a++){const l=t[a];o(l)}this.setAttribute("position",new re(r,3)),this.setAttribute("uv",new re(s,2)),this.computeVertexNormals();function o(a){const c=[],l=e.curveSegments!==void 0?e.curveSegments:12,u=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1;let f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,d=e.bevelThickness!==void 0?e.bevelThickness:.2,g=e.bevelSize!==void 0?e.bevelSize:d-.1,v=e.bevelOffset!==void 0?e.bevelOffset:0,m=e.bevelSegments!==void 0?e.bevelSegments:3;const p=e.extrudePath,A=e.UVGenerator!==void 0?e.UVGenerator:Zp;let y,S=!1,L,P,C,R;p&&(y=p.getSpacedPoints(u),S=!0,f=!1,L=p.computeFrenetFrames(u,!1),P=new D,C=new D,R=new D),f||(m=0,d=0,g=0,v=0);const E=a.extractPoints(l);let _=E.shape;const w=E.holes;if(!Rn.isClockWise(_)){_=_.reverse();for(let Z=0,et=w.length;Z<et;Z++){const b=w[Z];Rn.isClockWise(b)&&(w[Z]=b.reverse())}}const F=Rn.triangulateShape(_,w),k=_;for(let Z=0,et=w.length;Z<et;Z++){const b=w[Z];_=_.concat(b)}function X(Z,et,b){return et||console.error("THREE.ExtrudeGeometry: vec does not exist"),Z.clone().addScaledVector(et,b)}const G=_.length,$=F.length;function V(Z,et,b){let wt,it,Et;const at=Z.x-et.x,Ut=Z.y-et.y,gt=b.x-Z.x,T=b.y-Z.y,x=at*at+Ut*Ut,O=at*T-Ut*gt;if(Math.abs(O)>Number.EPSILON){const q=Math.sqrt(x),tt=Math.sqrt(gt*gt+T*T),K=et.x-Ut/q,Rt=et.y+at/q,ft=b.x-T/tt,Mt=b.y+gt/tt,qt=((ft-K)*T-(Mt-Rt)*gt)/(at*T-Ut*gt);wt=K+at*qt-Z.x,it=Rt+Ut*qt-Z.y;const st=wt*wt+it*it;if(st<=2)return new ct(wt,it);Et=Math.sqrt(st/2)}else{let q=!1;at>Number.EPSILON?gt>Number.EPSILON&&(q=!0):at<-Number.EPSILON?gt<-Number.EPSILON&&(q=!0):Math.sign(Ut)===Math.sign(T)&&(q=!0),q?(wt=-Ut,it=at,Et=Math.sqrt(x)):(wt=at,it=Ut,Et=Math.sqrt(x/2))}return new ct(wt/Et,it/Et)}const lt=[];for(let Z=0,et=k.length,b=et-1,wt=Z+1;Z<et;Z++,b++,wt++)b===et&&(b=0),wt===et&&(wt=0),lt[Z]=V(k[Z],k[b],k[wt]);const mt=[];let St,Ot=lt.concat();for(let Z=0,et=w.length;Z<et;Z++){const b=w[Z];St=[];for(let wt=0,it=b.length,Et=it-1,at=wt+1;wt<it;wt++,Et++,at++)Et===it&&(Et=0),at===it&&(at=0),St[wt]=V(b[wt],b[Et],b[at]);mt.push(St),Ot=Ot.concat(St)}for(let Z=0;Z<m;Z++){const et=Z/m,b=d*Math.cos(et*Math.PI/2),wt=g*Math.sin(et*Math.PI/2)+v;for(let it=0,Et=k.length;it<Et;it++){const at=X(k[it],lt[it],wt);J(at.x,at.y,-b)}for(let it=0,Et=w.length;it<Et;it++){const at=w[it];St=mt[it];for(let Ut=0,gt=at.length;Ut<gt;Ut++){const T=X(at[Ut],St[Ut],wt);J(T.x,T.y,-b)}}}const Zt=g+v;for(let Z=0;Z<G;Z++){const et=f?X(_[Z],Ot[Z],Zt):_[Z];S?(C.copy(L.normals[0]).multiplyScalar(et.x),P.copy(L.binormals[0]).multiplyScalar(et.y),R.copy(y[0]).add(C).add(P),J(R.x,R.y,R.z)):J(et.x,et.y,0)}for(let Z=1;Z<=u;Z++)for(let et=0;et<G;et++){const b=f?X(_[et],Ot[et],Zt):_[et];S?(C.copy(L.normals[Z]).multiplyScalar(b.x),P.copy(L.binormals[Z]).multiplyScalar(b.y),R.copy(y[Z]).add(C).add(P),J(R.x,R.y,R.z)):J(b.x,b.y,h/u*Z)}for(let Z=m-1;Z>=0;Z--){const et=Z/m,b=d*Math.cos(et*Math.PI/2),wt=g*Math.sin(et*Math.PI/2)+v;for(let it=0,Et=k.length;it<Et;it++){const at=X(k[it],lt[it],wt);J(at.x,at.y,h+b)}for(let it=0,Et=w.length;it<Et;it++){const at=w[it];St=mt[it];for(let Ut=0,gt=at.length;Ut<gt;Ut++){const T=X(at[Ut],St[Ut],wt);S?J(T.x,T.y+y[u-1].y,y[u-1].x+b):J(T.x,T.y,h+b)}}}Y(),ot();function Y(){const Z=r.length/3;if(f){let et=0,b=G*et;for(let wt=0;wt<$;wt++){const it=F[wt];ht(it[2]+b,it[1]+b,it[0]+b)}et=u+m*2,b=G*et;for(let wt=0;wt<$;wt++){const it=F[wt];ht(it[0]+b,it[1]+b,it[2]+b)}}else{for(let et=0;et<$;et++){const b=F[et];ht(b[2],b[1],b[0])}for(let et=0;et<$;et++){const b=F[et];ht(b[0]+G*u,b[1]+G*u,b[2]+G*u)}}n.addGroup(Z,r.length/3-Z,0)}function ot(){const Z=r.length/3;let et=0;Q(k,et),et+=k.length;for(let b=0,wt=w.length;b<wt;b++){const it=w[b];Q(it,et),et+=it.length}n.addGroup(Z,r.length/3-Z,1)}function Q(Z,et){let b=Z.length;for(;--b>=0;){const wt=b;let it=b-1;it<0&&(it=Z.length-1);for(let Et=0,at=u+m*2;Et<at;Et++){const Ut=G*Et,gt=G*(Et+1),T=et+wt+Ut,x=et+it+Ut,O=et+it+gt,q=et+wt+gt;xt(T,x,O,q)}}}function J(Z,et,b){c.push(Z),c.push(et),c.push(b)}function ht(Z,et,b){Ct(Z),Ct(et),Ct(b);const wt=r.length/3,it=A.generateTopUV(n,r,wt-3,wt-2,wt-1);Wt(it[0]),Wt(it[1]),Wt(it[2])}function xt(Z,et,b,wt){Ct(Z),Ct(et),Ct(wt),Ct(et),Ct(b),Ct(wt);const it=r.length/3,Et=A.generateSideWallUV(n,r,it-6,it-3,it-2,it-1);Wt(Et[0]),Wt(Et[1]),Wt(Et[3]),Wt(Et[1]),Wt(Et[2]),Wt(Et[3])}function Ct(Z){r.push(c[Z*3+0]),r.push(c[Z*3+1]),r.push(c[Z*3+2])}function Wt(Z){s.push(Z.x),s.push(Z.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return $p(e,n,t)}static fromJSON(t,e){const n=[];for(let s=0,o=t.shapes.length;s<o;s++){const a=e[t.shapes[s]];n.push(a)}const r=t.options.extrudePath;return r!==void 0&&(t.options.extrudePath=new Aa[r.type]().fromJSON(r)),new Lc(n,t.options)}}const Zp={generateTopUV:function(i,t,e,n,r){const s=t[e*3],o=t[e*3+1],a=t[n*3],c=t[n*3+1],l=t[r*3],u=t[r*3+1];return[new ct(s,o),new ct(a,c),new ct(l,u)]},generateSideWallUV:function(i,t,e,n,r,s){const o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[n*3],u=t[n*3+1],h=t[n*3+2],f=t[r*3],d=t[r*3+1],g=t[r*3+2],v=t[s*3],m=t[s*3+1],p=t[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new ct(o,1-c),new ct(l,1-h),new ct(f,1-g),new ct(v,1-p)]:[new ct(a,1-c),new ct(u,1-h),new ct(d,1-g),new ct(m,1-p)]}};function $p(i,t,e){if(e.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];e.shapes.push(s.uuid)}else e.shapes.push(i.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class _r extends De{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,o=e/2,a=Math.floor(n),c=Math.floor(r),l=a+1,u=c+1,h=t/a,f=e/c,d=[],g=[],v=[],m=[];for(let p=0;p<u;p++){const A=p*f-o;for(let y=0;y<l;y++){const S=y*h-s;g.push(S,-A,0),v.push(0,0,1),m.push(y/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let A=0;A<a;A++){const y=A+l*p,S=A+l*(p+1),L=A+1+l*(p+1),P=A+1+l*p;d.push(y,S,P),d.push(S,L,P)}this.setIndex(d),this.setAttribute("position",new re(g,3)),this.setAttribute("normal",new re(v,3)),this.setAttribute("uv",new re(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new _r(t.width,t.height,t.widthSegments,t.heightSegments)}}class as extends De{constructor(t=.5,e=1,n=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:o},n=Math.max(3,n),r=Math.max(1,r);const a=[],c=[],l=[],u=[];let h=t;const f=(e-t)/r,d=new D,g=new ct;for(let v=0;v<=r;v++){for(let m=0;m<=n;m++){const p=s+m/n*o;d.x=h*Math.cos(p),d.y=h*Math.sin(p),c.push(d.x,d.y,d.z),l.push(0,0,1),g.x=(d.x/e+1)/2,g.y=(d.y/e+1)/2,u.push(g.x,g.y)}h+=f}for(let v=0;v<r;v++){const m=v*(n+1);for(let p=0;p<n;p++){const A=p+m,y=A,S=A+n+1,L=A+n+2,P=A+1;a.push(y,S,P),a.push(S,L,P)}}this.setIndex(a),this.setAttribute("position",new re(c,3)),this.setAttribute("normal",new re(l,3)),this.setAttribute("uv",new re(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new as(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Dc extends De{constructor(t=new Pc([new ct(0,.5),new ct(-.5,-.5),new ct(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],r=[],s=[],o=[];let a=0,c=0;if(Array.isArray(t)===!1)l(t);else for(let u=0;u<t.length;u++)l(t[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new re(r,3)),this.setAttribute("normal",new re(s,3)),this.setAttribute("uv",new re(o,2));function l(u){const h=r.length/3,f=u.extractPoints(e);let d=f.shape;const g=f.holes;Rn.isClockWise(d)===!1&&(d=d.reverse());for(let m=0,p=g.length;m<p;m++){const A=g[m];Rn.isClockWise(A)===!0&&(g[m]=A.reverse())}const v=Rn.triangulateShape(d,g);for(let m=0,p=g.length;m<p;m++){const A=g[m];d=d.concat(A)}for(let m=0,p=d.length;m<p;m++){const A=d[m];r.push(A.x,A.y,0),s.push(0,0,1),o.push(A.x,A.y)}for(let m=0,p=v.length;m<p;m++){const A=v[m],y=A[0]+h,S=A[1]+h,L=A[2]+h;n.push(y,S,L),c+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return Jp(e,t)}static fromJSON(t,e){const n=[];for(let r=0,s=t.shapes.length;r<s;r++){const o=e[t.shapes[r]];n.push(o)}return new Dc(n,t.curveSegments)}}function Jp(i,t){if(t.shapes=[],Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const r=i[e];t.shapes.push(r.uuid)}else t.shapes.push(i.uuid);return t}class Uc extends De{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new D,f=new D,d=[],g=[],v=[],m=[];for(let p=0;p<=n;p++){const A=[],y=p/n;let S=0;p===0&&o===0?S=.5/e:p===n&&c===Math.PI&&(S=-.5/e);for(let L=0;L<=e;L++){const P=L/e;h.x=-t*Math.cos(r+P*s)*Math.sin(o+y*a),h.y=t*Math.cos(o+y*a),h.z=t*Math.sin(r+P*s)*Math.sin(o+y*a),g.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),m.push(P+S,1-y),A.push(l++)}u.push(A)}for(let p=0;p<n;p++)for(let A=0;A<e;A++){const y=u[p][A+1],S=u[p][A],L=u[p+1][A],P=u[p+1][A+1];(p!==0||o>0)&&d.push(y,S,P),(p!==n-1||c<Math.PI)&&d.push(S,L,P)}this.setIndex(d),this.setAttribute("position",new re(g,3)),this.setAttribute("normal",new re(v,3)),this.setAttribute("uv",new re(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Uc(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Ic extends De{constructor(t=1,e=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],c=[],l=[],u=new D,h=new D,f=new D;for(let d=0;d<=n;d++)for(let g=0;g<=r;g++){const v=g/r*s,m=d/n*Math.PI*2;h.x=(t+e*Math.cos(m))*Math.cos(v),h.y=(t+e*Math.cos(m))*Math.sin(v),h.z=e*Math.sin(m),a.push(h.x,h.y,h.z),u.x=t*Math.cos(v),u.y=t*Math.sin(v),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(g/r),l.push(d/n)}for(let d=1;d<=n;d++)for(let g=1;g<=r;g++){const v=(r+1)*d+g-1,m=(r+1)*(d-1)+g-1,p=(r+1)*(d-1)+g,A=(r+1)*d+g;o.push(v,m,A),o.push(m,p,A)}this.setIndex(o),this.setAttribute("position",new re(a,3)),this.setAttribute("normal",new re(c,3)),this.setAttribute("uv",new re(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ic(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Si extends gr{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Xt(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 Xt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hu,this.normalScale=new ct(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 en,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 Nl extends Si{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 ct(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Xt(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 Xt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Xt(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 jp extends gr{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_d,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 Qp extends gr{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}}const Fl={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class tm{constructor(t,e,n){const r=this;let s=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){const d=l[h],g=l[h+1];if(d.global&&(d.lastIndex=0),d.test(u))return g}return null}}}const em=new tm;class Nc{constructor(t){this.manager=t!==void 0?t:em,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}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}}Nc.DEFAULT_MATERIAL_NAME="__DEFAULT";class nm extends Nc{constructor(t){super(t)}load(t,e,n,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Fl.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;const a=ar("img");function c(){u(),Fl.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(h){u(),r&&r(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class im extends Nc{constructor(t){super(t)}load(t,e,n,r){const s=new ye,o=new nm(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},n,r),s}}class Fc extends xe{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Xt(t),this.intensity=e}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,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class rm extends Fc{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(xe.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Xt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const qs=new oe,Ol=new D,Bl=new D;class ah{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ct(512,512),this.map=null,this.mapPass=null,this.matrix=new oe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new bc,this._frameExtents=new ct(1,1),this._viewportCount=1,this._viewports=[new ie(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Ol.setFromMatrixPosition(t.matrixWorld),e.position.copy(Ol),Bl.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Bl),e.updateMatrixWorld(),qs.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(qs),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(qs)}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.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const zl=new oe,Ki=new D,Ys=new D;class sm extends ah{constructor(){super(new Fe(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ct(4,2),this._viewportCount=6,this._viewports=[new ie(2,1,1,1),new ie(0,1,1,1),new ie(3,1,1,1),new ie(1,1,1,1),new ie(3,0,1,1),new ie(1,0,1,1)],this._cubeDirections=[new D(1,0,0),new D(-1,0,0),new D(0,0,1),new D(0,0,-1),new D(0,1,0),new D(0,-1,0)],this._cubeUps=[new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,0,1),new D(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ki.setFromMatrixPosition(t.matrixWorld),n.position.copy(Ki),Ys.copy(n.position),Ys.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Ys),n.updateMatrixWorld(),r.makeTranslation(-Ki.x,-Ki.y,-Ki.z),zl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zl)}}class om extends Fc{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new sm}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}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}}class ch extends $u{constructor(t=-1,e=1,n=1,r=-1,s=.1,o=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=r,this.near=s,this.far=o,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=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,s,o){this.view===null&&(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=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(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,r=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=r+e,c=r-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class am extends ah{constructor(){super(new ch(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class cm extends Fc{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(xe.DEFAULT_UP),this.updateMatrix(),this.target=new xe,this.shadow=new am}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class lm extends Fe{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}const Hl=new oe;class um{constructor(t,e,n=0,r=1/0){this.ray=new Xu(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new Tc,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):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Hl.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Hl),this}intersectObject(t,e=!0,n=[]){return Ra(t,this,n,e),n.sort(kl),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)Ra(t[r],this,n,e);return n.sort(kl),n}}function kl(i,t){return i.distance-t.distance}function Ra(i,t,e,n){let r=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let o=0,a=s.length;o<a;o++)Ra(s[o],t,e,!0)}}function Vl(i,t,e,n){const r=hm(n);switch(e){case Uu:return i*t;case Nu:return i*t;case Fu:return i*t*2;case Ou:return i*t/r.components*r.byteLength;case xc:return i*t/r.components*r.byteLength;case Bu:return i*t*2/r.components*r.byteLength;case Mc:return i*t*2/r.components*r.byteLength;case Iu:return i*t*3/r.components*r.byteLength;case Ke:return i*t*4/r.components*r.byteLength;case Sc:return i*t*4/r.components*r.byteLength;case Kr:case Zr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case $r:case Jr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ta:case na:return Math.max(i,16)*Math.max(t,8)/4;case Qo:case ea:return Math.max(i,8)*Math.max(t,8)/2;case ia:case ra:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case sa:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case oa:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case aa:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case ca:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case la:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case ua:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case ha:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case fa:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case da:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case pa:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case ma:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case ga:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case _a:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case va:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case xa:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case jr:case Ma:case Sa:return Math.ceil(i/4)*Math.ceil(t/4)*16;case zu:case Ea:return Math.ceil(i/4)*Math.ceil(t/4)*8;case ya:case Ta:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function hm(i){switch(i){case gn:case Pu:return{byteLength:1,components:1};case sr:case Lu:case dr:return{byteLength:2,components:1};case _c:case vc:return{byteLength:2,components:4};case Zn:case gc:case dn:return{byteLength:4,components:1};case Du:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:mc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=mc);/**
|
|
45
83
|
* @license
|
|
46
84
|
* Copyright 2010-2024 Three.js Authors
|
|
47
85
|
* SPDX-License-Identifier: MIT
|
|
48
|
-
*/function
|
|
86
|
+
*/function lh(){let i=null,t=!1,e=null,n=null;function r(s,o){e(s,o),n=i.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(r),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function fm(i){const t=new WeakMap;function e(a,c){const l=a.array,u=a.usage,h=l.byteLength,f=i.createBuffer();i.bindBuffer(c,f),i.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=i.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=i.SHORT;else if(l instanceof Uint32Array)d=i.UNSIGNED_INT;else if(l instanceof Int32Array)d=i.INT;else if(l instanceof Int8Array)d=i.BYTE;else if(l instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){const u=c.array,h=c.updateRanges;if(i.bindBuffer(l,a),h.length===0)i.bufferSubData(l,0,u);else{h.sort((d,g)=>d.start-g.start);let f=0;for(let d=1;d<h.length;d++){const g=h[f],v=h[d];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++f,h[f]=v)}h.length=f+1;for(let d=0,g=h.length;d<g;d++){const v=h[d];i.bufferSubData(l,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=t.get(a);c&&(i.deleteBuffer(c.buffer),t.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const u=t.get(a);(!u||u.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const l=t.get(a);if(l===void 0)t.set(a,e(a,c));else if(l.version<a.version){if(l.size!==a.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.");n(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var dm=`#ifdef USE_ALPHAHASH
|
|
49
87
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
50
|
-
#endif`,
|
|
88
|
+
#endif`,pm=`#ifdef USE_ALPHAHASH
|
|
51
89
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
52
90
|
float hash2D( vec2 value ) {
|
|
53
91
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -82,20 +120,20 @@ var Vu=Object.defineProperty;var Wu=(i,t,e)=>t in i?Vu(i,t,{enumerable:!0,config
|
|
|
82
120
|
: cases.z;
|
|
83
121
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
84
122
|
}
|
|
85
|
-
#endif`,
|
|
123
|
+
#endif`,mm=`#ifdef USE_ALPHAMAP
|
|
86
124
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
87
|
-
#endif`,
|
|
125
|
+
#endif`,gm=`#ifdef USE_ALPHAMAP
|
|
88
126
|
uniform sampler2D alphaMap;
|
|
89
|
-
#endif`,
|
|
127
|
+
#endif`,_m=`#ifdef USE_ALPHATEST
|
|
90
128
|
#ifdef ALPHA_TO_COVERAGE
|
|
91
129
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
92
130
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
93
131
|
#else
|
|
94
132
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
95
133
|
#endif
|
|
96
|
-
#endif`,
|
|
134
|
+
#endif`,vm=`#ifdef USE_ALPHATEST
|
|
97
135
|
uniform float alphaTest;
|
|
98
|
-
#endif`,
|
|
136
|
+
#endif`,xm=`#ifdef USE_AOMAP
|
|
99
137
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
100
138
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
101
139
|
#if defined( USE_CLEARCOAT )
|
|
@@ -108,10 +146,10 @@ var Vu=Object.defineProperty;var Wu=(i,t,e)=>t in i?Vu(i,t,{enumerable:!0,config
|
|
|
108
146
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
109
147
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
110
148
|
#endif
|
|
111
|
-
#endif`,
|
|
149
|
+
#endif`,Mm=`#ifdef USE_AOMAP
|
|
112
150
|
uniform sampler2D aoMap;
|
|
113
151
|
uniform float aoMapIntensity;
|
|
114
|
-
#endif`,
|
|
152
|
+
#endif`,Sm=`#ifdef USE_BATCHING
|
|
115
153
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
116
154
|
#define gl_DrawID _gl_DrawID
|
|
117
155
|
uniform int _gl_DrawID;
|
|
@@ -145,15 +183,15 @@ var Vu=Object.defineProperty;var Wu=(i,t,e)=>t in i?Vu(i,t,{enumerable:!0,config
|
|
|
145
183
|
int y = j / size;
|
|
146
184
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
147
185
|
}
|
|
148
|
-
#endif`,
|
|
186
|
+
#endif`,Em=`#ifdef USE_BATCHING
|
|
149
187
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
150
|
-
#endif`,
|
|
188
|
+
#endif`,ym=`vec3 transformed = vec3( position );
|
|
151
189
|
#ifdef USE_ALPHAHASH
|
|
152
190
|
vPosition = vec3( position );
|
|
153
|
-
#endif`,
|
|
191
|
+
#endif`,Tm=`vec3 objectNormal = vec3( normal );
|
|
154
192
|
#ifdef USE_TANGENT
|
|
155
193
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
156
|
-
#endif`,
|
|
194
|
+
#endif`,Am=`float G_BlinnPhong_Implicit( ) {
|
|
157
195
|
return 0.25;
|
|
158
196
|
}
|
|
159
197
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -167,7 +205,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
167
205
|
float G = G_BlinnPhong_Implicit( );
|
|
168
206
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
169
207
|
return F * ( G * D );
|
|
170
|
-
} // validated`,
|
|
208
|
+
} // validated`,bm=`#ifdef USE_IRIDESCENCE
|
|
171
209
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
172
210
|
3.2404542, -0.9692660, 0.0556434,
|
|
173
211
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -230,7 +268,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
230
268
|
}
|
|
231
269
|
return max( I, vec3( 0.0 ) );
|
|
232
270
|
}
|
|
233
|
-
#endif`,
|
|
271
|
+
#endif`,wm=`#ifdef USE_BUMPMAP
|
|
234
272
|
uniform sampler2D bumpMap;
|
|
235
273
|
uniform float bumpScale;
|
|
236
274
|
vec2 dHdxy_fwd() {
|
|
@@ -251,7 +289,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
251
289
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
252
290
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
253
291
|
}
|
|
254
|
-
#endif`,
|
|
292
|
+
#endif`,Rm=`#if NUM_CLIPPING_PLANES > 0
|
|
255
293
|
vec4 plane;
|
|
256
294
|
#ifdef ALPHA_TO_COVERAGE
|
|
257
295
|
float distanceToPlane, distanceGradient;
|
|
@@ -297,26 +335,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
297
335
|
if ( clipped ) discard;
|
|
298
336
|
#endif
|
|
299
337
|
#endif
|
|
300
|
-
#endif`,
|
|
338
|
+
#endif`,Cm=`#if NUM_CLIPPING_PLANES > 0
|
|
301
339
|
varying vec3 vClipPosition;
|
|
302
340
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
303
|
-
#endif`,
|
|
341
|
+
#endif`,Pm=`#if NUM_CLIPPING_PLANES > 0
|
|
304
342
|
varying vec3 vClipPosition;
|
|
305
|
-
#endif`,
|
|
343
|
+
#endif`,Lm=`#if NUM_CLIPPING_PLANES > 0
|
|
306
344
|
vClipPosition = - mvPosition.xyz;
|
|
307
|
-
#endif`,
|
|
345
|
+
#endif`,Dm=`#if defined( USE_COLOR_ALPHA )
|
|
308
346
|
diffuseColor *= vColor;
|
|
309
347
|
#elif defined( USE_COLOR )
|
|
310
348
|
diffuseColor.rgb *= vColor;
|
|
311
|
-
#endif`,
|
|
349
|
+
#endif`,Um=`#if defined( USE_COLOR_ALPHA )
|
|
312
350
|
varying vec4 vColor;
|
|
313
351
|
#elif defined( USE_COLOR )
|
|
314
352
|
varying vec3 vColor;
|
|
315
|
-
#endif`,
|
|
353
|
+
#endif`,Im=`#if defined( USE_COLOR_ALPHA )
|
|
316
354
|
varying vec4 vColor;
|
|
317
355
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
318
356
|
varying vec3 vColor;
|
|
319
|
-
#endif`,
|
|
357
|
+
#endif`,Nm=`#if defined( USE_COLOR_ALPHA )
|
|
320
358
|
vColor = vec4( 1.0 );
|
|
321
359
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
322
360
|
vColor = vec3( 1.0 );
|
|
@@ -330,7 +368,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
330
368
|
#ifdef USE_BATCHING_COLOR
|
|
331
369
|
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
332
370
|
vColor.xyz *= batchingColor.xyz;
|
|
333
|
-
#endif`,
|
|
371
|
+
#endif`,Fm=`#define PI 3.141592653589793
|
|
334
372
|
#define PI2 6.283185307179586
|
|
335
373
|
#define PI_HALF 1.5707963267948966
|
|
336
374
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -404,7 +442,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
404
442
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
405
443
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
406
444
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
407
|
-
} // validated`,
|
|
445
|
+
} // validated`,Om=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
408
446
|
#define cubeUV_minMipLevel 4.0
|
|
409
447
|
#define cubeUV_minTileSize 16.0
|
|
410
448
|
float getFace( vec3 direction ) {
|
|
@@ -497,7 +535,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
497
535
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
498
536
|
}
|
|
499
537
|
}
|
|
500
|
-
#endif`,
|
|
538
|
+
#endif`,Bm=`vec3 transformedNormal = objectNormal;
|
|
501
539
|
#ifdef USE_TANGENT
|
|
502
540
|
vec3 transformedTangent = objectTangent;
|
|
503
541
|
#endif
|
|
@@ -526,21 +564,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
526
564
|
#ifdef FLIP_SIDED
|
|
527
565
|
transformedTangent = - transformedTangent;
|
|
528
566
|
#endif
|
|
529
|
-
#endif`,
|
|
567
|
+
#endif`,zm=`#ifdef USE_DISPLACEMENTMAP
|
|
530
568
|
uniform sampler2D displacementMap;
|
|
531
569
|
uniform float displacementScale;
|
|
532
570
|
uniform float displacementBias;
|
|
533
|
-
#endif`,
|
|
571
|
+
#endif`,Hm=`#ifdef USE_DISPLACEMENTMAP
|
|
534
572
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
535
|
-
#endif
|
|
573
|
+
#endif`,km=`#ifdef USE_EMISSIVEMAP
|
|
536
574
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
537
575
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
538
576
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
539
577
|
#endif
|
|
540
578
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
541
|
-
#endif`,
|
|
579
|
+
#endif`,Vm=`#ifdef USE_EMISSIVEMAP
|
|
542
580
|
uniform sampler2D emissiveMap;
|
|
543
|
-
#endif`,
|
|
581
|
+
#endif`,Gm="gl_FragColor = linearToOutputTexel( gl_FragColor );",Wm=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
544
582
|
return value;
|
|
545
583
|
}
|
|
546
584
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -548,7 +586,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
548
586
|
}
|
|
549
587
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
550
588
|
return 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 );
|
|
551
|
-
}`,
|
|
589
|
+
}`,Xm=`#ifdef USE_ENVMAP
|
|
552
590
|
#ifdef ENV_WORLDPOS
|
|
553
591
|
vec3 cameraToFrag;
|
|
554
592
|
if ( isOrthographic ) {
|
|
@@ -577,7 +615,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
577
615
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
578
616
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
579
617
|
#endif
|
|
580
|
-
#endif`,
|
|
618
|
+
#endif`,qm=`#ifdef USE_ENVMAP
|
|
581
619
|
uniform float envMapIntensity;
|
|
582
620
|
uniform float flipEnvMap;
|
|
583
621
|
uniform mat3 envMapRotation;
|
|
@@ -587,7 +625,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
587
625
|
uniform sampler2D envMap;
|
|
588
626
|
#endif
|
|
589
627
|
|
|
590
|
-
#endif`,
|
|
628
|
+
#endif`,Ym=`#ifdef USE_ENVMAP
|
|
591
629
|
uniform float reflectivity;
|
|
592
630
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
593
631
|
#define ENV_WORLDPOS
|
|
@@ -598,7 +636,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
598
636
|
#else
|
|
599
637
|
varying vec3 vReflect;
|
|
600
638
|
#endif
|
|
601
|
-
#endif`,
|
|
639
|
+
#endif`,Km=`#ifdef USE_ENVMAP
|
|
602
640
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
603
641
|
#define ENV_WORLDPOS
|
|
604
642
|
#endif
|
|
@@ -609,7 +647,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
609
647
|
varying vec3 vReflect;
|
|
610
648
|
uniform float refractionRatio;
|
|
611
649
|
#endif
|
|
612
|
-
#endif`,
|
|
650
|
+
#endif`,Zm=`#ifdef USE_ENVMAP
|
|
613
651
|
#ifdef ENV_WORLDPOS
|
|
614
652
|
vWorldPosition = worldPosition.xyz;
|
|
615
653
|
#else
|
|
@@ -626,18 +664,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
626
664
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
627
665
|
#endif
|
|
628
666
|
#endif
|
|
629
|
-
#endif
|
|
667
|
+
#endif`,$m=`#ifdef USE_FOG
|
|
630
668
|
vFogDepth = - mvPosition.z;
|
|
631
|
-
#endif`,
|
|
669
|
+
#endif`,Jm=`#ifdef USE_FOG
|
|
632
670
|
varying float vFogDepth;
|
|
633
|
-
#endif`,
|
|
671
|
+
#endif`,jm=`#ifdef USE_FOG
|
|
634
672
|
#ifdef FOG_EXP2
|
|
635
673
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
636
674
|
#else
|
|
637
675
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
638
676
|
#endif
|
|
639
677
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
640
|
-
#endif`,
|
|
678
|
+
#endif`,Qm=`#ifdef USE_FOG
|
|
641
679
|
uniform vec3 fogColor;
|
|
642
680
|
varying float vFogDepth;
|
|
643
681
|
#ifdef FOG_EXP2
|
|
@@ -646,7 +684,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
646
684
|
uniform float fogNear;
|
|
647
685
|
uniform float fogFar;
|
|
648
686
|
#endif
|
|
649
|
-
#endif`,
|
|
687
|
+
#endif`,tg=`#ifdef USE_GRADIENTMAP
|
|
650
688
|
uniform sampler2D gradientMap;
|
|
651
689
|
#endif
|
|
652
690
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -658,12 +696,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
658
696
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
659
697
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
660
698
|
#endif
|
|
661
|
-
}`,
|
|
699
|
+
}`,eg=`#ifdef USE_LIGHTMAP
|
|
662
700
|
uniform sampler2D lightMap;
|
|
663
701
|
uniform float lightMapIntensity;
|
|
664
|
-
#endif`,
|
|
702
|
+
#endif`,ng=`LambertMaterial material;
|
|
665
703
|
material.diffuseColor = diffuseColor.rgb;
|
|
666
|
-
material.specularStrength = specularStrength;`,
|
|
704
|
+
material.specularStrength = specularStrength;`,ig=`varying vec3 vViewPosition;
|
|
667
705
|
struct LambertMaterial {
|
|
668
706
|
vec3 diffuseColor;
|
|
669
707
|
float specularStrength;
|
|
@@ -677,7 +715,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
677
715
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
678
716
|
}
|
|
679
717
|
#define RE_Direct RE_Direct_Lambert
|
|
680
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
718
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,rg=`uniform bool receiveShadow;
|
|
681
719
|
uniform vec3 ambientLightColor;
|
|
682
720
|
#if defined( USE_LIGHT_PROBES )
|
|
683
721
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -793,7 +831,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
793
831
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
794
832
|
return irradiance;
|
|
795
833
|
}
|
|
796
|
-
#endif`,
|
|
834
|
+
#endif`,sg=`#ifdef USE_ENVMAP
|
|
797
835
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
798
836
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
799
837
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
@@ -826,8 +864,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
826
864
|
#endif
|
|
827
865
|
}
|
|
828
866
|
#endif
|
|
829
|
-
#endif`,
|
|
830
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
867
|
+
#endif`,og=`ToonMaterial material;
|
|
868
|
+
material.diffuseColor = diffuseColor.rgb;`,ag=`varying vec3 vViewPosition;
|
|
831
869
|
struct ToonMaterial {
|
|
832
870
|
vec3 diffuseColor;
|
|
833
871
|
};
|
|
@@ -839,11 +877,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
839
877
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
840
878
|
}
|
|
841
879
|
#define RE_Direct RE_Direct_Toon
|
|
842
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
880
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,cg=`BlinnPhongMaterial material;
|
|
843
881
|
material.diffuseColor = diffuseColor.rgb;
|
|
844
882
|
material.specularColor = specular;
|
|
845
883
|
material.specularShininess = shininess;
|
|
846
|
-
material.specularStrength = specularStrength;`,
|
|
884
|
+
material.specularStrength = specularStrength;`,lg=`varying vec3 vViewPosition;
|
|
847
885
|
struct BlinnPhongMaterial {
|
|
848
886
|
vec3 diffuseColor;
|
|
849
887
|
vec3 specularColor;
|
|
@@ -860,7 +898,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
860
898
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
861
899
|
}
|
|
862
900
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
863
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
901
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ug=`PhysicalMaterial material;
|
|
864
902
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
865
903
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
866
904
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
@@ -946,7 +984,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
946
984
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
947
985
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
948
986
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
949
|
-
#endif`,
|
|
987
|
+
#endif`,hg=`struct PhysicalMaterial {
|
|
950
988
|
vec3 diffuseColor;
|
|
951
989
|
float roughness;
|
|
952
990
|
vec3 specularColor;
|
|
@@ -1247,7 +1285,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1247
1285
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1248
1286
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1249
1287
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1250
|
-
}`,
|
|
1288
|
+
}`,fg=`
|
|
1251
1289
|
vec3 geometryPosition = - vViewPosition;
|
|
1252
1290
|
vec3 geometryNormal = normal;
|
|
1253
1291
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1362,7 +1400,7 @@ IncidentLight directLight;
|
|
|
1362
1400
|
#if defined( RE_IndirectSpecular )
|
|
1363
1401
|
vec3 radiance = vec3( 0.0 );
|
|
1364
1402
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1365
|
-
#endif`,
|
|
1403
|
+
#endif`,dg=`#if defined( RE_IndirectDiffuse )
|
|
1366
1404
|
#ifdef USE_LIGHTMAP
|
|
1367
1405
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1368
1406
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1381,32 +1419,32 @@ IncidentLight directLight;
|
|
|
1381
1419
|
#ifdef USE_CLEARCOAT
|
|
1382
1420
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1383
1421
|
#endif
|
|
1384
|
-
#endif`,
|
|
1422
|
+
#endif`,pg=`#if defined( RE_IndirectDiffuse )
|
|
1385
1423
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1386
1424
|
#endif
|
|
1387
1425
|
#if defined( RE_IndirectSpecular )
|
|
1388
1426
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1389
|
-
#endif`,
|
|
1427
|
+
#endif`,mg=`#if defined( USE_LOGDEPTHBUF )
|
|
1390
1428
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1391
|
-
#endif`,
|
|
1429
|
+
#endif`,gg=`#if defined( USE_LOGDEPTHBUF )
|
|
1392
1430
|
uniform float logDepthBufFC;
|
|
1393
1431
|
varying float vFragDepth;
|
|
1394
1432
|
varying float vIsPerspective;
|
|
1395
|
-
#endif`,
|
|
1433
|
+
#endif`,_g=`#ifdef USE_LOGDEPTHBUF
|
|
1396
1434
|
varying float vFragDepth;
|
|
1397
1435
|
varying float vIsPerspective;
|
|
1398
|
-
#endif`,
|
|
1436
|
+
#endif`,vg=`#ifdef USE_LOGDEPTHBUF
|
|
1399
1437
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1400
1438
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1401
|
-
#endif`,
|
|
1439
|
+
#endif`,xg=`#ifdef USE_MAP
|
|
1402
1440
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1403
1441
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1404
1442
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1405
1443
|
#endif
|
|
1406
1444
|
diffuseColor *= sampledDiffuseColor;
|
|
1407
|
-
#endif`,
|
|
1445
|
+
#endif`,Mg=`#ifdef USE_MAP
|
|
1408
1446
|
uniform sampler2D map;
|
|
1409
|
-
#endif`,
|
|
1447
|
+
#endif`,Sg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1410
1448
|
#if defined( USE_POINTS_UV )
|
|
1411
1449
|
vec2 uv = vUv;
|
|
1412
1450
|
#else
|
|
@@ -1418,7 +1456,7 @@ IncidentLight directLight;
|
|
|
1418
1456
|
#endif
|
|
1419
1457
|
#ifdef USE_ALPHAMAP
|
|
1420
1458
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1421
|
-
#endif`,
|
|
1459
|
+
#endif`,Eg=`#if defined( USE_POINTS_UV )
|
|
1422
1460
|
varying vec2 vUv;
|
|
1423
1461
|
#else
|
|
1424
1462
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1430,19 +1468,19 @@ IncidentLight directLight;
|
|
|
1430
1468
|
#endif
|
|
1431
1469
|
#ifdef USE_ALPHAMAP
|
|
1432
1470
|
uniform sampler2D alphaMap;
|
|
1433
|
-
#endif`,
|
|
1471
|
+
#endif`,yg=`float metalnessFactor = metalness;
|
|
1434
1472
|
#ifdef USE_METALNESSMAP
|
|
1435
1473
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1436
1474
|
metalnessFactor *= texelMetalness.b;
|
|
1437
|
-
#endif`,
|
|
1475
|
+
#endif`,Tg=`#ifdef USE_METALNESSMAP
|
|
1438
1476
|
uniform sampler2D metalnessMap;
|
|
1439
|
-
#endif`,
|
|
1477
|
+
#endif`,Ag=`#ifdef USE_INSTANCING_MORPH
|
|
1440
1478
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1441
1479
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1442
1480
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1443
1481
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1444
1482
|
}
|
|
1445
|
-
#endif`,
|
|
1483
|
+
#endif`,bg=`#if defined( USE_MORPHCOLORS )
|
|
1446
1484
|
vColor *= morphTargetBaseInfluence;
|
|
1447
1485
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1448
1486
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1451,12 +1489,12 @@ IncidentLight directLight;
|
|
|
1451
1489
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1452
1490
|
#endif
|
|
1453
1491
|
}
|
|
1454
|
-
#endif`,
|
|
1492
|
+
#endif`,wg=`#ifdef USE_MORPHNORMALS
|
|
1455
1493
|
objectNormal *= morphTargetBaseInfluence;
|
|
1456
1494
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1457
1495
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1458
1496
|
}
|
|
1459
|
-
#endif`,
|
|
1497
|
+
#endif`,Rg=`#ifdef USE_MORPHTARGETS
|
|
1460
1498
|
#ifndef USE_INSTANCING_MORPH
|
|
1461
1499
|
uniform float morphTargetBaseInfluence;
|
|
1462
1500
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1470,12 +1508,12 @@ IncidentLight directLight;
|
|
|
1470
1508
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1471
1509
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1472
1510
|
}
|
|
1473
|
-
#endif`,
|
|
1511
|
+
#endif`,Cg=`#ifdef USE_MORPHTARGETS
|
|
1474
1512
|
transformed *= morphTargetBaseInfluence;
|
|
1475
1513
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1476
1514
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1477
1515
|
}
|
|
1478
|
-
#endif`,
|
|
1516
|
+
#endif`,Pg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1479
1517
|
#ifdef FLAT_SHADED
|
|
1480
1518
|
vec3 fdx = dFdx( vViewPosition );
|
|
1481
1519
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1516,7 +1554,7 @@ IncidentLight directLight;
|
|
|
1516
1554
|
tbn2[1] *= faceDirection;
|
|
1517
1555
|
#endif
|
|
1518
1556
|
#endif
|
|
1519
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1557
|
+
vec3 nonPerturbedNormal = normal;`,Lg=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1520
1558
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1521
1559
|
#ifdef FLIP_SIDED
|
|
1522
1560
|
normal = - normal;
|
|
@@ -1531,25 +1569,25 @@ vec3 nonPerturbedNormal = normal;`,Gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1531
1569
|
normal = normalize( tbn * mapN );
|
|
1532
1570
|
#elif defined( USE_BUMPMAP )
|
|
1533
1571
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1534
|
-
#endif`,
|
|
1572
|
+
#endif`,Dg=`#ifndef FLAT_SHADED
|
|
1535
1573
|
varying vec3 vNormal;
|
|
1536
1574
|
#ifdef USE_TANGENT
|
|
1537
1575
|
varying vec3 vTangent;
|
|
1538
1576
|
varying vec3 vBitangent;
|
|
1539
1577
|
#endif
|
|
1540
|
-
#endif`,
|
|
1578
|
+
#endif`,Ug=`#ifndef FLAT_SHADED
|
|
1541
1579
|
varying vec3 vNormal;
|
|
1542
1580
|
#ifdef USE_TANGENT
|
|
1543
1581
|
varying vec3 vTangent;
|
|
1544
1582
|
varying vec3 vBitangent;
|
|
1545
1583
|
#endif
|
|
1546
|
-
#endif`,
|
|
1584
|
+
#endif`,Ig=`#ifndef FLAT_SHADED
|
|
1547
1585
|
vNormal = normalize( transformedNormal );
|
|
1548
1586
|
#ifdef USE_TANGENT
|
|
1549
1587
|
vTangent = normalize( transformedTangent );
|
|
1550
1588
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
1551
1589
|
#endif
|
|
1552
|
-
#endif`,
|
|
1590
|
+
#endif`,Ng=`#ifdef USE_NORMALMAP
|
|
1553
1591
|
uniform sampler2D normalMap;
|
|
1554
1592
|
uniform vec2 normalScale;
|
|
1555
1593
|
#endif
|
|
@@ -1571,13 +1609,13 @@ vec3 nonPerturbedNormal = normal;`,Gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1571
1609
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1572
1610
|
return mat3( T * scale, B * scale, N );
|
|
1573
1611
|
}
|
|
1574
|
-
#endif`,
|
|
1612
|
+
#endif`,Fg=`#ifdef USE_CLEARCOAT
|
|
1575
1613
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1576
|
-
#endif`,
|
|
1614
|
+
#endif`,Og=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1577
1615
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1578
1616
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1579
1617
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1580
|
-
#endif`,
|
|
1618
|
+
#endif`,Bg=`#ifdef USE_CLEARCOATMAP
|
|
1581
1619
|
uniform sampler2D clearcoatMap;
|
|
1582
1620
|
#endif
|
|
1583
1621
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1586,18 +1624,18 @@ vec3 nonPerturbedNormal = normal;`,Gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1586
1624
|
#endif
|
|
1587
1625
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1588
1626
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1589
|
-
#endif`,
|
|
1627
|
+
#endif`,zg=`#ifdef USE_IRIDESCENCEMAP
|
|
1590
1628
|
uniform sampler2D iridescenceMap;
|
|
1591
1629
|
#endif
|
|
1592
1630
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1593
1631
|
uniform sampler2D iridescenceThicknessMap;
|
|
1594
|
-
#endif`,
|
|
1632
|
+
#endif`,Hg=`#ifdef OPAQUE
|
|
1595
1633
|
diffuseColor.a = 1.0;
|
|
1596
1634
|
#endif
|
|
1597
1635
|
#ifdef USE_TRANSMISSION
|
|
1598
1636
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1599
1637
|
#endif
|
|
1600
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a )
|
|
1638
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,kg=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1601
1639
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1602
1640
|
}
|
|
1603
1641
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1666,9 +1704,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
|
|
|
1666
1704
|
}
|
|
1667
1705
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1668
1706
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1669
|
-
}`,
|
|
1707
|
+
}`,Vg=`#ifdef PREMULTIPLIED_ALPHA
|
|
1670
1708
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1671
|
-
#endif`,
|
|
1709
|
+
#endif`,Gg=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1672
1710
|
#ifdef USE_BATCHING
|
|
1673
1711
|
mvPosition = batchingMatrix * mvPosition;
|
|
1674
1712
|
#endif
|
|
@@ -1676,22 +1714,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1676
1714
|
mvPosition = instanceMatrix * mvPosition;
|
|
1677
1715
|
#endif
|
|
1678
1716
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1679
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1717
|
+
gl_Position = projectionMatrix * mvPosition;`,Wg=`#ifdef DITHERING
|
|
1680
1718
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1681
|
-
#endif`,
|
|
1719
|
+
#endif`,Xg=`#ifdef DITHERING
|
|
1682
1720
|
vec3 dithering( vec3 color ) {
|
|
1683
1721
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1684
1722
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1685
1723
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1686
1724
|
return color + dither_shift_RGB;
|
|
1687
1725
|
}
|
|
1688
|
-
#endif`,
|
|
1726
|
+
#endif`,qg=`float roughnessFactor = roughness;
|
|
1689
1727
|
#ifdef USE_ROUGHNESSMAP
|
|
1690
1728
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1691
1729
|
roughnessFactor *= texelRoughness.g;
|
|
1692
|
-
#endif`,
|
|
1730
|
+
#endif`,Yg=`#ifdef USE_ROUGHNESSMAP
|
|
1693
1731
|
uniform sampler2D roughnessMap;
|
|
1694
|
-
#endif`,
|
|
1732
|
+
#endif`,Kg=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1695
1733
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1696
1734
|
#endif
|
|
1697
1735
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -1877,7 +1915,7 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
1877
1915
|
}
|
|
1878
1916
|
return mix( 1.0, shadow, shadowIntensity );
|
|
1879
1917
|
}
|
|
1880
|
-
#endif`,
|
|
1918
|
+
#endif`,Zg=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1881
1919
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
1882
1920
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1883
1921
|
#endif
|
|
@@ -1918,7 +1956,7 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
1918
1956
|
};
|
|
1919
1957
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1920
1958
|
#endif
|
|
1921
|
-
#endif
|
|
1959
|
+
#endif`,$g=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
1922
1960
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
1923
1961
|
vec4 shadowWorldPosition;
|
|
1924
1962
|
#endif
|
|
@@ -1950,7 +1988,7 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
1950
1988
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
1951
1989
|
}
|
|
1952
1990
|
#pragma unroll_loop_end
|
|
1953
|
-
#endif`,
|
|
1991
|
+
#endif`,Jg=`float getShadowMask() {
|
|
1954
1992
|
float shadow = 1.0;
|
|
1955
1993
|
#ifdef USE_SHADOWMAP
|
|
1956
1994
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -1982,12 +2020,12 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
1982
2020
|
#endif
|
|
1983
2021
|
#endif
|
|
1984
2022
|
return shadow;
|
|
1985
|
-
}`,
|
|
2023
|
+
}`,jg=`#ifdef USE_SKINNING
|
|
1986
2024
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
1987
2025
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
1988
2026
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
1989
2027
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
1990
|
-
#endif`,
|
|
2028
|
+
#endif`,Qg=`#ifdef USE_SKINNING
|
|
1991
2029
|
uniform mat4 bindMatrix;
|
|
1992
2030
|
uniform mat4 bindMatrixInverse;
|
|
1993
2031
|
uniform highp sampler2D boneTexture;
|
|
@@ -2002,7 +2040,7 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
2002
2040
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2003
2041
|
return mat4( v1, v2, v3, v4 );
|
|
2004
2042
|
}
|
|
2005
|
-
#endif`,
|
|
2043
|
+
#endif`,t_=`#ifdef USE_SKINNING
|
|
2006
2044
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2007
2045
|
vec4 skinned = vec4( 0.0 );
|
|
2008
2046
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2010,7 +2048,7 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
2010
2048
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2011
2049
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2012
2050
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2013
|
-
#endif`,
|
|
2051
|
+
#endif`,e_=`#ifdef USE_SKINNING
|
|
2014
2052
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2015
2053
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2016
2054
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2021,17 +2059,17 @@ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
|
|
|
2021
2059
|
#ifdef USE_TANGENT
|
|
2022
2060
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2023
2061
|
#endif
|
|
2024
|
-
#endif`,
|
|
2062
|
+
#endif`,n_=`float specularStrength;
|
|
2025
2063
|
#ifdef USE_SPECULARMAP
|
|
2026
2064
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2027
2065
|
specularStrength = texelSpecular.r;
|
|
2028
2066
|
#else
|
|
2029
2067
|
specularStrength = 1.0;
|
|
2030
|
-
#endif`,
|
|
2068
|
+
#endif`,i_=`#ifdef USE_SPECULARMAP
|
|
2031
2069
|
uniform sampler2D specularMap;
|
|
2032
|
-
#endif`,
|
|
2070
|
+
#endif`,r_=`#if defined( TONE_MAPPING )
|
|
2033
2071
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2034
|
-
#endif`,
|
|
2072
|
+
#endif`,s_=`#ifndef saturate
|
|
2035
2073
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2036
2074
|
#endif
|
|
2037
2075
|
uniform float toneMappingExposure;
|
|
@@ -2128,7 +2166,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2128
2166
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2129
2167
|
return mix( color, vec3( newPeak ), g );
|
|
2130
2168
|
}
|
|
2131
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2169
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,o_=`#ifdef USE_TRANSMISSION
|
|
2132
2170
|
material.transmission = transmission;
|
|
2133
2171
|
material.transmissionAlpha = 1.0;
|
|
2134
2172
|
material.thickness = thickness;
|
|
@@ -2149,7 +2187,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISS
|
|
|
2149
2187
|
material.attenuationColor, material.attenuationDistance );
|
|
2150
2188
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2151
2189
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2152
|
-
#endif`,
|
|
2190
|
+
#endif`,a_=`#ifdef USE_TRANSMISSION
|
|
2153
2191
|
uniform float transmission;
|
|
2154
2192
|
uniform float thickness;
|
|
2155
2193
|
uniform float attenuationDistance;
|
|
@@ -2275,7 +2313,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISS
|
|
|
2275
2313
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2276
2314
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2277
2315
|
}
|
|
2278
|
-
#endif`,
|
|
2316
|
+
#endif`,c_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2279
2317
|
varying vec2 vUv;
|
|
2280
2318
|
#endif
|
|
2281
2319
|
#ifdef USE_MAP
|
|
@@ -2345,7 +2383,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISS
|
|
|
2345
2383
|
#ifdef USE_THICKNESSMAP
|
|
2346
2384
|
uniform mat3 thicknessMapTransform;
|
|
2347
2385
|
varying vec2 vThicknessMapUv;
|
|
2348
|
-
#endif`,
|
|
2386
|
+
#endif`,l_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2349
2387
|
varying vec2 vUv;
|
|
2350
2388
|
#endif
|
|
2351
2389
|
#ifdef USE_MAP
|
|
@@ -2439,7 +2477,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISS
|
|
|
2439
2477
|
#ifdef USE_THICKNESSMAP
|
|
2440
2478
|
uniform mat3 thicknessMapTransform;
|
|
2441
2479
|
varying vec2 vThicknessMapUv;
|
|
2442
|
-
#endif`,
|
|
2480
|
+
#endif`,u_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2443
2481
|
vUv = vec3( uv, 1 ).xy;
|
|
2444
2482
|
#endif
|
|
2445
2483
|
#ifdef USE_MAP
|
|
@@ -2510,7 +2548,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISS
|
|
|
2510
2548
|
#endif
|
|
2511
2549
|
#ifdef USE_THICKNESSMAP
|
|
2512
2550
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2513
|
-
#endif`,
|
|
2551
|
+
#endif`,h_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2514
2552
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2515
2553
|
#ifdef USE_BATCHING
|
|
2516
2554
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2519,12 +2557,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISS
|
|
|
2519
2557
|
worldPosition = instanceMatrix * worldPosition;
|
|
2520
2558
|
#endif
|
|
2521
2559
|
worldPosition = modelMatrix * worldPosition;
|
|
2522
|
-
#endif`;const
|
|
2560
|
+
#endif`;const f_=`varying vec2 vUv;
|
|
2523
2561
|
uniform mat3 uvTransform;
|
|
2524
2562
|
void main() {
|
|
2525
2563
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2526
2564
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2527
|
-
}`,
|
|
2565
|
+
}`,d_=`uniform sampler2D t2D;
|
|
2528
2566
|
uniform float backgroundIntensity;
|
|
2529
2567
|
varying vec2 vUv;
|
|
2530
2568
|
void main() {
|
|
@@ -2536,14 +2574,14 @@ void main() {
|
|
|
2536
2574
|
gl_FragColor = texColor;
|
|
2537
2575
|
#include <tonemapping_fragment>
|
|
2538
2576
|
#include <colorspace_fragment>
|
|
2539
|
-
}`,
|
|
2577
|
+
}`,p_=`varying vec3 vWorldDirection;
|
|
2540
2578
|
#include <common>
|
|
2541
2579
|
void main() {
|
|
2542
2580
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2543
2581
|
#include <begin_vertex>
|
|
2544
2582
|
#include <project_vertex>
|
|
2545
2583
|
gl_Position.z = gl_Position.w;
|
|
2546
|
-
}`,
|
|
2584
|
+
}`,m_=`#ifdef ENVMAP_TYPE_CUBE
|
|
2547
2585
|
uniform samplerCube envMap;
|
|
2548
2586
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2549
2587
|
uniform sampler2D envMap;
|
|
@@ -2566,14 +2604,14 @@ void main() {
|
|
|
2566
2604
|
gl_FragColor = texColor;
|
|
2567
2605
|
#include <tonemapping_fragment>
|
|
2568
2606
|
#include <colorspace_fragment>
|
|
2569
|
-
}`,
|
|
2607
|
+
}`,g_=`varying vec3 vWorldDirection;
|
|
2570
2608
|
#include <common>
|
|
2571
2609
|
void main() {
|
|
2572
2610
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2573
2611
|
#include <begin_vertex>
|
|
2574
2612
|
#include <project_vertex>
|
|
2575
2613
|
gl_Position.z = gl_Position.w;
|
|
2576
|
-
}`,
|
|
2614
|
+
}`,__=`uniform samplerCube tCube;
|
|
2577
2615
|
uniform float tFlip;
|
|
2578
2616
|
uniform float opacity;
|
|
2579
2617
|
varying vec3 vWorldDirection;
|
|
@@ -2583,7 +2621,7 @@ void main() {
|
|
|
2583
2621
|
gl_FragColor.a *= opacity;
|
|
2584
2622
|
#include <tonemapping_fragment>
|
|
2585
2623
|
#include <colorspace_fragment>
|
|
2586
|
-
}`,
|
|
2624
|
+
}`,v_=`#include <common>
|
|
2587
2625
|
#include <batching_pars_vertex>
|
|
2588
2626
|
#include <uv_pars_vertex>
|
|
2589
2627
|
#include <displacementmap_pars_vertex>
|
|
@@ -2610,7 +2648,7 @@ void main() {
|
|
|
2610
2648
|
#include <logdepthbuf_vertex>
|
|
2611
2649
|
#include <clipping_planes_vertex>
|
|
2612
2650
|
vHighPrecisionZW = gl_Position.zw;
|
|
2613
|
-
}`,
|
|
2651
|
+
}`,x_=`#if DEPTH_PACKING == 3200
|
|
2614
2652
|
uniform float opacity;
|
|
2615
2653
|
#endif
|
|
2616
2654
|
#include <common>
|
|
@@ -2644,7 +2682,7 @@ void main() {
|
|
|
2644
2682
|
#elif DEPTH_PACKING == 3203
|
|
2645
2683
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2646
2684
|
#endif
|
|
2647
|
-
}`,
|
|
2685
|
+
}`,M_=`#define DISTANCE
|
|
2648
2686
|
varying vec3 vWorldPosition;
|
|
2649
2687
|
#include <common>
|
|
2650
2688
|
#include <batching_pars_vertex>
|
|
@@ -2671,7 +2709,7 @@ void main() {
|
|
|
2671
2709
|
#include <worldpos_vertex>
|
|
2672
2710
|
#include <clipping_planes_vertex>
|
|
2673
2711
|
vWorldPosition = worldPosition.xyz;
|
|
2674
|
-
}`,
|
|
2712
|
+
}`,S_=`#define DISTANCE
|
|
2675
2713
|
uniform vec3 referencePosition;
|
|
2676
2714
|
uniform float nearDistance;
|
|
2677
2715
|
uniform float farDistance;
|
|
@@ -2695,13 +2733,13 @@ void main () {
|
|
|
2695
2733
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2696
2734
|
dist = saturate( dist );
|
|
2697
2735
|
gl_FragColor = packDepthToRGBA( dist );
|
|
2698
|
-
}`,
|
|
2736
|
+
}`,E_=`varying vec3 vWorldDirection;
|
|
2699
2737
|
#include <common>
|
|
2700
2738
|
void main() {
|
|
2701
2739
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2702
2740
|
#include <begin_vertex>
|
|
2703
2741
|
#include <project_vertex>
|
|
2704
|
-
}`,
|
|
2742
|
+
}`,y_=`uniform sampler2D tEquirect;
|
|
2705
2743
|
varying vec3 vWorldDirection;
|
|
2706
2744
|
#include <common>
|
|
2707
2745
|
void main() {
|
|
@@ -2710,7 +2748,7 @@ void main() {
|
|
|
2710
2748
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2711
2749
|
#include <tonemapping_fragment>
|
|
2712
2750
|
#include <colorspace_fragment>
|
|
2713
|
-
}`,
|
|
2751
|
+
}`,T_=`uniform float scale;
|
|
2714
2752
|
attribute float lineDistance;
|
|
2715
2753
|
varying float vLineDistance;
|
|
2716
2754
|
#include <common>
|
|
@@ -2732,7 +2770,7 @@ void main() {
|
|
|
2732
2770
|
#include <logdepthbuf_vertex>
|
|
2733
2771
|
#include <clipping_planes_vertex>
|
|
2734
2772
|
#include <fog_vertex>
|
|
2735
|
-
}`,
|
|
2773
|
+
}`,A_=`uniform vec3 diffuse;
|
|
2736
2774
|
uniform float opacity;
|
|
2737
2775
|
uniform float dashSize;
|
|
2738
2776
|
uniform float totalSize;
|
|
@@ -2760,7 +2798,7 @@ void main() {
|
|
|
2760
2798
|
#include <colorspace_fragment>
|
|
2761
2799
|
#include <fog_fragment>
|
|
2762
2800
|
#include <premultiplied_alpha_fragment>
|
|
2763
|
-
}`,
|
|
2801
|
+
}`,b_=`#include <common>
|
|
2764
2802
|
#include <batching_pars_vertex>
|
|
2765
2803
|
#include <uv_pars_vertex>
|
|
2766
2804
|
#include <envmap_pars_vertex>
|
|
@@ -2792,7 +2830,7 @@ void main() {
|
|
|
2792
2830
|
#include <worldpos_vertex>
|
|
2793
2831
|
#include <envmap_vertex>
|
|
2794
2832
|
#include <fog_vertex>
|
|
2795
|
-
}`,
|
|
2833
|
+
}`,w_=`uniform vec3 diffuse;
|
|
2796
2834
|
uniform float opacity;
|
|
2797
2835
|
#ifndef FLAT_SHADED
|
|
2798
2836
|
varying vec3 vNormal;
|
|
@@ -2840,7 +2878,7 @@ void main() {
|
|
|
2840
2878
|
#include <fog_fragment>
|
|
2841
2879
|
#include <premultiplied_alpha_fragment>
|
|
2842
2880
|
#include <dithering_fragment>
|
|
2843
|
-
}`,
|
|
2881
|
+
}`,R_=`#define LAMBERT
|
|
2844
2882
|
varying vec3 vViewPosition;
|
|
2845
2883
|
#include <common>
|
|
2846
2884
|
#include <batching_pars_vertex>
|
|
@@ -2879,7 +2917,7 @@ void main() {
|
|
|
2879
2917
|
#include <envmap_vertex>
|
|
2880
2918
|
#include <shadowmap_vertex>
|
|
2881
2919
|
#include <fog_vertex>
|
|
2882
|
-
}`,
|
|
2920
|
+
}`,C_=`#define LAMBERT
|
|
2883
2921
|
uniform vec3 diffuse;
|
|
2884
2922
|
uniform vec3 emissive;
|
|
2885
2923
|
uniform float opacity;
|
|
@@ -2936,7 +2974,7 @@ void main() {
|
|
|
2936
2974
|
#include <fog_fragment>
|
|
2937
2975
|
#include <premultiplied_alpha_fragment>
|
|
2938
2976
|
#include <dithering_fragment>
|
|
2939
|
-
}`,
|
|
2977
|
+
}`,P_=`#define MATCAP
|
|
2940
2978
|
varying vec3 vViewPosition;
|
|
2941
2979
|
#include <common>
|
|
2942
2980
|
#include <batching_pars_vertex>
|
|
@@ -2970,7 +3008,7 @@ void main() {
|
|
|
2970
3008
|
#include <clipping_planes_vertex>
|
|
2971
3009
|
#include <fog_vertex>
|
|
2972
3010
|
vViewPosition = - mvPosition.xyz;
|
|
2973
|
-
}`,
|
|
3011
|
+
}`,L_=`#define MATCAP
|
|
2974
3012
|
uniform vec3 diffuse;
|
|
2975
3013
|
uniform float opacity;
|
|
2976
3014
|
uniform sampler2D matcap;
|
|
@@ -3016,7 +3054,7 @@ void main() {
|
|
|
3016
3054
|
#include <fog_fragment>
|
|
3017
3055
|
#include <premultiplied_alpha_fragment>
|
|
3018
3056
|
#include <dithering_fragment>
|
|
3019
|
-
}`,
|
|
3057
|
+
}`,D_=`#define NORMAL
|
|
3020
3058
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3021
3059
|
varying vec3 vViewPosition;
|
|
3022
3060
|
#endif
|
|
@@ -3049,7 +3087,7 @@ void main() {
|
|
|
3049
3087
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3050
3088
|
vViewPosition = - mvPosition.xyz;
|
|
3051
3089
|
#endif
|
|
3052
|
-
}`,
|
|
3090
|
+
}`,U_=`#define NORMAL
|
|
3053
3091
|
uniform float opacity;
|
|
3054
3092
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3055
3093
|
varying vec3 vViewPosition;
|
|
@@ -3071,7 +3109,7 @@ void main() {
|
|
|
3071
3109
|
#ifdef OPAQUE
|
|
3072
3110
|
gl_FragColor.a = 1.0;
|
|
3073
3111
|
#endif
|
|
3074
|
-
}`,
|
|
3112
|
+
}`,I_=`#define PHONG
|
|
3075
3113
|
varying vec3 vViewPosition;
|
|
3076
3114
|
#include <common>
|
|
3077
3115
|
#include <batching_pars_vertex>
|
|
@@ -3110,7 +3148,7 @@ void main() {
|
|
|
3110
3148
|
#include <envmap_vertex>
|
|
3111
3149
|
#include <shadowmap_vertex>
|
|
3112
3150
|
#include <fog_vertex>
|
|
3113
|
-
}`,
|
|
3151
|
+
}`,N_=`#define PHONG
|
|
3114
3152
|
uniform vec3 diffuse;
|
|
3115
3153
|
uniform vec3 emissive;
|
|
3116
3154
|
uniform vec3 specular;
|
|
@@ -3169,7 +3207,7 @@ void main() {
|
|
|
3169
3207
|
#include <fog_fragment>
|
|
3170
3208
|
#include <premultiplied_alpha_fragment>
|
|
3171
3209
|
#include <dithering_fragment>
|
|
3172
|
-
}`,
|
|
3210
|
+
}`,F_=`#define STANDARD
|
|
3173
3211
|
varying vec3 vViewPosition;
|
|
3174
3212
|
#ifdef USE_TRANSMISSION
|
|
3175
3213
|
varying vec3 vWorldPosition;
|
|
@@ -3212,7 +3250,7 @@ void main() {
|
|
|
3212
3250
|
#ifdef USE_TRANSMISSION
|
|
3213
3251
|
vWorldPosition = worldPosition.xyz;
|
|
3214
3252
|
#endif
|
|
3215
|
-
}`,
|
|
3253
|
+
}`,O_=`#define STANDARD
|
|
3216
3254
|
#ifdef PHYSICAL
|
|
3217
3255
|
#define IOR
|
|
3218
3256
|
#define USE_SPECULAR
|
|
@@ -3337,7 +3375,7 @@ void main() {
|
|
|
3337
3375
|
#include <fog_fragment>
|
|
3338
3376
|
#include <premultiplied_alpha_fragment>
|
|
3339
3377
|
#include <dithering_fragment>
|
|
3340
|
-
}`,
|
|
3378
|
+
}`,B_=`#define TOON
|
|
3341
3379
|
varying vec3 vViewPosition;
|
|
3342
3380
|
#include <common>
|
|
3343
3381
|
#include <batching_pars_vertex>
|
|
@@ -3374,7 +3412,7 @@ void main() {
|
|
|
3374
3412
|
#include <worldpos_vertex>
|
|
3375
3413
|
#include <shadowmap_vertex>
|
|
3376
3414
|
#include <fog_vertex>
|
|
3377
|
-
}`,
|
|
3415
|
+
}`,z_=`#define TOON
|
|
3378
3416
|
uniform vec3 diffuse;
|
|
3379
3417
|
uniform vec3 emissive;
|
|
3380
3418
|
uniform float opacity;
|
|
@@ -3427,7 +3465,7 @@ void main() {
|
|
|
3427
3465
|
#include <fog_fragment>
|
|
3428
3466
|
#include <premultiplied_alpha_fragment>
|
|
3429
3467
|
#include <dithering_fragment>
|
|
3430
|
-
}`,
|
|
3468
|
+
}`,H_=`uniform float size;
|
|
3431
3469
|
uniform float scale;
|
|
3432
3470
|
#include <common>
|
|
3433
3471
|
#include <color_pars_vertex>
|
|
@@ -3458,7 +3496,7 @@ void main() {
|
|
|
3458
3496
|
#include <clipping_planes_vertex>
|
|
3459
3497
|
#include <worldpos_vertex>
|
|
3460
3498
|
#include <fog_vertex>
|
|
3461
|
-
}
|
|
3499
|
+
}`,k_=`uniform vec3 diffuse;
|
|
3462
3500
|
uniform float opacity;
|
|
3463
3501
|
#include <common>
|
|
3464
3502
|
#include <color_pars_fragment>
|
|
@@ -3483,7 +3521,7 @@ void main() {
|
|
|
3483
3521
|
#include <colorspace_fragment>
|
|
3484
3522
|
#include <fog_fragment>
|
|
3485
3523
|
#include <premultiplied_alpha_fragment>
|
|
3486
|
-
}`,
|
|
3524
|
+
}`,V_=`#include <common>
|
|
3487
3525
|
#include <batching_pars_vertex>
|
|
3488
3526
|
#include <fog_pars_vertex>
|
|
3489
3527
|
#include <morphtarget_pars_vertex>
|
|
@@ -3506,7 +3544,7 @@ void main() {
|
|
|
3506
3544
|
#include <worldpos_vertex>
|
|
3507
3545
|
#include <shadowmap_vertex>
|
|
3508
3546
|
#include <fog_vertex>
|
|
3509
|
-
}`,
|
|
3547
|
+
}`,G_=`uniform vec3 color;
|
|
3510
3548
|
uniform float opacity;
|
|
3511
3549
|
#include <common>
|
|
3512
3550
|
#include <packing>
|
|
@@ -3522,7 +3560,7 @@ void main() {
|
|
|
3522
3560
|
#include <tonemapping_fragment>
|
|
3523
3561
|
#include <colorspace_fragment>
|
|
3524
3562
|
#include <fog_fragment>
|
|
3525
|
-
}`,
|
|
3563
|
+
}`,W_=`uniform float rotation;
|
|
3526
3564
|
uniform vec2 center;
|
|
3527
3565
|
#include <common>
|
|
3528
3566
|
#include <uv_pars_vertex>
|
|
@@ -3546,7 +3584,7 @@ void main() {
|
|
|
3546
3584
|
#include <logdepthbuf_vertex>
|
|
3547
3585
|
#include <clipping_planes_vertex>
|
|
3548
3586
|
#include <fog_vertex>
|
|
3549
|
-
}`,
|
|
3587
|
+
}`,X_=`uniform vec3 diffuse;
|
|
3550
3588
|
uniform float opacity;
|
|
3551
3589
|
#include <common>
|
|
3552
3590
|
#include <uv_pars_fragment>
|
|
@@ -3571,7 +3609,7 @@ void main() {
|
|
|
3571
3609
|
#include <tonemapping_fragment>
|
|
3572
3610
|
#include <colorspace_fragment>
|
|
3573
3611
|
#include <fog_fragment>
|
|
3574
|
-
}`,kt={alphahash_fragment:Td,alphahash_pars_fragment:Ad,alphamap_fragment:bd,alphamap_pars_fragment:wd,alphatest_fragment:Rd,alphatest_pars_fragment:Cd,aomap_fragment:Pd,aomap_pars_fragment:Ld,batching_pars_vertex:Dd,batching_vertex:Ud,begin_vertex:Id,beginnormal_vertex:Nd,bsdfs:Fd,iridescence_fragment:Od,bumpmap_pars_fragment:Bd,clipping_planes_fragment:zd,clipping_planes_pars_fragment:Hd,clipping_planes_pars_vertex:kd,clipping_planes_vertex:Gd,color_fragment:Vd,color_pars_fragment:Wd,color_pars_vertex:Xd,color_vertex:qd,common:Yd,cube_uv_reflection_fragment:Zd,defaultnormal_vertex:Jd,displacementmap_pars_vertex:Kd,displacementmap_vertex:jd,emissivemap_fragment:$d,emissivemap_pars_fragment:Qd,colorspace_fragment:tp,colorspace_pars_fragment:ep,envmap_fragment:np,envmap_common_pars_fragment:ip,envmap_pars_fragment:rp,envmap_pars_vertex:sp,envmap_physical_pars_fragment:gp,envmap_vertex:op,fog_vertex:ap,fog_pars_vertex:cp,fog_fragment:lp,fog_pars_fragment:up,gradientmap_pars_fragment:hp,lightmap_pars_fragment:fp,lights_lambert_fragment:dp,lights_lambert_pars_fragment:pp,lights_pars_begin:mp,lights_toon_fragment:_p,lights_toon_pars_fragment:vp,lights_phong_fragment:xp,lights_phong_pars_fragment:Mp,lights_physical_fragment:Sp,lights_physical_pars_fragment:yp,lights_fragment_begin:Ep,lights_fragment_maps:Tp,lights_fragment_end:Ap,logdepthbuf_fragment:bp,logdepthbuf_pars_fragment:wp,logdepthbuf_pars_vertex:Rp,logdepthbuf_vertex:Cp,map_fragment:Pp,map_pars_fragment:Lp,map_particle_fragment:Dp,map_particle_pars_fragment:Up,metalnessmap_fragment:Ip,metalnessmap_pars_fragment:Np,morphinstance_vertex:Fp,morphcolor_vertex:Op,morphnormal_vertex:Bp,morphtarget_pars_vertex:zp,morphtarget_vertex:Hp,normal_fragment_begin:kp,normal_fragment_maps:Gp,normal_pars_fragment:Vp,normal_pars_vertex:Wp,normal_vertex:Xp,normalmap_pars_fragment:qp,clearcoat_normal_fragment_begin:Yp,clearcoat_normal_fragment_maps:Zp,clearcoat_pars_fragment:Jp,iridescence_pars_fragment:Kp,opaque_fragment:jp,packing:$p,premultiplied_alpha_fragment:Qp,project_vertex:tm,dithering_fragment:em,dithering_pars_fragment:nm,roughnessmap_fragment:im,roughnessmap_pars_fragment:rm,shadowmap_pars_fragment:sm,shadowmap_pars_vertex:om,shadowmap_vertex:am,shadowmask_pars_fragment:cm,skinbase_vertex:lm,skinning_pars_vertex:um,skinning_vertex:hm,skinnormal_vertex:fm,specularmap_fragment:dm,specularmap_pars_fragment:pm,tonemapping_fragment:mm,tonemapping_pars_fragment:gm,transmission_fragment:_m,transmission_pars_fragment:vm,uv_pars_fragment:xm,uv_pars_vertex:Mm,uv_vertex:Sm,worldpos_vertex:ym,background_vert:Em,background_frag:Tm,backgroundCube_vert:Am,backgroundCube_frag:bm,cube_vert:wm,cube_frag:Rm,depth_vert:Cm,depth_frag:Pm,distanceRGBA_vert:Lm,distanceRGBA_frag:Dm,equirect_vert:Um,equirect_frag:Im,linedashed_vert:Nm,linedashed_frag:Fm,meshbasic_vert:Om,meshbasic_frag:Bm,meshlambert_vert:zm,meshlambert_frag:Hm,meshmatcap_vert:km,meshmatcap_frag:Gm,meshnormal_vert:Vm,meshnormal_frag:Wm,meshphong_vert:Xm,meshphong_frag:qm,meshphysical_vert:Ym,meshphysical_frag:Zm,meshtoon_vert:Jm,meshtoon_frag:Km,points_vert:jm,points_frag:$m,shadow_vert:Qm,shadow_frag:tg,sprite_vert:eg,sprite_frag:ng},lt={common:{diffuse:{value:new Wt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zt}},envmap:{envMap:{value:null},envMapRotation:{value:new zt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zt},normalScale:{value:new at(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Wt(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 Wt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0},uvTransform:{value:new zt}},sprite:{diffuse:{value:new Wt(16777215)},opacity:{value:1},center:{value:new at(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}}},Ye={basic:{uniforms:Ae([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.fog]),vertexShader:kt.meshbasic_vert,fragmentShader:kt.meshbasic_frag},lambert:{uniforms:Ae([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)}}]),vertexShader:kt.meshlambert_vert,fragmentShader:kt.meshlambert_frag},phong:{uniforms:Ae([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)},specular:{value:new Wt(1118481)},shininess:{value:30}}]),vertexShader:kt.meshphong_vert,fragmentShader:kt.meshphong_frag},standard:{uniforms:Ae([lt.common,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.roughnessmap,lt.metalnessmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kt.meshphysical_vert,fragmentShader:kt.meshphysical_frag},toon:{uniforms:Ae([lt.common,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.gradientmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)}}]),vertexShader:kt.meshtoon_vert,fragmentShader:kt.meshtoon_frag},matcap:{uniforms:Ae([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,{matcap:{value:null}}]),vertexShader:kt.meshmatcap_vert,fragmentShader:kt.meshmatcap_frag},points:{uniforms:Ae([lt.points,lt.fog]),vertexShader:kt.points_vert,fragmentShader:kt.points_frag},dashed:{uniforms:Ae([lt.common,lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kt.linedashed_vert,fragmentShader:kt.linedashed_frag},depth:{uniforms:Ae([lt.common,lt.displacementmap]),vertexShader:kt.depth_vert,fragmentShader:kt.depth_frag},normal:{uniforms:Ae([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,{opacity:{value:1}}]),vertexShader:kt.meshnormal_vert,fragmentShader:kt.meshnormal_frag},sprite:{uniforms:Ae([lt.sprite,lt.fog]),vertexShader:kt.sprite_vert,fragmentShader:kt.sprite_frag},background:{uniforms:{uvTransform:{value:new zt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kt.background_vert,fragmentShader:kt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new zt}},vertexShader:kt.backgroundCube_vert,fragmentShader:kt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kt.cube_vert,fragmentShader:kt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kt.equirect_vert,fragmentShader:kt.equirect_frag},distanceRGBA:{uniforms:Ae([lt.common,lt.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kt.distanceRGBA_vert,fragmentShader:kt.distanceRGBA_frag},shadow:{uniforms:Ae([lt.lights,lt.fog,{color:{value:new Wt(0)},opacity:{value:1}}]),vertexShader:kt.shadow_vert,fragmentShader:kt.shadow_frag}};Ye.physical={uniforms:Ae([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zt},clearcoatNormalScale:{value:new at(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zt},sheen:{value:0},sheenColor:{value:new Wt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zt},transmissionSamplerSize:{value:new at},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zt},attenuationDistance:{value:0},attenuationColor:{value:new Wt(0)},specularColor:{value:new Wt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zt},anisotropyVector:{value:new at},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zt}}]),vertexShader:kt.meshphysical_vert,fragmentShader:kt.meshphysical_frag};const Dr={r:0,b:0,g:0},In=new $e,ig=new re;function rg(i,t,e,n,r,s,o){const a=new Wt(0);let c=s===!0?0:1,l,u,h=null,f=0,d=null;function g(T){let S=T.isScene===!0?T.background:null;return S&&S.isTexture&&(S=(T.backgroundBlurriness>0?e:t).get(S)),S}function v(T){let S=!1;const L=g(T);L===null?p(a,c):L&&L.isColor&&(p(L,1),S=!0);const C=i.xr.getEnvironmentBlendMode();C==="additive"?n.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(T,S){const L=g(S);L&&(L.isCubeTexture||L.mapping===Jr)?(u===void 0&&(u=new le(new Zn(1,1,1),new wn({name:"BackgroundCubeMaterial",uniforms:Li(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.backgroundCube.fragmentShader,side:Ce,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(C,R,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),In.copy(S.backgroundRotation),In.x*=-1,In.y*=-1,In.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(In.y*=-1,In.z*=-1),u.material.uniforms.envMap.value=L,u.material.uniforms.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(ig.makeRotationFromEuler(In)),u.material.toneMapped=Kt.getTransfer(L.colorSpace)!==te,(h!==L||f!==L.version||d!==i.toneMapping)&&(u.material.needsUpdate=!0,h=L,f=L.version,d=i.toneMapping),u.layers.enableAll(),T.unshift(u,u.geometry,u.material,0,0,null)):L&&L.isTexture&&(l===void 0&&(l=new le(new ar(2,2),new wn({name:"BackgroundMaterial",uniforms:Li(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!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=L,l.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,l.material.toneMapped=Kt.getTransfer(L.colorSpace)!==te,L.matrixAutoUpdate===!0&&L.updateMatrix(),l.material.uniforms.uvTransform.value.copy(L.matrix),(h!==L||f!==L.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=L,f=L.version,d=i.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null))}function p(T,S){T.getRGB(Dr,nu(i)),n.buffers.color.setClear(Dr.r,Dr.g,Dr.b,S,o)}function b(){u!==void 0&&(u.geometry.dispose(),u.material.dispose()),l!==void 0&&(l.geometry.dispose(),l.material.dispose())}return{getClearColor:function(){return a},setClearColor:function(T,S=1){a.set(T),c=S,p(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(T){c=T,p(a,c)},render:v,addToRenderList:m,dispose:b}}function sg(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null);let s=r,o=!1;function a(M,w,H,O,V){let X=!1;const G=h(O,H,w);s!==G&&(s=G,l(s.object)),X=d(M,O,H,V),X&&g(M,O,H,V),V!==null&&t.update(V,i.ELEMENT_ARRAY_BUFFER),(X||o)&&(o=!1,S(M,w,H,O),V!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(V).buffer))}function c(){return i.createVertexArray()}function l(M){return i.bindVertexArray(M)}function u(M){return i.deleteVertexArray(M)}function h(M,w,H){const O=H.wireframe===!0;let V=n[M.id];V===void 0&&(V={},n[M.id]=V);let X=V[w.id];X===void 0&&(X={},V[w.id]=X);let G=X[O];return G===void 0&&(G=f(c()),X[O]=G),G}function f(M){const w=[],H=[],O=[];for(let V=0;V<e;V++)w[V]=0,H[V]=0,O[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:w,enabledAttributes:H,attributeDivisors:O,object:M,attributes:{},index:null}}function d(M,w,H,O){const V=s.attributes,X=w.attributes;let G=0;const K=H.getAttributes();for(const k in K)if(K[k].location>=0){const pt=V[k];let Mt=X[k];if(Mt===void 0&&(k==="instanceMatrix"&&M.instanceMatrix&&(Mt=M.instanceMatrix),k==="instanceColor"&&M.instanceColor&&(Mt=M.instanceColor)),pt===void 0||pt.attribute!==Mt||Mt&&pt.data!==Mt.data)return!0;G++}return s.attributesNum!==G||s.index!==O}function g(M,w,H,O){const V={},X=w.attributes;let G=0;const K=H.getAttributes();for(const k in K)if(K[k].location>=0){let pt=X[k];pt===void 0&&(k==="instanceMatrix"&&M.instanceMatrix&&(pt=M.instanceMatrix),k==="instanceColor"&&M.instanceColor&&(pt=M.instanceColor));const Mt={};Mt.attribute=pt,pt&&pt.data&&(Mt.data=pt.data),V[k]=Mt,G++}s.attributes=V,s.attributesNum=G,s.index=O}function v(){const M=s.newAttributes;for(let w=0,H=M.length;w<H;w++)M[w]=0}function m(M){p(M,0)}function p(M,w){const H=s.newAttributes,O=s.enabledAttributes,V=s.attributeDivisors;H[M]=1,O[M]===0&&(i.enableVertexAttribArray(M),O[M]=1),V[M]!==w&&(i.vertexAttribDivisor(M,w),V[M]=w)}function b(){const M=s.newAttributes,w=s.enabledAttributes;for(let H=0,O=w.length;H<O;H++)w[H]!==M[H]&&(i.disableVertexAttribArray(H),w[H]=0)}function T(M,w,H,O,V,X,G){G===!0?i.vertexAttribIPointer(M,w,H,V,X):i.vertexAttribPointer(M,w,H,O,V,X)}function S(M,w,H,O){v();const V=O.attributes,X=H.getAttributes(),G=w.defaultAttributeValues;for(const K in X){const k=X[K];if(k.location>=0){let ct=V[K];if(ct===void 0&&(K==="instanceMatrix"&&M.instanceMatrix&&(ct=M.instanceMatrix),K==="instanceColor"&&M.instanceColor&&(ct=M.instanceColor)),ct!==void 0){const pt=ct.normalized,Mt=ct.itemSize,Ft=t.get(ct);if(Ft===void 0)continue;const Zt=Ft.buffer,Y=Ft.type,st=Ft.bytesPerElement,Q=Y===i.INT||Y===i.UNSIGNED_INT||ct.gpuType===Na;if(ct.isInterleavedBufferAttribute){const j=ct.data,ut=j.stride,vt=ct.offset;if(j.isInstancedInterleavedBuffer){for(let Rt=0;Rt<k.locationSize;Rt++)p(k.location+Rt,j.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let Rt=0;Rt<k.locationSize;Rt++)m(k.location+Rt);i.bindBuffer(i.ARRAY_BUFFER,Zt);for(let Rt=0;Rt<k.locationSize;Rt++)T(k.location+Rt,Mt/k.locationSize,Y,pt,ut*st,(vt+Mt/k.locationSize*Rt)*st,Q)}else{if(ct.isInstancedBufferAttribute){for(let j=0;j<k.locationSize;j++)p(k.location+j,ct.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let j=0;j<k.locationSize;j++)m(k.location+j);i.bindBuffer(i.ARRAY_BUFFER,Zt);for(let j=0;j<k.locationSize;j++)T(k.location+j,Mt/k.locationSize,Y,pt,Mt*st,Mt/k.locationSize*j*st,Q)}}else if(G!==void 0){const pt=G[K];if(pt!==void 0)switch(pt.length){case 2:i.vertexAttrib2fv(k.location,pt);break;case 3:i.vertexAttrib3fv(k.location,pt);break;case 4:i.vertexAttrib4fv(k.location,pt);break;default:i.vertexAttrib1fv(k.location,pt)}}}}b()}function L(){D();for(const M in n){const w=n[M];for(const H in w){const O=w[H];for(const V in O)u(O[V].object),delete O[V];delete w[H]}delete n[M]}}function C(M){if(n[M.id]===void 0)return;const w=n[M.id];for(const H in w){const O=w[H];for(const V in O)u(O[V].object),delete O[V];delete w[H]}delete n[M.id]}function R(M){for(const w in n){const H=n[w];if(H[M.id]===void 0)continue;const O=H[M.id];for(const V in O)u(O[V].object),delete O[V];delete H[M.id]}}function D(){y(),o=!0,s!==r&&(s=r,l(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:D,resetDefaultState:y,dispose:L,releaseStatesOfGeometry:C,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function og(i,t,e){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),e.update(u,n,1)}function o(l,u,h){h!==0&&(i.drawArraysInstanced(n,l,u,h),e.update(u,n,h))}function a(l,u,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let d=0;for(let g=0;g<h;g++)d+=u[g];e.update(d,n,1)}function c(l,u,h,f){if(h===0)return;const d=t.get("WEBGL_multi_draw");if(d===null)for(let g=0;g<l.length;g++)o(l[g],u[g],f[g]);else{d.multiDrawArraysInstancedWEBGL(n,l,0,u,0,f,0,h);let g=0;for(let v=0;v<h;v++)g+=u[v]*f[v];e.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function ag(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){return!(R!==We&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(R){const D=R===ir&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==fn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==ln&&!D)}function c(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const h=e.logarithmicDepthBuffer===!0,f=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=g>0,C=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:f,maxTextures:d,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:T,maxFragmentUniforms:S,vertexTextures:L,maxSamples:C}}function cg(i){const t=this;let e=null,n=0,r=!1,s=!1;const o=new xn,a=new zt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){const d=h.length!==0||f||n!==0||r;return r=f,n=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){e=u(h,f,0)},this.setState=function(h,f,d){const g=h.clippingPlanes,v=h.clipIntersection,m=h.clipShadows,p=i.get(h);if(!r||g===null||g.length===0||s&&!m)s?u(null):l();else{const b=s?0:n,T=b*4;let S=p.clippingState||null;c.value=S,S=u(g,f,T,d);for(let L=0;L!==T;++L)S[L]=e[L];p.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(h,f,d,g){const v=h!==null?h.length:0;let m=null;if(v!==0){if(m=c.value,g!==!0||m===null){const p=d+v*4,b=f.matrixWorldInverse;a.getNormalMatrix(b),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,S=d;T!==v;++T,S+=4)o.copy(h[T]).applyMatrix4(b,a),o.normal.toArray(m,S),m[S+3]=o.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}function lg(i){let t=new WeakMap;function e(o,a){return a===js?o.mapping=Ai:a===$s&&(o.mapping=bi),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===js||a===$s)if(t.has(o)){const c=t.get(o).texture;return e(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new bf(c.height);return l.fromEquirectangularTexture(i,o),t.set(o,l),o.addEventListener("dispose",r),e(l.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=t.get(a);c!==void 0&&(t.delete(a),c.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}const vi=4,il=[.125,.215,.35,.446,.526,.582],Bn=20,Ls=new mu,rl=new Wt;let Ds=null,Us=0,Is=0,Ns=!1;const Fn=(1+Math.sqrt(5))/2,di=1/Fn,sl=[new P(-Fn,di,0),new P(Fn,di,0),new P(-di,0,Fn),new P(di,0,Fn),new P(0,Fn,-di),new P(0,Fn,di),new P(-1,1,-1),new P(1,1,-1),new P(-1,1,1),new P(1,1,1)];class ol{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){Ds=this._renderer.getRenderTarget(),Us=this._renderer.getActiveCubeFace(),Is=this._renderer.getActiveMipmapLevel(),Ns=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,r,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ll(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=cl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Ds,Us,Is),this._renderer.xr.enabled=Ns,t.scissorTest=!1,Ur(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ai||t.mapping===bi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ds=this._renderer.getRenderTarget(),Us=this._renderer.getActiveCubeFace(),Is=this._renderer.getActiveMipmapLevel(),Ns=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:Je,minFilter:Je,generateMipmaps:!1,type:ir,format:We,colorSpace:Pi,depthBuffer:!1},r=al(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=al(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=ug(s)),this._blurMaterial=hg(s,t,e)}return r}_compileMaterial(t){const e=new le(this._lodPlanes[0],t);this._renderer.compile(e,Ls)}_sceneToCubeUV(t,e,n,r){const a=new Ie(90,1,e,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(rl),u.toneMapping=Tn,u.autoClear=!1;const d=new Vn({name:"PMREM.Background",side:Ce,depthWrite:!1,depthTest:!1}),g=new le(new Zn,d);let v=!1;const m=t.background;m?m.isColor&&(d.color.copy(m),t.background=null,v=!0):(d.color.copy(rl),v=!0);for(let p=0;p<6;p++){const b=p%3;b===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):b===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));const T=this._cubeSize;Ur(r,b*T,p>2?T:0,T,T),u.setRenderTarget(r),v&&u.render(g,a),u.render(t,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=f,u.autoClear=h,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===Ai||t.mapping===bi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ll()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=cl());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new le(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;const c=this._cubeSize;Ur(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(o,Ls)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=sl[(r-s-1)%sl.length];this._blur(t,s-1,s,o,a)}e.autoClear=n}_blur(t,e,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,r,"latitudinal",s),this._halfBlur(o,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new le(this._lodPlanes[r],l),f=l.uniforms,d=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Bn-1),v=s/g,m=isFinite(s)?1+Math.floor(u*v):Bn;m>Bn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Bn}`);const p=[];let b=0;for(let R=0;R<Bn;++R){const D=R/v,y=Math.exp(-D*D/2);p.push(y),R===0?b+=y:R<m&&(b+=2*y)}for(let R=0;R<p.length;R++)p[R]=p[R]/b;f.envMap.value=t.texture,f.samples.value=m,f.weights.value=p,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:T}=this;f.dTheta.value=g,f.mipInt.value=T-n;const S=this._sizeLods[r],L=3*S*(r>T-vi?r-T+vi:0),C=4*(this._cubeSize-S);Ur(e,L,C,3*S,2*S),c.setRenderTarget(e),c.render(h,Ls)}}function ug(i){const t=[],e=[],n=[];let r=i;const s=i-vi+1+il.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);e.push(a);let c=1/a;o>i-vi?c=il[o-i+vi-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,g=6,v=3,m=2,p=1,b=new Float32Array(v*g*d),T=new Float32Array(m*g*d),S=new Float32Array(p*g*d);for(let C=0;C<d;C++){const R=C%3*2/3-1,D=C>2?0:-1,y=[R,D,0,R+2/3,D,0,R+2/3,D+1,0,R,D,0,R+2/3,D+1,0,R,D+1,0];b.set(y,v*g*C),T.set(f,m*g*C);const M=[C,C,C,C,C,C];S.set(M,p*g*C)}const L=new Pe;L.setAttribute("position",new je(b,v)),L.setAttribute("uv",new je(T,m)),L.setAttribute("faceIndex",new je(S,p)),t.push(L),r>vi&&r--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function al(i,t,e){const n=new Yn(i,t,e);return n.texture.mapping=Jr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ur(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function hg(i,t,e){const n=new Float32Array(Bn),r=new P(0,1,0);return new wn({name:"SphericalGaussianBlur",defines:{n:Bn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:nc(),fragmentShader:`
|
|
3612
|
+
}`,Vt={alphahash_fragment:dm,alphahash_pars_fragment:pm,alphamap_fragment:mm,alphamap_pars_fragment:gm,alphatest_fragment:_m,alphatest_pars_fragment:vm,aomap_fragment:xm,aomap_pars_fragment:Mm,batching_pars_vertex:Sm,batching_vertex:Em,begin_vertex:ym,beginnormal_vertex:Tm,bsdfs:Am,iridescence_fragment:bm,bumpmap_pars_fragment:wm,clipping_planes_fragment:Rm,clipping_planes_pars_fragment:Cm,clipping_planes_pars_vertex:Pm,clipping_planes_vertex:Lm,color_fragment:Dm,color_pars_fragment:Um,color_pars_vertex:Im,color_vertex:Nm,common:Fm,cube_uv_reflection_fragment:Om,defaultnormal_vertex:Bm,displacementmap_pars_vertex:zm,displacementmap_vertex:Hm,emissivemap_fragment:km,emissivemap_pars_fragment:Vm,colorspace_fragment:Gm,colorspace_pars_fragment:Wm,envmap_fragment:Xm,envmap_common_pars_fragment:qm,envmap_pars_fragment:Ym,envmap_pars_vertex:Km,envmap_physical_pars_fragment:sg,envmap_vertex:Zm,fog_vertex:$m,fog_pars_vertex:Jm,fog_fragment:jm,fog_pars_fragment:Qm,gradientmap_pars_fragment:tg,lightmap_pars_fragment:eg,lights_lambert_fragment:ng,lights_lambert_pars_fragment:ig,lights_pars_begin:rg,lights_toon_fragment:og,lights_toon_pars_fragment:ag,lights_phong_fragment:cg,lights_phong_pars_fragment:lg,lights_physical_fragment:ug,lights_physical_pars_fragment:hg,lights_fragment_begin:fg,lights_fragment_maps:dg,lights_fragment_end:pg,logdepthbuf_fragment:mg,logdepthbuf_pars_fragment:gg,logdepthbuf_pars_vertex:_g,logdepthbuf_vertex:vg,map_fragment:xg,map_pars_fragment:Mg,map_particle_fragment:Sg,map_particle_pars_fragment:Eg,metalnessmap_fragment:yg,metalnessmap_pars_fragment:Tg,morphinstance_vertex:Ag,morphcolor_vertex:bg,morphnormal_vertex:wg,morphtarget_pars_vertex:Rg,morphtarget_vertex:Cg,normal_fragment_begin:Pg,normal_fragment_maps:Lg,normal_pars_fragment:Dg,normal_pars_vertex:Ug,normal_vertex:Ig,normalmap_pars_fragment:Ng,clearcoat_normal_fragment_begin:Fg,clearcoat_normal_fragment_maps:Og,clearcoat_pars_fragment:Bg,iridescence_pars_fragment:zg,opaque_fragment:Hg,packing:kg,premultiplied_alpha_fragment:Vg,project_vertex:Gg,dithering_fragment:Wg,dithering_pars_fragment:Xg,roughnessmap_fragment:qg,roughnessmap_pars_fragment:Yg,shadowmap_pars_fragment:Kg,shadowmap_pars_vertex:Zg,shadowmap_vertex:$g,shadowmask_pars_fragment:Jg,skinbase_vertex:jg,skinning_pars_vertex:Qg,skinning_vertex:t_,skinnormal_vertex:e_,specularmap_fragment:n_,specularmap_pars_fragment:i_,tonemapping_fragment:r_,tonemapping_pars_fragment:s_,transmission_fragment:o_,transmission_pars_fragment:a_,uv_pars_fragment:c_,uv_pars_vertex:l_,uv_vertex:u_,worldpos_vertex:h_,background_vert:f_,background_frag:d_,backgroundCube_vert:p_,backgroundCube_frag:m_,cube_vert:g_,cube_frag:__,depth_vert:v_,depth_frag:x_,distanceRGBA_vert:M_,distanceRGBA_frag:S_,equirect_vert:E_,equirect_frag:y_,linedashed_vert:T_,linedashed_frag:A_,meshbasic_vert:b_,meshbasic_frag:w_,meshlambert_vert:R_,meshlambert_frag:C_,meshmatcap_vert:P_,meshmatcap_frag:L_,meshnormal_vert:D_,meshnormal_frag:U_,meshphong_vert:I_,meshphong_frag:N_,meshphysical_vert:F_,meshphysical_frag:O_,meshtoon_vert:B_,meshtoon_frag:z_,points_vert:H_,points_frag:k_,shadow_vert:V_,shadow_frag:G_,sprite_vert:W_,sprite_frag:X_},ut={common:{diffuse:{value:new Xt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ht},alphaMap:{value:null},alphaMapTransform:{value:new Ht},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ht}},envmap:{envMap:{value:null},envMapRotation:{value:new Ht},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ht}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ht}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ht},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ht},normalScale:{value:new ct(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ht},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ht}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ht}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ht}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Xt(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 Xt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ht},alphaTest:{value:0},uvTransform:{value:new Ht}},sprite:{diffuse:{value:new Xt(16777215)},opacity:{value:1},center:{value:new ct(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ht},alphaMap:{value:null},alphaMapTransform:{value:new Ht},alphaTest:{value:0}}},Je={basic:{uniforms:be([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.fog]),vertexShader:Vt.meshbasic_vert,fragmentShader:Vt.meshbasic_frag},lambert:{uniforms:be([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Xt(0)}}]),vertexShader:Vt.meshlambert_vert,fragmentShader:Vt.meshlambert_frag},phong:{uniforms:be([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Xt(0)},specular:{value:new Xt(1118481)},shininess:{value:30}}]),vertexShader:Vt.meshphong_vert,fragmentShader:Vt.meshphong_frag},standard:{uniforms:be([ut.common,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.roughnessmap,ut.metalnessmap,ut.fog,ut.lights,{emissive:{value:new Xt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag},toon:{uniforms:be([ut.common,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.gradientmap,ut.fog,ut.lights,{emissive:{value:new Xt(0)}}]),vertexShader:Vt.meshtoon_vert,fragmentShader:Vt.meshtoon_frag},matcap:{uniforms:be([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,{matcap:{value:null}}]),vertexShader:Vt.meshmatcap_vert,fragmentShader:Vt.meshmatcap_frag},points:{uniforms:be([ut.points,ut.fog]),vertexShader:Vt.points_vert,fragmentShader:Vt.points_frag},dashed:{uniforms:be([ut.common,ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vt.linedashed_vert,fragmentShader:Vt.linedashed_frag},depth:{uniforms:be([ut.common,ut.displacementmap]),vertexShader:Vt.depth_vert,fragmentShader:Vt.depth_frag},normal:{uniforms:be([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,{opacity:{value:1}}]),vertexShader:Vt.meshnormal_vert,fragmentShader:Vt.meshnormal_frag},sprite:{uniforms:be([ut.sprite,ut.fog]),vertexShader:Vt.sprite_vert,fragmentShader:Vt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ht},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vt.background_vert,fragmentShader:Vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ht}},vertexShader:Vt.backgroundCube_vert,fragmentShader:Vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vt.cube_vert,fragmentShader:Vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vt.equirect_vert,fragmentShader:Vt.equirect_frag},distanceRGBA:{uniforms:be([ut.common,ut.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vt.distanceRGBA_vert,fragmentShader:Vt.distanceRGBA_frag},shadow:{uniforms:be([ut.lights,ut.fog,{color:{value:new Xt(0)},opacity:{value:1}}]),vertexShader:Vt.shadow_vert,fragmentShader:Vt.shadow_frag}};Je.physical={uniforms:be([Je.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ht},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ht},clearcoatNormalScale:{value:new ct(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ht},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ht},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ht},sheen:{value:0},sheenColor:{value:new Xt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ht},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ht},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ht},transmissionSamplerSize:{value:new ct},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ht},attenuationDistance:{value:0},attenuationColor:{value:new Xt(0)},specularColor:{value:new Xt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ht},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ht},anisotropyVector:{value:new ct},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ht}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag};const Wr={r:0,b:0,g:0},Bn=new en,q_=new oe;function Y_(i,t,e,n,r,s,o){const a=new Xt(0);let c=s===!0?0:1,l,u,h=null,f=0,d=null;function g(y){let S=y.isScene===!0?y.background:null;return S&&S.isTexture&&(S=(y.backgroundBlurriness>0?e:t).get(S)),S}function v(y){let S=!1;const L=g(y);L===null?p(a,c):L&&L.isColor&&(p(L,1),S=!0);const P=i.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,o):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(y,S){const L=g(S);L&&(L.isCubeTexture||L.mapping===ds)?(u===void 0&&(u=new he(new Jn(1,1,1),new Pn({name:"BackgroundCubeMaterial",uniforms:Oi(Je.backgroundCube.uniforms),vertexShader:Je.backgroundCube.vertexShader,fragmentShader:Je.backgroundCube.fragmentShader,side:Pe,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Bn.copy(S.backgroundRotation),Bn.x*=-1,Bn.y*=-1,Bn.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(Bn.y*=-1,Bn.z*=-1),u.material.uniforms.envMap.value=L,u.material.uniforms.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(q_.makeRotationFromEuler(Bn)),u.material.toneMapped=Jt.getTransfer(L.colorSpace)!==ne,(h!==L||f!==L.version||d!==i.toneMapping)&&(u.material.needsUpdate=!0,h=L,f=L.version,d=i.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):L&&L.isTexture&&(l===void 0&&(l=new he(new _r(2,2),new Pn({name:"BackgroundMaterial",uniforms:Oi(Je.background.uniforms),vertexShader:Je.background.vertexShader,fragmentShader:Je.background.fragmentShader,side:Cn,depthTest:!1,depthWrite:!1,fog:!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=L,l.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,l.material.toneMapped=Jt.getTransfer(L.colorSpace)!==ne,L.matrixAutoUpdate===!0&&L.updateMatrix(),l.material.uniforms.uvTransform.value.copy(L.matrix),(h!==L||f!==L.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=L,f=L.version,d=i.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function p(y,S){y.getRGB(Wr,Zu(i)),n.buffers.color.setClear(Wr.r,Wr.g,Wr.b,S,o)}function A(){u!==void 0&&(u.geometry.dispose(),u.material.dispose()),l!==void 0&&(l.geometry.dispose(),l.material.dispose())}return{getClearColor:function(){return a},setClearColor:function(y,S=1){a.set(y),c=S,p(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,p(a,c)},render:v,addToRenderList:m,dispose:A}}function K_(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null);let s=r,o=!1;function a(_,w,B,F,k){let X=!1;const G=h(F,B,w);s!==G&&(s=G,l(s.object)),X=d(_,F,B,k),X&&g(_,F,B,k),k!==null&&t.update(k,i.ELEMENT_ARRAY_BUFFER),(X||o)&&(o=!1,S(_,w,B,F),k!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(k).buffer))}function c(){return i.createVertexArray()}function l(_){return i.bindVertexArray(_)}function u(_){return i.deleteVertexArray(_)}function h(_,w,B){const F=B.wireframe===!0;let k=n[_.id];k===void 0&&(k={},n[_.id]=k);let X=k[w.id];X===void 0&&(X={},k[w.id]=X);let G=X[F];return G===void 0&&(G=f(c()),X[F]=G),G}function f(_){const w=[],B=[],F=[];for(let k=0;k<e;k++)w[k]=0,B[k]=0,F[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:w,enabledAttributes:B,attributeDivisors:F,object:_,attributes:{},index:null}}function d(_,w,B,F){const k=s.attributes,X=w.attributes;let G=0;const $=B.getAttributes();for(const V in $)if($[V].location>=0){const mt=k[V];let St=X[V];if(St===void 0&&(V==="instanceMatrix"&&_.instanceMatrix&&(St=_.instanceMatrix),V==="instanceColor"&&_.instanceColor&&(St=_.instanceColor)),mt===void 0||mt.attribute!==St||St&&mt.data!==St.data)return!0;G++}return s.attributesNum!==G||s.index!==F}function g(_,w,B,F){const k={},X=w.attributes;let G=0;const $=B.getAttributes();for(const V in $)if($[V].location>=0){let mt=X[V];mt===void 0&&(V==="instanceMatrix"&&_.instanceMatrix&&(mt=_.instanceMatrix),V==="instanceColor"&&_.instanceColor&&(mt=_.instanceColor));const St={};St.attribute=mt,mt&&mt.data&&(St.data=mt.data),k[V]=St,G++}s.attributes=k,s.attributesNum=G,s.index=F}function v(){const _=s.newAttributes;for(let w=0,B=_.length;w<B;w++)_[w]=0}function m(_){p(_,0)}function p(_,w){const B=s.newAttributes,F=s.enabledAttributes,k=s.attributeDivisors;B[_]=1,F[_]===0&&(i.enableVertexAttribArray(_),F[_]=1),k[_]!==w&&(i.vertexAttribDivisor(_,w),k[_]=w)}function A(){const _=s.newAttributes,w=s.enabledAttributes;for(let B=0,F=w.length;B<F;B++)w[B]!==_[B]&&(i.disableVertexAttribArray(B),w[B]=0)}function y(_,w,B,F,k,X,G){G===!0?i.vertexAttribIPointer(_,w,B,k,X):i.vertexAttribPointer(_,w,B,F,k,X)}function S(_,w,B,F){v();const k=F.attributes,X=B.getAttributes(),G=w.defaultAttributeValues;for(const $ in X){const V=X[$];if(V.location>=0){let lt=k[$];if(lt===void 0&&($==="instanceMatrix"&&_.instanceMatrix&&(lt=_.instanceMatrix),$==="instanceColor"&&_.instanceColor&&(lt=_.instanceColor)),lt!==void 0){const mt=lt.normalized,St=lt.itemSize,Ot=t.get(lt);if(Ot===void 0)continue;const Zt=Ot.buffer,Y=Ot.type,ot=Ot.bytesPerElement,Q=Y===i.INT||Y===i.UNSIGNED_INT||lt.gpuType===gc;if(lt.isInterleavedBufferAttribute){const J=lt.data,ht=J.stride,xt=lt.offset;if(J.isInstancedInterleavedBuffer){for(let Ct=0;Ct<V.locationSize;Ct++)p(V.location+Ct,J.meshPerAttribute);_.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let Ct=0;Ct<V.locationSize;Ct++)m(V.location+Ct);i.bindBuffer(i.ARRAY_BUFFER,Zt);for(let Ct=0;Ct<V.locationSize;Ct++)y(V.location+Ct,St/V.locationSize,Y,mt,ht*ot,(xt+St/V.locationSize*Ct)*ot,Q)}else{if(lt.isInstancedBufferAttribute){for(let J=0;J<V.locationSize;J++)p(V.location+J,lt.meshPerAttribute);_.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=lt.meshPerAttribute*lt.count)}else for(let J=0;J<V.locationSize;J++)m(V.location+J);i.bindBuffer(i.ARRAY_BUFFER,Zt);for(let J=0;J<V.locationSize;J++)y(V.location+J,St/V.locationSize,Y,mt,St*ot,St/V.locationSize*J*ot,Q)}}else if(G!==void 0){const mt=G[$];if(mt!==void 0)switch(mt.length){case 2:i.vertexAttrib2fv(V.location,mt);break;case 3:i.vertexAttrib3fv(V.location,mt);break;case 4:i.vertexAttrib4fv(V.location,mt);break;default:i.vertexAttrib1fv(V.location,mt)}}}}A()}function L(){R();for(const _ in n){const w=n[_];for(const B in w){const F=w[B];for(const k in F)u(F[k].object),delete F[k];delete w[B]}delete n[_]}}function P(_){if(n[_.id]===void 0)return;const w=n[_.id];for(const B in w){const F=w[B];for(const k in F)u(F[k].object),delete F[k];delete w[B]}delete n[_.id]}function C(_){for(const w in n){const B=n[w];if(B[_.id]===void 0)continue;const F=B[_.id];for(const k in F)u(F[k].object),delete F[k];delete B[_.id]}}function R(){E(),o=!0,s!==r&&(s=r,l(s.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:R,resetDefaultState:E,dispose:L,releaseStatesOfGeometry:P,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:m,disableUnusedAttributes:A}}function Z_(i,t,e){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),e.update(u,n,1)}function o(l,u,h){h!==0&&(i.drawArraysInstanced(n,l,u,h),e.update(u,n,h))}function a(l,u,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let d=0;for(let g=0;g<h;g++)d+=u[g];e.update(d,n,1)}function c(l,u,h,f){if(h===0)return;const d=t.get("WEBGL_multi_draw");if(d===null)for(let g=0;g<l.length;g++)o(l[g],u[g],f[g]);else{d.multiDrawArraysInstancedWEBGL(n,l,0,u,0,f,0,h);let g=0;for(let v=0;v<h;v++)g+=u[v]*f[v];e.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function $_(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const C=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(C){return!(C!==Ke&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){const R=C===dr&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(C!==gn&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==dn&&!R)}function c(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const h=e.logarithmicDepthBuffer===!0,f=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),y=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=g>0,P=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:f,maxTextures:d,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:A,maxVaryings:y,maxFragmentUniforms:S,vertexTextures:L,maxSamples:P}}function J_(i){const t=this;let e=null,n=0,r=!1,s=!1;const o=new yn,a=new Ht,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){const d=h.length!==0||f||n!==0||r;return r=f,n=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){e=u(h,f,0)},this.setState=function(h,f,d){const g=h.clippingPlanes,v=h.clipIntersection,m=h.clipShadows,p=i.get(h);if(!r||g===null||g.length===0||s&&!m)s?u(null):l();else{const A=s?0:n,y=A*4;let S=p.clippingState||null;c.value=S,S=u(g,f,y,d);for(let L=0;L!==y;++L)S[L]=e[L];p.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(h,f,d,g){const v=h!==null?h.length:0;let m=null;if(v!==0){if(m=c.value,g!==!0||m===null){const p=d+v*4,A=f.matrixWorldInverse;a.getNormalMatrix(A),(m===null||m.length<p)&&(m=new Float32Array(p));for(let y=0,S=d;y!==v;++y,S+=4)o.copy(h[y]).applyMatrix4(A,a),o.normal.toArray(m,S),m[S+3]=o.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}function j_(i){let t=new WeakMap;function e(o,a){return a===$o?o.mapping=Li:a===Jo&&(o.mapping=Di),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===$o||a===Jo)if(t.has(o)){const c=t.get(o).texture;return e(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new mp(c.height);return l.fromEquirectangularTexture(i,o),t.set(o,l),o.addEventListener("dispose",r),e(l.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=t.get(a);c!==void 0&&(t.delete(a),c.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}const yi=4,Gl=[.125,.215,.35,.446,.526,.582],Vn=20,Ks=new ch,Wl=new Xt;let Zs=null,$s=0,Js=0,js=!1;const Hn=(1+Math.sqrt(5))/2,vi=1/Hn,Xl=[new D(-Hn,vi,0),new D(Hn,vi,0),new D(-vi,0,Hn),new D(vi,0,Hn),new D(0,Hn,-vi),new D(0,Hn,vi),new D(-1,1,-1),new D(1,1,-1),new D(-1,1,1),new D(1,1,1)];class ql{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){Zs=this._renderer.getRenderTarget(),$s=this._renderer.getActiveCubeFace(),Js=this._renderer.getActiveMipmapLevel(),js=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,r,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zl(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Kl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Zs,$s,Js),this._renderer.xr.enabled=js,t.scissorTest=!1,Xr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Li||t.mapping===Di?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Zs=this._renderer.getRenderTarget(),$s=this._renderer.getActiveCubeFace(),Js=this._renderer.getActiveMipmapLevel(),js=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:Qe,minFilter:Qe,generateMipmaps:!1,type:dr,format:Ke,colorSpace:Fi,depthBuffer:!1},r=Yl(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Yl(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Q_(s)),this._blurMaterial=tv(s,t,e)}return r}_compileMaterial(t){const e=new he(this._lodPlanes[0],t);this._renderer.compile(e,Ks)}_sceneToCubeUV(t,e,n,r){const a=new Fe(90,1,e,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(Wl),u.toneMapping=wn,u.autoClear=!1;const d=new qn({name:"PMREM.Background",side:Pe,depthWrite:!1,depthTest:!1}),g=new he(new Jn,d);let v=!1;const m=t.background;m?m.isColor&&(d.color.copy(m),t.background=null,v=!0):(d.color.copy(Wl),v=!0);for(let p=0;p<6;p++){const A=p%3;A===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):A===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));const y=this._cubeSize;Xr(r,A*y,p>2?y:0,y,y),u.setRenderTarget(r),v&&u.render(g,a),u.render(t,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=f,u.autoClear=h,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===Li||t.mapping===Di;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zl()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Kl());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new he(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;const c=this._cubeSize;Xr(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(o,Ks)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Xl[(r-s-1)%Xl.length];this._blur(t,s-1,s,o,a)}e.autoClear=n}_blur(t,e,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,r,"latitudinal",s),this._halfBlur(o,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new he(this._lodPlanes[r],l),f=l.uniforms,d=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Vn-1),v=s/g,m=isFinite(s)?1+Math.floor(u*v):Vn;m>Vn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Vn}`);const p=[];let A=0;for(let C=0;C<Vn;++C){const R=C/v,E=Math.exp(-R*R/2);p.push(E),C===0?A+=E:C<m&&(A+=2*E)}for(let C=0;C<p.length;C++)p[C]=p[C]/A;f.envMap.value=t.texture,f.samples.value=m,f.weights.value=p,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:y}=this;f.dTheta.value=g,f.mipInt.value=y-n;const S=this._sizeLods[r],L=3*S*(r>y-yi?r-y+yi:0),P=4*(this._cubeSize-S);Xr(e,L,P,3*S,2*S),c.setRenderTarget(e),c.render(h,Ks)}}function Q_(i){const t=[],e=[],n=[];let r=i;const s=i-yi+1+Gl.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);e.push(a);let c=1/a;o>i-yi?c=Gl[o-i+yi-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,g=6,v=3,m=2,p=1,A=new Float32Array(v*g*d),y=new Float32Array(m*g*d),S=new Float32Array(p*g*d);for(let P=0;P<d;P++){const C=P%3*2/3-1,R=P>2?0:-1,E=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];A.set(E,v*g*P),y.set(f,m*g*P);const _=[P,P,P,P,P,P];S.set(_,p*g*P)}const L=new De;L.setAttribute("position",new tn(A,v)),L.setAttribute("uv",new tn(y,m)),L.setAttribute("faceIndex",new tn(S,p)),t.push(L),r>yi&&r--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Yl(i,t,e){const n=new $n(i,t,e);return n.texture.mapping=ds,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Xr(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function tv(i,t,e){const n=new Float32Array(Vn),r=new D(0,1,0);return new Pn({name:"SphericalGaussianBlur",defines:{n:Vn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Oc(),fragmentShader:`
|
|
3575
3613
|
|
|
3576
3614
|
precision mediump float;
|
|
3577
3615
|
precision mediump int;
|
|
@@ -3631,7 +3669,7 @@ void main() {
|
|
|
3631
3669
|
}
|
|
3632
3670
|
|
|
3633
3671
|
}
|
|
3634
|
-
`,blending:
|
|
3672
|
+
`,blending:bn,depthTest:!1,depthWrite:!1})}function Kl(){return new Pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Oc(),fragmentShader:`
|
|
3635
3673
|
|
|
3636
3674
|
precision mediump float;
|
|
3637
3675
|
precision mediump int;
|
|
@@ -3650,7 +3688,7 @@ void main() {
|
|
|
3650
3688
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3651
3689
|
|
|
3652
3690
|
}
|
|
3653
|
-
`,blending:
|
|
3691
|
+
`,blending:bn,depthTest:!1,depthWrite:!1})}function Zl(){return new Pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Oc(),fragmentShader:`
|
|
3654
3692
|
|
|
3655
3693
|
precision mediump float;
|
|
3656
3694
|
precision mediump int;
|
|
@@ -3666,7 +3704,7 @@ void main() {
|
|
|
3666
3704
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3667
3705
|
|
|
3668
3706
|
}
|
|
3669
|
-
`,blending:
|
|
3707
|
+
`,blending:bn,depthTest:!1,depthWrite:!1})}function Oc(){return`
|
|
3670
3708
|
|
|
3671
3709
|
precision mediump float;
|
|
3672
3710
|
precision mediump int;
|
|
@@ -3721,17 +3759,17 @@ void main() {
|
|
|
3721
3759
|
gl_Position = vec4( position, 1.0 );
|
|
3722
3760
|
|
|
3723
3761
|
}
|
|
3724
|
-
`}function fg(i){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===js||c===$s,u=c===Ai||c===bi;if(l||u){let h=t.get(a);const f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return e===null&&(e=new ol(i)),h=l?e.fromEquirectangular(a,h):e.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),h.texture;if(h!==void 0)return h.texture;{const d=a.image;return l&&d&&d.height>0||u&&d&&r(d)?(e===null&&(e=new ol(i)),h=l?e.fromEquirectangular(a):e.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){const c=a.target;c.removeEventListener("dispose",s);const l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:o}}function dg(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&mi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function pg(i,t,e,n){const r={},s=new WeakMap;function o(h){const f=h.target;f.index!==null&&t.remove(f.index);for(const g in f.attributes)t.remove(f.attributes[g]);f.removeEventListener("dispose",o),delete r[f.id];const d=s.get(f);d&&(t.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function a(h,f){return r[f.id]===!0||(f.addEventListener("dispose",o),r[f.id]=!0,e.memory.geometries++),f}function c(h){const f=h.attributes;for(const d in f)t.update(f[d],i.ARRAY_BUFFER)}function l(h){const f=[],d=h.index,g=h.attributes.position;let v=0;if(d!==null){const b=d.array;v=d.version;for(let T=0,S=b.length;T<S;T+=3){const L=b[T+0],C=b[T+1],R=b[T+2];f.push(L,C,C,R,R,L)}}else if(g!==void 0){const b=g.array;v=g.version;for(let T=0,S=b.length/3-1;T<S;T+=3){const L=T+0,C=T+1,R=T+2;f.push(L,C,C,R,R,L)}}else return;const m=new(Jl(f)?eu:tu)(f,1);m.version=v;const p=s.get(h);p&&t.remove(p),s.set(h,m)}function u(h){const f=s.get(h);if(f){const d=h.index;d!==null&&f.version<d.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function mg(i,t,e){let n;function r(f){n=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,d){i.drawElements(n,d,s,f*o),e.update(d,n,1)}function l(f,d,g){g!==0&&(i.drawElementsInstanced(n,d,s,f*o,g),e.update(d,n,g))}function u(f,d,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,s,f,0,g);let m=0;for(let p=0;p<g;p++)m+=d[p];e.update(m,n,1)}function h(f,d,g,v){if(g===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<f.length;p++)l(f[p]/o,d[p],v[p]);else{m.multiDrawElementsInstancedWEBGL(n,d,0,s,f,0,v,0,g);let p=0;for(let b=0;b<g;b++)p+=d[b]*v[b];e.update(p,n,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function gg(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(e.calls++,o){case i.TRIANGLES:e.triangles+=a*(s/3);break;case i.LINES:e.lines+=a*(s/2);break;case i.LINE_STRIP:e.lines+=a*(s-1);break;case i.LINE_LOOP:e.lines+=a*s;break;case i.POINTS:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function _g(i,t,e){const n=new WeakMap,r=new ee;function s(o,a,c){const l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let f=n.get(a);if(f===void 0||f.count!==h){let M=function(){D.dispose(),n.delete(a),a.removeEventListener("dispose",M)};var d=M;f!==void 0&&f.texture.dispose();const g=a.morphAttributes.position!==void 0,v=a.morphAttributes.normal!==void 0,m=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],b=a.morphAttributes.normal||[],T=a.morphAttributes.color||[];let S=0;g===!0&&(S=1),v===!0&&(S=2),m===!0&&(S=3);let L=a.attributes.position.count*S,C=1;L>t.maxTextureSize&&(C=Math.ceil(L/t.maxTextureSize),L=t.maxTextureSize);const R=new Float32Array(L*C*4*h),D=new jl(R,L,C,h);D.type=ln,D.needsUpdate=!0;const y=S*4;for(let w=0;w<h;w++){const H=p[w],O=b[w],V=T[w],X=L*C*4*w;for(let G=0;G<H.count;G++){const K=G*y;g===!0&&(r.fromBufferAttribute(H,G),R[X+K+0]=r.x,R[X+K+1]=r.y,R[X+K+2]=r.z,R[X+K+3]=0),v===!0&&(r.fromBufferAttribute(O,G),R[X+K+4]=r.x,R[X+K+5]=r.y,R[X+K+6]=r.z,R[X+K+7]=0),m===!0&&(r.fromBufferAttribute(V,G),R[X+K+8]=r.x,R[X+K+9]=r.y,R[X+K+10]=r.z,R[X+K+11]=V.itemSize===4?r.w:1)}}f={count:h,texture:D,size:new at(L,C)},n.set(a,f),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,e);else{let g=0;for(let m=0;m<l.length;m++)g+=l[m];const v=a.morphTargetsRelative?1:1-g;c.getUniforms().setValue(i,"morphTargetBaseInfluence",v),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",f.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:s}}function vg(i,t,e,n){let r=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,h=t.get(c,u);if(r.get(h)!==l&&(t.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==l&&(f.update(),r.set(f,l))}return h}function o(){r=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:s,dispose:o}}const _u=new ye,ul=new ou(1,1),vu=new jl,xu=new uf,Mu=new ru,hl=[],fl=[],dl=new Float32Array(16),pl=new Float32Array(9),ml=new Float32Array(4);function Ui(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=hl[r];if(s===void 0&&(s=new Float32Array(r),hl[r]=s),t!==0){n.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(s,a)}return s}function fe(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function de(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function jr(i,t){let e=fl[t];e===void 0&&(e=new Int32Array(t),fl[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function xg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Mg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(fe(e,t))return;i.uniform2fv(this.addr,t),de(e,t)}}function Sg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(fe(e,t))return;i.uniform3fv(this.addr,t),de(e,t)}}function yg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(fe(e,t))return;i.uniform4fv(this.addr,t),de(e,t)}}function Eg(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(fe(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),de(e,t)}else{if(fe(e,n))return;ml.set(n),i.uniformMatrix2fv(this.addr,!1,ml),de(e,n)}}function Tg(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(fe(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),de(e,t)}else{if(fe(e,n))return;pl.set(n),i.uniformMatrix3fv(this.addr,!1,pl),de(e,n)}}function Ag(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(fe(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),de(e,t)}else{if(fe(e,n))return;dl.set(n),i.uniformMatrix4fv(this.addr,!1,dl),de(e,n)}}function bg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function wg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(fe(e,t))return;i.uniform2iv(this.addr,t),de(e,t)}}function Rg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(fe(e,t))return;i.uniform3iv(this.addr,t),de(e,t)}}function Cg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(fe(e,t))return;i.uniform4iv(this.addr,t),de(e,t)}}function Pg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Lg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(fe(e,t))return;i.uniform2uiv(this.addr,t),de(e,t)}}function Dg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(fe(e,t))return;i.uniform3uiv(this.addr,t),de(e,t)}}function Ug(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(fe(e,t))return;i.uniform4uiv(this.addr,t),de(e,t)}}function Ig(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(ul.compareFunction=Zl,s=ul):s=_u,e.setTexture2D(t||s,r)}function Ng(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||xu,r)}function Fg(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||Mu,r)}function Og(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||vu,r)}function Bg(i){switch(i){case 5126:return xg;case 35664:return Mg;case 35665:return Sg;case 35666:return yg;case 35674:return Eg;case 35675:return Tg;case 35676:return Ag;case 5124:case 35670:return bg;case 35667:case 35671:return wg;case 35668:case 35672:return Rg;case 35669:case 35673:return Cg;case 5125:return Pg;case 36294:return Lg;case 36295:return Dg;case 36296:return Ug;case 35678:case 36198:case 36298:case 36306:case 35682:return Ig;case 35679:case 36299:case 36307:return Ng;case 35680:case 36300:case 36308:case 36293:return Fg;case 36289:case 36303:case 36311:case 36292:return Og}}function zg(i,t){i.uniform1fv(this.addr,t)}function Hg(i,t){const e=Ui(t,this.size,2);i.uniform2fv(this.addr,e)}function kg(i,t){const e=Ui(t,this.size,3);i.uniform3fv(this.addr,e)}function Gg(i,t){const e=Ui(t,this.size,4);i.uniform4fv(this.addr,e)}function Vg(i,t){const e=Ui(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Wg(i,t){const e=Ui(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Xg(i,t){const e=Ui(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function qg(i,t){i.uniform1iv(this.addr,t)}function Yg(i,t){i.uniform2iv(this.addr,t)}function Zg(i,t){i.uniform3iv(this.addr,t)}function Jg(i,t){i.uniform4iv(this.addr,t)}function Kg(i,t){i.uniform1uiv(this.addr,t)}function jg(i,t){i.uniform2uiv(this.addr,t)}function $g(i,t){i.uniform3uiv(this.addr,t)}function Qg(i,t){i.uniform4uiv(this.addr,t)}function t_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTexture2D(t[o]||_u,s[o])}function e_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTexture3D(t[o]||xu,s[o])}function n_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTextureCube(t[o]||Mu,s[o])}function i_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTexture2DArray(t[o]||vu,s[o])}function r_(i){switch(i){case 5126:return zg;case 35664:return Hg;case 35665:return kg;case 35666:return Gg;case 35674:return Vg;case 35675:return Wg;case 35676:return Xg;case 5124:case 35670:return qg;case 35667:case 35671:return Yg;case 35668:case 35672:return Zg;case 35669:case 35673:return Jg;case 5125:return Kg;case 36294:return jg;case 36295:return $g;case 36296:return Qg;case 35678:case 36198:case 36298:case 36306:case 35682:return t_;case 35679:case 36299:case 36307:return e_;case 35680:case 36300:case 36308:case 36293:return n_;case 36289:case 36303:case 36311:case 36292:return i_}}class s_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Bg(e.type)}}class o_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=r_(e.type)}}class a_{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(t,e[a.id],n)}}}const Fs=/(\w+)(\])?(\[|\.)?/g;function gl(i,t){i.seq.push(t),i.map[t.id]=t}function c_(i,t,e){const n=i.name,r=n.length;for(Fs.lastIndex=0;;){const s=Fs.exec(n),o=Fs.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){gl(e,l===void 0?new s_(a,i,t):new o_(a,i,t));break}else{let h=e.map[a];h===void 0&&(h=new a_(a),gl(e,h)),e=h}}}class Hr{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=t.getActiveUniform(e,r),o=t.getUniformLocation(e,s.name);c_(s,o,this)}}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,o=e.length;s!==o;++s){const a=e[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(t,c.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const o=t[r];o.id in e&&n.push(o)}return n}}function _l(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const l_=37297;let u_=0;function h_(i,t){const e=i.split(`
|
|
3762
|
+
`}function ev(i){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===$o||c===Jo,u=c===Li||c===Di;if(l||u){let h=t.get(a);const f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return e===null&&(e=new ql(i)),h=l?e.fromEquirectangular(a,h):e.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),h.texture;if(h!==void 0)return h.texture;{const d=a.image;return l&&d&&d.height>0||u&&d&&r(d)?(e===null&&(e=new ql(i)),h=l?e.fromEquirectangular(a):e.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){const c=a.target;c.removeEventListener("dispose",s);const l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:o}}function nv(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&Mi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function iv(i,t,e,n){const r={},s=new WeakMap;function o(h){const f=h.target;f.index!==null&&t.remove(f.index);for(const g in f.attributes)t.remove(f.attributes[g]);f.removeEventListener("dispose",o),delete r[f.id];const d=s.get(f);d&&(t.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function a(h,f){return r[f.id]===!0||(f.addEventListener("dispose",o),r[f.id]=!0,e.memory.geometries++),f}function c(h){const f=h.attributes;for(const d in f)t.update(f[d],i.ARRAY_BUFFER)}function l(h){const f=[],d=h.index,g=h.attributes.position;let v=0;if(d!==null){const A=d.array;v=d.version;for(let y=0,S=A.length;y<S;y+=3){const L=A[y+0],P=A[y+1],C=A[y+2];f.push(L,P,P,C,C,L)}}else if(g!==void 0){const A=g.array;v=g.version;for(let y=0,S=A.length/3-1;y<S;y+=3){const L=y+0,P=y+1,C=y+2;f.push(L,P,P,C,C,L)}}else return;const m=new(Vu(f)?Ku:Yu)(f,1);m.version=v;const p=s.get(h);p&&t.remove(p),s.set(h,m)}function u(h){const f=s.get(h);if(f){const d=h.index;d!==null&&f.version<d.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function rv(i,t,e){let n;function r(f){n=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,d){i.drawElements(n,d,s,f*o),e.update(d,n,1)}function l(f,d,g){g!==0&&(i.drawElementsInstanced(n,d,s,f*o,g),e.update(d,n,g))}function u(f,d,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,s,f,0,g);let m=0;for(let p=0;p<g;p++)m+=d[p];e.update(m,n,1)}function h(f,d,g,v){if(g===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<f.length;p++)l(f[p]/o,d[p],v[p]);else{m.multiDrawElementsInstancedWEBGL(n,d,0,s,f,0,v,0,g);let p=0;for(let A=0;A<g;A++)p+=d[A]*v[A];e.update(p,n,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function sv(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(e.calls++,o){case i.TRIANGLES:e.triangles+=a*(s/3);break;case i.LINES:e.lines+=a*(s/2);break;case i.LINE_STRIP:e.lines+=a*(s-1);break;case i.LINE_LOOP:e.lines+=a*s;break;case i.POINTS:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function ov(i,t,e){const n=new WeakMap,r=new ie;function s(o,a,c){const l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let f=n.get(a);if(f===void 0||f.count!==h){let _=function(){R.dispose(),n.delete(a),a.removeEventListener("dispose",_)};var d=_;f!==void 0&&f.texture.dispose();const g=a.morphAttributes.position!==void 0,v=a.morphAttributes.normal!==void 0,m=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],A=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let S=0;g===!0&&(S=1),v===!0&&(S=2),m===!0&&(S=3);let L=a.attributes.position.count*S,P=1;L>t.maxTextureSize&&(P=Math.ceil(L/t.maxTextureSize),L=t.maxTextureSize);const C=new Float32Array(L*P*4*h),R=new Wu(C,L,P,h);R.type=dn,R.needsUpdate=!0;const E=S*4;for(let w=0;w<h;w++){const B=p[w],F=A[w],k=y[w],X=L*P*4*w;for(let G=0;G<B.count;G++){const $=G*E;g===!0&&(r.fromBufferAttribute(B,G),C[X+$+0]=r.x,C[X+$+1]=r.y,C[X+$+2]=r.z,C[X+$+3]=0),v===!0&&(r.fromBufferAttribute(F,G),C[X+$+4]=r.x,C[X+$+5]=r.y,C[X+$+6]=r.z,C[X+$+7]=0),m===!0&&(r.fromBufferAttribute(k,G),C[X+$+8]=r.x,C[X+$+9]=r.y,C[X+$+10]=r.z,C[X+$+11]=k.itemSize===4?r.w:1)}}f={count:h,texture:R,size:new ct(L,P)},n.set(a,f),a.addEventListener("dispose",_)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,e);else{let g=0;for(let m=0;m<l.length;m++)g+=l[m];const v=a.morphTargetsRelative?1:1-g;c.getUniforms().setValue(i,"morphTargetBaseInfluence",v),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",f.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:s}}function av(i,t,e,n){let r=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,h=t.get(c,u);if(r.get(h)!==l&&(t.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==l&&(f.update(),r.set(f,l))}return h}function o(){r=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:s,dispose:o}}const uh=new ye,$l=new Qu(1,1),hh=new Wu,fh=new Qd,dh=new Ju,Jl=[],jl=[],Ql=new Float32Array(16),tu=new Float32Array(9),eu=new Float32Array(4);function ki(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=Jl[r];if(s===void 0&&(s=new Float32Array(r),Jl[r]=s),t!==0){n.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(s,a)}return s}function pe(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function me(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function ms(i,t){let e=jl[t];e===void 0&&(e=new Int32Array(t),jl[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function cv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function lv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(pe(e,t))return;i.uniform2fv(this.addr,t),me(e,t)}}function uv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(pe(e,t))return;i.uniform3fv(this.addr,t),me(e,t)}}function hv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(pe(e,t))return;i.uniform4fv(this.addr,t),me(e,t)}}function fv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(pe(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),me(e,t)}else{if(pe(e,n))return;eu.set(n),i.uniformMatrix2fv(this.addr,!1,eu),me(e,n)}}function dv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(pe(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),me(e,t)}else{if(pe(e,n))return;tu.set(n),i.uniformMatrix3fv(this.addr,!1,tu),me(e,n)}}function pv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(pe(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),me(e,t)}else{if(pe(e,n))return;Ql.set(n),i.uniformMatrix4fv(this.addr,!1,Ql),me(e,n)}}function mv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function gv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(pe(e,t))return;i.uniform2iv(this.addr,t),me(e,t)}}function _v(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(pe(e,t))return;i.uniform3iv(this.addr,t),me(e,t)}}function vv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(pe(e,t))return;i.uniform4iv(this.addr,t),me(e,t)}}function xv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Mv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(pe(e,t))return;i.uniform2uiv(this.addr,t),me(e,t)}}function Sv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(pe(e,t))return;i.uniform3uiv(this.addr,t),me(e,t)}}function Ev(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(pe(e,t))return;i.uniform4uiv(this.addr,t),me(e,t)}}function yv(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?($l.compareFunction=ku,s=$l):s=uh,e.setTexture2D(t||s,r)}function Tv(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||fh,r)}function Av(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||dh,r)}function bv(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||hh,r)}function wv(i){switch(i){case 5126:return cv;case 35664:return lv;case 35665:return uv;case 35666:return hv;case 35674:return fv;case 35675:return dv;case 35676:return pv;case 5124:case 35670:return mv;case 35667:case 35671:return gv;case 35668:case 35672:return _v;case 35669:case 35673:return vv;case 5125:return xv;case 36294:return Mv;case 36295:return Sv;case 36296:return Ev;case 35678:case 36198:case 36298:case 36306:case 35682:return yv;case 35679:case 36299:case 36307:return Tv;case 35680:case 36300:case 36308:case 36293:return Av;case 36289:case 36303:case 36311:case 36292:return bv}}function Rv(i,t){i.uniform1fv(this.addr,t)}function Cv(i,t){const e=ki(t,this.size,2);i.uniform2fv(this.addr,e)}function Pv(i,t){const e=ki(t,this.size,3);i.uniform3fv(this.addr,e)}function Lv(i,t){const e=ki(t,this.size,4);i.uniform4fv(this.addr,e)}function Dv(i,t){const e=ki(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Uv(i,t){const e=ki(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Iv(i,t){const e=ki(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Nv(i,t){i.uniform1iv(this.addr,t)}function Fv(i,t){i.uniform2iv(this.addr,t)}function Ov(i,t){i.uniform3iv(this.addr,t)}function Bv(i,t){i.uniform4iv(this.addr,t)}function zv(i,t){i.uniform1uiv(this.addr,t)}function Hv(i,t){i.uniform2uiv(this.addr,t)}function kv(i,t){i.uniform3uiv(this.addr,t)}function Vv(i,t){i.uniform4uiv(this.addr,t)}function Gv(i,t,e){const n=this.cache,r=t.length,s=ms(e,r);pe(n,s)||(i.uniform1iv(this.addr,s),me(n,s));for(let o=0;o!==r;++o)e.setTexture2D(t[o]||uh,s[o])}function Wv(i,t,e){const n=this.cache,r=t.length,s=ms(e,r);pe(n,s)||(i.uniform1iv(this.addr,s),me(n,s));for(let o=0;o!==r;++o)e.setTexture3D(t[o]||fh,s[o])}function Xv(i,t,e){const n=this.cache,r=t.length,s=ms(e,r);pe(n,s)||(i.uniform1iv(this.addr,s),me(n,s));for(let o=0;o!==r;++o)e.setTextureCube(t[o]||dh,s[o])}function qv(i,t,e){const n=this.cache,r=t.length,s=ms(e,r);pe(n,s)||(i.uniform1iv(this.addr,s),me(n,s));for(let o=0;o!==r;++o)e.setTexture2DArray(t[o]||hh,s[o])}function Yv(i){switch(i){case 5126:return Rv;case 35664:return Cv;case 35665:return Pv;case 35666:return Lv;case 35674:return Dv;case 35675:return Uv;case 35676:return Iv;case 5124:case 35670:return Nv;case 35667:case 35671:return Fv;case 35668:case 35672:return Ov;case 35669:case 35673:return Bv;case 5125:return zv;case 36294:return Hv;case 36295:return kv;case 36296:return Vv;case 35678:case 36198:case 36298:case 36306:case 35682:return Gv;case 35679:case 36299:case 36307:return Wv;case 35680:case 36300:case 36308:case 36293:return Xv;case 36289:case 36303:case 36311:case 36292:return qv}}class Kv{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=wv(e.type)}}class Zv{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=Yv(e.type)}}class $v{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(t,e[a.id],n)}}}const Qs=/(\w+)(\])?(\[|\.)?/g;function nu(i,t){i.seq.push(t),i.map[t.id]=t}function Jv(i,t,e){const n=i.name,r=n.length;for(Qs.lastIndex=0;;){const s=Qs.exec(n),o=Qs.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){nu(e,l===void 0?new Kv(a,i,t):new Zv(a,i,t));break}else{let h=e.map[a];h===void 0&&(h=new $v(a),nu(e,h)),e=h}}}class Qr{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=t.getActiveUniform(e,r),o=t.getUniformLocation(e,s.name);Jv(s,o,this)}}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,o=e.length;s!==o;++s){const a=e[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(t,c.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const o=t[r];o.id in e&&n.push(o)}return n}}function iu(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const jv=37297;let Qv=0;function t0(i,t){const e=i.split(`
|
|
3725
3763
|
`),n=[],r=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let o=r;o<s;o++){const a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
|
|
3726
|
-
`)}const
|
|
3764
|
+
`)}const ru=new Ht;function e0(i){Jt._getMatrix(ru,Jt.workingColorSpace,i);const t=`mat3( ${ru.elements.map(e=>e.toFixed(4))} )`;switch(Jt.getTransfer(i)){case rs:return[t,"LinearTransferOETF"];case ne:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function su(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=i.getShaderInfoLog(t).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return e.toUpperCase()+`
|
|
3727
3765
|
|
|
3728
3766
|
`+r+`
|
|
3729
3767
|
|
|
3730
|
-
`+
|
|
3731
|
-
`)}function
|
|
3732
|
-
`)}function
|
|
3733
|
-
`)}function
|
|
3734
|
-
`)}function
|
|
3768
|
+
`+t0(i.getShaderSource(t),o)}else return r}function n0(i,t){const e=e0(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
|
|
3769
|
+
`)}function i0(i,t){let e;switch(t){case ud:e="Linear";break;case hd:e="Reinhard";break;case fd:e="Cineon";break;case Ru:e="ACESFilmic";break;case pd:e="AgX";break;case md:e="Neutral";break;case dd:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const qr=new D;function r0(){Jt.getLuminanceCoefficients(qr);const i=qr.x.toFixed(4),t=qr.y.toFixed(4),e=qr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
3770
|
+
`)}function s0(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zi).join(`
|
|
3771
|
+
`)}function o0(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
3772
|
+
`)}function a0(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(t,r),o=s.name;let a=1;s.type===i.FLOAT_MAT2&&(a=2),s.type===i.FLOAT_MAT3&&(a=3),s.type===i.FLOAT_MAT4&&(a=4),e[o]={type:s.type,location:i.getAttribLocation(t,o),locationSize:a}}return e}function Zi(i){return i!==""}function ou(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function au(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const c0=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ca(i){return i.replace(c0,u0)}const l0=new Map;function u0(i,t){let e=Vt[t];if(e===void 0){const n=l0.get(t);if(n!==void 0)e=Vt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Ca(e)}const h0=/#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 cu(i){return i.replace(h0,f0)}function f0(i,t,e,n){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function lu(i){let t=`precision ${i.precision} float;
|
|
3735
3773
|
precision ${i.precision} int;
|
|
3736
3774
|
precision ${i.precision} sampler2D;
|
|
3737
3775
|
precision ${i.precision} samplerCube;
|
|
@@ -3751,30 +3789,30 @@ void main() {
|
|
|
3751
3789
|
`;return i.precision==="highp"?t+=`
|
|
3752
3790
|
#define HIGH_PRECISION`:i.precision==="mediump"?t+=`
|
|
3753
3791
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
|
|
3754
|
-
#define LOW_PRECISION`),t}function
|
|
3755
|
-
`:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(
|
|
3792
|
+
#define LOW_PRECISION`),t}function d0(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Au?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===bu?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===hn&&(t="SHADOWMAP_TYPE_VSM"),t}function p0(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Li:case Di:t="ENVMAP_TYPE_CUBE";break;case ds:t="ENVMAP_TYPE_CUBE_UV";break}return t}function m0(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Di:t="ENVMAP_MODE_REFRACTION";break}return t}function g0(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case wu:t="ENVMAP_BLENDING_MULTIPLY";break;case cd:t="ENVMAP_BLENDING_MIX";break;case ld:t="ENVMAP_BLENDING_ADD";break}return t}function _0(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function v0(i,t,e,n){const r=i.getContext(),s=e.defines;let o=e.vertexShader,a=e.fragmentShader;const c=d0(e),l=p0(e),u=m0(e),h=g0(e),f=_0(e),d=s0(e),g=o0(s),v=r.createProgram();let m,p,A=e.glslVersion?"#version "+e.glslVersion+`
|
|
3793
|
+
`:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Zi).join(`
|
|
3756
3794
|
`),m.length>0&&(m+=`
|
|
3757
|
-
`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(
|
|
3795
|
+
`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Zi).join(`
|
|
3758
3796
|
`),p.length>0&&(p+=`
|
|
3759
|
-
`)):(m=[
|
|
3760
|
-
`].filter(
|
|
3761
|
-
`),p=[
|
|
3762
|
-
`].filter(
|
|
3763
|
-
`)),o=
|
|
3797
|
+
`)):(m=[lu(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
3798
|
+
`].filter(Zi).join(`
|
|
3799
|
+
`),p=[lu(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+u:"",e.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==wn?"#define TONE_MAPPING":"",e.toneMapping!==wn?Vt.tonemapping_pars_fragment:"",e.toneMapping!==wn?i0("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Vt.colorspace_pars_fragment,n0("linearToOutputTexel",e.outputColorSpace),r0(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
3800
|
+
`].filter(Zi).join(`
|
|
3801
|
+
`)),o=Ca(o),o=ou(o,e),o=au(o,e),a=Ca(a),a=ou(a,e),a=au(a,e),o=cu(o),a=cu(a),e.isRawShaderMaterial!==!0&&(A=`#version 300 es
|
|
3764
3802
|
`,m=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3765
3803
|
`)+`
|
|
3766
|
-
`+m,p=["#define varying in",e.glslVersion===
|
|
3804
|
+
`+m,p=["#define varying in",e.glslVersion===hl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===hl?"":"#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(`
|
|
3767
3805
|
`)+`
|
|
3768
|
-
`+p);const
|
|
3806
|
+
`+p);const y=A+m+o,S=A+p+a,L=iu(r,r.VERTEX_SHADER,y),P=iu(r,r.FRAGMENT_SHADER,S);r.attachShader(v,L),r.attachShader(v,P),e.index0AttributeName!==void 0?r.bindAttribLocation(v,0,e.index0AttributeName):e.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function C(w){if(i.debug.checkShaderErrors){const B=r.getProgramInfoLog(v).trim(),F=r.getShaderInfoLog(L).trim(),k=r.getShaderInfoLog(P).trim();let X=!0,G=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(X=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,v,L,P);else{const $=su(r,L,"vertex"),V=su(r,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
|
|
3769
3807
|
|
|
3770
3808
|
Material Name: `+w.name+`
|
|
3771
3809
|
Material Type: `+w.type+`
|
|
3772
3810
|
|
|
3773
|
-
Program Info Log: `+
|
|
3774
|
-
|
|
3775
|
-
`+k)}else H!==""?console.warn("THREE.WebGLProgram: Program Info Log:",H):(O===""||V==="")&&(G=!1);G&&(w.diagnostics={runnable:X,programLog:H,vertexShader:{log:O,prefix:m},fragmentShader:{log:V,prefix:p}})}r.deleteShader(L),r.deleteShader(C),D=new Hr(r,v),y=v_(r,v)}let D;this.getUniforms=function(){return D===void 0&&R(this),D};let y;this.getAttributes=function(){return y===void 0&&R(this),y};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,l_)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=u_++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=L,this.fragmentShader=C,this}let P_=0;class L_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&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 n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new D_(t),e.set(t,n)),n}}class D_{constructor(t){this.id=P_++,this.code=t,this.usedTimes=0}}function U_(i,t,e,n,r,s,o){const a=new Va,c=new L_,l=new Set,u=[],h=r.logarithmicDepthBuffer,f=r.vertexTextures;let d=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 v(y){return l.add(y),y===0?"uv":`uv${y}`}function m(y,M,w,H,O){const V=H.fog,X=O.geometry,G=y.isMeshStandardMaterial?H.environment:null,K=(y.isMeshStandardMaterial?e:t).get(y.envMap||G),k=K&&K.mapping===Jr?K.image.height:null,ct=g[y.type];y.precision!==null&&(d=r.getMaxPrecision(y.precision),d!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",d,"instead."));const pt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Mt=pt!==void 0?pt.length:0;let Ft=0;X.morphAttributes.position!==void 0&&(Ft=1),X.morphAttributes.normal!==void 0&&(Ft=2),X.morphAttributes.color!==void 0&&(Ft=3);let Zt,Y,st,Q;if(ct){const Qt=Ye[ct];Zt=Qt.vertexShader,Y=Qt.fragmentShader}else Zt=y.vertexShader,Y=y.fragmentShader,c.update(y),st=c.getVertexShaderID(y),Q=c.getFragmentShaderID(y);const j=i.getRenderTarget(),ut=i.state.buffers.depth.getReversed(),vt=O.isInstancedMesh===!0,Rt=O.isBatchedMesh===!0,Vt=!!y.map,J=!!y.matcap,et=!!K,A=!!y.aoMap,bt=!!y.lightMap,nt=!!y.bumpMap,St=!!y.normalMap,ot=!!y.displacementMap,Dt=!!y.emissiveMap,mt=!!y.metalnessMap,E=!!y.roughnessMap,_=y.anisotropy>0,F=y.clearcoat>0,q=y.dispersion>0,tt=y.iridescence>0,Z=y.sheen>0,wt=y.transmission>0,ht=_&&!!y.anisotropyMap,xt=F&&!!y.clearcoatMap,Xt=F&&!!y.clearcoatNormalMap,rt=F&&!!y.clearcoatRoughnessMap,Et=tt&&!!y.iridescenceMap,Lt=tt&&!!y.iridescenceThicknessMap,Ut=Z&&!!y.sheenColorMap,Tt=Z&&!!y.sheenRoughnessMap,qt=!!y.specularMap,Ht=!!y.specularColorMap,ie=!!y.specularIntensityMap,U=wt&&!!y.transmissionMap,ft=wt&&!!y.thicknessMap,W=!!y.gradientMap,$=!!y.alphaMap,_t=y.alphaTest>0,gt=!!y.alphaHash,Bt=!!y.extensions;let ae=Tn;y.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(ae=i.toneMapping);const xe={shaderID:ct,shaderType:y.type,shaderName:y.name,vertexShader:Zt,fragmentShader:Y,defines:y.defines,customVertexShaderID:st,customFragmentShaderID:Q,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:d,batching:Rt,batchingColor:Rt&&O._colorsTexture!==null,instancing:vt,instancingColor:vt&&O.instanceColor!==null,instancingMorph:vt&&O.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:j===null?i.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Pi,alphaToCoverage:!!y.alphaToCoverage,map:Vt,matcap:J,envMap:et,envMapMode:et&&K.mapping,envMapCubeUVHeight:k,aoMap:A,lightMap:bt,bumpMap:nt,normalMap:St,displacementMap:f&&ot,emissiveMap:Dt,normalMapObjectSpace:St&&y.normalMapType===Ch,normalMapTangentSpace:St&&y.normalMapType===Yl,metalnessMap:mt,roughnessMap:E,anisotropy:_,anisotropyMap:ht,clearcoat:F,clearcoatMap:xt,clearcoatNormalMap:Xt,clearcoatRoughnessMap:rt,dispersion:q,iridescence:tt,iridescenceMap:Et,iridescenceThicknessMap:Lt,sheen:Z,sheenColorMap:Ut,sheenRoughnessMap:Tt,specularMap:qt,specularColorMap:Ht,specularIntensityMap:ie,transmission:wt,transmissionMap:U,thicknessMap:ft,gradientMap:W,opaque:y.transparent===!1&&y.blending===Mi&&y.alphaToCoverage===!1,alphaMap:$,alphaTest:_t,alphaHash:gt,combine:y.combine,mapUv:Vt&&v(y.map.channel),aoMapUv:A&&v(y.aoMap.channel),lightMapUv:bt&&v(y.lightMap.channel),bumpMapUv:nt&&v(y.bumpMap.channel),normalMapUv:St&&v(y.normalMap.channel),displacementMapUv:ot&&v(y.displacementMap.channel),emissiveMapUv:Dt&&v(y.emissiveMap.channel),metalnessMapUv:mt&&v(y.metalnessMap.channel),roughnessMapUv:E&&v(y.roughnessMap.channel),anisotropyMapUv:ht&&v(y.anisotropyMap.channel),clearcoatMapUv:xt&&v(y.clearcoatMap.channel),clearcoatNormalMapUv:Xt&&v(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&v(y.clearcoatRoughnessMap.channel),iridescenceMapUv:Et&&v(y.iridescenceMap.channel),iridescenceThicknessMapUv:Lt&&v(y.iridescenceThicknessMap.channel),sheenColorMapUv:Ut&&v(y.sheenColorMap.channel),sheenRoughnessMapUv:Tt&&v(y.sheenRoughnessMap.channel),specularMapUv:qt&&v(y.specularMap.channel),specularColorMapUv:Ht&&v(y.specularColorMap.channel),specularIntensityMapUv:ie&&v(y.specularIntensityMap.channel),transmissionMapUv:U&&v(y.transmissionMap.channel),thicknessMapUv:ft&&v(y.thicknessMap.channel),alphaMapUv:$&&v(y.alphaMap.channel),vertexTangents:!!X.attributes.tangent&&(St||_),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!X.attributes.uv&&(Vt||$),fog:!!V,useFog:y.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:ut,skinning:O.isSkinnedMesh===!0,morphTargets:X.morphAttributes.position!==void 0,morphNormals:X.morphAttributes.normal!==void 0,morphColors:X.morphAttributes.color!==void 0,morphTargetsCount:Mt,morphTextureStride:Ft,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&w.length>0,shadowMapType:i.shadowMap.type,toneMapping:ae,decodeVideoTexture:Vt&&y.map.isVideoTexture===!0&&Kt.getTransfer(y.map.colorSpace)===te,decodeVideoTextureEmissive:Dt&&y.emissiveMap.isVideoTexture===!0&&Kt.getTransfer(y.emissiveMap.colorSpace)===te,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Ze,flipSided:y.side===Ce,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:Bt&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Bt&&y.extensions.multiDraw===!0||Rt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return xe.vertexUv1s=l.has(1),xe.vertexUv2s=l.has(2),xe.vertexUv3s=l.has(3),l.clear(),xe}function p(y){const M=[];if(y.shaderID?M.push(y.shaderID):(M.push(y.customVertexShaderID),M.push(y.customFragmentShaderID)),y.defines!==void 0)for(const w in y.defines)M.push(w),M.push(y.defines[w]);return y.isRawShaderMaterial===!1&&(b(M,y),T(M,y),M.push(i.outputColorSpace)),M.push(y.customProgramCacheKey),M.join()}function b(y,M){y.push(M.precision),y.push(M.outputColorSpace),y.push(M.envMapMode),y.push(M.envMapCubeUVHeight),y.push(M.mapUv),y.push(M.alphaMapUv),y.push(M.lightMapUv),y.push(M.aoMapUv),y.push(M.bumpMapUv),y.push(M.normalMapUv),y.push(M.displacementMapUv),y.push(M.emissiveMapUv),y.push(M.metalnessMapUv),y.push(M.roughnessMapUv),y.push(M.anisotropyMapUv),y.push(M.clearcoatMapUv),y.push(M.clearcoatNormalMapUv),y.push(M.clearcoatRoughnessMapUv),y.push(M.iridescenceMapUv),y.push(M.iridescenceThicknessMapUv),y.push(M.sheenColorMapUv),y.push(M.sheenRoughnessMapUv),y.push(M.specularMapUv),y.push(M.specularColorMapUv),y.push(M.specularIntensityMapUv),y.push(M.transmissionMapUv),y.push(M.thicknessMapUv),y.push(M.combine),y.push(M.fogExp2),y.push(M.sizeAttenuation),y.push(M.morphTargetsCount),y.push(M.morphAttributeCount),y.push(M.numDirLights),y.push(M.numPointLights),y.push(M.numSpotLights),y.push(M.numSpotLightMaps),y.push(M.numHemiLights),y.push(M.numRectAreaLights),y.push(M.numDirLightShadows),y.push(M.numPointLightShadows),y.push(M.numSpotLightShadows),y.push(M.numSpotLightShadowsWithMaps),y.push(M.numLightProbes),y.push(M.shadowMapType),y.push(M.toneMapping),y.push(M.numClippingPlanes),y.push(M.numClipIntersection),y.push(M.depthPacking)}function T(y,M){a.disableAll(),M.supportsVertexTextures&&a.enable(0),M.instancing&&a.enable(1),M.instancingColor&&a.enable(2),M.instancingMorph&&a.enable(3),M.matcap&&a.enable(4),M.envMap&&a.enable(5),M.normalMapObjectSpace&&a.enable(6),M.normalMapTangentSpace&&a.enable(7),M.clearcoat&&a.enable(8),M.iridescence&&a.enable(9),M.alphaTest&&a.enable(10),M.vertexColors&&a.enable(11),M.vertexAlphas&&a.enable(12),M.vertexUv1s&&a.enable(13),M.vertexUv2s&&a.enable(14),M.vertexUv3s&&a.enable(15),M.vertexTangents&&a.enable(16),M.anisotropy&&a.enable(17),M.alphaHash&&a.enable(18),M.batching&&a.enable(19),M.dispersion&&a.enable(20),M.batchingColor&&a.enable(21),y.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.reverseDepthBuffer&&a.enable(4),M.skinning&&a.enable(5),M.morphTargets&&a.enable(6),M.morphNormals&&a.enable(7),M.morphColors&&a.enable(8),M.premultipliedAlpha&&a.enable(9),M.shadowMapEnabled&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.decodeVideoTextureEmissive&&a.enable(20),M.alphaToCoverage&&a.enable(21),y.push(a.mask)}function S(y){const M=g[y.type];let w;if(M){const H=Ye[M];w=yf.clone(H.uniforms)}else w=y.uniforms;return w}function L(y,M){let w;for(let H=0,O=u.length;H<O;H++){const V=u[H];if(V.cacheKey===M){w=V,++w.usedTimes;break}}return w===void 0&&(w=new C_(i,M,y,s),u.push(w)),w}function C(y){if(--y.usedTimes===0){const M=u.indexOf(y);u[M]=u[u.length-1],u.pop(),y.destroy()}}function R(y){c.remove(y)}function D(){c.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:S,acquireProgram:L,releaseProgram:C,releaseShaderCache:R,programs:u,dispose:D}}function I_(){let i=new WeakMap;function t(o){return i.has(o)}function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,c){i.get(o)[a]=c}function s(){i=new WeakMap}return{has:t,get:e,remove:n,update:r,dispose:s}}function N_(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function Tl(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Al(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function o(h,f,d,g,v,m){let p=i[t];return p===void 0?(p={id:h.id,object:h,geometry:f,material:d,groupOrder:g,renderOrder:h.renderOrder,z:v,group:m},i[t]=p):(p.id=h.id,p.object=h,p.geometry=f,p.material=d,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=v,p.group=m),t++,p}function a(h,f,d,g,v,m){const p=o(h,f,d,g,v,m);d.transmission>0?n.push(p):d.transparent===!0?r.push(p):e.push(p)}function c(h,f,d,g,v,m){const p=o(h,f,d,g,v,m);d.transmission>0?n.unshift(p):d.transparent===!0?r.unshift(p):e.unshift(p)}function l(h,f){e.length>1&&e.sort(h||N_),n.length>1&&n.sort(f||Tl),r.length>1&&r.sort(f||Tl)}function u(){for(let h=t,f=i.length;h<f;h++){const d=i[h];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:e,transmissive:n,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function F_(){let i=new WeakMap;function t(n,r){const s=i.get(n);let o;return s===void 0?(o=new Al,i.set(n,[o])):r>=s.length?(o=new Al,s.push(o)):o=s[r],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function O_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new Wt};break;case"SpotLight":e={position:new P,direction:new P,color:new Wt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new Wt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new Wt,groundColor:new Wt};break;case"RectAreaLight":e={color:new Wt,position:new P,halfWidth:new P,halfHeight:new P};break}return i[t.id]=e,e}}}function B_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let z_=0;function H_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function k_(i){const t=new O_,e=B_(),n={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 l=0;l<9;l++)n.probe.push(new P);const r=new P,s=new re,o=new re;function a(l){let u=0,h=0,f=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let d=0,g=0,v=0,m=0,p=0,b=0,T=0,S=0,L=0,C=0,R=0;l.sort(H_);for(let y=0,M=l.length;y<M;y++){const w=l[y],H=w.color,O=w.intensity,V=w.distance,X=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)u+=H.r*O,h+=H.g*O,f+=H.b*O;else if(w.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(w.sh.coefficients[G],O);R++}else if(w.isDirectionalLight){const G=t.get(w);if(G.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){const K=w.shadow,k=e.get(w);k.shadowIntensity=K.intensity,k.shadowBias=K.bias,k.shadowNormalBias=K.normalBias,k.shadowRadius=K.radius,k.shadowMapSize=K.mapSize,n.directionalShadow[d]=k,n.directionalShadowMap[d]=X,n.directionalShadowMatrix[d]=w.shadow.matrix,b++}n.directional[d]=G,d++}else if(w.isSpotLight){const G=t.get(w);G.position.setFromMatrixPosition(w.matrixWorld),G.color.copy(H).multiplyScalar(O),G.distance=V,G.coneCos=Math.cos(w.angle),G.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),G.decay=w.decay,n.spot[v]=G;const K=w.shadow;if(w.map&&(n.spotLightMap[L]=w.map,L++,K.updateMatrices(w),w.castShadow&&C++),n.spotLightMatrix[v]=K.matrix,w.castShadow){const k=e.get(w);k.shadowIntensity=K.intensity,k.shadowBias=K.bias,k.shadowNormalBias=K.normalBias,k.shadowRadius=K.radius,k.shadowMapSize=K.mapSize,n.spotShadow[v]=k,n.spotShadowMap[v]=X,S++}v++}else if(w.isRectAreaLight){const G=t.get(w);G.color.copy(H).multiplyScalar(O),G.halfWidth.set(w.width*.5,0,0),G.halfHeight.set(0,w.height*.5,0),n.rectArea[m]=G,m++}else if(w.isPointLight){const G=t.get(w);if(G.color.copy(w.color).multiplyScalar(w.intensity),G.distance=w.distance,G.decay=w.decay,w.castShadow){const K=w.shadow,k=e.get(w);k.shadowIntensity=K.intensity,k.shadowBias=K.bias,k.shadowNormalBias=K.normalBias,k.shadowRadius=K.radius,k.shadowMapSize=K.mapSize,k.shadowCameraNear=K.camera.near,k.shadowCameraFar=K.camera.far,n.pointShadow[g]=k,n.pointShadowMap[g]=X,n.pointShadowMatrix[g]=w.shadow.matrix,T++}n.point[g]=G,g++}else if(w.isHemisphereLight){const G=t.get(w);G.skyColor.copy(w.color).multiplyScalar(O),G.groundColor.copy(w.groundColor).multiplyScalar(O),n.hemi[p]=G,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=lt.LTC_FLOAT_1,n.rectAreaLTC2=lt.LTC_FLOAT_2):(n.rectAreaLTC1=lt.LTC_HALF_1,n.rectAreaLTC2=lt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;const D=n.hash;(D.directionalLength!==d||D.pointLength!==g||D.spotLength!==v||D.rectAreaLength!==m||D.hemiLength!==p||D.numDirectionalShadows!==b||D.numPointShadows!==T||D.numSpotShadows!==S||D.numSpotMaps!==L||D.numLightProbes!==R)&&(n.directional.length=d,n.spot.length=v,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=S+L-C,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=C,n.numLightProbes=R,D.directionalLength=d,D.pointLength=g,D.spotLength=v,D.rectAreaLength=m,D.hemiLength=p,D.numDirectionalShadows=b,D.numPointShadows=T,D.numSpotShadows=S,D.numSpotMaps=L,D.numLightProbes=R,n.version=z_++)}function c(l,u){let h=0,f=0,d=0,g=0,v=0;const m=u.matrixWorldInverse;for(let p=0,b=l.length;p<b;p++){const T=l[p];if(T.isDirectionalLight){const S=n.directional[h];S.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),h++}else if(T.isSpotLight){const S=n.spot[d];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),d++}else if(T.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),o.identity(),s.copy(T.matrixWorld),s.premultiply(m),o.extractRotation(s),S.halfWidth.set(T.width*.5,0,0),S.halfHeight.set(0,T.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),g++}else if(T.isPointLight){const S=n.point[f];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),f++}else if(T.isHemisphereLight){const S=n.hemi[v];S.direction.setFromMatrixPosition(T.matrixWorld),S.direction.transformDirection(m),v++}}}return{setup:a,setupView:c,state:n}}function bl(i){const t=new k_(i),e=[],n=[];function r(u){l.camera=u,e.length=0,n.length=0}function s(u){e.push(u)}function o(u){n.push(u)}function a(){t.setup(e)}function c(u){t.setupView(e,u)}const l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function G_(i){let t=new WeakMap;function e(r,s=0){const o=t.get(r);let a;return o===void 0?(a=new bl(i),t.set(r,[a])):s>=o.length?(a=new bl(i),o.push(a)):a=o[s],a}function n(){t=new WeakMap}return{get:e,dispose:n}}const V_=`void main() {
|
|
3811
|
+
Program Info Log: `+B+`
|
|
3812
|
+
`+$+`
|
|
3813
|
+
`+V)}else B!==""?console.warn("THREE.WebGLProgram: Program Info Log:",B):(F===""||k==="")&&(G=!1);G&&(w.diagnostics={runnable:X,programLog:B,vertexShader:{log:F,prefix:m},fragmentShader:{log:k,prefix:p}})}r.deleteShader(L),r.deleteShader(P),R=new Qr(r,v),E=a0(r,v)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let E;this.getAttributes=function(){return E===void 0&&C(this),E};let _=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return _===!1&&(_=r.getProgramParameter(v,jv)),_},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Qv++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=L,this.fragmentShader=P,this}let x0=0;class M0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&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 n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new S0(t),e.set(t,n)),n}}class S0{constructor(t){this.id=x0++,this.code=t,this.usedTimes=0}}function E0(i,t,e,n,r,s,o){const a=new Tc,c=new M0,l=new Set,u=[],h=r.logarithmicDepthBuffer,f=r.vertexTextures;let d=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 v(E){return l.add(E),E===0?"uv":`uv${E}`}function m(E,_,w,B,F){const k=B.fog,X=F.geometry,G=E.isMeshStandardMaterial?B.environment:null,$=(E.isMeshStandardMaterial?e:t).get(E.envMap||G),V=$&&$.mapping===ds?$.image.height:null,lt=g[E.type];E.precision!==null&&(d=r.getMaxPrecision(E.precision),d!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",d,"instead."));const mt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,St=mt!==void 0?mt.length:0;let Ot=0;X.morphAttributes.position!==void 0&&(Ot=1),X.morphAttributes.normal!==void 0&&(Ot=2),X.morphAttributes.color!==void 0&&(Ot=3);let Zt,Y,ot,Q;if(lt){const te=Je[lt];Zt=te.vertexShader,Y=te.fragmentShader}else Zt=E.vertexShader,Y=E.fragmentShader,c.update(E),ot=c.getVertexShaderID(E),Q=c.getFragmentShaderID(E);const J=i.getRenderTarget(),ht=i.state.buffers.depth.getReversed(),xt=F.isInstancedMesh===!0,Ct=F.isBatchedMesh===!0,Wt=!!E.map,Z=!!E.matcap,et=!!$,b=!!E.aoMap,wt=!!E.lightMap,it=!!E.bumpMap,Et=!!E.normalMap,at=!!E.displacementMap,Ut=!!E.emissiveMap,gt=!!E.metalnessMap,T=!!E.roughnessMap,x=E.anisotropy>0,O=E.clearcoat>0,q=E.dispersion>0,tt=E.iridescence>0,K=E.sheen>0,Rt=E.transmission>0,ft=x&&!!E.anisotropyMap,Mt=O&&!!E.clearcoatMap,qt=O&&!!E.clearcoatNormalMap,st=O&&!!E.clearcoatRoughnessMap,Tt=tt&&!!E.iridescenceMap,Dt=tt&&!!E.iridescenceThicknessMap,Nt=K&&!!E.sheenColorMap,At=K&&!!E.sheenRoughnessMap,Yt=!!E.specularMap,kt=!!E.specularColorMap,se=!!E.specularIntensityMap,U=Rt&&!!E.transmissionMap,dt=Rt&&!!E.thicknessMap,W=!!E.gradientMap,j=!!E.alphaMap,vt=E.alphaTest>0,_t=!!E.alphaHash,zt=!!E.extensions;let le=wn;E.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(le=i.toneMapping);const Me={shaderID:lt,shaderType:E.type,shaderName:E.name,vertexShader:Zt,fragmentShader:Y,defines:E.defines,customVertexShaderID:ot,customFragmentShaderID:Q,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:d,batching:Ct,batchingColor:Ct&&F._colorsTexture!==null,instancing:xt,instancingColor:xt&&F.instanceColor!==null,instancingMorph:xt&&F.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:J===null?i.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:Fi,alphaToCoverage:!!E.alphaToCoverage,map:Wt,matcap:Z,envMap:et,envMapMode:et&&$.mapping,envMapCubeUVHeight:V,aoMap:b,lightMap:wt,bumpMap:it,normalMap:Et,displacementMap:f&&at,emissiveMap:Ut,normalMapObjectSpace:Et&&E.normalMapType===xd,normalMapTangentSpace:Et&&E.normalMapType===Hu,metalnessMap:gt,roughnessMap:T,anisotropy:x,anisotropyMap:ft,clearcoat:O,clearcoatMap:Mt,clearcoatNormalMap:qt,clearcoatRoughnessMap:st,dispersion:q,iridescence:tt,iridescenceMap:Tt,iridescenceThicknessMap:Dt,sheen:K,sheenColorMap:Nt,sheenRoughnessMap:At,specularMap:Yt,specularColorMap:kt,specularIntensityMap:se,transmission:Rt,transmissionMap:U,thicknessMap:dt,gradientMap:W,opaque:E.transparent===!1&&E.blending===bi&&E.alphaToCoverage===!1,alphaMap:j,alphaTest:vt,alphaHash:_t,combine:E.combine,mapUv:Wt&&v(E.map.channel),aoMapUv:b&&v(E.aoMap.channel),lightMapUv:wt&&v(E.lightMap.channel),bumpMapUv:it&&v(E.bumpMap.channel),normalMapUv:Et&&v(E.normalMap.channel),displacementMapUv:at&&v(E.displacementMap.channel),emissiveMapUv:Ut&&v(E.emissiveMap.channel),metalnessMapUv:gt&&v(E.metalnessMap.channel),roughnessMapUv:T&&v(E.roughnessMap.channel),anisotropyMapUv:ft&&v(E.anisotropyMap.channel),clearcoatMapUv:Mt&&v(E.clearcoatMap.channel),clearcoatNormalMapUv:qt&&v(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:st&&v(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Tt&&v(E.iridescenceMap.channel),iridescenceThicknessMapUv:Dt&&v(E.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&v(E.sheenColorMap.channel),sheenRoughnessMapUv:At&&v(E.sheenRoughnessMap.channel),specularMapUv:Yt&&v(E.specularMap.channel),specularColorMapUv:kt&&v(E.specularColorMap.channel),specularIntensityMapUv:se&&v(E.specularIntensityMap.channel),transmissionMapUv:U&&v(E.transmissionMap.channel),thicknessMapUv:dt&&v(E.thicknessMap.channel),alphaMapUv:j&&v(E.alphaMap.channel),vertexTangents:!!X.attributes.tangent&&(Et||x),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!X.attributes.uv&&(Wt||j),fog:!!k,useFog:E.fog===!0,fogExp2:!!k&&k.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:ht,skinning:F.isSkinnedMesh===!0,morphTargets:X.morphAttributes.position!==void 0,morphNormals:X.morphAttributes.normal!==void 0,morphColors:X.morphAttributes.color!==void 0,morphTargetsCount:St,morphTextureStride:Ot,numDirLights:_.directional.length,numPointLights:_.point.length,numSpotLights:_.spot.length,numSpotLightMaps:_.spotLightMap.length,numRectAreaLights:_.rectArea.length,numHemiLights:_.hemi.length,numDirLightShadows:_.directionalShadowMap.length,numPointLightShadows:_.pointShadowMap.length,numSpotLightShadows:_.spotShadowMap.length,numSpotLightShadowsWithMaps:_.numSpotLightShadowsWithMaps,numLightProbes:_.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:i.shadowMap.enabled&&w.length>0,shadowMapType:i.shadowMap.type,toneMapping:le,decodeVideoTexture:Wt&&E.map.isVideoTexture===!0&&Jt.getTransfer(E.map.colorSpace)===ne,decodeVideoTextureEmissive:Ut&&E.emissiveMap.isVideoTexture===!0&&Jt.getTransfer(E.emissiveMap.colorSpace)===ne,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===je,flipSided:E.side===Pe,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:zt&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(zt&&E.extensions.multiDraw===!0||Ct)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return Me.vertexUv1s=l.has(1),Me.vertexUv2s=l.has(2),Me.vertexUv3s=l.has(3),l.clear(),Me}function p(E){const _=[];if(E.shaderID?_.push(E.shaderID):(_.push(E.customVertexShaderID),_.push(E.customFragmentShaderID)),E.defines!==void 0)for(const w in E.defines)_.push(w),_.push(E.defines[w]);return E.isRawShaderMaterial===!1&&(A(_,E),y(_,E),_.push(i.outputColorSpace)),_.push(E.customProgramCacheKey),_.join()}function A(E,_){E.push(_.precision),E.push(_.outputColorSpace),E.push(_.envMapMode),E.push(_.envMapCubeUVHeight),E.push(_.mapUv),E.push(_.alphaMapUv),E.push(_.lightMapUv),E.push(_.aoMapUv),E.push(_.bumpMapUv),E.push(_.normalMapUv),E.push(_.displacementMapUv),E.push(_.emissiveMapUv),E.push(_.metalnessMapUv),E.push(_.roughnessMapUv),E.push(_.anisotropyMapUv),E.push(_.clearcoatMapUv),E.push(_.clearcoatNormalMapUv),E.push(_.clearcoatRoughnessMapUv),E.push(_.iridescenceMapUv),E.push(_.iridescenceThicknessMapUv),E.push(_.sheenColorMapUv),E.push(_.sheenRoughnessMapUv),E.push(_.specularMapUv),E.push(_.specularColorMapUv),E.push(_.specularIntensityMapUv),E.push(_.transmissionMapUv),E.push(_.thicknessMapUv),E.push(_.combine),E.push(_.fogExp2),E.push(_.sizeAttenuation),E.push(_.morphTargetsCount),E.push(_.morphAttributeCount),E.push(_.numDirLights),E.push(_.numPointLights),E.push(_.numSpotLights),E.push(_.numSpotLightMaps),E.push(_.numHemiLights),E.push(_.numRectAreaLights),E.push(_.numDirLightShadows),E.push(_.numPointLightShadows),E.push(_.numSpotLightShadows),E.push(_.numSpotLightShadowsWithMaps),E.push(_.numLightProbes),E.push(_.shadowMapType),E.push(_.toneMapping),E.push(_.numClippingPlanes),E.push(_.numClipIntersection),E.push(_.depthPacking)}function y(E,_){a.disableAll(),_.supportsVertexTextures&&a.enable(0),_.instancing&&a.enable(1),_.instancingColor&&a.enable(2),_.instancingMorph&&a.enable(3),_.matcap&&a.enable(4),_.envMap&&a.enable(5),_.normalMapObjectSpace&&a.enable(6),_.normalMapTangentSpace&&a.enable(7),_.clearcoat&&a.enable(8),_.iridescence&&a.enable(9),_.alphaTest&&a.enable(10),_.vertexColors&&a.enable(11),_.vertexAlphas&&a.enable(12),_.vertexUv1s&&a.enable(13),_.vertexUv2s&&a.enable(14),_.vertexUv3s&&a.enable(15),_.vertexTangents&&a.enable(16),_.anisotropy&&a.enable(17),_.alphaHash&&a.enable(18),_.batching&&a.enable(19),_.dispersion&&a.enable(20),_.batchingColor&&a.enable(21),E.push(a.mask),a.disableAll(),_.fog&&a.enable(0),_.useFog&&a.enable(1),_.flatShading&&a.enable(2),_.logarithmicDepthBuffer&&a.enable(3),_.reverseDepthBuffer&&a.enable(4),_.skinning&&a.enable(5),_.morphTargets&&a.enable(6),_.morphNormals&&a.enable(7),_.morphColors&&a.enable(8),_.premultipliedAlpha&&a.enable(9),_.shadowMapEnabled&&a.enable(10),_.doubleSided&&a.enable(11),_.flipSided&&a.enable(12),_.useDepthPacking&&a.enable(13),_.dithering&&a.enable(14),_.transmission&&a.enable(15),_.sheen&&a.enable(16),_.opaque&&a.enable(17),_.pointsUvs&&a.enable(18),_.decodeVideoTexture&&a.enable(19),_.decodeVideoTextureEmissive&&a.enable(20),_.alphaToCoverage&&a.enable(21),E.push(a.mask)}function S(E){const _=g[E.type];let w;if(_){const B=Je[_];w=hp.clone(B.uniforms)}else w=E.uniforms;return w}function L(E,_){let w;for(let B=0,F=u.length;B<F;B++){const k=u[B];if(k.cacheKey===_){w=k,++w.usedTimes;break}}return w===void 0&&(w=new v0(i,_,E,s),u.push(w)),w}function P(E){if(--E.usedTimes===0){const _=u.indexOf(E);u[_]=u[u.length-1],u.pop(),E.destroy()}}function C(E){c.remove(E)}function R(){c.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:S,acquireProgram:L,releaseProgram:P,releaseShaderCache:C,programs:u,dispose:R}}function y0(){let i=new WeakMap;function t(o){return i.has(o)}function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,c){i.get(o)[a]=c}function s(){i=new WeakMap}return{has:t,get:e,remove:n,update:r,dispose:s}}function T0(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function uu(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function hu(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function o(h,f,d,g,v,m){let p=i[t];return p===void 0?(p={id:h.id,object:h,geometry:f,material:d,groupOrder:g,renderOrder:h.renderOrder,z:v,group:m},i[t]=p):(p.id=h.id,p.object=h,p.geometry=f,p.material=d,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=v,p.group=m),t++,p}function a(h,f,d,g,v,m){const p=o(h,f,d,g,v,m);d.transmission>0?n.push(p):d.transparent===!0?r.push(p):e.push(p)}function c(h,f,d,g,v,m){const p=o(h,f,d,g,v,m);d.transmission>0?n.unshift(p):d.transparent===!0?r.unshift(p):e.unshift(p)}function l(h,f){e.length>1&&e.sort(h||T0),n.length>1&&n.sort(f||uu),r.length>1&&r.sort(f||uu)}function u(){for(let h=t,f=i.length;h<f;h++){const d=i[h];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:e,transmissive:n,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function A0(){let i=new WeakMap;function t(n,r){const s=i.get(n);let o;return s===void 0?(o=new hu,i.set(n,[o])):r>=s.length?(o=new hu,s.push(o)):o=s[r],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function b0(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new D,color:new Xt};break;case"SpotLight":e={position:new D,direction:new D,color:new Xt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new D,color:new Xt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new D,skyColor:new Xt,groundColor:new Xt};break;case"RectAreaLight":e={color:new Xt,position:new D,halfWidth:new D,halfHeight:new D};break}return i[t.id]=e,e}}}function w0(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ct};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ct};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ct,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let R0=0;function C0(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function P0(i){const t=new b0,e=w0(),n={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 l=0;l<9;l++)n.probe.push(new D);const r=new D,s=new oe,o=new oe;function a(l){let u=0,h=0,f=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let d=0,g=0,v=0,m=0,p=0,A=0,y=0,S=0,L=0,P=0,C=0;l.sort(C0);for(let E=0,_=l.length;E<_;E++){const w=l[E],B=w.color,F=w.intensity,k=w.distance,X=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)u+=B.r*F,h+=B.g*F,f+=B.b*F;else if(w.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(w.sh.coefficients[G],F);C++}else if(w.isDirectionalLight){const G=t.get(w);if(G.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){const $=w.shadow,V=e.get(w);V.shadowIntensity=$.intensity,V.shadowBias=$.bias,V.shadowNormalBias=$.normalBias,V.shadowRadius=$.radius,V.shadowMapSize=$.mapSize,n.directionalShadow[d]=V,n.directionalShadowMap[d]=X,n.directionalShadowMatrix[d]=w.shadow.matrix,A++}n.directional[d]=G,d++}else if(w.isSpotLight){const G=t.get(w);G.position.setFromMatrixPosition(w.matrixWorld),G.color.copy(B).multiplyScalar(F),G.distance=k,G.coneCos=Math.cos(w.angle),G.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),G.decay=w.decay,n.spot[v]=G;const $=w.shadow;if(w.map&&(n.spotLightMap[L]=w.map,L++,$.updateMatrices(w),w.castShadow&&P++),n.spotLightMatrix[v]=$.matrix,w.castShadow){const V=e.get(w);V.shadowIntensity=$.intensity,V.shadowBias=$.bias,V.shadowNormalBias=$.normalBias,V.shadowRadius=$.radius,V.shadowMapSize=$.mapSize,n.spotShadow[v]=V,n.spotShadowMap[v]=X,S++}v++}else if(w.isRectAreaLight){const G=t.get(w);G.color.copy(B).multiplyScalar(F),G.halfWidth.set(w.width*.5,0,0),G.halfHeight.set(0,w.height*.5,0),n.rectArea[m]=G,m++}else if(w.isPointLight){const G=t.get(w);if(G.color.copy(w.color).multiplyScalar(w.intensity),G.distance=w.distance,G.decay=w.decay,w.castShadow){const $=w.shadow,V=e.get(w);V.shadowIntensity=$.intensity,V.shadowBias=$.bias,V.shadowNormalBias=$.normalBias,V.shadowRadius=$.radius,V.shadowMapSize=$.mapSize,V.shadowCameraNear=$.camera.near,V.shadowCameraFar=$.camera.far,n.pointShadow[g]=V,n.pointShadowMap[g]=X,n.pointShadowMatrix[g]=w.shadow.matrix,y++}n.point[g]=G,g++}else if(w.isHemisphereLight){const G=t.get(w);G.skyColor.copy(w.color).multiplyScalar(F),G.groundColor.copy(w.groundColor).multiplyScalar(F),n.hemi[p]=G,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ut.LTC_FLOAT_1,n.rectAreaLTC2=ut.LTC_FLOAT_2):(n.rectAreaLTC1=ut.LTC_HALF_1,n.rectAreaLTC2=ut.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;const R=n.hash;(R.directionalLength!==d||R.pointLength!==g||R.spotLength!==v||R.rectAreaLength!==m||R.hemiLength!==p||R.numDirectionalShadows!==A||R.numPointShadows!==y||R.numSpotShadows!==S||R.numSpotMaps!==L||R.numLightProbes!==C)&&(n.directional.length=d,n.spot.length=v,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=y,n.pointShadowMap.length=y,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=y,n.spotLightMatrix.length=S+L-P,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=C,R.directionalLength=d,R.pointLength=g,R.spotLength=v,R.rectAreaLength=m,R.hemiLength=p,R.numDirectionalShadows=A,R.numPointShadows=y,R.numSpotShadows=S,R.numSpotMaps=L,R.numLightProbes=C,n.version=R0++)}function c(l,u){let h=0,f=0,d=0,g=0,v=0;const m=u.matrixWorldInverse;for(let p=0,A=l.length;p<A;p++){const y=l[p];if(y.isDirectionalLight){const S=n.directional[h];S.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),h++}else if(y.isSpotLight){const S=n.spot[d];S.position.setFromMatrixPosition(y.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),d++}else if(y.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(y.matrixWorld),S.position.applyMatrix4(m),o.identity(),s.copy(y.matrixWorld),s.premultiply(m),o.extractRotation(s),S.halfWidth.set(y.width*.5,0,0),S.halfHeight.set(0,y.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),g++}else if(y.isPointLight){const S=n.point[f];S.position.setFromMatrixPosition(y.matrixWorld),S.position.applyMatrix4(m),f++}else if(y.isHemisphereLight){const S=n.hemi[v];S.direction.setFromMatrixPosition(y.matrixWorld),S.direction.transformDirection(m),v++}}}return{setup:a,setupView:c,state:n}}function fu(i){const t=new P0(i),e=[],n=[];function r(u){l.camera=u,e.length=0,n.length=0}function s(u){e.push(u)}function o(u){n.push(u)}function a(){t.setup(e)}function c(u){t.setupView(e,u)}const l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function L0(i){let t=new WeakMap;function e(r,s=0){const o=t.get(r);let a;return o===void 0?(a=new fu(i),t.set(r,[a])):s>=o.length?(a=new fu(i),o.push(a)):a=o[s],a}function n(){t=new WeakMap}return{get:e,dispose:n}}const D0=`void main() {
|
|
3776
3814
|
gl_Position = vec4( position, 1.0 );
|
|
3777
|
-
}`,
|
|
3815
|
+
}`,U0=`uniform sampler2D shadow_pass;
|
|
3778
3816
|
uniform vec2 resolution;
|
|
3779
3817
|
uniform float radius;
|
|
3780
3818
|
#include <packing>
|
|
@@ -3800,12 +3838,12 @@ void main() {
|
|
|
3800
3838
|
squared_mean = squared_mean / samples;
|
|
3801
3839
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3802
3840
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3803
|
-
}`;function X_(i,t,e){let n=new Xa;const r=new at,s=new at,o=new ee,a=new ld({depthPacking:Rh}),c=new ud,l={},u=e.maxTextureSize,h={[bn]:Ce,[Ce]:bn,[Ze]:Ze},f=new wn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new at},radius:{value:4}},vertexShader:V_,fragmentShader:W_}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const g=new Pe;g.setAttribute("position",new je(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new le(g,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Dl;let p=this.type;this.render=function(C,R,D){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||C.length===0)return;const y=i.getRenderTarget(),M=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),H=i.state;H.setBlending(En),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const O=p!==an&&this.type===an,V=p===an&&this.type!==an;for(let X=0,G=C.length;X<G;X++){const K=C[X],k=K.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);const ct=k.getFrameExtents();if(r.multiply(ct),s.copy(k.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ct.x),r.x=s.x*ct.x,k.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ct.y),r.y=s.y*ct.y,k.mapSize.y=s.y)),k.map===null||O===!0||V===!0){const Mt=this.type!==an?{minFilter:Xe,magFilter:Xe}:{};k.map!==null&&k.map.dispose(),k.map=new Yn(r.x,r.y,Mt),k.map.texture.name=K.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();const pt=k.getViewportCount();for(let Mt=0;Mt<pt;Mt++){const Ft=k.getViewport(Mt);o.set(s.x*Ft.x,s.y*Ft.y,s.x*Ft.z,s.y*Ft.w),H.viewport(o),k.updateMatrices(K,Mt),n=k.getFrustum(),S(R,D,k.camera,K,this.type)}k.isPointLightShadow!==!0&&this.type===an&&b(k,D),k.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(y,M,w)};function b(C,R){const D=t.update(v);f.defines.VSM_SAMPLES!==C.blurSamples&&(f.defines.VSM_SAMPLES=C.blurSamples,d.defines.VSM_SAMPLES=C.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new Yn(r.x,r.y)),f.uniforms.shadow_pass.value=C.map.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,i.setRenderTarget(C.mapPass),i.clear(),i.renderBufferDirect(R,null,D,f,v,null),d.uniforms.shadow_pass.value=C.mapPass.texture,d.uniforms.resolution.value=C.mapSize,d.uniforms.radius.value=C.radius,i.setRenderTarget(C.map),i.clear(),i.renderBufferDirect(R,null,D,d,v,null)}function T(C,R,D,y){let M=null;const w=D.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(w!==void 0)M=w;else if(M=D.isPointLight===!0?c:a,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){const H=M.uuid,O=R.uuid;let V=l[H];V===void 0&&(V={},l[H]=V);let X=V[O];X===void 0&&(X=M.clone(),V[O]=X,R.addEventListener("dispose",L)),M=X}if(M.visible=R.visible,M.wireframe=R.wireframe,y===an?M.side=R.shadowSide!==null?R.shadowSide:R.side:M.side=R.shadowSide!==null?R.shadowSide:h[R.side],M.alphaMap=R.alphaMap,M.alphaTest=R.alphaTest,M.map=R.map,M.clipShadows=R.clipShadows,M.clippingPlanes=R.clippingPlanes,M.clipIntersection=R.clipIntersection,M.displacementMap=R.displacementMap,M.displacementScale=R.displacementScale,M.displacementBias=R.displacementBias,M.wireframeLinewidth=R.wireframeLinewidth,M.linewidth=R.linewidth,D.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const H=i.properties.get(M);H.light=D}return M}function S(C,R,D,y,M){if(C.visible===!1)return;if(C.layers.test(R.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&M===an)&&(!C.frustumCulled||n.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,C.matrixWorld);const O=t.update(C),V=C.material;if(Array.isArray(V)){const X=O.groups;for(let G=0,K=X.length;G<K;G++){const k=X[G],ct=V[k.materialIndex];if(ct&&ct.visible){const pt=T(C,ct,y,M);C.onBeforeShadow(i,C,R,D,O,pt,k),i.renderBufferDirect(D,null,O,pt,C,k),C.onAfterShadow(i,C,R,D,O,pt,k)}}}else if(V.visible){const X=T(C,V,y,M);C.onBeforeShadow(i,C,R,D,O,X,null),i.renderBufferDirect(D,null,O,X,C,null),C.onAfterShadow(i,C,R,D,O,X,null)}}const H=C.children;for(let O=0,V=H.length;O<V;O++)S(H[O],R,D,y,M)}function L(C){C.target.removeEventListener("dispose",L);for(const D in l){const y=l[D],M=C.target.uuid;M in y&&(y[M].dispose(),delete y[M])}}}const q_={[Ws]:Xs,[qs]:Js,[Ys]:Ks,[Ti]:Zs,[Xs]:Ws,[Js]:qs,[Ks]:Ys,[Zs]:Ti};function Y_(i,t){function e(){let U=!1;const ft=new ee;let W=null;const $=new ee(0,0,0,0);return{setMask:function(_t){W!==_t&&!U&&(i.colorMask(_t,_t,_t,_t),W=_t)},setLocked:function(_t){U=_t},setClear:function(_t,gt,Bt,ae,xe){xe===!0&&(_t*=ae,gt*=ae,Bt*=ae),ft.set(_t,gt,Bt,ae),$.equals(ft)===!1&&(i.clearColor(_t,gt,Bt,ae),$.copy(ft))},reset:function(){U=!1,W=null,$.set(-1,0,0,0)}}}function n(){let U=!1,ft=!1,W=null,$=null,_t=null;return{setReversed:function(gt){if(ft!==gt){const Bt=t.get("EXT_clip_control");ft?Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.ZERO_TO_ONE_EXT):Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.NEGATIVE_ONE_TO_ONE_EXT);const ae=_t;_t=null,this.setClear(ae)}ft=gt},getReversed:function(){return ft},setTest:function(gt){gt?j(i.DEPTH_TEST):ut(i.DEPTH_TEST)},setMask:function(gt){W!==gt&&!U&&(i.depthMask(gt),W=gt)},setFunc:function(gt){if(ft&&(gt=q_[gt]),$!==gt){switch(gt){case Ws:i.depthFunc(i.NEVER);break;case Xs:i.depthFunc(i.ALWAYS);break;case qs:i.depthFunc(i.LESS);break;case Ti:i.depthFunc(i.LEQUAL);break;case Ys:i.depthFunc(i.EQUAL);break;case Zs:i.depthFunc(i.GEQUAL);break;case Js:i.depthFunc(i.GREATER);break;case Ks:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}$=gt}},setLocked:function(gt){U=gt},setClear:function(gt){_t!==gt&&(ft&&(gt=1-gt),i.clearDepth(gt),_t=gt)},reset:function(){U=!1,W=null,$=null,_t=null,ft=!1}}}function r(){let U=!1,ft=null,W=null,$=null,_t=null,gt=null,Bt=null,ae=null,xe=null;return{setTest:function(Qt){U||(Qt?j(i.STENCIL_TEST):ut(i.STENCIL_TEST))},setMask:function(Qt){ft!==Qt&&!U&&(i.stencilMask(Qt),ft=Qt)},setFunc:function(Qt,Be,tn){(W!==Qt||$!==Be||_t!==tn)&&(i.stencilFunc(Qt,Be,tn),W=Qt,$=Be,_t=tn)},setOp:function(Qt,Be,tn){(gt!==Qt||Bt!==Be||ae!==tn)&&(i.stencilOp(Qt,Be,tn),gt=Qt,Bt=Be,ae=tn)},setLocked:function(Qt){U=Qt},setClear:function(Qt){xe!==Qt&&(i.clearStencil(Qt),xe=Qt)},reset:function(){U=!1,ft=null,W=null,$=null,_t=null,gt=null,Bt=null,ae=null,xe=null}}}const s=new e,o=new n,a=new r,c=new WeakMap,l=new WeakMap;let u={},h={},f=new WeakMap,d=[],g=null,v=!1,m=null,p=null,b=null,T=null,S=null,L=null,C=null,R=new Wt(0,0,0),D=0,y=!1,M=null,w=null,H=null,O=null,V=null;const X=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,K=0;const k=i.getParameter(i.VERSION);k.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(k)[1]),G=K>=1):k.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),G=K>=2);let ct=null,pt={};const Mt=i.getParameter(i.SCISSOR_BOX),Ft=i.getParameter(i.VIEWPORT),Zt=new ee().fromArray(Mt),Y=new ee().fromArray(Ft);function st(U,ft,W,$){const _t=new Uint8Array(4),gt=i.createTexture();i.bindTexture(U,gt),i.texParameteri(U,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(U,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Bt=0;Bt<W;Bt++)U===i.TEXTURE_3D||U===i.TEXTURE_2D_ARRAY?i.texImage3D(ft,0,i.RGBA,1,1,$,0,i.RGBA,i.UNSIGNED_BYTE,_t):i.texImage2D(ft+Bt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,_t);return gt}const Q={};Q[i.TEXTURE_2D]=st(i.TEXTURE_2D,i.TEXTURE_2D,1),Q[i.TEXTURE_CUBE_MAP]=st(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Q[i.TEXTURE_2D_ARRAY]=st(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Q[i.TEXTURE_3D]=st(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),j(i.DEPTH_TEST),o.setFunc(Ti),nt(!1),St(xc),j(i.CULL_FACE),A(En);function j(U){u[U]!==!0&&(i.enable(U),u[U]=!0)}function ut(U){u[U]!==!1&&(i.disable(U),u[U]=!1)}function vt(U,ft){return h[U]!==ft?(i.bindFramebuffer(U,ft),h[U]=ft,U===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=ft),U===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=ft),!0):!1}function Rt(U,ft){let W=d,$=!1;if(U){W=f.get(ft),W===void 0&&(W=[],f.set(ft,W));const _t=U.textures;if(W.length!==_t.length||W[0]!==i.COLOR_ATTACHMENT0){for(let gt=0,Bt=_t.length;gt<Bt;gt++)W[gt]=i.COLOR_ATTACHMENT0+gt;W.length=_t.length,$=!0}}else W[0]!==i.BACK&&(W[0]=i.BACK,$=!0);$&&i.drawBuffers(W)}function Vt(U){return g!==U?(i.useProgram(U),g=U,!0):!1}const J={[On]:i.FUNC_ADD,[eh]:i.FUNC_SUBTRACT,[nh]:i.FUNC_REVERSE_SUBTRACT};J[ih]=i.MIN,J[rh]=i.MAX;const et={[sh]:i.ZERO,[oh]:i.ONE,[ah]:i.SRC_COLOR,[Gs]:i.SRC_ALPHA,[dh]:i.SRC_ALPHA_SATURATE,[hh]:i.DST_COLOR,[lh]:i.DST_ALPHA,[ch]:i.ONE_MINUS_SRC_COLOR,[Vs]:i.ONE_MINUS_SRC_ALPHA,[fh]:i.ONE_MINUS_DST_COLOR,[uh]:i.ONE_MINUS_DST_ALPHA,[ph]:i.CONSTANT_COLOR,[mh]:i.ONE_MINUS_CONSTANT_COLOR,[gh]:i.CONSTANT_ALPHA,[_h]:i.ONE_MINUS_CONSTANT_ALPHA};function A(U,ft,W,$,_t,gt,Bt,ae,xe,Qt){if(U===En){v===!0&&(ut(i.BLEND),v=!1);return}if(v===!1&&(j(i.BLEND),v=!0),U!==th){if(U!==m||Qt!==y){if((p!==On||S!==On)&&(i.blendEquation(i.FUNC_ADD),p=On,S=On),Qt)switch(U){case Mi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mc:i.blendFunc(i.ONE,i.ONE);break;case Sc:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case yc:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case Mi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mc:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Sc:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case yc:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}b=null,T=null,L=null,C=null,R.set(0,0,0),D=0,m=U,y=Qt}return}_t=_t||ft,gt=gt||W,Bt=Bt||$,(ft!==p||_t!==S)&&(i.blendEquationSeparate(J[ft],J[_t]),p=ft,S=_t),(W!==b||$!==T||gt!==L||Bt!==C)&&(i.blendFuncSeparate(et[W],et[$],et[gt],et[Bt]),b=W,T=$,L=gt,C=Bt),(ae.equals(R)===!1||xe!==D)&&(i.blendColor(ae.r,ae.g,ae.b,xe),R.copy(ae),D=xe),m=U,y=!1}function bt(U,ft){U.side===Ze?ut(i.CULL_FACE):j(i.CULL_FACE);let W=U.side===Ce;ft&&(W=!W),nt(W),U.blending===Mi&&U.transparent===!1?A(En):A(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),s.setMask(U.colorWrite);const $=U.stencilWrite;a.setTest($),$&&(a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),Dt(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?j(i.SAMPLE_ALPHA_TO_COVERAGE):ut(i.SAMPLE_ALPHA_TO_COVERAGE)}function nt(U){M!==U&&(U?i.frontFace(i.CW):i.frontFace(i.CCW),M=U)}function St(U){U!==$u?(j(i.CULL_FACE),U!==w&&(U===xc?i.cullFace(i.BACK):U===Qu?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ut(i.CULL_FACE),w=U}function ot(U){U!==H&&(G&&i.lineWidth(U),H=U)}function Dt(U,ft,W){U?(j(i.POLYGON_OFFSET_FILL),(O!==ft||V!==W)&&(i.polygonOffset(ft,W),O=ft,V=W)):ut(i.POLYGON_OFFSET_FILL)}function mt(U){U?j(i.SCISSOR_TEST):ut(i.SCISSOR_TEST)}function E(U){U===void 0&&(U=i.TEXTURE0+X-1),ct!==U&&(i.activeTexture(U),ct=U)}function _(U,ft,W){W===void 0&&(ct===null?W=i.TEXTURE0+X-1:W=ct);let $=pt[W];$===void 0&&($={type:void 0,texture:void 0},pt[W]=$),($.type!==U||$.texture!==ft)&&(ct!==W&&(i.activeTexture(W),ct=W),i.bindTexture(U,ft||Q[U]),$.type=U,$.texture=ft)}function F(){const U=pt[ct];U!==void 0&&U.type!==void 0&&(i.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function q(){try{i.compressedTexImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function tt(){try{i.compressedTexImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Z(){try{i.texSubImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function wt(){try{i.texSubImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ht(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function xt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Xt(){try{i.texStorage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function rt(){try{i.texStorage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Et(){try{i.texImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Lt(){try{i.texImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ut(U){Zt.equals(U)===!1&&(i.scissor(U.x,U.y,U.z,U.w),Zt.copy(U))}function Tt(U){Y.equals(U)===!1&&(i.viewport(U.x,U.y,U.z,U.w),Y.copy(U))}function qt(U,ft){let W=l.get(ft);W===void 0&&(W=new WeakMap,l.set(ft,W));let $=W.get(U);$===void 0&&($=i.getUniformBlockIndex(ft,U.name),W.set(U,$))}function Ht(U,ft){const $=l.get(ft).get(U);c.get(ft)!==$&&(i.uniformBlockBinding(ft,$,U.__bindingPointIndex),c.set(ft,$))}function ie(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),u={},ct=null,pt={},h={},f=new WeakMap,d=[],g=null,v=!1,m=null,p=null,b=null,T=null,S=null,L=null,C=null,R=new Wt(0,0,0),D=0,y=!1,M=null,w=null,H=null,O=null,V=null,Zt.set(0,0,i.canvas.width,i.canvas.height),Y.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:j,disable:ut,bindFramebuffer:vt,drawBuffers:Rt,useProgram:Vt,setBlending:A,setMaterial:bt,setFlipSided:nt,setCullFace:St,setLineWidth:ot,setPolygonOffset:Dt,setScissorTest:mt,activeTexture:E,bindTexture:_,unbindTexture:F,compressedTexImage2D:q,compressedTexImage3D:tt,texImage2D:Et,texImage3D:Lt,updateUBOMapping:qt,uniformBlockBinding:Ht,texStorage2D:Xt,texStorage3D:rt,texSubImage2D:Z,texSubImage3D:wt,compressedTexSubImage2D:ht,compressedTexSubImage3D:xt,scissor:Ut,viewport:Tt,reset:ie}}function Z_(i,t,e,n,r,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new at,u=new WeakMap;let h;const f=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(E,_){return d?new OffscreenCanvas(E,_):$i("canvas")}function v(E,_,F){let q=1;const tt=mt(E);if((tt.width>F||tt.height>F)&&(q=F/Math.max(tt.width,tt.height)),q<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const Z=Math.floor(q*tt.width),wt=Math.floor(q*tt.height);h===void 0&&(h=g(Z,wt));const ht=_?g(Z,wt):h;return ht.width=Z,ht.height=wt,ht.getContext("2d").drawImage(E,0,0,Z,wt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+tt.width+"x"+tt.height+") to ("+Z+"x"+wt+")."),ht}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+tt.width+"x"+tt.height+")."),E;return E}function m(E){return E.generateMipmaps}function p(E){i.generateMipmap(E)}function b(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function T(E,_,F,q,tt=!1){if(E!==null){if(i[E]!==void 0)return i[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let Z=_;if(_===i.RED&&(F===i.FLOAT&&(Z=i.R32F),F===i.HALF_FLOAT&&(Z=i.R16F),F===i.UNSIGNED_BYTE&&(Z=i.R8)),_===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.R8UI),F===i.UNSIGNED_SHORT&&(Z=i.R16UI),F===i.UNSIGNED_INT&&(Z=i.R32UI),F===i.BYTE&&(Z=i.R8I),F===i.SHORT&&(Z=i.R16I),F===i.INT&&(Z=i.R32I)),_===i.RG&&(F===i.FLOAT&&(Z=i.RG32F),F===i.HALF_FLOAT&&(Z=i.RG16F),F===i.UNSIGNED_BYTE&&(Z=i.RG8)),_===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RG8UI),F===i.UNSIGNED_SHORT&&(Z=i.RG16UI),F===i.UNSIGNED_INT&&(Z=i.RG32UI),F===i.BYTE&&(Z=i.RG8I),F===i.SHORT&&(Z=i.RG16I),F===i.INT&&(Z=i.RG32I)),_===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RGB8UI),F===i.UNSIGNED_SHORT&&(Z=i.RGB16UI),F===i.UNSIGNED_INT&&(Z=i.RGB32UI),F===i.BYTE&&(Z=i.RGB8I),F===i.SHORT&&(Z=i.RGB16I),F===i.INT&&(Z=i.RGB32I)),_===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(Z=i.RGBA16UI),F===i.UNSIGNED_INT&&(Z=i.RGBA32UI),F===i.BYTE&&(Z=i.RGBA8I),F===i.SHORT&&(Z=i.RGBA16I),F===i.INT&&(Z=i.RGBA32I)),_===i.RGB&&F===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),_===i.RGBA){const wt=tt?Vr:Kt.getTransfer(q);F===i.FLOAT&&(Z=i.RGBA32F),F===i.HALF_FLOAT&&(Z=i.RGBA16F),F===i.UNSIGNED_BYTE&&(Z=wt===te?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(Z=i.RGB5_A1)}return(Z===i.R16F||Z===i.R32F||Z===i.RG16F||Z===i.RG32F||Z===i.RGBA16F||Z===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function S(E,_){let F;return E?_===null||_===qn||_===Ri?F=i.DEPTH24_STENCIL8:_===ln?F=i.DEPTH32F_STENCIL8:_===Ki&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===qn||_===Ri?F=i.DEPTH_COMPONENT24:_===ln?F=i.DEPTH_COMPONENT32F:_===Ki&&(F=i.DEPTH_COMPONENT16),F}function L(E,_){return m(E)===!0||E.isFramebufferTexture&&E.minFilter!==Xe&&E.minFilter!==Je?Math.log2(Math.max(_.width,_.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?_.mipmaps.length:1}function C(E){const _=E.target;_.removeEventListener("dispose",C),D(_),_.isVideoTexture&&u.delete(_)}function R(E){const _=E.target;_.removeEventListener("dispose",R),M(_)}function D(E){const _=n.get(E);if(_.__webglInit===void 0)return;const F=E.source,q=f.get(F);if(q){const tt=q[_.__cacheKey];tt.usedTimes--,tt.usedTimes===0&&y(E),Object.keys(q).length===0&&f.delete(F)}n.remove(E)}function y(E){const _=n.get(E);i.deleteTexture(_.__webglTexture);const F=E.source,q=f.get(F);delete q[_.__cacheKey],o.memory.textures--}function M(E){const _=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(_.__webglFramebuffer[q]))for(let tt=0;tt<_.__webglFramebuffer[q].length;tt++)i.deleteFramebuffer(_.__webglFramebuffer[q][tt]);else i.deleteFramebuffer(_.__webglFramebuffer[q]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[q])}else{if(Array.isArray(_.__webglFramebuffer))for(let q=0;q<_.__webglFramebuffer.length;q++)i.deleteFramebuffer(_.__webglFramebuffer[q]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let q=0;q<_.__webglColorRenderbuffer.length;q++)_.__webglColorRenderbuffer[q]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[q]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const F=E.textures;for(let q=0,tt=F.length;q<tt;q++){const Z=n.get(F[q]);Z.__webglTexture&&(i.deleteTexture(Z.__webglTexture),o.memory.textures--),n.remove(F[q])}n.remove(E)}let w=0;function H(){w=0}function O(){const E=w;return E>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),w+=1,E}function V(E){const _=[];return _.push(E.wrapS),_.push(E.wrapT),_.push(E.wrapR||0),_.push(E.magFilter),_.push(E.minFilter),_.push(E.anisotropy),_.push(E.internalFormat),_.push(E.format),_.push(E.type),_.push(E.generateMipmaps),_.push(E.premultiplyAlpha),_.push(E.flipY),_.push(E.unpackAlignment),_.push(E.colorSpace),_.join()}function X(E,_){const F=n.get(E);if(E.isVideoTexture&&ot(E),E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){const q=E.image;if(q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(F,E,_);return}}e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+_)}function G(E,_){const F=n.get(E);if(E.version>0&&F.__version!==E.version){Y(F,E,_);return}e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+_)}function K(E,_){const F=n.get(E);if(E.version>0&&F.__version!==E.version){Y(F,E,_);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+_)}function k(E,_){const F=n.get(E);if(E.version>0&&F.__version!==E.version){st(F,E,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+_)}const ct={[wi]:i.REPEAT,[kn]:i.CLAMP_TO_EDGE,[Qs]:i.MIRRORED_REPEAT},pt={[Xe]:i.NEAREST,[bh]:i.NEAREST_MIPMAP_NEAREST,[hr]:i.NEAREST_MIPMAP_LINEAR,[Je]:i.LINEAR,[ss]:i.LINEAR_MIPMAP_NEAREST,[Gn]:i.LINEAR_MIPMAP_LINEAR},Mt={[Ph]:i.NEVER,[Fh]:i.ALWAYS,[Lh]:i.LESS,[Zl]:i.LEQUAL,[Dh]:i.EQUAL,[Nh]:i.GEQUAL,[Uh]:i.GREATER,[Ih]:i.NOTEQUAL};function Ft(E,_){if(_.type===ln&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===Je||_.magFilter===ss||_.magFilter===hr||_.magFilter===Gn||_.minFilter===Je||_.minFilter===ss||_.minFilter===hr||_.minFilter===Gn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,ct[_.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,ct[_.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,ct[_.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,pt[_.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,pt[_.minFilter]),_.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,Mt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Xe||_.minFilter!==hr&&_.minFilter!==Gn||_.type===ln&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(E,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Zt(E,_){let F=!1;E.__webglInit===void 0&&(E.__webglInit=!0,_.addEventListener("dispose",C));const q=_.source;let tt=f.get(q);tt===void 0&&(tt={},f.set(q,tt));const Z=V(_);if(Z!==E.__cacheKey){tt[Z]===void 0&&(tt[Z]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,F=!0),tt[Z].usedTimes++;const wt=tt[E.__cacheKey];wt!==void 0&&(tt[E.__cacheKey].usedTimes--,wt.usedTimes===0&&y(_)),E.__cacheKey=Z,E.__webglTexture=tt[Z].texture}return F}function Y(E,_,F){let q=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(q=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(q=i.TEXTURE_3D);const tt=Zt(E,_),Z=_.source;e.bindTexture(q,E.__webglTexture,i.TEXTURE0+F);const wt=n.get(Z);if(Z.version!==wt.__version||tt===!0){e.activeTexture(i.TEXTURE0+F);const ht=Kt.getPrimaries(Kt.workingColorSpace),xt=_.colorSpace===Mn?null:Kt.getPrimaries(_.colorSpace),Xt=_.colorSpace===Mn||ht===xt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xt);let rt=v(_.image,!1,r.maxTextureSize);rt=Dt(_,rt);const Et=s.convert(_.format,_.colorSpace),Lt=s.convert(_.type);let Ut=T(_.internalFormat,Et,Lt,_.colorSpace,_.isVideoTexture);Ft(q,_);let Tt;const qt=_.mipmaps,Ht=_.isVideoTexture!==!0,ie=wt.__version===void 0||tt===!0,U=Z.dataReady,ft=L(_,rt);if(_.isDepthTexture)Ut=S(_.format===Ci,_.type),ie&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,Ut,rt.width,rt.height):e.texImage2D(i.TEXTURE_2D,0,Ut,rt.width,rt.height,0,Et,Lt,null));else if(_.isDataTexture)if(qt.length>0){Ht&&ie&&e.texStorage2D(i.TEXTURE_2D,ft,Ut,qt[0].width,qt[0].height);for(let W=0,$=qt.length;W<$;W++)Tt=qt[W],Ht?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Tt.width,Tt.height,Et,Lt,Tt.data):e.texImage2D(i.TEXTURE_2D,W,Ut,Tt.width,Tt.height,0,Et,Lt,Tt.data);_.generateMipmaps=!1}else Ht?(ie&&e.texStorage2D(i.TEXTURE_2D,ft,Ut,rt.width,rt.height),U&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,rt.width,rt.height,Et,Lt,rt.data)):e.texImage2D(i.TEXTURE_2D,0,Ut,rt.width,rt.height,0,Et,Lt,rt.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Ht&&ie&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ft,Ut,qt[0].width,qt[0].height,rt.depth);for(let W=0,$=qt.length;W<$;W++)if(Tt=qt[W],_.format!==We)if(Et!==null)if(Ht){if(U)if(_.layerUpdates.size>0){const _t=nl(Tt.width,Tt.height,_.format,_.type);for(const gt of _.layerUpdates){const Bt=Tt.data.subarray(gt*_t/Tt.data.BYTES_PER_ELEMENT,(gt+1)*_t/Tt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,gt,Tt.width,Tt.height,1,Et,Bt)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,0,Tt.width,Tt.height,rt.depth,Et,Tt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,W,Ut,Tt.width,Tt.height,rt.depth,0,Tt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ht?U&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,0,Tt.width,Tt.height,rt.depth,Et,Lt,Tt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,W,Ut,Tt.width,Tt.height,rt.depth,0,Et,Lt,Tt.data)}else{Ht&&ie&&e.texStorage2D(i.TEXTURE_2D,ft,Ut,qt[0].width,qt[0].height);for(let W=0,$=qt.length;W<$;W++)Tt=qt[W],_.format!==We?Et!==null?Ht?U&&e.compressedTexSubImage2D(i.TEXTURE_2D,W,0,0,Tt.width,Tt.height,Et,Tt.data):e.compressedTexImage2D(i.TEXTURE_2D,W,Ut,Tt.width,Tt.height,0,Tt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ht?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Tt.width,Tt.height,Et,Lt,Tt.data):e.texImage2D(i.TEXTURE_2D,W,Ut,Tt.width,Tt.height,0,Et,Lt,Tt.data)}else if(_.isDataArrayTexture)if(Ht){if(ie&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ft,Ut,rt.width,rt.height,rt.depth),U)if(_.layerUpdates.size>0){const W=nl(rt.width,rt.height,_.format,_.type);for(const $ of _.layerUpdates){const _t=rt.data.subarray($*W/rt.data.BYTES_PER_ELEMENT,($+1)*W/rt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,$,rt.width,rt.height,1,Et,Lt,_t)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,Et,Lt,rt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Ut,rt.width,rt.height,rt.depth,0,Et,Lt,rt.data);else if(_.isData3DTexture)Ht?(ie&&e.texStorage3D(i.TEXTURE_3D,ft,Ut,rt.width,rt.height,rt.depth),U&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,Et,Lt,rt.data)):e.texImage3D(i.TEXTURE_3D,0,Ut,rt.width,rt.height,rt.depth,0,Et,Lt,rt.data);else if(_.isFramebufferTexture){if(ie)if(Ht)e.texStorage2D(i.TEXTURE_2D,ft,Ut,rt.width,rt.height);else{let W=rt.width,$=rt.height;for(let _t=0;_t<ft;_t++)e.texImage2D(i.TEXTURE_2D,_t,Ut,W,$,0,Et,Lt,null),W>>=1,$>>=1}}else if(qt.length>0){if(Ht&&ie){const W=mt(qt[0]);e.texStorage2D(i.TEXTURE_2D,ft,Ut,W.width,W.height)}for(let W=0,$=qt.length;W<$;W++)Tt=qt[W],Ht?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Et,Lt,Tt):e.texImage2D(i.TEXTURE_2D,W,Ut,Et,Lt,Tt);_.generateMipmaps=!1}else if(Ht){if(ie){const W=mt(rt);e.texStorage2D(i.TEXTURE_2D,ft,Ut,W.width,W.height)}U&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,Et,Lt,rt)}else e.texImage2D(i.TEXTURE_2D,0,Ut,Et,Lt,rt);m(_)&&p(q),wt.__version=Z.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function st(E,_,F){if(_.image.length!==6)return;const q=Zt(E,_),tt=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+F);const Z=n.get(tt);if(tt.version!==Z.__version||q===!0){e.activeTexture(i.TEXTURE0+F);const wt=Kt.getPrimaries(Kt.workingColorSpace),ht=_.colorSpace===Mn?null:Kt.getPrimaries(_.colorSpace),xt=_.colorSpace===Mn||wt===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xt);const Xt=_.isCompressedTexture||_.image[0].isCompressedTexture,rt=_.image[0]&&_.image[0].isDataTexture,Et=[];for(let $=0;$<6;$++)!Xt&&!rt?Et[$]=v(_.image[$],!0,r.maxCubemapSize):Et[$]=rt?_.image[$].image:_.image[$],Et[$]=Dt(_,Et[$]);const Lt=Et[0],Ut=s.convert(_.format,_.colorSpace),Tt=s.convert(_.type),qt=T(_.internalFormat,Ut,Tt,_.colorSpace),Ht=_.isVideoTexture!==!0,ie=Z.__version===void 0||q===!0,U=tt.dataReady;let ft=L(_,Lt);Ft(i.TEXTURE_CUBE_MAP,_);let W;if(Xt){Ht&&ie&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ft,qt,Lt.width,Lt.height);for(let $=0;$<6;$++){W=Et[$].mipmaps;for(let _t=0;_t<W.length;_t++){const gt=W[_t];_.format!==We?Ut!==null?Ht?U&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,0,0,gt.width,gt.height,Ut,gt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,qt,gt.width,gt.height,0,gt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,0,0,gt.width,gt.height,Ut,Tt,gt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,qt,gt.width,gt.height,0,Ut,Tt,gt.data)}}}else{if(W=_.mipmaps,Ht&&ie){W.length>0&&ft++;const $=mt(Et[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ft,qt,$.width,$.height)}for(let $=0;$<6;$++)if(rt){Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,Et[$].width,Et[$].height,Ut,Tt,Et[$].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,qt,Et[$].width,Et[$].height,0,Ut,Tt,Et[$].data);for(let _t=0;_t<W.length;_t++){const Bt=W[_t].image[$].image;Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,0,0,Bt.width,Bt.height,Ut,Tt,Bt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,qt,Bt.width,Bt.height,0,Ut,Tt,Bt.data)}}else{Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,Ut,Tt,Et[$]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,qt,Ut,Tt,Et[$]);for(let _t=0;_t<W.length;_t++){const gt=W[_t];Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,0,0,Ut,Tt,gt.image[$]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,qt,Ut,Tt,gt.image[$])}}}m(_)&&p(i.TEXTURE_CUBE_MAP),Z.__version=tt.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function Q(E,_,F,q,tt,Z){const wt=s.convert(F.format,F.colorSpace),ht=s.convert(F.type),xt=T(F.internalFormat,wt,ht,F.colorSpace),Xt=n.get(_),rt=n.get(F);if(rt.__renderTarget=_,!Xt.__hasExternalTextures){const Et=Math.max(1,_.width>>Z),Lt=Math.max(1,_.height>>Z);tt===i.TEXTURE_3D||tt===i.TEXTURE_2D_ARRAY?e.texImage3D(tt,Z,xt,Et,Lt,_.depth,0,wt,ht,null):e.texImage2D(tt,Z,xt,Et,Lt,0,wt,ht,null)}e.bindFramebuffer(i.FRAMEBUFFER,E),St(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,q,tt,rt.__webglTexture,0,nt(_)):(tt===i.TEXTURE_2D||tt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&tt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,q,tt,rt.__webglTexture,Z),e.bindFramebuffer(i.FRAMEBUFFER,null)}function j(E,_,F){if(i.bindRenderbuffer(i.RENDERBUFFER,E),_.depthBuffer){const q=_.depthTexture,tt=q&&q.isDepthTexture?q.type:null,Z=S(_.stencilBuffer,tt),wt=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ht=nt(_);St(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ht,Z,_.width,_.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,ht,Z,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,Z,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,wt,i.RENDERBUFFER,E)}else{const q=_.textures;for(let tt=0;tt<q.length;tt++){const Z=q[tt],wt=s.convert(Z.format,Z.colorSpace),ht=s.convert(Z.type),xt=T(Z.internalFormat,wt,ht,Z.colorSpace),Xt=nt(_);F&&St(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Xt,xt,_.width,_.height):St(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Xt,xt,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,xt,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ut(E,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,E),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const q=n.get(_.depthTexture);q.__renderTarget=_,(!q.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),X(_.depthTexture,0);const tt=q.__webglTexture,Z=nt(_);if(_.depthTexture.format===Si)St(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,tt,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,tt,0);else if(_.depthTexture.format===Ci)St(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,tt,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,tt,0);else throw new Error("Unknown depthTexture format")}function vt(E){const _=n.get(E),F=E.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==E.depthTexture){const q=E.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),q){const tt=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,q.removeEventListener("dispose",tt)};q.addEventListener("dispose",tt),_.__depthDisposeCallback=tt}_.__boundDepthTexture=q}if(E.depthTexture&&!_.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");ut(_.__webglFramebuffer,E)}else if(F){_.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[q]),_.__webglDepthbuffer[q]===void 0)_.__webglDepthbuffer[q]=i.createRenderbuffer(),j(_.__webglDepthbuffer[q],E,!1);else{const tt=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Z=_.__webglDepthbuffer[q];i.bindRenderbuffer(i.RENDERBUFFER,Z),i.framebufferRenderbuffer(i.FRAMEBUFFER,tt,i.RENDERBUFFER,Z)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),j(_.__webglDepthbuffer,E,!1);else{const q=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,tt=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,tt),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,tt)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Rt(E,_,F){const q=n.get(E);_!==void 0&&Q(q.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&vt(E)}function Vt(E){const _=E.texture,F=n.get(E),q=n.get(_);E.addEventListener("dispose",R);const tt=E.textures,Z=E.isWebGLCubeRenderTarget===!0,wt=tt.length>1;if(wt||(q.__webglTexture===void 0&&(q.__webglTexture=i.createTexture()),q.__version=_.version,o.memory.textures++),Z){F.__webglFramebuffer=[];for(let ht=0;ht<6;ht++)if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer[ht]=[];for(let xt=0;xt<_.mipmaps.length;xt++)F.__webglFramebuffer[ht][xt]=i.createFramebuffer()}else F.__webglFramebuffer[ht]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer=[];for(let ht=0;ht<_.mipmaps.length;ht++)F.__webglFramebuffer[ht]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(wt)for(let ht=0,xt=tt.length;ht<xt;ht++){const Xt=n.get(tt[ht]);Xt.__webglTexture===void 0&&(Xt.__webglTexture=i.createTexture(),o.memory.textures++)}if(E.samples>0&&St(E)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ht=0;ht<tt.length;ht++){const xt=tt[ht];F.__webglColorRenderbuffer[ht]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[ht]);const Xt=s.convert(xt.format,xt.colorSpace),rt=s.convert(xt.type),Et=T(xt.internalFormat,Xt,rt,xt.colorSpace,E.isXRRenderTarget===!0),Lt=nt(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,Lt,Et,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,F.__webglColorRenderbuffer[ht])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),j(F.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Z){e.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture),Ft(i.TEXTURE_CUBE_MAP,_);for(let ht=0;ht<6;ht++)if(_.mipmaps&&_.mipmaps.length>0)for(let xt=0;xt<_.mipmaps.length;xt++)Q(F.__webglFramebuffer[ht][xt],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,xt);else Q(F.__webglFramebuffer[ht],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0);m(_)&&p(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(wt){for(let ht=0,xt=tt.length;ht<xt;ht++){const Xt=tt[ht],rt=n.get(Xt);e.bindTexture(i.TEXTURE_2D,rt.__webglTexture),Ft(i.TEXTURE_2D,Xt),Q(F.__webglFramebuffer,E,Xt,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,0),m(Xt)&&p(i.TEXTURE_2D)}e.unbindTexture()}else{let ht=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ht=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ht,q.__webglTexture),Ft(ht,_),_.mipmaps&&_.mipmaps.length>0)for(let xt=0;xt<_.mipmaps.length;xt++)Q(F.__webglFramebuffer[xt],E,_,i.COLOR_ATTACHMENT0,ht,xt);else Q(F.__webglFramebuffer,E,_,i.COLOR_ATTACHMENT0,ht,0);m(_)&&p(ht),e.unbindTexture()}E.depthBuffer&&vt(E)}function J(E){const _=E.textures;for(let F=0,q=_.length;F<q;F++){const tt=_[F];if(m(tt)){const Z=b(E),wt=n.get(tt).__webglTexture;e.bindTexture(Z,wt),p(Z),e.unbindTexture()}}}const et=[],A=[];function bt(E){if(E.samples>0){if(St(E)===!1){const _=E.textures,F=E.width,q=E.height;let tt=i.COLOR_BUFFER_BIT;const Z=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,wt=n.get(E),ht=_.length>1;if(ht)for(let xt=0;xt<_.length;xt++)e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,wt.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,wt.__webglFramebuffer);for(let xt=0;xt<_.length;xt++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(tt|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(tt|=i.STENCIL_BUFFER_BIT)),ht){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,wt.__webglColorRenderbuffer[xt]);const Xt=n.get(_[xt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Xt,0)}i.blitFramebuffer(0,0,F,q,0,0,F,q,tt,i.NEAREST),c===!0&&(et.length=0,A.length=0,et.push(i.COLOR_ATTACHMENT0+xt),E.depthBuffer&&E.resolveDepthBuffer===!1&&(et.push(Z),A.push(Z),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,A)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,et))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ht)for(let xt=0;xt<_.length;xt++){e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,wt.__webglColorRenderbuffer[xt]);const Xt=n.get(_[xt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,Xt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,wt.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&c){const _=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function nt(E){return Math.min(r.maxSamples,E.samples)}function St(E){const _=n.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function ot(E){const _=o.render.frame;u.get(E)!==_&&(u.set(E,_),E.update())}function Dt(E,_){const F=E.colorSpace,q=E.format,tt=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||F!==Pi&&F!==Mn&&(Kt.getTransfer(F)===te?(q!==We||tt!==fn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),_}function mt(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=O,this.resetTextureUnits=H,this.setTexture2D=X,this.setTexture2DArray=G,this.setTexture3D=K,this.setTextureCube=k,this.rebindTextures=Rt,this.setupRenderTarget=Vt,this.updateRenderTargetMipmap=J,this.updateMultisampleRenderTarget=bt,this.setupDepthRenderbuffer=vt,this.setupFrameBufferTexture=Q,this.useMultisampledRTT=St}function J_(i,t){function e(n,r=Mn){let s;const o=Kt.getTransfer(r);if(n===fn)return i.UNSIGNED_BYTE;if(n===Fa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Oa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===zl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Ol)return i.BYTE;if(n===Bl)return i.SHORT;if(n===Ki)return i.UNSIGNED_SHORT;if(n===Na)return i.INT;if(n===qn)return i.UNSIGNED_INT;if(n===ln)return i.FLOAT;if(n===ir)return i.HALF_FLOAT;if(n===Hl)return i.ALPHA;if(n===kl)return i.RGB;if(n===We)return i.RGBA;if(n===Gl)return i.LUMINANCE;if(n===Vl)return i.LUMINANCE_ALPHA;if(n===Si)return i.DEPTH_COMPONENT;if(n===Ci)return i.DEPTH_STENCIL;if(n===Wl)return i.RED;if(n===Ba)return i.RED_INTEGER;if(n===Xl)return i.RG;if(n===za)return i.RG_INTEGER;if(n===Ha)return i.RGBA_INTEGER;if(n===Nr||n===Fr||n===Or||n===Br)if(o===te)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Nr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Fr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Or)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Br)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Nr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Fr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Or)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Br)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===to||n===eo||n===no||n===io)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===to)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===eo)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===no)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===io)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ro||n===so||n===oo)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ro||n===so)return o===te?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===oo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ao||n===co||n===lo||n===uo||n===ho||n===fo||n===po||n===mo||n===go||n===_o||n===vo||n===xo||n===Mo||n===So)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ao)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===co)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===lo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===uo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ho)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===po)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===mo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===go)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===_o)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Mo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===So)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===zr||n===yo||n===Eo)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===zr)return o===te?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===yo)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Eo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ql||n===To||n===Ao||n===bo)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===zr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===To)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ao)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===bo)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ri?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const K_={type:"move"};class Os{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Wn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&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}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){o=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,n),p=this._getHandJoint(l,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,g=.005;l.inputState.pinching&&f>d+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=d-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(K_)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Wn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const j_=`
|
|
3841
|
+
}`;function I0(i,t,e){let n=new bc;const r=new ct,s=new ct,o=new ie,a=new jp({depthPacking:vd}),c=new Qp,l={},u=e.maxTextureSize,h={[Cn]:Pe,[Pe]:Cn,[je]:je},f=new Pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ct},radius:{value:4}},vertexShader:D0,fragmentShader:U0}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const g=new De;g.setAttribute("position",new tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new he(g,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Au;let p=this.type;this.render=function(P,C,R){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||P.length===0)return;const E=i.getRenderTarget(),_=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),B=i.state;B.setBlending(bn),B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const F=p!==hn&&this.type===hn,k=p===hn&&this.type!==hn;for(let X=0,G=P.length;X<G;X++){const $=P[X],V=$.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",$,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;r.copy(V.mapSize);const lt=V.getFrameExtents();if(r.multiply(lt),s.copy(V.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/lt.x),r.x=s.x*lt.x,V.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/lt.y),r.y=s.y*lt.y,V.mapSize.y=s.y)),V.map===null||F===!0||k===!0){const St=this.type!==hn?{minFilter:$e,magFilter:$e}:{};V.map!==null&&V.map.dispose(),V.map=new $n(r.x,r.y,St),V.map.texture.name=$.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();const mt=V.getViewportCount();for(let St=0;St<mt;St++){const Ot=V.getViewport(St);o.set(s.x*Ot.x,s.y*Ot.y,s.x*Ot.z,s.y*Ot.w),B.viewport(o),V.updateMatrices($,St),n=V.getFrustum(),S(C,R,V.camera,$,this.type)}V.isPointLightShadow!==!0&&this.type===hn&&A(V,R),V.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(E,_,w)};function A(P,C){const R=t.update(v);f.defines.VSM_SAMPLES!==P.blurSamples&&(f.defines.VSM_SAMPLES=P.blurSamples,d.defines.VSM_SAMPLES=P.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new $n(r.x,r.y)),f.uniforms.shadow_pass.value=P.map.texture,f.uniforms.resolution.value=P.mapSize,f.uniforms.radius.value=P.radius,i.setRenderTarget(P.mapPass),i.clear(),i.renderBufferDirect(C,null,R,f,v,null),d.uniforms.shadow_pass.value=P.mapPass.texture,d.uniforms.resolution.value=P.mapSize,d.uniforms.radius.value=P.radius,i.setRenderTarget(P.map),i.clear(),i.renderBufferDirect(C,null,R,d,v,null)}function y(P,C,R,E){let _=null;const w=R.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(w!==void 0)_=w;else if(_=R.isPointLight===!0?c:a,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const B=_.uuid,F=C.uuid;let k=l[B];k===void 0&&(k={},l[B]=k);let X=k[F];X===void 0&&(X=_.clone(),k[F]=X,C.addEventListener("dispose",L)),_=X}if(_.visible=C.visible,_.wireframe=C.wireframe,E===hn?_.side=C.shadowSide!==null?C.shadowSide:C.side:_.side=C.shadowSide!==null?C.shadowSide:h[C.side],_.alphaMap=C.alphaMap,_.alphaTest=C.alphaTest,_.map=C.map,_.clipShadows=C.clipShadows,_.clippingPlanes=C.clippingPlanes,_.clipIntersection=C.clipIntersection,_.displacementMap=C.displacementMap,_.displacementScale=C.displacementScale,_.displacementBias=C.displacementBias,_.wireframeLinewidth=C.wireframeLinewidth,_.linewidth=C.linewidth,R.isPointLight===!0&&_.isMeshDistanceMaterial===!0){const B=i.properties.get(_);B.light=R}return _}function S(P,C,R,E,_){if(P.visible===!1)return;if(P.layers.test(C.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&_===hn)&&(!P.frustumCulled||n.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,P.matrixWorld);const F=t.update(P),k=P.material;if(Array.isArray(k)){const X=F.groups;for(let G=0,$=X.length;G<$;G++){const V=X[G],lt=k[V.materialIndex];if(lt&<.visible){const mt=y(P,lt,E,_);P.onBeforeShadow(i,P,C,R,F,mt,V),i.renderBufferDirect(R,null,F,mt,P,V),P.onAfterShadow(i,P,C,R,F,mt,V)}}}else if(k.visible){const X=y(P,k,E,_);P.onBeforeShadow(i,P,C,R,F,X,null),i.renderBufferDirect(R,null,F,X,P,null),P.onAfterShadow(i,P,C,R,F,X,null)}}const B=P.children;for(let F=0,k=B.length;F<k;F++)S(B[F],C,R,E,_)}function L(P){P.target.removeEventListener("dispose",L);for(const R in l){const E=l[R],_=P.target.uuid;_ in E&&(E[_].dispose(),delete E[_])}}}const N0={[Go]:Wo,[Xo]:Ko,[qo]:Zo,[Pi]:Yo,[Wo]:Go,[Ko]:Xo,[Zo]:qo,[Yo]:Pi};function F0(i,t){function e(){let U=!1;const dt=new ie;let W=null;const j=new ie(0,0,0,0);return{setMask:function(vt){W!==vt&&!U&&(i.colorMask(vt,vt,vt,vt),W=vt)},setLocked:function(vt){U=vt},setClear:function(vt,_t,zt,le,Me){Me===!0&&(vt*=le,_t*=le,zt*=le),dt.set(vt,_t,zt,le),j.equals(dt)===!1&&(i.clearColor(vt,_t,zt,le),j.copy(dt))},reset:function(){U=!1,W=null,j.set(-1,0,0,0)}}}function n(){let U=!1,dt=!1,W=null,j=null,vt=null;return{setReversed:function(_t){if(dt!==_t){const zt=t.get("EXT_clip_control");dt?zt.clipControlEXT(zt.LOWER_LEFT_EXT,zt.ZERO_TO_ONE_EXT):zt.clipControlEXT(zt.LOWER_LEFT_EXT,zt.NEGATIVE_ONE_TO_ONE_EXT);const le=vt;vt=null,this.setClear(le)}dt=_t},getReversed:function(){return dt},setTest:function(_t){_t?J(i.DEPTH_TEST):ht(i.DEPTH_TEST)},setMask:function(_t){W!==_t&&!U&&(i.depthMask(_t),W=_t)},setFunc:function(_t){if(dt&&(_t=N0[_t]),j!==_t){switch(_t){case Go:i.depthFunc(i.NEVER);break;case Wo:i.depthFunc(i.ALWAYS);break;case Xo:i.depthFunc(i.LESS);break;case Pi:i.depthFunc(i.LEQUAL);break;case qo:i.depthFunc(i.EQUAL);break;case Yo:i.depthFunc(i.GEQUAL);break;case Ko:i.depthFunc(i.GREATER);break;case Zo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}j=_t}},setLocked:function(_t){U=_t},setClear:function(_t){vt!==_t&&(dt&&(_t=1-_t),i.clearDepth(_t),vt=_t)},reset:function(){U=!1,W=null,j=null,vt=null,dt=!1}}}function r(){let U=!1,dt=null,W=null,j=null,vt=null,_t=null,zt=null,le=null,Me=null;return{setTest:function(te){U||(te?J(i.STENCIL_TEST):ht(i.STENCIL_TEST))},setMask:function(te){dt!==te&&!U&&(i.stencilMask(te),dt=te)},setFunc:function(te,Ve,sn){(W!==te||j!==Ve||vt!==sn)&&(i.stencilFunc(te,Ve,sn),W=te,j=Ve,vt=sn)},setOp:function(te,Ve,sn){(_t!==te||zt!==Ve||le!==sn)&&(i.stencilOp(te,Ve,sn),_t=te,zt=Ve,le=sn)},setLocked:function(te){U=te},setClear:function(te){Me!==te&&(i.clearStencil(te),Me=te)},reset:function(){U=!1,dt=null,W=null,j=null,vt=null,_t=null,zt=null,le=null,Me=null}}}const s=new e,o=new n,a=new r,c=new WeakMap,l=new WeakMap;let u={},h={},f=new WeakMap,d=[],g=null,v=!1,m=null,p=null,A=null,y=null,S=null,L=null,P=null,C=new Xt(0,0,0),R=0,E=!1,_=null,w=null,B=null,F=null,k=null;const X=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,$=0;const V=i.getParameter(i.VERSION);V.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(V)[1]),G=$>=1):V.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),G=$>=2);let lt=null,mt={};const St=i.getParameter(i.SCISSOR_BOX),Ot=i.getParameter(i.VIEWPORT),Zt=new ie().fromArray(St),Y=new ie().fromArray(Ot);function ot(U,dt,W,j){const vt=new Uint8Array(4),_t=i.createTexture();i.bindTexture(U,_t),i.texParameteri(U,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(U,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let zt=0;zt<W;zt++)U===i.TEXTURE_3D||U===i.TEXTURE_2D_ARRAY?i.texImage3D(dt,0,i.RGBA,1,1,j,0,i.RGBA,i.UNSIGNED_BYTE,vt):i.texImage2D(dt+zt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,vt);return _t}const Q={};Q[i.TEXTURE_2D]=ot(i.TEXTURE_2D,i.TEXTURE_2D,1),Q[i.TEXTURE_CUBE_MAP]=ot(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Q[i.TEXTURE_2D_ARRAY]=ot(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Q[i.TEXTURE_3D]=ot(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),J(i.DEPTH_TEST),o.setFunc(Pi),it(!1),Et(sl),J(i.CULL_FACE),b(bn);function J(U){u[U]!==!0&&(i.enable(U),u[U]=!0)}function ht(U){u[U]!==!1&&(i.disable(U),u[U]=!1)}function xt(U,dt){return h[U]!==dt?(i.bindFramebuffer(U,dt),h[U]=dt,U===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=dt),U===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=dt),!0):!1}function Ct(U,dt){let W=d,j=!1;if(U){W=f.get(dt),W===void 0&&(W=[],f.set(dt,W));const vt=U.textures;if(W.length!==vt.length||W[0]!==i.COLOR_ATTACHMENT0){for(let _t=0,zt=vt.length;_t<zt;_t++)W[_t]=i.COLOR_ATTACHMENT0+_t;W.length=vt.length,j=!0}}else W[0]!==i.BACK&&(W[0]=i.BACK,j=!0);j&&i.drawBuffers(W)}function Wt(U){return g!==U?(i.useProgram(U),g=U,!0):!1}const Z={[kn]:i.FUNC_ADD,[Xf]:i.FUNC_SUBTRACT,[qf]:i.FUNC_REVERSE_SUBTRACT};Z[Yf]=i.MIN,Z[Kf]=i.MAX;const et={[Zf]:i.ZERO,[$f]:i.ONE,[Jf]:i.SRC_COLOR,[ko]:i.SRC_ALPHA,[id]:i.SRC_ALPHA_SATURATE,[ed]:i.DST_COLOR,[Qf]:i.DST_ALPHA,[jf]:i.ONE_MINUS_SRC_COLOR,[Vo]:i.ONE_MINUS_SRC_ALPHA,[nd]:i.ONE_MINUS_DST_COLOR,[td]:i.ONE_MINUS_DST_ALPHA,[rd]:i.CONSTANT_COLOR,[sd]:i.ONE_MINUS_CONSTANT_COLOR,[od]:i.CONSTANT_ALPHA,[ad]:i.ONE_MINUS_CONSTANT_ALPHA};function b(U,dt,W,j,vt,_t,zt,le,Me,te){if(U===bn){v===!0&&(ht(i.BLEND),v=!1);return}if(v===!1&&(J(i.BLEND),v=!0),U!==Wf){if(U!==m||te!==E){if((p!==kn||S!==kn)&&(i.blendEquation(i.FUNC_ADD),p=kn,S=kn),te)switch(U){case bi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ol:i.blendFunc(i.ONE,i.ONE);break;case al:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case cl:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case bi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ol:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case al:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case cl:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}A=null,y=null,L=null,P=null,C.set(0,0,0),R=0,m=U,E=te}return}vt=vt||dt,_t=_t||W,zt=zt||j,(dt!==p||vt!==S)&&(i.blendEquationSeparate(Z[dt],Z[vt]),p=dt,S=vt),(W!==A||j!==y||_t!==L||zt!==P)&&(i.blendFuncSeparate(et[W],et[j],et[_t],et[zt]),A=W,y=j,L=_t,P=zt),(le.equals(C)===!1||Me!==R)&&(i.blendColor(le.r,le.g,le.b,Me),C.copy(le),R=Me),m=U,E=!1}function wt(U,dt){U.side===je?ht(i.CULL_FACE):J(i.CULL_FACE);let W=U.side===Pe;dt&&(W=!W),it(W),U.blending===bi&&U.transparent===!1?b(bn):b(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),s.setMask(U.colorWrite);const j=U.stencilWrite;a.setTest(j),j&&(a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),Ut(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?J(i.SAMPLE_ALPHA_TO_COVERAGE):ht(i.SAMPLE_ALPHA_TO_COVERAGE)}function it(U){_!==U&&(U?i.frontFace(i.CW):i.frontFace(i.CCW),_=U)}function Et(U){U!==Vf?(J(i.CULL_FACE),U!==w&&(U===sl?i.cullFace(i.BACK):U===Gf?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ht(i.CULL_FACE),w=U}function at(U){U!==B&&(G&&i.lineWidth(U),B=U)}function Ut(U,dt,W){U?(J(i.POLYGON_OFFSET_FILL),(F!==dt||k!==W)&&(i.polygonOffset(dt,W),F=dt,k=W)):ht(i.POLYGON_OFFSET_FILL)}function gt(U){U?J(i.SCISSOR_TEST):ht(i.SCISSOR_TEST)}function T(U){U===void 0&&(U=i.TEXTURE0+X-1),lt!==U&&(i.activeTexture(U),lt=U)}function x(U,dt,W){W===void 0&&(lt===null?W=i.TEXTURE0+X-1:W=lt);let j=mt[W];j===void 0&&(j={type:void 0,texture:void 0},mt[W]=j),(j.type!==U||j.texture!==dt)&&(lt!==W&&(i.activeTexture(W),lt=W),i.bindTexture(U,dt||Q[U]),j.type=U,j.texture=dt)}function O(){const U=mt[lt];U!==void 0&&U.type!==void 0&&(i.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function q(){try{i.compressedTexImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function tt(){try{i.compressedTexImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function K(){try{i.texSubImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Rt(){try{i.texSubImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ft(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Mt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function qt(){try{i.texStorage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function st(){try{i.texStorage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Tt(){try{i.texImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Dt(){try{i.texImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Nt(U){Zt.equals(U)===!1&&(i.scissor(U.x,U.y,U.z,U.w),Zt.copy(U))}function At(U){Y.equals(U)===!1&&(i.viewport(U.x,U.y,U.z,U.w),Y.copy(U))}function Yt(U,dt){let W=l.get(dt);W===void 0&&(W=new WeakMap,l.set(dt,W));let j=W.get(U);j===void 0&&(j=i.getUniformBlockIndex(dt,U.name),W.set(U,j))}function kt(U,dt){const j=l.get(dt).get(U);c.get(dt)!==j&&(i.uniformBlockBinding(dt,j,U.__bindingPointIndex),c.set(dt,j))}function se(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),u={},lt=null,mt={},h={},f=new WeakMap,d=[],g=null,v=!1,m=null,p=null,A=null,y=null,S=null,L=null,P=null,C=new Xt(0,0,0),R=0,E=!1,_=null,w=null,B=null,F=null,k=null,Zt.set(0,0,i.canvas.width,i.canvas.height),Y.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:J,disable:ht,bindFramebuffer:xt,drawBuffers:Ct,useProgram:Wt,setBlending:b,setMaterial:wt,setFlipSided:it,setCullFace:Et,setLineWidth:at,setPolygonOffset:Ut,setScissorTest:gt,activeTexture:T,bindTexture:x,unbindTexture:O,compressedTexImage2D:q,compressedTexImage3D:tt,texImage2D:Tt,texImage3D:Dt,updateUBOMapping:Yt,uniformBlockBinding:kt,texStorage2D:qt,texStorage3D:st,texSubImage2D:K,texSubImage3D:Rt,compressedTexSubImage2D:ft,compressedTexSubImage3D:Mt,scissor:Nt,viewport:At,reset:se}}function O0(i,t,e,n,r,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new ct,u=new WeakMap;let h;const f=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(T,x){return d?new OffscreenCanvas(T,x):ar("canvas")}function v(T,x,O){let q=1;const tt=gt(T);if((tt.width>O||tt.height>O)&&(q=O/Math.max(tt.width,tt.height)),q<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const K=Math.floor(q*tt.width),Rt=Math.floor(q*tt.height);h===void 0&&(h=g(K,Rt));const ft=x?g(K,Rt):h;return ft.width=K,ft.height=Rt,ft.getContext("2d").drawImage(T,0,0,K,Rt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+tt.width+"x"+tt.height+") to ("+K+"x"+Rt+")."),ft}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+tt.width+"x"+tt.height+")."),T;return T}function m(T){return T.generateMipmaps}function p(T){i.generateMipmap(T)}function A(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function y(T,x,O,q,tt=!1){if(T!==null){if(i[T]!==void 0)return i[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let K=x;if(x===i.RED&&(O===i.FLOAT&&(K=i.R32F),O===i.HALF_FLOAT&&(K=i.R16F),O===i.UNSIGNED_BYTE&&(K=i.R8)),x===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.R8UI),O===i.UNSIGNED_SHORT&&(K=i.R16UI),O===i.UNSIGNED_INT&&(K=i.R32UI),O===i.BYTE&&(K=i.R8I),O===i.SHORT&&(K=i.R16I),O===i.INT&&(K=i.R32I)),x===i.RG&&(O===i.FLOAT&&(K=i.RG32F),O===i.HALF_FLOAT&&(K=i.RG16F),O===i.UNSIGNED_BYTE&&(K=i.RG8)),x===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RG8UI),O===i.UNSIGNED_SHORT&&(K=i.RG16UI),O===i.UNSIGNED_INT&&(K=i.RG32UI),O===i.BYTE&&(K=i.RG8I),O===i.SHORT&&(K=i.RG16I),O===i.INT&&(K=i.RG32I)),x===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGB8UI),O===i.UNSIGNED_SHORT&&(K=i.RGB16UI),O===i.UNSIGNED_INT&&(K=i.RGB32UI),O===i.BYTE&&(K=i.RGB8I),O===i.SHORT&&(K=i.RGB16I),O===i.INT&&(K=i.RGB32I)),x===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(K=i.RGBA16UI),O===i.UNSIGNED_INT&&(K=i.RGBA32UI),O===i.BYTE&&(K=i.RGBA8I),O===i.SHORT&&(K=i.RGBA16I),O===i.INT&&(K=i.RGBA32I)),x===i.RGB&&O===i.UNSIGNED_INT_5_9_9_9_REV&&(K=i.RGB9_E5),x===i.RGBA){const Rt=tt?rs:Jt.getTransfer(q);O===i.FLOAT&&(K=i.RGBA32F),O===i.HALF_FLOAT&&(K=i.RGBA16F),O===i.UNSIGNED_BYTE&&(K=Rt===ne?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT_4_4_4_4&&(K=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(K=i.RGB5_A1)}return(K===i.R16F||K===i.R32F||K===i.RG16F||K===i.RG32F||K===i.RGBA16F||K===i.RGBA32F)&&t.get("EXT_color_buffer_float"),K}function S(T,x){let O;return T?x===null||x===Zn||x===Ii?O=i.DEPTH24_STENCIL8:x===dn?O=i.DEPTH32F_STENCIL8:x===sr&&(O=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Zn||x===Ii?O=i.DEPTH_COMPONENT24:x===dn?O=i.DEPTH_COMPONENT32F:x===sr&&(O=i.DEPTH_COMPONENT16),O}function L(T,x){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==$e&&T.minFilter!==Qe?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function P(T){const x=T.target;x.removeEventListener("dispose",P),R(x),x.isVideoTexture&&u.delete(x)}function C(T){const x=T.target;x.removeEventListener("dispose",C),_(x)}function R(T){const x=n.get(T);if(x.__webglInit===void 0)return;const O=T.source,q=f.get(O);if(q){const tt=q[x.__cacheKey];tt.usedTimes--,tt.usedTimes===0&&E(T),Object.keys(q).length===0&&f.delete(O)}n.remove(T)}function E(T){const x=n.get(T);i.deleteTexture(x.__webglTexture);const O=T.source,q=f.get(O);delete q[x.__cacheKey],o.memory.textures--}function _(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(x.__webglFramebuffer[q]))for(let tt=0;tt<x.__webglFramebuffer[q].length;tt++)i.deleteFramebuffer(x.__webglFramebuffer[q][tt]);else i.deleteFramebuffer(x.__webglFramebuffer[q]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[q])}else{if(Array.isArray(x.__webglFramebuffer))for(let q=0;q<x.__webglFramebuffer.length;q++)i.deleteFramebuffer(x.__webglFramebuffer[q]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let q=0;q<x.__webglColorRenderbuffer.length;q++)x.__webglColorRenderbuffer[q]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[q]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const O=T.textures;for(let q=0,tt=O.length;q<tt;q++){const K=n.get(O[q]);K.__webglTexture&&(i.deleteTexture(K.__webglTexture),o.memory.textures--),n.remove(O[q])}n.remove(T)}let w=0;function B(){w=0}function F(){const T=w;return T>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),w+=1,T}function k(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function X(T,x){const O=n.get(T);if(T.isVideoTexture&&at(T),T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){const q=T.image;if(q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(O,T,x);return}}e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+x)}function G(T,x){const O=n.get(T);if(T.version>0&&O.__version!==T.version){Y(O,T,x);return}e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+x)}function $(T,x){const O=n.get(T);if(T.version>0&&O.__version!==T.version){Y(O,T,x);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+x)}function V(T,x){const O=n.get(T);if(T.version>0&&O.__version!==T.version){ot(O,T,x);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+x)}const lt={[Ui]:i.REPEAT,[Wn]:i.CLAMP_TO_EDGE,[jo]:i.MIRRORED_REPEAT},mt={[$e]:i.NEAREST,[gd]:i.NEAREST_MIPMAP_NEAREST,[yr]:i.NEAREST_MIPMAP_LINEAR,[Qe]:i.LINEAR,[Es]:i.LINEAR_MIPMAP_NEAREST,[Xn]:i.LINEAR_MIPMAP_LINEAR},St={[Md]:i.NEVER,[bd]:i.ALWAYS,[Sd]:i.LESS,[ku]:i.LEQUAL,[Ed]:i.EQUAL,[Ad]:i.GEQUAL,[yd]:i.GREATER,[Td]:i.NOTEQUAL};function Ot(T,x){if(x.type===dn&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===Qe||x.magFilter===Es||x.magFilter===yr||x.magFilter===Xn||x.minFilter===Qe||x.minFilter===Es||x.minFilter===yr||x.minFilter===Xn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,lt[x.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,lt[x.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,lt[x.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,mt[x.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,mt[x.minFilter]),x.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,St[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===$e||x.minFilter!==yr&&x.minFilter!==Xn||x.type===dn&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(T,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,r.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function Zt(T,x){let O=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",P));const q=x.source;let tt=f.get(q);tt===void 0&&(tt={},f.set(q,tt));const K=k(x);if(K!==T.__cacheKey){tt[K]===void 0&&(tt[K]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,O=!0),tt[K].usedTimes++;const Rt=tt[T.__cacheKey];Rt!==void 0&&(tt[T.__cacheKey].usedTimes--,Rt.usedTimes===0&&E(x)),T.__cacheKey=K,T.__webglTexture=tt[K].texture}return O}function Y(T,x,O){let q=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(q=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(q=i.TEXTURE_3D);const tt=Zt(T,x),K=x.source;e.bindTexture(q,T.__webglTexture,i.TEXTURE0+O);const Rt=n.get(K);if(K.version!==Rt.__version||tt===!0){e.activeTexture(i.TEXTURE0+O);const ft=Jt.getPrimaries(Jt.workingColorSpace),Mt=x.colorSpace===Tn?null:Jt.getPrimaries(x.colorSpace),qt=x.colorSpace===Tn||ft===Mt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,qt);let st=v(x.image,!1,r.maxTextureSize);st=Ut(x,st);const Tt=s.convert(x.format,x.colorSpace),Dt=s.convert(x.type);let Nt=y(x.internalFormat,Tt,Dt,x.colorSpace,x.isVideoTexture);Ot(q,x);let At;const Yt=x.mipmaps,kt=x.isVideoTexture!==!0,se=Rt.__version===void 0||tt===!0,U=K.dataReady,dt=L(x,st);if(x.isDepthTexture)Nt=S(x.format===Ni,x.type),se&&(kt?e.texStorage2D(i.TEXTURE_2D,1,Nt,st.width,st.height):e.texImage2D(i.TEXTURE_2D,0,Nt,st.width,st.height,0,Tt,Dt,null));else if(x.isDataTexture)if(Yt.length>0){kt&&se&&e.texStorage2D(i.TEXTURE_2D,dt,Nt,Yt[0].width,Yt[0].height);for(let W=0,j=Yt.length;W<j;W++)At=Yt[W],kt?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,At.width,At.height,Tt,Dt,At.data):e.texImage2D(i.TEXTURE_2D,W,Nt,At.width,At.height,0,Tt,Dt,At.data);x.generateMipmaps=!1}else kt?(se&&e.texStorage2D(i.TEXTURE_2D,dt,Nt,st.width,st.height),U&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,st.width,st.height,Tt,Dt,st.data)):e.texImage2D(i.TEXTURE_2D,0,Nt,st.width,st.height,0,Tt,Dt,st.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){kt&&se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,dt,Nt,Yt[0].width,Yt[0].height,st.depth);for(let W=0,j=Yt.length;W<j;W++)if(At=Yt[W],x.format!==Ke)if(Tt!==null)if(kt){if(U)if(x.layerUpdates.size>0){const vt=Vl(At.width,At.height,x.format,x.type);for(const _t of x.layerUpdates){const zt=At.data.subarray(_t*vt/At.data.BYTES_PER_ELEMENT,(_t+1)*vt/At.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,_t,At.width,At.height,1,Tt,zt)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,0,At.width,At.height,st.depth,Tt,At.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,W,Nt,At.width,At.height,st.depth,0,At.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else kt?U&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,0,At.width,At.height,st.depth,Tt,Dt,At.data):e.texImage3D(i.TEXTURE_2D_ARRAY,W,Nt,At.width,At.height,st.depth,0,Tt,Dt,At.data)}else{kt&&se&&e.texStorage2D(i.TEXTURE_2D,dt,Nt,Yt[0].width,Yt[0].height);for(let W=0,j=Yt.length;W<j;W++)At=Yt[W],x.format!==Ke?Tt!==null?kt?U&&e.compressedTexSubImage2D(i.TEXTURE_2D,W,0,0,At.width,At.height,Tt,At.data):e.compressedTexImage2D(i.TEXTURE_2D,W,Nt,At.width,At.height,0,At.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):kt?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,At.width,At.height,Tt,Dt,At.data):e.texImage2D(i.TEXTURE_2D,W,Nt,At.width,At.height,0,Tt,Dt,At.data)}else if(x.isDataArrayTexture)if(kt){if(se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,dt,Nt,st.width,st.height,st.depth),U)if(x.layerUpdates.size>0){const W=Vl(st.width,st.height,x.format,x.type);for(const j of x.layerUpdates){const vt=st.data.subarray(j*W/st.data.BYTES_PER_ELEMENT,(j+1)*W/st.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,j,st.width,st.height,1,Tt,Dt,vt)}x.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,st.width,st.height,st.depth,Tt,Dt,st.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Nt,st.width,st.height,st.depth,0,Tt,Dt,st.data);else if(x.isData3DTexture)kt?(se&&e.texStorage3D(i.TEXTURE_3D,dt,Nt,st.width,st.height,st.depth),U&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,st.width,st.height,st.depth,Tt,Dt,st.data)):e.texImage3D(i.TEXTURE_3D,0,Nt,st.width,st.height,st.depth,0,Tt,Dt,st.data);else if(x.isFramebufferTexture){if(se)if(kt)e.texStorage2D(i.TEXTURE_2D,dt,Nt,st.width,st.height);else{let W=st.width,j=st.height;for(let vt=0;vt<dt;vt++)e.texImage2D(i.TEXTURE_2D,vt,Nt,W,j,0,Tt,Dt,null),W>>=1,j>>=1}}else if(Yt.length>0){if(kt&&se){const W=gt(Yt[0]);e.texStorage2D(i.TEXTURE_2D,dt,Nt,W.width,W.height)}for(let W=0,j=Yt.length;W<j;W++)At=Yt[W],kt?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Tt,Dt,At):e.texImage2D(i.TEXTURE_2D,W,Nt,Tt,Dt,At);x.generateMipmaps=!1}else if(kt){if(se){const W=gt(st);e.texStorage2D(i.TEXTURE_2D,dt,Nt,W.width,W.height)}U&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,Tt,Dt,st)}else e.texImage2D(i.TEXTURE_2D,0,Nt,Tt,Dt,st);m(x)&&p(q),Rt.__version=K.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function ot(T,x,O){if(x.image.length!==6)return;const q=Zt(T,x),tt=x.source;e.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+O);const K=n.get(tt);if(tt.version!==K.__version||q===!0){e.activeTexture(i.TEXTURE0+O);const Rt=Jt.getPrimaries(Jt.workingColorSpace),ft=x.colorSpace===Tn?null:Jt.getPrimaries(x.colorSpace),Mt=x.colorSpace===Tn||Rt===ft?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Mt);const qt=x.isCompressedTexture||x.image[0].isCompressedTexture,st=x.image[0]&&x.image[0].isDataTexture,Tt=[];for(let j=0;j<6;j++)!qt&&!st?Tt[j]=v(x.image[j],!0,r.maxCubemapSize):Tt[j]=st?x.image[j].image:x.image[j],Tt[j]=Ut(x,Tt[j]);const Dt=Tt[0],Nt=s.convert(x.format,x.colorSpace),At=s.convert(x.type),Yt=y(x.internalFormat,Nt,At,x.colorSpace),kt=x.isVideoTexture!==!0,se=K.__version===void 0||q===!0,U=tt.dataReady;let dt=L(x,Dt);Ot(i.TEXTURE_CUBE_MAP,x);let W;if(qt){kt&&se&&e.texStorage2D(i.TEXTURE_CUBE_MAP,dt,Yt,Dt.width,Dt.height);for(let j=0;j<6;j++){W=Tt[j].mipmaps;for(let vt=0;vt<W.length;vt++){const _t=W[vt];x.format!==Ke?Nt!==null?kt?U&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt,0,0,_t.width,_t.height,Nt,_t.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt,Yt,_t.width,_t.height,0,_t.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):kt?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt,0,0,_t.width,_t.height,Nt,At,_t.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt,Yt,_t.width,_t.height,0,Nt,At,_t.data)}}}else{if(W=x.mipmaps,kt&&se){W.length>0&&dt++;const j=gt(Tt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,dt,Yt,j.width,j.height)}for(let j=0;j<6;j++)if(st){kt?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Tt[j].width,Tt[j].height,Nt,At,Tt[j].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Yt,Tt[j].width,Tt[j].height,0,Nt,At,Tt[j].data);for(let vt=0;vt<W.length;vt++){const zt=W[vt].image[j].image;kt?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt+1,0,0,zt.width,zt.height,Nt,At,zt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt+1,Yt,zt.width,zt.height,0,Nt,At,zt.data)}}else{kt?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Nt,At,Tt[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Yt,Nt,At,Tt[j]);for(let vt=0;vt<W.length;vt++){const _t=W[vt];kt?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt+1,0,0,Nt,At,_t.image[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,vt+1,Yt,Nt,At,_t.image[j])}}}m(x)&&p(i.TEXTURE_CUBE_MAP),K.__version=tt.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Q(T,x,O,q,tt,K){const Rt=s.convert(O.format,O.colorSpace),ft=s.convert(O.type),Mt=y(O.internalFormat,Rt,ft,O.colorSpace),qt=n.get(x),st=n.get(O);if(st.__renderTarget=x,!qt.__hasExternalTextures){const Tt=Math.max(1,x.width>>K),Dt=Math.max(1,x.height>>K);tt===i.TEXTURE_3D||tt===i.TEXTURE_2D_ARRAY?e.texImage3D(tt,K,Mt,Tt,Dt,x.depth,0,Rt,ft,null):e.texImage2D(tt,K,Mt,Tt,Dt,0,Rt,ft,null)}e.bindFramebuffer(i.FRAMEBUFFER,T),Et(x)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,q,tt,st.__webglTexture,0,it(x)):(tt===i.TEXTURE_2D||tt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&tt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,q,tt,st.__webglTexture,K),e.bindFramebuffer(i.FRAMEBUFFER,null)}function J(T,x,O){if(i.bindRenderbuffer(i.RENDERBUFFER,T),x.depthBuffer){const q=x.depthTexture,tt=q&&q.isDepthTexture?q.type:null,K=S(x.stencilBuffer,tt),Rt=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ft=it(x);Et(x)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft,K,x.width,x.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft,K,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,K,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Rt,i.RENDERBUFFER,T)}else{const q=x.textures;for(let tt=0;tt<q.length;tt++){const K=q[tt],Rt=s.convert(K.format,K.colorSpace),ft=s.convert(K.type),Mt=y(K.internalFormat,Rt,ft,K.colorSpace),qt=it(x);O&&Et(x)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,qt,Mt,x.width,x.height):Et(x)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,qt,Mt,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,Mt,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ht(T,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const q=n.get(x.depthTexture);q.__renderTarget=x,(!q.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X(x.depthTexture,0);const tt=q.__webglTexture,K=it(x);if(x.depthTexture.format===wi)Et(x)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,tt,0,K):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,tt,0);else if(x.depthTexture.format===Ni)Et(x)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,tt,0,K):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,tt,0);else throw new Error("Unknown depthTexture format")}function xt(T){const x=n.get(T),O=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const q=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),q){const tt=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,q.removeEventListener("dispose",tt)};q.addEventListener("dispose",tt),x.__depthDisposeCallback=tt}x.__boundDepthTexture=q}if(T.depthTexture&&!x.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");ht(x.__webglFramebuffer,T)}else if(O){x.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[q]),x.__webglDepthbuffer[q]===void 0)x.__webglDepthbuffer[q]=i.createRenderbuffer(),J(x.__webglDepthbuffer[q],T,!1);else{const tt=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer[q];i.bindRenderbuffer(i.RENDERBUFFER,K),i.framebufferRenderbuffer(i.FRAMEBUFFER,tt,i.RENDERBUFFER,K)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),J(x.__webglDepthbuffer,T,!1);else{const q=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,tt=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,tt),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,tt)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ct(T,x,O){const q=n.get(T);x!==void 0&&Q(q.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&xt(T)}function Wt(T){const x=T.texture,O=n.get(T),q=n.get(x);T.addEventListener("dispose",C);const tt=T.textures,K=T.isWebGLCubeRenderTarget===!0,Rt=tt.length>1;if(Rt||(q.__webglTexture===void 0&&(q.__webglTexture=i.createTexture()),q.__version=x.version,o.memory.textures++),K){O.__webglFramebuffer=[];for(let ft=0;ft<6;ft++)if(x.mipmaps&&x.mipmaps.length>0){O.__webglFramebuffer[ft]=[];for(let Mt=0;Mt<x.mipmaps.length;Mt++)O.__webglFramebuffer[ft][Mt]=i.createFramebuffer()}else O.__webglFramebuffer[ft]=i.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){O.__webglFramebuffer=[];for(let ft=0;ft<x.mipmaps.length;ft++)O.__webglFramebuffer[ft]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(Rt)for(let ft=0,Mt=tt.length;ft<Mt;ft++){const qt=n.get(tt[ft]);qt.__webglTexture===void 0&&(qt.__webglTexture=i.createTexture(),o.memory.textures++)}if(T.samples>0&&Et(T)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let ft=0;ft<tt.length;ft++){const Mt=tt[ft];O.__webglColorRenderbuffer[ft]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[ft]);const qt=s.convert(Mt.format,Mt.colorSpace),st=s.convert(Mt.type),Tt=y(Mt.internalFormat,qt,st,Mt.colorSpace,T.isXRRenderTarget===!0),Dt=it(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,Dt,Tt,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.RENDERBUFFER,O.__webglColorRenderbuffer[ft])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),J(O.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(K){e.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture),Ot(i.TEXTURE_CUBE_MAP,x);for(let ft=0;ft<6;ft++)if(x.mipmaps&&x.mipmaps.length>0)for(let Mt=0;Mt<x.mipmaps.length;Mt++)Q(O.__webglFramebuffer[ft][Mt],T,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,Mt);else Q(O.__webglFramebuffer[ft],T,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,0);m(x)&&p(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Rt){for(let ft=0,Mt=tt.length;ft<Mt;ft++){const qt=tt[ft],st=n.get(qt);e.bindTexture(i.TEXTURE_2D,st.__webglTexture),Ot(i.TEXTURE_2D,qt),Q(O.__webglFramebuffer,T,qt,i.COLOR_ATTACHMENT0+ft,i.TEXTURE_2D,0),m(qt)&&p(i.TEXTURE_2D)}e.unbindTexture()}else{let ft=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ft=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ft,q.__webglTexture),Ot(ft,x),x.mipmaps&&x.mipmaps.length>0)for(let Mt=0;Mt<x.mipmaps.length;Mt++)Q(O.__webglFramebuffer[Mt],T,x,i.COLOR_ATTACHMENT0,ft,Mt);else Q(O.__webglFramebuffer,T,x,i.COLOR_ATTACHMENT0,ft,0);m(x)&&p(ft),e.unbindTexture()}T.depthBuffer&&xt(T)}function Z(T){const x=T.textures;for(let O=0,q=x.length;O<q;O++){const tt=x[O];if(m(tt)){const K=A(T),Rt=n.get(tt).__webglTexture;e.bindTexture(K,Rt),p(K),e.unbindTexture()}}}const et=[],b=[];function wt(T){if(T.samples>0){if(Et(T)===!1){const x=T.textures,O=T.width,q=T.height;let tt=i.COLOR_BUFFER_BIT;const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Rt=n.get(T),ft=x.length>1;if(ft)for(let Mt=0;Mt<x.length;Mt++)e.bindFramebuffer(i.FRAMEBUFFER,Rt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Mt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,Rt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Mt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,Rt.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Rt.__webglFramebuffer);for(let Mt=0;Mt<x.length;Mt++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(tt|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(tt|=i.STENCIL_BUFFER_BIT)),ft){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Rt.__webglColorRenderbuffer[Mt]);const qt=n.get(x[Mt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,qt,0)}i.blitFramebuffer(0,0,O,q,0,0,O,q,tt,i.NEAREST),c===!0&&(et.length=0,b.length=0,et.push(i.COLOR_ATTACHMENT0+Mt),T.depthBuffer&&T.resolveDepthBuffer===!1&&(et.push(K),b.push(K),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,b)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,et))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ft)for(let Mt=0;Mt<x.length;Mt++){e.bindFramebuffer(i.FRAMEBUFFER,Rt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Mt,i.RENDERBUFFER,Rt.__webglColorRenderbuffer[Mt]);const qt=n.get(x[Mt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,Rt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Mt,i.TEXTURE_2D,qt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Rt.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function it(T){return Math.min(r.maxSamples,T.samples)}function Et(T){const x=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function at(T){const x=o.render.frame;u.get(T)!==x&&(u.set(T,x),T.update())}function Ut(T,x){const O=T.colorSpace,q=T.format,tt=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||O!==Fi&&O!==Tn&&(Jt.getTransfer(O)===ne?(q!==Ke||tt!==gn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),x}function gt(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=F,this.resetTextureUnits=B,this.setTexture2D=X,this.setTexture2DArray=G,this.setTexture3D=$,this.setTextureCube=V,this.rebindTextures=Ct,this.setupRenderTarget=Wt,this.updateRenderTargetMipmap=Z,this.updateMultisampleRenderTarget=wt,this.setupDepthRenderbuffer=xt,this.setupFrameBufferTexture=Q,this.useMultisampledRTT=Et}function B0(i,t){function e(n,r=Tn){let s;const o=Jt.getTransfer(r);if(n===gn)return i.UNSIGNED_BYTE;if(n===_c)return i.UNSIGNED_SHORT_4_4_4_4;if(n===vc)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Du)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Pu)return i.BYTE;if(n===Lu)return i.SHORT;if(n===sr)return i.UNSIGNED_SHORT;if(n===gc)return i.INT;if(n===Zn)return i.UNSIGNED_INT;if(n===dn)return i.FLOAT;if(n===dr)return i.HALF_FLOAT;if(n===Uu)return i.ALPHA;if(n===Iu)return i.RGB;if(n===Ke)return i.RGBA;if(n===Nu)return i.LUMINANCE;if(n===Fu)return i.LUMINANCE_ALPHA;if(n===wi)return i.DEPTH_COMPONENT;if(n===Ni)return i.DEPTH_STENCIL;if(n===Ou)return i.RED;if(n===xc)return i.RED_INTEGER;if(n===Bu)return i.RG;if(n===Mc)return i.RG_INTEGER;if(n===Sc)return i.RGBA_INTEGER;if(n===Kr||n===Zr||n===$r||n===Jr)if(o===ne)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Kr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Zr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===$r)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Jr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Kr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Zr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===$r)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Jr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Qo||n===ta||n===ea||n===na)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Qo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ta)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ea)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===na)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ia||n===ra||n===sa)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ia||n===ra)return o===ne?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===sa)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===oa||n===aa||n===ca||n===la||n===ua||n===ha||n===fa||n===da||n===pa||n===ma||n===ga||n===_a||n===va||n===xa)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===oa)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===aa)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ca)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===la)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ua)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ha)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===fa)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===da)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===pa)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ma)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ga)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===_a)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===va)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===xa)return o===ne?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===jr||n===Ma||n===Sa)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===jr)return o===ne?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ma)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Sa)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===zu||n===Ea||n===ya||n===Ta)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===jr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ea)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ya)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ta)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ii?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const z0={type:"move"};class to{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Yn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Yn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Yn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&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}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){o=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,n),p=this._getHandJoint(l,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,g=.005;l.inputState.pinching&&f>d+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=d-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(z0)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Yn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const H0=`
|
|
3804
3842
|
void main() {
|
|
3805
3843
|
|
|
3806
3844
|
gl_Position = vec4( position, 1.0 );
|
|
3807
3845
|
|
|
3808
|
-
}
|
|
3846
|
+
}`,k0=`
|
|
3809
3847
|
uniform sampler2DArray depthColor;
|
|
3810
3848
|
uniform float depthWidth;
|
|
3811
3849
|
uniform float depthHeight;
|
|
@@ -3824,7 +3862,7 @@ void main() {
|
|
|
3824
3862
|
|
|
3825
3863
|
}
|
|
3826
3864
|
|
|
3827
|
-
}`;class Q_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const r=new ye,s=t.properties.get(r);s.__webglTexture=e.texture,(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new wn({vertexShader:j_,fragmentShader:$_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new le(new ar(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class tv extends Di{constructor(t,e){super();const n=this;let r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,d=null,g=null;const v=new Q_,m=e.getContextAttributes();let p=null,b=null;const T=[],S=[],L=new at;let C=null;const R=new Ie;R.viewport=new ee;const D=new Ie;D.viewport=new ee;const y=[R,D],M=new Md;let w=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let st=T[Y];return st===void 0&&(st=new Os,T[Y]=st),st.getTargetRaySpace()},this.getControllerGrip=function(Y){let st=T[Y];return st===void 0&&(st=new Os,T[Y]=st),st.getGripSpace()},this.getHand=function(Y){let st=T[Y];return st===void 0&&(st=new Os,T[Y]=st),st.getHandSpace()};function O(Y){const st=S.indexOf(Y.inputSource);if(st===-1)return;const Q=T[st];Q!==void 0&&(Q.update(Y.inputSource,Y.frame,l||o),Q.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",V),r.removeEventListener("inputsourceschange",X);for(let Y=0;Y<T.length;Y++){const st=S[Y];st!==null&&(S[Y]=null,T[Y].disconnect(st))}w=null,H=null,v.reset(),t.setRenderTarget(p),d=null,f=null,h=null,r=null,b=null,Zt.stop(),n.isPresenting=!1,t.setPixelRatio(C),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){a=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(p=t.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",V),r.addEventListener("inputsourceschange",X),m.xrCompatible!==!0&&await e.makeXRCompatible(),C=t.getPixelRatio(),t.getSize(L),r.enabledFeatures!==void 0&&r.enabledFeatures.includes("layers")){let Q=null,j=null,ut=null;m.depth&&(ut=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Q=m.stencil?Ci:Si,j=m.stencil?Ri:qn);const vt={colorFormat:e.RGBA8,depthFormat:ut,scaleFactor:s};h=new XRWebGLBinding(r,e),f=h.createProjectionLayer(vt),r.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),b=new Yn(f.textureWidth,f.textureHeight,{format:We,type:fn,depthTexture:new ou(f.textureWidth,f.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}else{const Q={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,e,Q),r.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),b=new Yn(d.framebufferWidth,d.framebufferHeight,{format:We,type:fn,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}b.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),Zt.setContext(r),Zt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function X(Y){for(let st=0;st<Y.removed.length;st++){const Q=Y.removed[st],j=S.indexOf(Q);j>=0&&(S[j]=null,T[j].disconnect(Q))}for(let st=0;st<Y.added.length;st++){const Q=Y.added[st];let j=S.indexOf(Q);if(j===-1){for(let vt=0;vt<T.length;vt++)if(vt>=S.length){S.push(Q),j=vt;break}else if(S[vt]===null){S[vt]=Q,j=vt;break}if(j===-1)break}const ut=T[j];ut&&ut.connect(Q)}}const G=new P,K=new P;function k(Y,st,Q){G.setFromMatrixPosition(st.matrixWorld),K.setFromMatrixPosition(Q.matrixWorld);const j=G.distanceTo(K),ut=st.projectionMatrix.elements,vt=Q.projectionMatrix.elements,Rt=ut[14]/(ut[10]-1),Vt=ut[14]/(ut[10]+1),J=(ut[9]+1)/ut[5],et=(ut[9]-1)/ut[5],A=(ut[8]-1)/ut[0],bt=(vt[8]+1)/vt[0],nt=Rt*A,St=Rt*bt,ot=j/(-A+bt),Dt=ot*-A;if(st.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Dt),Y.translateZ(ot),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),ut[10]===-1)Y.projectionMatrix.copy(st.projectionMatrix),Y.projectionMatrixInverse.copy(st.projectionMatrixInverse);else{const mt=Rt+ot,E=Vt+ot,_=nt-Dt,F=St+(j-Dt),q=J*Vt/E*mt,tt=et*Vt/E*mt;Y.projectionMatrix.makePerspective(_,F,q,tt,mt,E),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ct(Y,st){st===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(st.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let st=Y.near,Q=Y.far;v.texture!==null&&(v.depthNear>0&&(st=v.depthNear),v.depthFar>0&&(Q=v.depthFar)),M.near=D.near=R.near=st,M.far=D.far=R.far=Q,(w!==M.near||H!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),w=M.near,H=M.far),R.layers.mask=Y.layers.mask|2,D.layers.mask=Y.layers.mask|4,M.layers.mask=R.layers.mask|D.layers.mask;const j=Y.parent,ut=M.cameras;ct(M,j);for(let vt=0;vt<ut.length;vt++)ct(ut[vt],j);ut.length===2?k(M,R,D):M.projectionMatrix.copy(R.projectionMatrix),pt(Y,M,j)};function pt(Y,st,Q){Q===null?Y.matrix.copy(st.matrixWorld):(Y.matrix.copy(Q.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(st.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(st.projectionMatrix),Y.projectionMatrixInverse.copy(st.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=ji*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(Y){c=Y,f!==null&&(f.fixedFoveation=Y),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Y)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Mt=null;function Ft(Y,st){if(u=st.getViewerPose(l||o),g=st,u!==null){const Q=u.views;d!==null&&(t.setRenderTargetFramebuffer(b,d.framebuffer),t.setRenderTarget(b));let j=!1;Q.length!==M.cameras.length&&(M.cameras.length=0,j=!0);for(let vt=0;vt<Q.length;vt++){const Rt=Q[vt];let Vt=null;if(d!==null)Vt=d.getViewport(Rt);else{const et=h.getViewSubImage(f,Rt);Vt=et.viewport,vt===0&&(t.setRenderTargetTextures(b,et.colorTexture,f.ignoreDepthValues?void 0:et.depthStencilTexture),t.setRenderTarget(b))}let J=y[vt];J===void 0&&(J=new Ie,J.layers.enable(vt),J.viewport=new ee,y[vt]=J),J.matrix.fromArray(Rt.transform.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale),J.projectionMatrix.fromArray(Rt.projectionMatrix),J.projectionMatrixInverse.copy(J.projectionMatrix).invert(),J.viewport.set(Vt.x,Vt.y,Vt.width,Vt.height),vt===0&&(M.matrix.copy(J.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),j===!0&&M.cameras.push(J)}const ut=r.enabledFeatures;if(ut&&ut.includes("depth-sensing")){const vt=h.getDepthInformation(Q[0]);vt&&vt.isValid&&vt.texture&&v.init(t,vt,r.renderState)}}for(let Q=0;Q<T.length;Q++){const j=S[Q],ut=T[Q];j!==null&&ut!==void 0&&ut.update(j,st,l||o)}Mt&&Mt(Y,st),st.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:st}),g=null}const Zt=new gu;Zt.setAnimationLoop(Ft),this.setAnimationLoop=function(Y){Mt=Y},this.dispose=function(){}}}const Nn=new $e,ev=new re;function nv(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,nu(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function r(m,p,b,T,S){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),h(m,p)):p.isMeshPhongMaterial?(s(m,p),u(m,p)):p.isMeshStandardMaterial?(s(m,p),f(m,p),p.isMeshPhysicalMaterial&&d(m,p,S)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),v(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,b,T):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ce&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ce&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const b=t.get(p),T=b.envMap,S=b.envMapRotation;T&&(m.envMap.value=T,Nn.copy(S),Nn.x*=-1,Nn.y*=-1,Nn.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Nn.y*=-1,Nn.z*=-1),m.envMapRotation.value.setFromMatrix4(ev.makeRotationFromEuler(Nn)),m.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,b,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=T*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function f(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function d(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ce&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){const b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function iv(i,t,e,n){let r={},s={},o=[];const a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(b,T){const S=T.program;n.uniformBlockBinding(b,S)}function l(b,T){let S=r[b.id];S===void 0&&(g(b),S=u(b),r[b.id]=S,b.addEventListener("dispose",m));const L=T.program;n.updateUBOMapping(b,L);const C=t.render.frame;s[b.id]!==C&&(f(b),s[b.id]=C)}function u(b){const T=h();b.__bindingPointIndex=T;const S=i.createBuffer(),L=b.__size,C=b.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,L,C),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,S),S}function h(){for(let b=0;b<a;b++)if(o.indexOf(b)===-1)return o.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(b){const T=r[b.id],S=b.uniforms,L=b.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let C=0,R=S.length;C<R;C++){const D=Array.isArray(S[C])?S[C]:[S[C]];for(let y=0,M=D.length;y<M;y++){const w=D[y];if(d(w,C,y,L)===!0){const H=w.__offset,O=Array.isArray(w.value)?w.value:[w.value];let V=0;for(let X=0;X<O.length;X++){const G=O[X],K=v(G);typeof G=="number"||typeof G=="boolean"?(w.__data[0]=G,i.bufferSubData(i.UNIFORM_BUFFER,H+V,w.__data)):G.isMatrix3?(w.__data[0]=G.elements[0],w.__data[1]=G.elements[1],w.__data[2]=G.elements[2],w.__data[3]=0,w.__data[4]=G.elements[3],w.__data[5]=G.elements[4],w.__data[6]=G.elements[5],w.__data[7]=0,w.__data[8]=G.elements[6],w.__data[9]=G.elements[7],w.__data[10]=G.elements[8],w.__data[11]=0):(G.toArray(w.__data,V),V+=K.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,w.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(b,T,S,L){const C=b.value,R=T+"_"+S;if(L[R]===void 0)return typeof C=="number"||typeof C=="boolean"?L[R]=C:L[R]=C.clone(),!0;{const D=L[R];if(typeof C=="number"||typeof C=="boolean"){if(D!==C)return L[R]=C,!0}else if(D.equals(C)===!1)return D.copy(C),!0}return!1}function g(b){const T=b.uniforms;let S=0;const L=16;for(let R=0,D=T.length;R<D;R++){const y=Array.isArray(T[R])?T[R]:[T[R]];for(let M=0,w=y.length;M<w;M++){const H=y[M],O=Array.isArray(H.value)?H.value:[H.value];for(let V=0,X=O.length;V<X;V++){const G=O[V],K=v(G),k=S%L,ct=k%K.boundary,pt=k+ct;S+=ct,pt!==0&&L-pt<K.storage&&(S+=L-pt),H.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=S,S+=K.storage}}}const C=S%L;return C>0&&(S+=L-C),b.__size=S,b.__cache={},this}function v(b){const T={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(T.boundary=4,T.storage=4):b.isVector2?(T.boundary=8,T.storage=8):b.isVector3||b.isColor?(T.boundary=16,T.storage=12):b.isVector4?(T.boundary=16,T.storage=16):b.isMatrix3?(T.boundary=48,T.storage=48):b.isMatrix4?(T.boundary=64,T.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),T}function m(b){const T=b.target;T.removeEventListener("dispose",m);const S=o.indexOf(T.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function p(){for(const b in r)i.deleteBuffer(r[b]);o=[],r={},s={}}return{bind:c,update:l,dispose:p}}class rv{constructor(t={}){const{canvas:e=tf(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:f=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const g=new Uint32Array(4),v=new Int32Array(4);let m=null,p=null;const b=[],T=[];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._outputColorSpace=we,this.toneMapping=Tn,this.toneMappingExposure=1;const S=this;let L=!1,C=0,R=0,D=null,y=-1,M=null;const w=new ee,H=new ee;let O=null;const V=new Wt(0);let X=0,G=e.width,K=e.height,k=1,ct=null,pt=null;const Mt=new ee(0,0,G,K),Ft=new ee(0,0,G,K);let Zt=!1;const Y=new Xa;let st=!1,Q=!1;this.transmissionResolutionScale=1;const j=new re,ut=new re,vt=new P,Rt=new ee,Vt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let J=!1;function et(){return D===null?k:1}let A=n;function bt(x,I){return e.getContext(x,I)}try{const x={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ia}`),e.addEventListener("webglcontextlost",$,!1),e.addEventListener("webglcontextrestored",_t,!1),e.addEventListener("webglcontextcreationerror",gt,!1),A===null){const I="webgl2";if(A=bt(I,x),A===null)throw bt(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(x){throw console.error("THREE.WebGLRenderer: "+x.message),x}let nt,St,ot,Dt,mt,E,_,F,q,tt,Z,wt,ht,xt,Xt,rt,Et,Lt,Ut,Tt,qt,Ht,ie,U;function ft(){nt=new dg(A),nt.init(),Ht=new J_(A,nt),St=new ag(A,nt,t,Ht),ot=new Y_(A,nt),St.reverseDepthBuffer&&f&&ot.buffers.depth.setReversed(!0),Dt=new gg(A),mt=new I_,E=new Z_(A,nt,ot,mt,St,Ht,Dt),_=new lg(S),F=new fg(S),q=new Ed(A),ie=new sg(A,q),tt=new pg(A,q,Dt,ie),Z=new vg(A,tt,q,Dt),Ut=new _g(A,St,E),rt=new cg(mt),wt=new U_(S,_,F,nt,St,ie,rt),ht=new nv(S,mt),xt=new F_,Xt=new G_(nt),Lt=new rg(S,_,F,ot,Z,d,c),Et=new X_(S,Z,St),U=new iv(A,Dt,St,ot),Tt=new og(A,nt,Dt),qt=new mg(A,nt,Dt),Dt.programs=wt.programs,S.capabilities=St,S.extensions=nt,S.properties=mt,S.renderLists=xt,S.shadowMap=Et,S.state=ot,S.info=Dt}ft();const W=new tv(S,A);this.xr=W,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const x=nt.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=nt.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(x){x!==void 0&&(k=x,this.setSize(G,K,!1))},this.getSize=function(x){return x.set(G,K)},this.setSize=function(x,I,B=!0){if(W.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=x,K=I,e.width=Math.floor(x*k),e.height=Math.floor(I*k),B===!0&&(e.style.width=x+"px",e.style.height=I+"px"),this.setViewport(0,0,x,I)},this.getDrawingBufferSize=function(x){return x.set(G*k,K*k).floor()},this.setDrawingBufferSize=function(x,I,B){G=x,K=I,k=B,e.width=Math.floor(x*B),e.height=Math.floor(I*B),this.setViewport(0,0,x,I)},this.getCurrentViewport=function(x){return x.copy(w)},this.getViewport=function(x){return x.copy(Mt)},this.setViewport=function(x,I,B,z){x.isVector4?Mt.set(x.x,x.y,x.z,x.w):Mt.set(x,I,B,z),ot.viewport(w.copy(Mt).multiplyScalar(k).round())},this.getScissor=function(x){return x.copy(Ft)},this.setScissor=function(x,I,B,z){x.isVector4?Ft.set(x.x,x.y,x.z,x.w):Ft.set(x,I,B,z),ot.scissor(H.copy(Ft).multiplyScalar(k).round())},this.getScissorTest=function(){return Zt},this.setScissorTest=function(x){ot.setScissorTest(Zt=x)},this.setOpaqueSort=function(x){ct=x},this.setTransparentSort=function(x){pt=x},this.getClearColor=function(x){return x.copy(Lt.getClearColor())},this.setClearColor=function(){Lt.setClearColor.apply(Lt,arguments)},this.getClearAlpha=function(){return Lt.getClearAlpha()},this.setClearAlpha=function(){Lt.setClearAlpha.apply(Lt,arguments)},this.clear=function(x=!0,I=!0,B=!0){let z=0;if(x){let N=!1;if(D!==null){const it=D.texture.format;N=it===Ha||it===za||it===Ba}if(N){const it=D.texture.type,dt=it===fn||it===qn||it===Ki||it===Ri||it===Fa||it===Oa,yt=Lt.getClearColor(),At=Lt.getClearAlpha(),It=yt.r,Ot=yt.g,Ct=yt.b;dt?(g[0]=It,g[1]=Ot,g[2]=Ct,g[3]=At,A.clearBufferuiv(A.COLOR,0,g)):(v[0]=It,v[1]=Ot,v[2]=Ct,v[3]=At,A.clearBufferiv(A.COLOR,0,v))}else z|=A.COLOR_BUFFER_BIT}I&&(z|=A.DEPTH_BUFFER_BIT),B&&(z|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(z)},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",$,!1),e.removeEventListener("webglcontextrestored",_t,!1),e.removeEventListener("webglcontextcreationerror",gt,!1),Lt.dispose(),xt.dispose(),Xt.dispose(),mt.dispose(),_.dispose(),F.dispose(),Z.dispose(),ie.dispose(),U.dispose(),wt.dispose(),W.dispose(),W.removeEventListener("sessionstart",hc),W.removeEventListener("sessionend",fc),Rn.stop()};function $(x){x.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function _t(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;const x=Dt.autoReset,I=Et.enabled,B=Et.autoUpdate,z=Et.needsUpdate,N=Et.type;ft(),Dt.autoReset=x,Et.enabled=I,Et.autoUpdate=B,Et.needsUpdate=z,Et.type=N}function gt(x){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function Bt(x){const I=x.target;I.removeEventListener("dispose",Bt),ae(I)}function ae(x){xe(x),mt.remove(x)}function xe(x){const I=mt.get(x).programs;I!==void 0&&(I.forEach(function(B){wt.releaseProgram(B)}),x.isShaderMaterial&&wt.releaseShaderCache(x))}this.renderBufferDirect=function(x,I,B,z,N,it){I===null&&(I=Vt);const dt=N.isMesh&&N.matrixWorld.determinant()<0,yt=Ou(x,I,B,z,N);ot.setMaterial(z,dt);let At=B.index,It=1;if(z.wireframe===!0){if(At=tt.getWireframeAttribute(B),At===void 0)return;It=2}const Ot=B.drawRange,Ct=B.attributes.position;let Yt=Ot.start*It,jt=(Ot.start+Ot.count)*It;it!==null&&(Yt=Math.max(Yt,it.start*It),jt=Math.min(jt,(it.start+it.count)*It)),At!==null?(Yt=Math.max(Yt,0),jt=Math.min(jt,At.count)):Ct!=null&&(Yt=Math.max(Yt,0),jt=Math.min(jt,Ct.count));const ue=jt-Yt;if(ue<0||ue===1/0)return;ie.setup(N,z,yt,B,At);let ce,Jt=Tt;if(At!==null&&(ce=q.get(At),Jt=qt,Jt.setIndex(ce)),N.isMesh)z.wireframe===!0?(ot.setLineWidth(z.wireframeLinewidth*et()),Jt.setMode(A.LINES)):Jt.setMode(A.TRIANGLES);else if(N.isLine){let Pt=z.linewidth;Pt===void 0&&(Pt=1),ot.setLineWidth(Pt*et()),N.isLineSegments?Jt.setMode(A.LINES):N.isLineLoop?Jt.setMode(A.LINE_LOOP):Jt.setMode(A.LINE_STRIP)}else N.isPoints?Jt.setMode(A.POINTS):N.isSprite&&Jt.setMode(A.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)Jt.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(nt.get("WEBGL_multi_draw"))Jt.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const Pt=N._multiDrawStarts,_e=N._multiDrawCounts,$t=N._multiDrawCount,ze=At?q.get(At).bytesPerElement:1,Qn=mt.get(z).currentProgram.getUniforms();for(let Le=0;Le<$t;Le++)Qn.setValue(A,"_gl_DrawID",Le),Jt.render(Pt[Le]/ze,_e[Le])}else if(N.isInstancedMesh)Jt.renderInstances(Yt,ue,N.count);else if(B.isInstancedBufferGeometry){const Pt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,_e=Math.min(B.instanceCount,Pt);Jt.renderInstances(Yt,ue,_e)}else Jt.render(Yt,ue)};function Qt(x,I,B){x.transparent===!0&&x.side===Ze&&x.forceSinglePass===!1?(x.side=Ce,x.needsUpdate=!0,lr(x,I,B),x.side=bn,x.needsUpdate=!0,lr(x,I,B),x.side=Ze):lr(x,I,B)}this.compile=function(x,I,B=null){B===null&&(B=x),p=Xt.get(B),p.init(I),T.push(p),B.traverseVisible(function(N){N.isLight&&N.layers.test(I.layers)&&(p.pushLight(N),N.castShadow&&p.pushShadow(N))}),x!==B&&x.traverseVisible(function(N){N.isLight&&N.layers.test(I.layers)&&(p.pushLight(N),N.castShadow&&p.pushShadow(N))}),p.setupLights();const z=new Set;return x.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const it=N.material;if(it)if(Array.isArray(it))for(let dt=0;dt<it.length;dt++){const yt=it[dt];Qt(yt,B,N),z.add(yt)}else Qt(it,B,N),z.add(it)}),T.pop(),p=null,z},this.compileAsync=function(x,I,B=null){const z=this.compile(x,I,B);return new Promise(N=>{function it(){if(z.forEach(function(dt){mt.get(dt).currentProgram.isReady()&&z.delete(dt)}),z.size===0){N(x);return}setTimeout(it,10)}nt.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let Be=null;function tn(x){Be&&Be(x)}function hc(){Rn.stop()}function fc(){Rn.start()}const Rn=new gu;Rn.setAnimationLoop(tn),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(x){Be=x,W.setAnimationLoop(x),x===null?Rn.stop():Rn.start()},W.addEventListener("sessionstart",hc),W.addEventListener("sessionend",fc),this.render=function(x,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),W.enabled===!0&&W.isPresenting===!0&&(W.cameraAutoUpdate===!0&&W.updateCamera(I),I=W.getCamera()),x.isScene===!0&&x.onBeforeRender(S,x,I,D),p=Xt.get(x,T.length),p.init(I),T.push(p),ut.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Y.setFromProjectionMatrix(ut),Q=this.localClippingEnabled,st=rt.init(this.clippingPlanes,Q),m=xt.get(x,b.length),m.init(),b.push(m),W.enabled===!0&&W.isPresenting===!0){const it=S.xr.getDepthSensingMesh();it!==null&&is(it,I,-1/0,S.sortObjects)}is(x,I,0,S.sortObjects),m.finish(),S.sortObjects===!0&&m.sort(ct,pt),J=W.enabled===!1||W.isPresenting===!1||W.hasDepthSensing()===!1,J&&Lt.addToRenderList(m,x),this.info.render.frame++,st===!0&&rt.beginShadows();const B=p.state.shadowsArray;Et.render(B,x,I),st===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=m.opaque,N=m.transmissive;if(p.setupLights(),I.isArrayCamera){const it=I.cameras;if(N.length>0)for(let dt=0,yt=it.length;dt<yt;dt++){const At=it[dt];pc(z,N,x,At)}J&&Lt.render(x);for(let dt=0,yt=it.length;dt<yt;dt++){const At=it[dt];dc(m,x,At,At.viewport)}}else N.length>0&&pc(z,N,x,I),J&&Lt.render(x),dc(m,x,I);D!==null&&R===0&&(E.updateMultisampleRenderTarget(D),E.updateRenderTargetMipmap(D)),x.isScene===!0&&x.onAfterRender(S,x,I),ie.resetDefaultState(),y=-1,M=null,T.pop(),T.length>0?(p=T[T.length-1],st===!0&&rt.setGlobalState(S.clippingPlanes,p.state.camera)):p=null,b.pop(),b.length>0?m=b[b.length-1]:m=null};function is(x,I,B,z){if(x.visible===!1)return;if(x.layers.test(I.layers)){if(x.isGroup)B=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(I);else if(x.isLight)p.pushLight(x),x.castShadow&&p.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Y.intersectsSprite(x)){z&&Rt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ut);const dt=Z.update(x),yt=x.material;yt.visible&&m.push(x,dt,yt,B,Rt.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Y.intersectsObject(x))){const dt=Z.update(x),yt=x.material;if(z&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),Rt.copy(x.boundingSphere.center)):(dt.boundingSphere===null&&dt.computeBoundingSphere(),Rt.copy(dt.boundingSphere.center)),Rt.applyMatrix4(x.matrixWorld).applyMatrix4(ut)),Array.isArray(yt)){const At=dt.groups;for(let It=0,Ot=At.length;It<Ot;It++){const Ct=At[It],Yt=yt[Ct.materialIndex];Yt&&Yt.visible&&m.push(x,dt,Yt,B,Rt.z,Ct)}}else yt.visible&&m.push(x,dt,yt,B,Rt.z,null)}}const it=x.children;for(let dt=0,yt=it.length;dt<yt;dt++)is(it[dt],I,B,z)}function dc(x,I,B,z){const N=x.opaque,it=x.transmissive,dt=x.transparent;p.setupLightsView(B),st===!0&&rt.setGlobalState(S.clippingPlanes,B),z&&ot.viewport(w.copy(z)),N.length>0&&cr(N,I,B),it.length>0&&cr(it,I,B),dt.length>0&&cr(dt,I,B),ot.buffers.depth.setTest(!0),ot.buffers.depth.setMask(!0),ot.buffers.color.setMask(!0),ot.setPolygonOffset(!1)}function pc(x,I,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new Yn(1,1,{generateMipmaps:!0,type:nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float")?ir:fn,minFilter:Gn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace}));const it=p.state.transmissionRenderTarget[z.id],dt=z.viewport||w;it.setSize(dt.z*S.transmissionResolutionScale,dt.w*S.transmissionResolutionScale);const yt=S.getRenderTarget();S.setRenderTarget(it),S.getClearColor(V),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear(),J&&Lt.render(B);const At=S.toneMapping;S.toneMapping=Tn;const It=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),st===!0&&rt.setGlobalState(S.clippingPlanes,z),cr(x,B,z),E.updateMultisampleRenderTarget(it),E.updateRenderTargetMipmap(it),nt.has("WEBGL_multisampled_render_to_texture")===!1){let Ot=!1;for(let Ct=0,Yt=I.length;Ct<Yt;Ct++){const jt=I[Ct],ue=jt.object,ce=jt.geometry,Jt=jt.material,Pt=jt.group;if(Jt.side===Ze&&ue.layers.test(z.layers)){const _e=Jt.side;Jt.side=Ce,Jt.needsUpdate=!0,mc(ue,B,z,ce,Jt,Pt),Jt.side=_e,Jt.needsUpdate=!0,Ot=!0}}Ot===!0&&(E.updateMultisampleRenderTarget(it),E.updateRenderTargetMipmap(it))}S.setRenderTarget(yt),S.setClearColor(V,X),It!==void 0&&(z.viewport=It),S.toneMapping=At}function cr(x,I,B){const z=I.isScene===!0?I.overrideMaterial:null;for(let N=0,it=x.length;N<it;N++){const dt=x[N],yt=dt.object,At=dt.geometry,It=z===null?dt.material:z,Ot=dt.group;yt.layers.test(B.layers)&&mc(yt,I,B,At,It,Ot)}}function mc(x,I,B,z,N,it){x.onBeforeRender(S,I,B,z,N,it),x.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),N.onBeforeRender(S,I,B,z,x,it),N.transparent===!0&&N.side===Ze&&N.forceSinglePass===!1?(N.side=Ce,N.needsUpdate=!0,S.renderBufferDirect(B,I,z,N,x,it),N.side=bn,N.needsUpdate=!0,S.renderBufferDirect(B,I,z,N,x,it),N.side=Ze):S.renderBufferDirect(B,I,z,N,x,it),x.onAfterRender(S,I,B,z,N,it)}function lr(x,I,B){I.isScene!==!0&&(I=Vt);const z=mt.get(x),N=p.state.lights,it=p.state.shadowsArray,dt=N.state.version,yt=wt.getParameters(x,N.state,it,I,B),At=wt.getProgramCacheKey(yt);let It=z.programs;z.environment=x.isMeshStandardMaterial?I.environment:null,z.fog=I.fog,z.envMap=(x.isMeshStandardMaterial?F:_).get(x.envMap||z.environment),z.envMapRotation=z.environment!==null&&x.envMap===null?I.environmentRotation:x.envMapRotation,It===void 0&&(x.addEventListener("dispose",Bt),It=new Map,z.programs=It);let Ot=It.get(At);if(Ot!==void 0){if(z.currentProgram===Ot&&z.lightsStateVersion===dt)return _c(x,yt),Ot}else yt.uniforms=wt.getUniforms(x),x.onBeforeCompile(yt,S),Ot=wt.acquireProgram(yt,At),It.set(At,Ot),z.uniforms=yt.uniforms;const Ct=z.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(Ct.clippingPlanes=rt.uniform),_c(x,yt),z.needsLights=zu(x),z.lightsStateVersion=dt,z.needsLights&&(Ct.ambientLightColor.value=N.state.ambient,Ct.lightProbe.value=N.state.probe,Ct.directionalLights.value=N.state.directional,Ct.directionalLightShadows.value=N.state.directionalShadow,Ct.spotLights.value=N.state.spot,Ct.spotLightShadows.value=N.state.spotShadow,Ct.rectAreaLights.value=N.state.rectArea,Ct.ltc_1.value=N.state.rectAreaLTC1,Ct.ltc_2.value=N.state.rectAreaLTC2,Ct.pointLights.value=N.state.point,Ct.pointLightShadows.value=N.state.pointShadow,Ct.hemisphereLights.value=N.state.hemi,Ct.directionalShadowMap.value=N.state.directionalShadowMap,Ct.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Ct.spotShadowMap.value=N.state.spotShadowMap,Ct.spotLightMatrix.value=N.state.spotLightMatrix,Ct.spotLightMap.value=N.state.spotLightMap,Ct.pointShadowMap.value=N.state.pointShadowMap,Ct.pointShadowMatrix.value=N.state.pointShadowMatrix),z.currentProgram=Ot,z.uniformsList=null,Ot}function gc(x){if(x.uniformsList===null){const I=x.currentProgram.getUniforms();x.uniformsList=Hr.seqWithValue(I.seq,x.uniforms)}return x.uniformsList}function _c(x,I){const B=mt.get(x);B.outputColorSpace=I.outputColorSpace,B.batching=I.batching,B.batchingColor=I.batchingColor,B.instancing=I.instancing,B.instancingColor=I.instancingColor,B.instancingMorph=I.instancingMorph,B.skinning=I.skinning,B.morphTargets=I.morphTargets,B.morphNormals=I.morphNormals,B.morphColors=I.morphColors,B.morphTargetsCount=I.morphTargetsCount,B.numClippingPlanes=I.numClippingPlanes,B.numIntersection=I.numClipIntersection,B.vertexAlphas=I.vertexAlphas,B.vertexTangents=I.vertexTangents,B.toneMapping=I.toneMapping}function Ou(x,I,B,z,N){I.isScene!==!0&&(I=Vt),E.resetTextureUnits();const it=I.fog,dt=z.isMeshStandardMaterial?I.environment:null,yt=D===null?S.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Pi,At=(z.isMeshStandardMaterial?F:_).get(z.envMap||dt),It=z.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Ot=!!B.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Ct=!!B.morphAttributes.position,Yt=!!B.morphAttributes.normal,jt=!!B.morphAttributes.color;let ue=Tn;z.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(ue=S.toneMapping);const ce=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,Jt=ce!==void 0?ce.length:0,Pt=mt.get(z),_e=p.state.lights;if(st===!0&&(Q===!0||x!==M)){const Ee=x===M&&z.id===y;rt.setState(z,x,Ee)}let $t=!1;z.version===Pt.__version?(Pt.needsLights&&Pt.lightsStateVersion!==_e.state.version||Pt.outputColorSpace!==yt||N.isBatchedMesh&&Pt.batching===!1||!N.isBatchedMesh&&Pt.batching===!0||N.isBatchedMesh&&Pt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Pt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Pt.instancing===!1||!N.isInstancedMesh&&Pt.instancing===!0||N.isSkinnedMesh&&Pt.skinning===!1||!N.isSkinnedMesh&&Pt.skinning===!0||N.isInstancedMesh&&Pt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Pt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Pt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Pt.instancingMorph===!1&&N.morphTexture!==null||Pt.envMap!==At||z.fog===!0&&Pt.fog!==it||Pt.numClippingPlanes!==void 0&&(Pt.numClippingPlanes!==rt.numPlanes||Pt.numIntersection!==rt.numIntersection)||Pt.vertexAlphas!==It||Pt.vertexTangents!==Ot||Pt.morphTargets!==Ct||Pt.morphNormals!==Yt||Pt.morphColors!==jt||Pt.toneMapping!==ue||Pt.morphTargetsCount!==Jt)&&($t=!0):($t=!0,Pt.__version=z.version);let ze=Pt.currentProgram;$t===!0&&(ze=lr(z,I,N));let Qn=!1,Le=!1,Oi=!1;const se=ze.getUniforms(),Ne=Pt.uniforms;if(ot.useProgram(ze.program)&&(Qn=!0,Le=!0,Oi=!0),z.id!==y&&(y=z.id,Le=!0),Qn||M!==x){ot.buffers.depth.getReversed()?(j.copy(x.projectionMatrix),nf(j),rf(j),se.setValue(A,"projectionMatrix",j)):se.setValue(A,"projectionMatrix",x.projectionMatrix),se.setValue(A,"viewMatrix",x.matrixWorldInverse);const be=se.map.cameraPosition;be!==void 0&&be.setValue(A,vt.setFromMatrixPosition(x.matrixWorld)),St.logarithmicDepthBuffer&&se.setValue(A,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&se.setValue(A,"isOrthographic",x.isOrthographicCamera===!0),M!==x&&(M=x,Le=!0,Oi=!0)}if(N.isSkinnedMesh){se.setOptional(A,N,"bindMatrix"),se.setOptional(A,N,"bindMatrixInverse");const Ee=N.skeleton;Ee&&(Ee.boneTexture===null&&Ee.computeBoneTexture(),se.setValue(A,"boneTexture",Ee.boneTexture,E))}N.isBatchedMesh&&(se.setOptional(A,N,"batchingTexture"),se.setValue(A,"batchingTexture",N._matricesTexture,E),se.setOptional(A,N,"batchingIdTexture"),se.setValue(A,"batchingIdTexture",N._indirectTexture,E),se.setOptional(A,N,"batchingColorTexture"),N._colorsTexture!==null&&se.setValue(A,"batchingColorTexture",N._colorsTexture,E));const Fe=B.morphAttributes;if((Fe.position!==void 0||Fe.normal!==void 0||Fe.color!==void 0)&&Ut.update(N,B,ze),(Le||Pt.receiveShadow!==N.receiveShadow)&&(Pt.receiveShadow=N.receiveShadow,se.setValue(A,"receiveShadow",N.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(Ne.envMap.value=At,Ne.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&I.environment!==null&&(Ne.envMapIntensity.value=I.environmentIntensity),Le&&(se.setValue(A,"toneMappingExposure",S.toneMappingExposure),Pt.needsLights&&Bu(Ne,Oi),it&&z.fog===!0&&ht.refreshFogUniforms(Ne,it),ht.refreshMaterialUniforms(Ne,z,k,K,p.state.transmissionRenderTarget[x.id]),Hr.upload(A,gc(Pt),Ne,E)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Hr.upload(A,gc(Pt),Ne,E),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&se.setValue(A,"center",N.center),se.setValue(A,"modelViewMatrix",N.modelViewMatrix),se.setValue(A,"normalMatrix",N.normalMatrix),se.setValue(A,"modelMatrix",N.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const Ee=z.uniformsGroups;for(let be=0,rs=Ee.length;be<rs;be++){const Cn=Ee[be];U.update(Cn,ze),U.bind(Cn,ze)}}return ze}function Bu(x,I){x.ambientLightColor.needsUpdate=I,x.lightProbe.needsUpdate=I,x.directionalLights.needsUpdate=I,x.directionalLightShadows.needsUpdate=I,x.pointLights.needsUpdate=I,x.pointLightShadows.needsUpdate=I,x.spotLights.needsUpdate=I,x.spotLightShadows.needsUpdate=I,x.rectAreaLights.needsUpdate=I,x.hemisphereLights.needsUpdate=I}function zu(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(x,I,B){mt.get(x.texture).__webglTexture=I,mt.get(x.depthTexture).__webglTexture=B;const z=mt.get(x);z.__hasExternalTextures=!0,z.__autoAllocateDepthBuffer=B===void 0,z.__autoAllocateDepthBuffer||nt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),z.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(x,I){const B=mt.get(x);B.__webglFramebuffer=I,B.__useDefaultFramebuffer=I===void 0};const Hu=A.createFramebuffer();this.setRenderTarget=function(x,I=0,B=0){D=x,C=I,R=B;let z=!0,N=null,it=!1,dt=!1;if(x){const At=mt.get(x);if(At.__useDefaultFramebuffer!==void 0)ot.bindFramebuffer(A.FRAMEBUFFER,null),z=!1;else if(At.__webglFramebuffer===void 0)E.setupRenderTarget(x);else if(At.__hasExternalTextures)E.rebindTextures(x,mt.get(x.texture).__webglTexture,mt.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const Ct=x.depthTexture;if(At.__boundDepthTexture!==Ct){if(Ct!==null&&mt.has(Ct)&&(x.width!==Ct.image.width||x.height!==Ct.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");E.setupDepthRenderbuffer(x)}}const It=x.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(dt=!0);const Ot=mt.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(Ot[I])?N=Ot[I][B]:N=Ot[I],it=!0):x.samples>0&&E.useMultisampledRTT(x)===!1?N=mt.get(x).__webglMultisampledFramebuffer:Array.isArray(Ot)?N=Ot[B]:N=Ot,w.copy(x.viewport),H.copy(x.scissor),O=x.scissorTest}else w.copy(Mt).multiplyScalar(k).floor(),H.copy(Ft).multiplyScalar(k).floor(),O=Zt;if(B!==0&&(N=Hu),ot.bindFramebuffer(A.FRAMEBUFFER,N)&&z&&ot.drawBuffers(x,N),ot.viewport(w),ot.scissor(H),ot.setScissorTest(O),it){const At=mt.get(x.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+I,At.__webglTexture,B)}else if(dt){const At=mt.get(x.texture),It=I;A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,At.__webglTexture,B,It)}else if(x!==null&&B!==0){const At=mt.get(x.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,At.__webglTexture,B)}y=-1},this.readRenderTargetPixels=function(x,I,B,z,N,it,dt){if(!(x&&x.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=mt.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&dt!==void 0&&(yt=yt[dt]),yt){ot.bindFramebuffer(A.FRAMEBUFFER,yt);try{const At=x.texture,It=At.format,Ot=At.type;if(!St.textureFormatReadable(It)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!St.textureTypeReadable(Ot)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=x.width-z&&B>=0&&B<=x.height-N&&A.readPixels(I,B,z,N,Ht.convert(It),Ht.convert(Ot),it)}finally{const At=D!==null?mt.get(D).__webglFramebuffer:null;ot.bindFramebuffer(A.FRAMEBUFFER,At)}}},this.readRenderTargetPixelsAsync=async function(x,I,B,z,N,it,dt){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let yt=mt.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&dt!==void 0&&(yt=yt[dt]),yt){const At=x.texture,It=At.format,Ot=At.type;if(!St.textureFormatReadable(It))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!St.textureTypeReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(I>=0&&I<=x.width-z&&B>=0&&B<=x.height-N){ot.bindFramebuffer(A.FRAMEBUFFER,yt);const Ct=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Ct),A.bufferData(A.PIXEL_PACK_BUFFER,it.byteLength,A.STREAM_READ),A.readPixels(I,B,z,N,Ht.convert(It),Ht.convert(Ot),0);const Yt=D!==null?mt.get(D).__webglFramebuffer:null;ot.bindFramebuffer(A.FRAMEBUFFER,Yt);const jt=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await ef(A,jt,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Ct),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,it),A.deleteBuffer(Ct),A.deleteSync(jt),it}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(x,I=null,B=0){x.isTexture!==!0&&(mi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),I=arguments[0]||null,x=arguments[1]);const z=Math.pow(2,-B),N=Math.floor(x.image.width*z),it=Math.floor(x.image.height*z),dt=I!==null?I.x:0,yt=I!==null?I.y:0;E.setTexture2D(x,0),A.copyTexSubImage2D(A.TEXTURE_2D,B,0,0,dt,yt,N,it),ot.unbindTexture()};const ku=A.createFramebuffer(),Gu=A.createFramebuffer();this.copyTextureToTexture=function(x,I,B=null,z=null,N=0,it=null){x.isTexture!==!0&&(mi("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,x=arguments[1],I=arguments[2],it=arguments[3]||0,B=null),it===null&&(N!==0?(mi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),it=N,N=0):it=0);let dt,yt,At,It,Ot,Ct,Yt,jt,ue;const ce=x.isCompressedTexture?x.mipmaps[it]:x.image;if(B!==null)dt=B.max.x-B.min.x,yt=B.max.y-B.min.y,At=B.isBox3?B.max.z-B.min.z:1,It=B.min.x,Ot=B.min.y,Ct=B.isBox3?B.min.z:0;else{const Fe=Math.pow(2,-N);dt=Math.floor(ce.width*Fe),yt=Math.floor(ce.height*Fe),x.isDataArrayTexture?At=ce.depth:x.isData3DTexture?At=Math.floor(ce.depth*Fe):At=1,It=0,Ot=0,Ct=0}z!==null?(Yt=z.x,jt=z.y,ue=z.z):(Yt=0,jt=0,ue=0);const Jt=Ht.convert(I.format),Pt=Ht.convert(I.type);let _e;I.isData3DTexture?(E.setTexture3D(I,0),_e=A.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(E.setTexture2DArray(I,0),_e=A.TEXTURE_2D_ARRAY):(E.setTexture2D(I,0),_e=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,I.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,I.unpackAlignment);const $t=A.getParameter(A.UNPACK_ROW_LENGTH),ze=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Qn=A.getParameter(A.UNPACK_SKIP_PIXELS),Le=A.getParameter(A.UNPACK_SKIP_ROWS),Oi=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,ce.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ce.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,It),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ot),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ct);const se=x.isDataArrayTexture||x.isData3DTexture,Ne=I.isDataArrayTexture||I.isData3DTexture;if(x.isDepthTexture){const Fe=mt.get(x),Ee=mt.get(I),be=mt.get(Fe.__renderTarget),rs=mt.get(Ee.__renderTarget);ot.bindFramebuffer(A.READ_FRAMEBUFFER,be.__webglFramebuffer),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,rs.__webglFramebuffer);for(let Cn=0;Cn<At;Cn++)se&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,mt.get(x).__webglTexture,N,Ct+Cn),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,mt.get(I).__webglTexture,it,ue+Cn)),A.blitFramebuffer(It,Ot,dt,yt,Yt,jt,dt,yt,A.DEPTH_BUFFER_BIT,A.NEAREST);ot.bindFramebuffer(A.READ_FRAMEBUFFER,null),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(N!==0||x.isRenderTargetTexture||mt.has(x)){const Fe=mt.get(x),Ee=mt.get(I);ot.bindFramebuffer(A.READ_FRAMEBUFFER,ku),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,Gu);for(let be=0;be<At;be++)se?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Fe.__webglTexture,N,Ct+be):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Fe.__webglTexture,N),Ne?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Ee.__webglTexture,it,ue+be):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Ee.__webglTexture,it),N!==0?A.blitFramebuffer(It,Ot,dt,yt,Yt,jt,dt,yt,A.COLOR_BUFFER_BIT,A.NEAREST):Ne?A.copyTexSubImage3D(_e,it,Yt,jt,ue+be,It,Ot,dt,yt):A.copyTexSubImage2D(_e,it,Yt,jt,It,Ot,dt,yt);ot.bindFramebuffer(A.READ_FRAMEBUFFER,null),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else Ne?x.isDataTexture||x.isData3DTexture?A.texSubImage3D(_e,it,Yt,jt,ue,dt,yt,At,Jt,Pt,ce.data):I.isCompressedArrayTexture?A.compressedTexSubImage3D(_e,it,Yt,jt,ue,dt,yt,At,Jt,ce.data):A.texSubImage3D(_e,it,Yt,jt,ue,dt,yt,At,Jt,Pt,ce):x.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,it,Yt,jt,dt,yt,Jt,Pt,ce.data):x.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,it,Yt,jt,ce.width,ce.height,Jt,ce.data):A.texSubImage2D(A.TEXTURE_2D,it,Yt,jt,dt,yt,Jt,Pt,ce);A.pixelStorei(A.UNPACK_ROW_LENGTH,$t),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ze),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Qn),A.pixelStorei(A.UNPACK_SKIP_ROWS,Le),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Oi),it===0&&I.generateMipmaps&&A.generateMipmap(_e),ot.unbindTexture()},this.copyTextureToTexture3D=function(x,I,B=null,z=null,N=0){return x.isTexture!==!0&&(mi("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,z=arguments[1]||null,x=arguments[2],I=arguments[3],N=arguments[4]||0),mi('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(x,I,B,z,N)},this.initRenderTarget=function(x){mt.get(x).__webglFramebuffer===void 0&&E.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?E.setTextureCube(x,0):x.isData3DTexture?E.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?E.setTexture2DArray(x,0):E.setTexture2D(x,0),ot.unbindTexture()},this.resetState=function(){C=0,R=0,D=null,ot.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return un}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=Kt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Kt._getUnpackColorSpace()}}const Xn=ge-1,ic=16.25,cn=.72,Yr=.42,Zr=cn+.41*Yr,wl=Zr+.25;function zn(i,t){return{x:t-Xn/2,z:i-Xn/2}}function sv(){const i=document.createElement("canvas");i.width=i.height=256;const t=i.getContext("2d");t.fillStyle="#141a22",t.fillRect(0,0,256,256);for(let n=0;n<1700;n++){const r=20+Math.floor(Math.random()*20);t.fillStyle=`rgba(${r+6}, ${r+10}, ${r+15}, .16)`,t.fillRect(Math.random()*256,Math.random()*256,1,1)}const e=new su(i);return e.wrapS=e.wrapT=wi,e.repeat.set(7,7),e}function ov(){const i=new pd,t=i.load("images/wood.jpg"),e=i.load("images/wood_normal.jpg");return t.colorSpace=we,t.wrapS=t.wrapT=wi,e.wrapS=e.wrapT=wi,t.repeat.set(1.6,1.6),e.repeat.set(1.6,1.6),t.center.set(.5,.5),e.center.set(.5,.5),t.rotation=Math.PI/2,e.rotation=Math.PI/2,t.anisotropy=4,e.anisotropy=4,{color:t,normal:e}}function av(){const i=document.createElement("canvas");i.width=i.height=128;const t=i.getContext("2d"),e=t.createRadialGradient(64,64,8,64,64,64);return e.addColorStop(0,"rgba(13, 13, 13, 0.56)"),e.addColorStop(.5,"rgba(13, 13, 13, 0.46)"),e.addColorStop(.82,"rgba(13, 13, 13, 0.2)"),e.addColorStop(1,"rgba(13, 13, 13, 0)"),t.fillStyle=e,t.fillRect(0,0,128,128),new su(i)}function Su(i=ic){const t=new Ja,e=i/2,n=.35;return t.moveTo(-e+n,-e),t.lineTo(e-n,-e),t.quadraticCurveTo(e,-e,e,-e+n),t.lineTo(e,e-n),t.quadraticCurveTo(e,e,e-n,e),t.lineTo(-e+n,e),t.quadraticCurveTo(-e,e,-e,e-n),t.lineTo(-e,-e+n),t.quadraticCurveTo(-e,-e,-e+n,-e),t}function cv(){const i=Su(),t=new Ka(i,{depth:.68,bevelEnabled:!0,bevelThickness:.12,bevelSize:.1,bevelSegments:4});return t.rotateX(-Math.PI/2),t}function lv(){const i=ic-.2,t=new ja(Su(i)),e=t.getAttribute("position"),n=[];for(let r=0;r<e.count;r++)n.push((e.getX(r)+i/2)/i,(e.getY(r)+i/2)/i);return t.setAttribute("uv",new ne(n,2)),t.rotateX(-Math.PI/2),t}function uv(){const i=new Wn,t=new Vn({color:2166792}),e=new Zn(Xn,.018,.038),n=new Zn(.038,.018,Xn);for(let r=0;r<ge;r++){const s=r-Xn/2,o=new le(e,t);o.position.set(0,cn+.012,s),i.add(o);const a=new le(n,t);a.position.set(s,cn+.012,0),i.add(a)}return i}function hv(){const i=new rv({antialias:!0,powerPreference:"high-performance"});i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.outputColorSpace=we,i.toneMapping=Nl,i.toneMappingExposure=1.12,i.shadowMap.enabled=!0,i.shadowMap.type=Ul,document.getElementById("app").prepend(i.domElement);const t=new wf;t.background=new Wt("#0e131a"),t.fog=new Wa("#0e131a",30,65);const e=new Ie(38,1,.1,100);t.add(e);const n=new le(new ar(80,80),new gi({map:sv(),color:10134444,roughness:.96}));n.rotation.x=-Math.PI/2,n.position.y=-.46,n.receiveShadow=!0,t.add(n);const r=new le(cv(),new gi({color:7225887,roughness:.5,metalness:.02}));r.position.y=-.1,r.castShadow=!1,r.receiveShadow=!0,t.add(r);const s=ov(),o=new le(lv(),new gi({map:s.color,normalMap:s.normal,normalScale:new at(.7,.7),color:16777215,roughness:.5,side:Ze})),a=o.material;a.onBeforeCompile=Q=>{Q.fragmentShader=Q.fragmentShader.replace("#include <map_fragment>",`#include <map_fragment>
|
|
3865
|
+
}`;class V0{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const r=new ye,s=t.properties.get(r);s.__webglTexture=e.texture,(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new Pn({vertexShader:H0,fragmentShader:k0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new he(new _r(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class G0 extends Hi{constructor(t,e){super();const n=this;let r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,d=null,g=null;const v=new V0,m=e.getContextAttributes();let p=null,A=null;const y=[],S=[],L=new ct;let P=null;const C=new Fe;C.viewport=new ie;const R=new Fe;R.viewport=new ie;const E=[C,R],_=new lm;let w=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let ot=y[Y];return ot===void 0&&(ot=new to,y[Y]=ot),ot.getTargetRaySpace()},this.getControllerGrip=function(Y){let ot=y[Y];return ot===void 0&&(ot=new to,y[Y]=ot),ot.getGripSpace()},this.getHand=function(Y){let ot=y[Y];return ot===void 0&&(ot=new to,y[Y]=ot),ot.getHandSpace()};function F(Y){const ot=S.indexOf(Y.inputSource);if(ot===-1)return;const Q=y[ot];Q!==void 0&&(Q.update(Y.inputSource,Y.frame,l||o),Q.dispatchEvent({type:Y.type,data:Y.inputSource}))}function k(){r.removeEventListener("select",F),r.removeEventListener("selectstart",F),r.removeEventListener("selectend",F),r.removeEventListener("squeeze",F),r.removeEventListener("squeezestart",F),r.removeEventListener("squeezeend",F),r.removeEventListener("end",k),r.removeEventListener("inputsourceschange",X);for(let Y=0;Y<y.length;Y++){const ot=S[Y];ot!==null&&(S[Y]=null,y[Y].disconnect(ot))}w=null,B=null,v.reset(),t.setRenderTarget(p),d=null,f=null,h=null,r=null,A=null,Zt.stop(),n.isPresenting=!1,t.setPixelRatio(P),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){a=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(p=t.getRenderTarget(),r.addEventListener("select",F),r.addEventListener("selectstart",F),r.addEventListener("selectend",F),r.addEventListener("squeeze",F),r.addEventListener("squeezestart",F),r.addEventListener("squeezeend",F),r.addEventListener("end",k),r.addEventListener("inputsourceschange",X),m.xrCompatible!==!0&&await e.makeXRCompatible(),P=t.getPixelRatio(),t.getSize(L),r.enabledFeatures!==void 0&&r.enabledFeatures.includes("layers")){let Q=null,J=null,ht=null;m.depth&&(ht=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Q=m.stencil?Ni:wi,J=m.stencil?Ii:Zn);const xt={colorFormat:e.RGBA8,depthFormat:ht,scaleFactor:s};h=new XRWebGLBinding(r,e),f=h.createProjectionLayer(xt),r.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),A=new $n(f.textureWidth,f.textureHeight,{format:Ke,type:gn,depthTexture:new Qu(f.textureWidth,f.textureHeight,J,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}else{const Q={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,e,Q),r.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),A=new $n(d.framebufferWidth,d.framebufferHeight,{format:Ke,type:gn,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}A.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),Zt.setContext(r),Zt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function X(Y){for(let ot=0;ot<Y.removed.length;ot++){const Q=Y.removed[ot],J=S.indexOf(Q);J>=0&&(S[J]=null,y[J].disconnect(Q))}for(let ot=0;ot<Y.added.length;ot++){const Q=Y.added[ot];let J=S.indexOf(Q);if(J===-1){for(let xt=0;xt<y.length;xt++)if(xt>=S.length){S.push(Q),J=xt;break}else if(S[xt]===null){S[xt]=Q,J=xt;break}if(J===-1)break}const ht=y[J];ht&&ht.connect(Q)}}const G=new D,$=new D;function V(Y,ot,Q){G.setFromMatrixPosition(ot.matrixWorld),$.setFromMatrixPosition(Q.matrixWorld);const J=G.distanceTo($),ht=ot.projectionMatrix.elements,xt=Q.projectionMatrix.elements,Ct=ht[14]/(ht[10]-1),Wt=ht[14]/(ht[10]+1),Z=(ht[9]+1)/ht[5],et=(ht[9]-1)/ht[5],b=(ht[8]-1)/ht[0],wt=(xt[8]+1)/xt[0],it=Ct*b,Et=Ct*wt,at=J/(-b+wt),Ut=at*-b;if(ot.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ut),Y.translateZ(at),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),ht[10]===-1)Y.projectionMatrix.copy(ot.projectionMatrix),Y.projectionMatrixInverse.copy(ot.projectionMatrixInverse);else{const gt=Ct+at,T=Wt+at,x=it-Ut,O=Et+(J-Ut),q=Z*Wt/T*gt,tt=et*Wt/T*gt;Y.projectionMatrix.makePerspective(x,O,q,tt,gt,T),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function lt(Y,ot){ot===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(ot.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let ot=Y.near,Q=Y.far;v.texture!==null&&(v.depthNear>0&&(ot=v.depthNear),v.depthFar>0&&(Q=v.depthFar)),_.near=R.near=C.near=ot,_.far=R.far=C.far=Q,(w!==_.near||B!==_.far)&&(r.updateRenderState({depthNear:_.near,depthFar:_.far}),w=_.near,B=_.far),C.layers.mask=Y.layers.mask|2,R.layers.mask=Y.layers.mask|4,_.layers.mask=C.layers.mask|R.layers.mask;const J=Y.parent,ht=_.cameras;lt(_,J);for(let xt=0;xt<ht.length;xt++)lt(ht[xt],J);ht.length===2?V(_,C,R):_.projectionMatrix.copy(C.projectionMatrix),mt(Y,_,J)};function mt(Y,ot,Q){Q===null?Y.matrix.copy(ot.matrixWorld):(Y.matrix.copy(Q.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(ot.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(ot.projectionMatrix),Y.projectionMatrixInverse.copy(ot.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=or*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return _},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(Y){c=Y,f!==null&&(f.fixedFoveation=Y),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Y)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(_)};let St=null;function Ot(Y,ot){if(u=ot.getViewerPose(l||o),g=ot,u!==null){const Q=u.views;d!==null&&(t.setRenderTargetFramebuffer(A,d.framebuffer),t.setRenderTarget(A));let J=!1;Q.length!==_.cameras.length&&(_.cameras.length=0,J=!0);for(let xt=0;xt<Q.length;xt++){const Ct=Q[xt];let Wt=null;if(d!==null)Wt=d.getViewport(Ct);else{const et=h.getViewSubImage(f,Ct);Wt=et.viewport,xt===0&&(t.setRenderTargetTextures(A,et.colorTexture,f.ignoreDepthValues?void 0:et.depthStencilTexture),t.setRenderTarget(A))}let Z=E[xt];Z===void 0&&(Z=new Fe,Z.layers.enable(xt),Z.viewport=new ie,E[xt]=Z),Z.matrix.fromArray(Ct.transform.matrix),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.projectionMatrix.fromArray(Ct.projectionMatrix),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert(),Z.viewport.set(Wt.x,Wt.y,Wt.width,Wt.height),xt===0&&(_.matrix.copy(Z.matrix),_.matrix.decompose(_.position,_.quaternion,_.scale)),J===!0&&_.cameras.push(Z)}const ht=r.enabledFeatures;if(ht&&ht.includes("depth-sensing")){const xt=h.getDepthInformation(Q[0]);xt&&xt.isValid&&xt.texture&&v.init(t,xt,r.renderState)}}for(let Q=0;Q<y.length;Q++){const J=S[Q],ht=y[Q];J!==null&&ht!==void 0&&ht.update(J,ot,l||o)}St&&St(Y,ot),ot.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ot}),g=null}const Zt=new lh;Zt.setAnimationLoop(Ot),this.setAnimationLoop=function(Y){St=Y},this.dispose=function(){}}}const zn=new en,W0=new oe;function X0(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Zu(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function r(m,p,A,y,S){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),h(m,p)):p.isMeshPhongMaterial?(s(m,p),u(m,p)):p.isMeshStandardMaterial?(s(m,p),f(m,p),p.isMeshPhysicalMaterial&&d(m,p,S)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),v(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,A,y):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Pe&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Pe&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const A=t.get(p),y=A.envMap,S=A.envMapRotation;y&&(m.envMap.value=y,zn.copy(S),zn.x*=-1,zn.y*=-1,zn.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(zn.y*=-1,zn.z*=-1),m.envMapRotation.value.setFromMatrix4(W0.makeRotationFromEuler(zn)),m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,A,y){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*A,m.scale.value=y*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function f(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function d(m,p,A){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Pe&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){const A=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(A.matrixWorld),m.nearDistance.value=A.shadow.camera.near,m.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function q0(i,t,e,n){let r={},s={},o=[];const a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(A,y){const S=y.program;n.uniformBlockBinding(A,S)}function l(A,y){let S=r[A.id];S===void 0&&(g(A),S=u(A),r[A.id]=S,A.addEventListener("dispose",m));const L=y.program;n.updateUBOMapping(A,L);const P=t.render.frame;s[A.id]!==P&&(f(A),s[A.id]=P)}function u(A){const y=h();A.__bindingPointIndex=y;const S=i.createBuffer(),L=A.__size,P=A.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,L,P),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,S),S}function h(){for(let A=0;A<a;A++)if(o.indexOf(A)===-1)return o.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(A){const y=r[A.id],S=A.uniforms,L=A.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let P=0,C=S.length;P<C;P++){const R=Array.isArray(S[P])?S[P]:[S[P]];for(let E=0,_=R.length;E<_;E++){const w=R[E];if(d(w,P,E,L)===!0){const B=w.__offset,F=Array.isArray(w.value)?w.value:[w.value];let k=0;for(let X=0;X<F.length;X++){const G=F[X],$=v(G);typeof G=="number"||typeof G=="boolean"?(w.__data[0]=G,i.bufferSubData(i.UNIFORM_BUFFER,B+k,w.__data)):G.isMatrix3?(w.__data[0]=G.elements[0],w.__data[1]=G.elements[1],w.__data[2]=G.elements[2],w.__data[3]=0,w.__data[4]=G.elements[3],w.__data[5]=G.elements[4],w.__data[6]=G.elements[5],w.__data[7]=0,w.__data[8]=G.elements[6],w.__data[9]=G.elements[7],w.__data[10]=G.elements[8],w.__data[11]=0):(G.toArray(w.__data,k),k+=$.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,B,w.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(A,y,S,L){const P=A.value,C=y+"_"+S;if(L[C]===void 0)return typeof P=="number"||typeof P=="boolean"?L[C]=P:L[C]=P.clone(),!0;{const R=L[C];if(typeof P=="number"||typeof P=="boolean"){if(R!==P)return L[C]=P,!0}else if(R.equals(P)===!1)return R.copy(P),!0}return!1}function g(A){const y=A.uniforms;let S=0;const L=16;for(let C=0,R=y.length;C<R;C++){const E=Array.isArray(y[C])?y[C]:[y[C]];for(let _=0,w=E.length;_<w;_++){const B=E[_],F=Array.isArray(B.value)?B.value:[B.value];for(let k=0,X=F.length;k<X;k++){const G=F[k],$=v(G),V=S%L,lt=V%$.boundary,mt=V+lt;S+=lt,mt!==0&&L-mt<$.storage&&(S+=L-mt),B.__data=new Float32Array($.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=S,S+=$.storage}}}const P=S%L;return P>0&&(S+=L-P),A.__size=S,A.__cache={},this}function v(A){const y={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(y.boundary=4,y.storage=4):A.isVector2?(y.boundary=8,y.storage=8):A.isVector3||A.isColor?(y.boundary=16,y.storage=12):A.isVector4?(y.boundary=16,y.storage=16):A.isMatrix3?(y.boundary=48,y.storage=48):A.isMatrix4?(y.boundary=64,y.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),y}function m(A){const y=A.target;y.removeEventListener("dispose",m);const S=o.indexOf(y.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function p(){for(const A in r)i.deleteBuffer(r[A]);o=[],r={},s={}}return{bind:c,update:l,dispose:p}}class Y0{constructor(t={}){const{canvas:e=Wd(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:f=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const g=new Uint32Array(4),v=new Int32Array(4);let m=null,p=null;const A=[],y=[];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._outputColorSpace=Re,this.toneMapping=wn,this.toneMappingExposure=1;const S=this;let L=!1,P=0,C=0,R=null,E=-1,_=null;const w=new ie,B=new ie;let F=null;const k=new Xt(0);let X=0,G=e.width,$=e.height,V=1,lt=null,mt=null;const St=new ie(0,0,G,$),Ot=new ie(0,0,G,$);let Zt=!1;const Y=new bc;let ot=!1,Q=!1;this.transmissionResolutionScale=1;const J=new oe,ht=new oe,xt=new D,Ct=new ie,Wt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Z=!1;function et(){return R===null?V:1}let b=n;function wt(M,I){return e.getContext(M,I)}try{const M={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${mc}`),e.addEventListener("webglcontextlost",j,!1),e.addEventListener("webglcontextrestored",vt,!1),e.addEventListener("webglcontextcreationerror",_t,!1),b===null){const I="webgl2";if(b=wt(I,M),b===null)throw wt(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw console.error("THREE.WebGLRenderer: "+M.message),M}let it,Et,at,Ut,gt,T,x,O,q,tt,K,Rt,ft,Mt,qt,st,Tt,Dt,Nt,At,Yt,kt,se,U;function dt(){it=new nv(b),it.init(),kt=new B0(b,it),Et=new $_(b,it,t,kt),at=new F0(b,it),Et.reverseDepthBuffer&&f&&at.buffers.depth.setReversed(!0),Ut=new sv(b),gt=new y0,T=new O0(b,it,at,gt,Et,kt,Ut),x=new j_(S),O=new ev(S),q=new fm(b),se=new K_(b,q),tt=new iv(b,q,Ut,se),K=new av(b,tt,q,Ut),Nt=new ov(b,Et,T),st=new J_(gt),Rt=new E0(S,x,O,it,Et,se,st),ft=new X0(S,gt),Mt=new A0,qt=new L0(it),Dt=new Y_(S,x,O,at,K,d,c),Tt=new I0(S,K,Et),U=new q0(b,Ut,Et,at),At=new Z_(b,it,Ut),Yt=new rv(b,it,Ut),Ut.programs=Rt.programs,S.capabilities=Et,S.extensions=it,S.properties=gt,S.renderLists=Mt,S.shadowMap=Tt,S.state=at,S.info=Ut}dt();const W=new G0(S,b);this.xr=W,this.getContext=function(){return b},this.getContextAttributes=function(){return b.getContextAttributes()},this.forceContextLoss=function(){const M=it.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=it.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(M){M!==void 0&&(V=M,this.setSize(G,$,!1))},this.getSize=function(M){return M.set(G,$)},this.setSize=function(M,I,z=!0){if(W.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=M,$=I,e.width=Math.floor(M*V),e.height=Math.floor(I*V),z===!0&&(e.style.width=M+"px",e.style.height=I+"px"),this.setViewport(0,0,M,I)},this.getDrawingBufferSize=function(M){return M.set(G*V,$*V).floor()},this.setDrawingBufferSize=function(M,I,z){G=M,$=I,V=z,e.width=Math.floor(M*z),e.height=Math.floor(I*z),this.setViewport(0,0,M,I)},this.getCurrentViewport=function(M){return M.copy(w)},this.getViewport=function(M){return M.copy(St)},this.setViewport=function(M,I,z,H){M.isVector4?St.set(M.x,M.y,M.z,M.w):St.set(M,I,z,H),at.viewport(w.copy(St).multiplyScalar(V).round())},this.getScissor=function(M){return M.copy(Ot)},this.setScissor=function(M,I,z,H){M.isVector4?Ot.set(M.x,M.y,M.z,M.w):Ot.set(M,I,z,H),at.scissor(B.copy(Ot).multiplyScalar(V).round())},this.getScissorTest=function(){return Zt},this.setScissorTest=function(M){at.setScissorTest(Zt=M)},this.setOpaqueSort=function(M){lt=M},this.setTransparentSort=function(M){mt=M},this.getClearColor=function(M){return M.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor.apply(Dt,arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha.apply(Dt,arguments)},this.clear=function(M=!0,I=!0,z=!0){let H=0;if(M){let N=!1;if(R!==null){const rt=R.texture.format;N=rt===Sc||rt===Mc||rt===xc}if(N){const rt=R.texture.type,pt=rt===gn||rt===Zn||rt===sr||rt===Ii||rt===_c||rt===vc,yt=Dt.getClearColor(),bt=Dt.getClearAlpha(),Ft=yt.r,Bt=yt.g,Pt=yt.b;pt?(g[0]=Ft,g[1]=Bt,g[2]=Pt,g[3]=bt,b.clearBufferuiv(b.COLOR,0,g)):(v[0]=Ft,v[1]=Bt,v[2]=Pt,v[3]=bt,b.clearBufferiv(b.COLOR,0,v))}else H|=b.COLOR_BUFFER_BIT}I&&(H|=b.DEPTH_BUFFER_BIT),z&&(H|=b.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),b.clear(H)},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",j,!1),e.removeEventListener("webglcontextrestored",vt,!1),e.removeEventListener("webglcontextcreationerror",_t,!1),Dt.dispose(),Mt.dispose(),qt.dispose(),gt.dispose(),x.dispose(),O.dispose(),K.dispose(),se.dispose(),U.dispose(),Rt.dispose(),W.dispose(),W.removeEventListener("sessionstart",Gc),W.removeEventListener("sessionend",Wc),Dn.stop()};function j(M){M.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function vt(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;const M=Ut.autoReset,I=Tt.enabled,z=Tt.autoUpdate,H=Tt.needsUpdate,N=Tt.type;dt(),Ut.autoReset=M,Tt.enabled=I,Tt.autoUpdate=z,Tt.needsUpdate=H,Tt.type=N}function _t(M){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function zt(M){const I=M.target;I.removeEventListener("dispose",zt),le(I)}function le(M){Me(M),gt.remove(M)}function Me(M){const I=gt.get(M).programs;I!==void 0&&(I.forEach(function(z){Rt.releaseProgram(z)}),M.isShaderMaterial&&Rt.releaseShaderCache(M))}this.renderBufferDirect=function(M,I,z,H,N,rt){I===null&&(I=Wt);const pt=N.isMesh&&N.matrixWorld.determinant()<0,yt=bh(M,I,z,H,N);at.setMaterial(H,pt);let bt=z.index,Ft=1;if(H.wireframe===!0){if(bt=tt.getWireframeAttribute(z),bt===void 0)return;Ft=2}const Bt=z.drawRange,Pt=z.attributes.position;let Kt=Bt.start*Ft,jt=(Bt.start+Bt.count)*Ft;rt!==null&&(Kt=Math.max(Kt,rt.start*Ft),jt=Math.min(jt,(rt.start+rt.count)*Ft)),bt!==null?(Kt=Math.max(Kt,0),jt=Math.min(jt,bt.count)):Pt!=null&&(Kt=Math.max(Kt,0),jt=Math.min(jt,Pt.count));const fe=jt-Kt;if(fe<0||fe===1/0)return;se.setup(N,H,yt,z,bt);let ue,$t=At;if(bt!==null&&(ue=q.get(bt),$t=Yt,$t.setIndex(ue)),N.isMesh)H.wireframe===!0?(at.setLineWidth(H.wireframeLinewidth*et()),$t.setMode(b.LINES)):$t.setMode(b.TRIANGLES);else if(N.isLine){let Lt=H.linewidth;Lt===void 0&&(Lt=1),at.setLineWidth(Lt*et()),N.isLineSegments?$t.setMode(b.LINES):N.isLineLoop?$t.setMode(b.LINE_LOOP):$t.setMode(b.LINE_STRIP)}else N.isPoints?$t.setMode(b.POINTS):N.isSprite&&$t.setMode(b.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)$t.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(it.get("WEBGL_multi_draw"))$t.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const Lt=N._multiDrawStarts,ve=N._multiDrawCounts,Qt=N._multiDrawCount,Ge=bt?q.get(bt).bytesPerElement:1,ii=gt.get(H).currentProgram.getUniforms();for(let Ue=0;Ue<Qt;Ue++)ii.setValue(b,"_gl_DrawID",Ue),$t.render(Lt[Ue]/Ge,ve[Ue])}else if(N.isInstancedMesh)$t.renderInstances(Kt,fe,N.count);else if(z.isInstancedBufferGeometry){const Lt=z._maxInstanceCount!==void 0?z._maxInstanceCount:1/0,ve=Math.min(z.instanceCount,Lt);$t.renderInstances(Kt,fe,ve)}else $t.render(Kt,fe)};function te(M,I,z){M.transparent===!0&&M.side===je&&M.forceSinglePass===!1?(M.side=Pe,M.needsUpdate=!0,xr(M,I,z),M.side=Cn,M.needsUpdate=!0,xr(M,I,z),M.side=je):xr(M,I,z)}this.compile=function(M,I,z=null){z===null&&(z=M),p=qt.get(z),p.init(I),y.push(p),z.traverseVisible(function(N){N.isLight&&N.layers.test(I.layers)&&(p.pushLight(N),N.castShadow&&p.pushShadow(N))}),M!==z&&M.traverseVisible(function(N){N.isLight&&N.layers.test(I.layers)&&(p.pushLight(N),N.castShadow&&p.pushShadow(N))}),p.setupLights();const H=new Set;return M.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const rt=N.material;if(rt)if(Array.isArray(rt))for(let pt=0;pt<rt.length;pt++){const yt=rt[pt];te(yt,z,N),H.add(yt)}else te(rt,z,N),H.add(rt)}),y.pop(),p=null,H},this.compileAsync=function(M,I,z=null){const H=this.compile(M,I,z);return new Promise(N=>{function rt(){if(H.forEach(function(pt){gt.get(pt).currentProgram.isReady()&&H.delete(pt)}),H.size===0){N(M);return}setTimeout(rt,10)}it.get("KHR_parallel_shader_compile")!==null?rt():setTimeout(rt,10)})};let Ve=null;function sn(M){Ve&&Ve(M)}function Gc(){Dn.stop()}function Wc(){Dn.start()}const Dn=new lh;Dn.setAnimationLoop(sn),typeof self<"u"&&Dn.setContext(self),this.setAnimationLoop=function(M){Ve=M,W.setAnimationLoop(M),M===null?Dn.stop():Dn.start()},W.addEventListener("sessionstart",Gc),W.addEventListener("sessionend",Wc),this.render=function(M,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),W.enabled===!0&&W.isPresenting===!0&&(W.cameraAutoUpdate===!0&&W.updateCamera(I),I=W.getCamera()),M.isScene===!0&&M.onBeforeRender(S,M,I,R),p=qt.get(M,y.length),p.init(I),y.push(p),ht.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Y.setFromProjectionMatrix(ht),Q=this.localClippingEnabled,ot=st.init(this.clippingPlanes,Q),m=Mt.get(M,A.length),m.init(),A.push(m),W.enabled===!0&&W.isPresenting===!0){const rt=S.xr.getDepthSensingMesh();rt!==null&&xs(rt,I,-1/0,S.sortObjects)}xs(M,I,0,S.sortObjects),m.finish(),S.sortObjects===!0&&m.sort(lt,mt),Z=W.enabled===!1||W.isPresenting===!1||W.hasDepthSensing()===!1,Z&&Dt.addToRenderList(m,M),this.info.render.frame++,ot===!0&&st.beginShadows();const z=p.state.shadowsArray;Tt.render(z,M,I),ot===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=m.opaque,N=m.transmissive;if(p.setupLights(),I.isArrayCamera){const rt=I.cameras;if(N.length>0)for(let pt=0,yt=rt.length;pt<yt;pt++){const bt=rt[pt];qc(H,N,M,bt)}Z&&Dt.render(M);for(let pt=0,yt=rt.length;pt<yt;pt++){const bt=rt[pt];Xc(m,M,bt,bt.viewport)}}else N.length>0&&qc(H,N,M,I),Z&&Dt.render(M),Xc(m,M,I);R!==null&&C===0&&(T.updateMultisampleRenderTarget(R),T.updateRenderTargetMipmap(R)),M.isScene===!0&&M.onAfterRender(S,M,I),se.resetDefaultState(),E=-1,_=null,y.pop(),y.length>0?(p=y[y.length-1],ot===!0&&st.setGlobalState(S.clippingPlanes,p.state.camera)):p=null,A.pop(),A.length>0?m=A[A.length-1]:m=null};function xs(M,I,z,H){if(M.visible===!1)return;if(M.layers.test(I.layers)){if(M.isGroup)z=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(I);else if(M.isLight)p.pushLight(M),M.castShadow&&p.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||Y.intersectsSprite(M)){H&&Ct.setFromMatrixPosition(M.matrixWorld).applyMatrix4(ht);const pt=K.update(M),yt=M.material;yt.visible&&m.push(M,pt,yt,z,Ct.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||Y.intersectsObject(M))){const pt=K.update(M),yt=M.material;if(H&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Ct.copy(M.boundingSphere.center)):(pt.boundingSphere===null&&pt.computeBoundingSphere(),Ct.copy(pt.boundingSphere.center)),Ct.applyMatrix4(M.matrixWorld).applyMatrix4(ht)),Array.isArray(yt)){const bt=pt.groups;for(let Ft=0,Bt=bt.length;Ft<Bt;Ft++){const Pt=bt[Ft],Kt=yt[Pt.materialIndex];Kt&&Kt.visible&&m.push(M,pt,Kt,z,Ct.z,Pt)}}else yt.visible&&m.push(M,pt,yt,z,Ct.z,null)}}const rt=M.children;for(let pt=0,yt=rt.length;pt<yt;pt++)xs(rt[pt],I,z,H)}function Xc(M,I,z,H){const N=M.opaque,rt=M.transmissive,pt=M.transparent;p.setupLightsView(z),ot===!0&&st.setGlobalState(S.clippingPlanes,z),H&&at.viewport(w.copy(H)),N.length>0&&vr(N,I,z),rt.length>0&&vr(rt,I,z),pt.length>0&&vr(pt,I,z),at.buffers.depth.setTest(!0),at.buffers.depth.setMask(!0),at.buffers.color.setMask(!0),at.setPolygonOffset(!1)}function qc(M,I,z,H){if((z.isScene===!0?z.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[H.id]===void 0&&(p.state.transmissionRenderTarget[H.id]=new $n(1,1,{generateMipmaps:!0,type:it.has("EXT_color_buffer_half_float")||it.has("EXT_color_buffer_float")?dr:gn,minFilter:Xn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Jt.workingColorSpace}));const rt=p.state.transmissionRenderTarget[H.id],pt=H.viewport||w;rt.setSize(pt.z*S.transmissionResolutionScale,pt.w*S.transmissionResolutionScale);const yt=S.getRenderTarget();S.setRenderTarget(rt),S.getClearColor(k),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear(),Z&&Dt.render(z);const bt=S.toneMapping;S.toneMapping=wn;const Ft=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),p.setupLightsView(H),ot===!0&&st.setGlobalState(S.clippingPlanes,H),vr(M,z,H),T.updateMultisampleRenderTarget(rt),T.updateRenderTargetMipmap(rt),it.has("WEBGL_multisampled_render_to_texture")===!1){let Bt=!1;for(let Pt=0,Kt=I.length;Pt<Kt;Pt++){const jt=I[Pt],fe=jt.object,ue=jt.geometry,$t=jt.material,Lt=jt.group;if($t.side===je&&fe.layers.test(H.layers)){const ve=$t.side;$t.side=Pe,$t.needsUpdate=!0,Yc(fe,z,H,ue,$t,Lt),$t.side=ve,$t.needsUpdate=!0,Bt=!0}}Bt===!0&&(T.updateMultisampleRenderTarget(rt),T.updateRenderTargetMipmap(rt))}S.setRenderTarget(yt),S.setClearColor(k,X),Ft!==void 0&&(H.viewport=Ft),S.toneMapping=bt}function vr(M,I,z){const H=I.isScene===!0?I.overrideMaterial:null;for(let N=0,rt=M.length;N<rt;N++){const pt=M[N],yt=pt.object,bt=pt.geometry,Ft=H===null?pt.material:H,Bt=pt.group;yt.layers.test(z.layers)&&Yc(yt,I,z,bt,Ft,Bt)}}function Yc(M,I,z,H,N,rt){M.onBeforeRender(S,I,z,H,N,rt),M.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),N.onBeforeRender(S,I,z,H,M,rt),N.transparent===!0&&N.side===je&&N.forceSinglePass===!1?(N.side=Pe,N.needsUpdate=!0,S.renderBufferDirect(z,I,H,N,M,rt),N.side=Cn,N.needsUpdate=!0,S.renderBufferDirect(z,I,H,N,M,rt),N.side=je):S.renderBufferDirect(z,I,H,N,M,rt),M.onAfterRender(S,I,z,H,N,rt)}function xr(M,I,z){I.isScene!==!0&&(I=Wt);const H=gt.get(M),N=p.state.lights,rt=p.state.shadowsArray,pt=N.state.version,yt=Rt.getParameters(M,N.state,rt,I,z),bt=Rt.getProgramCacheKey(yt);let Ft=H.programs;H.environment=M.isMeshStandardMaterial?I.environment:null,H.fog=I.fog,H.envMap=(M.isMeshStandardMaterial?O:x).get(M.envMap||H.environment),H.envMapRotation=H.environment!==null&&M.envMap===null?I.environmentRotation:M.envMapRotation,Ft===void 0&&(M.addEventListener("dispose",zt),Ft=new Map,H.programs=Ft);let Bt=Ft.get(bt);if(Bt!==void 0){if(H.currentProgram===Bt&&H.lightsStateVersion===pt)return Zc(M,yt),Bt}else yt.uniforms=Rt.getUniforms(M),M.onBeforeCompile(yt,S),Bt=Rt.acquireProgram(yt,bt),Ft.set(bt,Bt),H.uniforms=yt.uniforms;const Pt=H.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(Pt.clippingPlanes=st.uniform),Zc(M,yt),H.needsLights=Rh(M),H.lightsStateVersion=pt,H.needsLights&&(Pt.ambientLightColor.value=N.state.ambient,Pt.lightProbe.value=N.state.probe,Pt.directionalLights.value=N.state.directional,Pt.directionalLightShadows.value=N.state.directionalShadow,Pt.spotLights.value=N.state.spot,Pt.spotLightShadows.value=N.state.spotShadow,Pt.rectAreaLights.value=N.state.rectArea,Pt.ltc_1.value=N.state.rectAreaLTC1,Pt.ltc_2.value=N.state.rectAreaLTC2,Pt.pointLights.value=N.state.point,Pt.pointLightShadows.value=N.state.pointShadow,Pt.hemisphereLights.value=N.state.hemi,Pt.directionalShadowMap.value=N.state.directionalShadowMap,Pt.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Pt.spotShadowMap.value=N.state.spotShadowMap,Pt.spotLightMatrix.value=N.state.spotLightMatrix,Pt.spotLightMap.value=N.state.spotLightMap,Pt.pointShadowMap.value=N.state.pointShadowMap,Pt.pointShadowMatrix.value=N.state.pointShadowMatrix),H.currentProgram=Bt,H.uniformsList=null,Bt}function Kc(M){if(M.uniformsList===null){const I=M.currentProgram.getUniforms();M.uniformsList=Qr.seqWithValue(I.seq,M.uniforms)}return M.uniformsList}function Zc(M,I){const z=gt.get(M);z.outputColorSpace=I.outputColorSpace,z.batching=I.batching,z.batchingColor=I.batchingColor,z.instancing=I.instancing,z.instancingColor=I.instancingColor,z.instancingMorph=I.instancingMorph,z.skinning=I.skinning,z.morphTargets=I.morphTargets,z.morphNormals=I.morphNormals,z.morphColors=I.morphColors,z.morphTargetsCount=I.morphTargetsCount,z.numClippingPlanes=I.numClippingPlanes,z.numIntersection=I.numClipIntersection,z.vertexAlphas=I.vertexAlphas,z.vertexTangents=I.vertexTangents,z.toneMapping=I.toneMapping}function bh(M,I,z,H,N){I.isScene!==!0&&(I=Wt),T.resetTextureUnits();const rt=I.fog,pt=H.isMeshStandardMaterial?I.environment:null,yt=R===null?S.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Fi,bt=(H.isMeshStandardMaterial?O:x).get(H.envMap||pt),Ft=H.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,Bt=!!z.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Pt=!!z.morphAttributes.position,Kt=!!z.morphAttributes.normal,jt=!!z.morphAttributes.color;let fe=wn;H.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(fe=S.toneMapping);const ue=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,$t=ue!==void 0?ue.length:0,Lt=gt.get(H),ve=p.state.lights;if(ot===!0&&(Q===!0||M!==_)){const Te=M===_&&H.id===E;st.setState(H,M,Te)}let Qt=!1;H.version===Lt.__version?(Lt.needsLights&&Lt.lightsStateVersion!==ve.state.version||Lt.outputColorSpace!==yt||N.isBatchedMesh&&Lt.batching===!1||!N.isBatchedMesh&&Lt.batching===!0||N.isBatchedMesh&&Lt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Lt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Lt.instancing===!1||!N.isInstancedMesh&&Lt.instancing===!0||N.isSkinnedMesh&&Lt.skinning===!1||!N.isSkinnedMesh&&Lt.skinning===!0||N.isInstancedMesh&&Lt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Lt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Lt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Lt.instancingMorph===!1&&N.morphTexture!==null||Lt.envMap!==bt||H.fog===!0&&Lt.fog!==rt||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==st.numPlanes||Lt.numIntersection!==st.numIntersection)||Lt.vertexAlphas!==Ft||Lt.vertexTangents!==Bt||Lt.morphTargets!==Pt||Lt.morphNormals!==Kt||Lt.morphColors!==jt||Lt.toneMapping!==fe||Lt.morphTargetsCount!==$t)&&(Qt=!0):(Qt=!0,Lt.__version=H.version);let Ge=Lt.currentProgram;Qt===!0&&(Ge=xr(H,I,N));let ii=!1,Ue=!1,Vi=!1;const ae=Ge.getUniforms(),Be=Lt.uniforms;if(at.useProgram(Ge.program)&&(ii=!0,Ue=!0,Vi=!0),H.id!==E&&(E=H.id,Ue=!0),ii||_!==M){at.buffers.depth.getReversed()?(J.copy(M.projectionMatrix),qd(J),Yd(J),ae.setValue(b,"projectionMatrix",J)):ae.setValue(b,"projectionMatrix",M.projectionMatrix),ae.setValue(b,"viewMatrix",M.matrixWorldInverse);const we=ae.map.cameraPosition;we!==void 0&&we.setValue(b,xt.setFromMatrixPosition(M.matrixWorld)),Et.logarithmicDepthBuffer&&ae.setValue(b,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&ae.setValue(b,"isOrthographic",M.isOrthographicCamera===!0),_!==M&&(_=M,Ue=!0,Vi=!0)}if(N.isSkinnedMesh){ae.setOptional(b,N,"bindMatrix"),ae.setOptional(b,N,"bindMatrixInverse");const Te=N.skeleton;Te&&(Te.boneTexture===null&&Te.computeBoneTexture(),ae.setValue(b,"boneTexture",Te.boneTexture,T))}N.isBatchedMesh&&(ae.setOptional(b,N,"batchingTexture"),ae.setValue(b,"batchingTexture",N._matricesTexture,T),ae.setOptional(b,N,"batchingIdTexture"),ae.setValue(b,"batchingIdTexture",N._indirectTexture,T),ae.setOptional(b,N,"batchingColorTexture"),N._colorsTexture!==null&&ae.setValue(b,"batchingColorTexture",N._colorsTexture,T));const ze=z.morphAttributes;if((ze.position!==void 0||ze.normal!==void 0||ze.color!==void 0)&&Nt.update(N,z,Ge),(Ue||Lt.receiveShadow!==N.receiveShadow)&&(Lt.receiveShadow=N.receiveShadow,ae.setValue(b,"receiveShadow",N.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Be.envMap.value=bt,Be.flipEnvMap.value=bt.isCubeTexture&&bt.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&I.environment!==null&&(Be.envMapIntensity.value=I.environmentIntensity),Ue&&(ae.setValue(b,"toneMappingExposure",S.toneMappingExposure),Lt.needsLights&&wh(Be,Vi),rt&&H.fog===!0&&ft.refreshFogUniforms(Be,rt),ft.refreshMaterialUniforms(Be,H,V,$,p.state.transmissionRenderTarget[M.id]),Qr.upload(b,Kc(Lt),Be,T)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(Qr.upload(b,Kc(Lt),Be,T),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&ae.setValue(b,"center",N.center),ae.setValue(b,"modelViewMatrix",N.modelViewMatrix),ae.setValue(b,"normalMatrix",N.normalMatrix),ae.setValue(b,"modelMatrix",N.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const Te=H.uniformsGroups;for(let we=0,Ms=Te.length;we<Ms;we++){const Un=Te[we];U.update(Un,Ge),U.bind(Un,Ge)}}return Ge}function wh(M,I){M.ambientLightColor.needsUpdate=I,M.lightProbe.needsUpdate=I,M.directionalLights.needsUpdate=I,M.directionalLightShadows.needsUpdate=I,M.pointLights.needsUpdate=I,M.pointLightShadows.needsUpdate=I,M.spotLights.needsUpdate=I,M.spotLightShadows.needsUpdate=I,M.rectAreaLights.needsUpdate=I,M.hemisphereLights.needsUpdate=I}function Rh(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(M,I,z){gt.get(M.texture).__webglTexture=I,gt.get(M.depthTexture).__webglTexture=z;const H=gt.get(M);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=z===void 0,H.__autoAllocateDepthBuffer||it.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(M,I){const z=gt.get(M);z.__webglFramebuffer=I,z.__useDefaultFramebuffer=I===void 0};const Ch=b.createFramebuffer();this.setRenderTarget=function(M,I=0,z=0){R=M,P=I,C=z;let H=!0,N=null,rt=!1,pt=!1;if(M){const bt=gt.get(M);if(bt.__useDefaultFramebuffer!==void 0)at.bindFramebuffer(b.FRAMEBUFFER,null),H=!1;else if(bt.__webglFramebuffer===void 0)T.setupRenderTarget(M);else if(bt.__hasExternalTextures)T.rebindTextures(M,gt.get(M.texture).__webglTexture,gt.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Pt=M.depthTexture;if(bt.__boundDepthTexture!==Pt){if(Pt!==null&>.has(Pt)&&(M.width!==Pt.image.width||M.height!==Pt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");T.setupDepthRenderbuffer(M)}}const Ft=M.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(pt=!0);const Bt=gt.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Bt[I])?N=Bt[I][z]:N=Bt[I],rt=!0):M.samples>0&&T.useMultisampledRTT(M)===!1?N=gt.get(M).__webglMultisampledFramebuffer:Array.isArray(Bt)?N=Bt[z]:N=Bt,w.copy(M.viewport),B.copy(M.scissor),F=M.scissorTest}else w.copy(St).multiplyScalar(V).floor(),B.copy(Ot).multiplyScalar(V).floor(),F=Zt;if(z!==0&&(N=Ch),at.bindFramebuffer(b.FRAMEBUFFER,N)&&H&&at.drawBuffers(M,N),at.viewport(w),at.scissor(B),at.setScissorTest(F),rt){const bt=gt.get(M.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_CUBE_MAP_POSITIVE_X+I,bt.__webglTexture,z)}else if(pt){const bt=gt.get(M.texture),Ft=I;b.framebufferTextureLayer(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,bt.__webglTexture,z,Ft)}else if(M!==null&&z!==0){const bt=gt.get(M.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,bt.__webglTexture,z)}E=-1},this.readRenderTargetPixels=function(M,I,z,H,N,rt,pt){if(!(M&&M.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=gt.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&pt!==void 0&&(yt=yt[pt]),yt){at.bindFramebuffer(b.FRAMEBUFFER,yt);try{const bt=M.texture,Ft=bt.format,Bt=bt.type;if(!Et.textureFormatReadable(Ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Et.textureTypeReadable(Bt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=M.width-H&&z>=0&&z<=M.height-N&&b.readPixels(I,z,H,N,kt.convert(Ft),kt.convert(Bt),rt)}finally{const bt=R!==null?gt.get(R).__webglFramebuffer:null;at.bindFramebuffer(b.FRAMEBUFFER,bt)}}},this.readRenderTargetPixelsAsync=async function(M,I,z,H,N,rt,pt){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let yt=gt.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&pt!==void 0&&(yt=yt[pt]),yt){const bt=M.texture,Ft=bt.format,Bt=bt.type;if(!Et.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Et.textureTypeReadable(Bt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(I>=0&&I<=M.width-H&&z>=0&&z<=M.height-N){at.bindFramebuffer(b.FRAMEBUFFER,yt);const Pt=b.createBuffer();b.bindBuffer(b.PIXEL_PACK_BUFFER,Pt),b.bufferData(b.PIXEL_PACK_BUFFER,rt.byteLength,b.STREAM_READ),b.readPixels(I,z,H,N,kt.convert(Ft),kt.convert(Bt),0);const Kt=R!==null?gt.get(R).__webglFramebuffer:null;at.bindFramebuffer(b.FRAMEBUFFER,Kt);const jt=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);return b.flush(),await Xd(b,jt,4),b.bindBuffer(b.PIXEL_PACK_BUFFER,Pt),b.getBufferSubData(b.PIXEL_PACK_BUFFER,0,rt),b.deleteBuffer(Pt),b.deleteSync(jt),rt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(M,I=null,z=0){M.isTexture!==!0&&(Mi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),I=arguments[0]||null,M=arguments[1]);const H=Math.pow(2,-z),N=Math.floor(M.image.width*H),rt=Math.floor(M.image.height*H),pt=I!==null?I.x:0,yt=I!==null?I.y:0;T.setTexture2D(M,0),b.copyTexSubImage2D(b.TEXTURE_2D,z,0,0,pt,yt,N,rt),at.unbindTexture()};const Ph=b.createFramebuffer(),Lh=b.createFramebuffer();this.copyTextureToTexture=function(M,I,z=null,H=null,N=0,rt=null){M.isTexture!==!0&&(Mi("WebGLRenderer: copyTextureToTexture function signature has changed."),H=arguments[0]||null,M=arguments[1],I=arguments[2],rt=arguments[3]||0,z=null),rt===null&&(N!==0?(Mi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),rt=N,N=0):rt=0);let pt,yt,bt,Ft,Bt,Pt,Kt,jt,fe;const ue=M.isCompressedTexture?M.mipmaps[rt]:M.image;if(z!==null)pt=z.max.x-z.min.x,yt=z.max.y-z.min.y,bt=z.isBox3?z.max.z-z.min.z:1,Ft=z.min.x,Bt=z.min.y,Pt=z.isBox3?z.min.z:0;else{const ze=Math.pow(2,-N);pt=Math.floor(ue.width*ze),yt=Math.floor(ue.height*ze),M.isDataArrayTexture?bt=ue.depth:M.isData3DTexture?bt=Math.floor(ue.depth*ze):bt=1,Ft=0,Bt=0,Pt=0}H!==null?(Kt=H.x,jt=H.y,fe=H.z):(Kt=0,jt=0,fe=0);const $t=kt.convert(I.format),Lt=kt.convert(I.type);let ve;I.isData3DTexture?(T.setTexture3D(I,0),ve=b.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(T.setTexture2DArray(I,0),ve=b.TEXTURE_2D_ARRAY):(T.setTexture2D(I,0),ve=b.TEXTURE_2D),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,I.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,I.unpackAlignment);const Qt=b.getParameter(b.UNPACK_ROW_LENGTH),Ge=b.getParameter(b.UNPACK_IMAGE_HEIGHT),ii=b.getParameter(b.UNPACK_SKIP_PIXELS),Ue=b.getParameter(b.UNPACK_SKIP_ROWS),Vi=b.getParameter(b.UNPACK_SKIP_IMAGES);b.pixelStorei(b.UNPACK_ROW_LENGTH,ue.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,ue.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Ft),b.pixelStorei(b.UNPACK_SKIP_ROWS,Bt),b.pixelStorei(b.UNPACK_SKIP_IMAGES,Pt);const ae=M.isDataArrayTexture||M.isData3DTexture,Be=I.isDataArrayTexture||I.isData3DTexture;if(M.isDepthTexture){const ze=gt.get(M),Te=gt.get(I),we=gt.get(ze.__renderTarget),Ms=gt.get(Te.__renderTarget);at.bindFramebuffer(b.READ_FRAMEBUFFER,we.__webglFramebuffer),at.bindFramebuffer(b.DRAW_FRAMEBUFFER,Ms.__webglFramebuffer);for(let Un=0;Un<bt;Un++)ae&&(b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,gt.get(M).__webglTexture,N,Pt+Un),b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,gt.get(I).__webglTexture,rt,fe+Un)),b.blitFramebuffer(Ft,Bt,pt,yt,Kt,jt,pt,yt,b.DEPTH_BUFFER_BIT,b.NEAREST);at.bindFramebuffer(b.READ_FRAMEBUFFER,null),at.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else if(N!==0||M.isRenderTargetTexture||gt.has(M)){const ze=gt.get(M),Te=gt.get(I);at.bindFramebuffer(b.READ_FRAMEBUFFER,Ph),at.bindFramebuffer(b.DRAW_FRAMEBUFFER,Lh);for(let we=0;we<bt;we++)ae?b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,ze.__webglTexture,N,Pt+we):b.framebufferTexture2D(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,ze.__webglTexture,N),Be?b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,Te.__webglTexture,rt,fe+we):b.framebufferTexture2D(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,Te.__webglTexture,rt),N!==0?b.blitFramebuffer(Ft,Bt,pt,yt,Kt,jt,pt,yt,b.COLOR_BUFFER_BIT,b.NEAREST):Be?b.copyTexSubImage3D(ve,rt,Kt,jt,fe+we,Ft,Bt,pt,yt):b.copyTexSubImage2D(ve,rt,Kt,jt,Ft,Bt,pt,yt);at.bindFramebuffer(b.READ_FRAMEBUFFER,null),at.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else Be?M.isDataTexture||M.isData3DTexture?b.texSubImage3D(ve,rt,Kt,jt,fe,pt,yt,bt,$t,Lt,ue.data):I.isCompressedArrayTexture?b.compressedTexSubImage3D(ve,rt,Kt,jt,fe,pt,yt,bt,$t,ue.data):b.texSubImage3D(ve,rt,Kt,jt,fe,pt,yt,bt,$t,Lt,ue):M.isDataTexture?b.texSubImage2D(b.TEXTURE_2D,rt,Kt,jt,pt,yt,$t,Lt,ue.data):M.isCompressedTexture?b.compressedTexSubImage2D(b.TEXTURE_2D,rt,Kt,jt,ue.width,ue.height,$t,ue.data):b.texSubImage2D(b.TEXTURE_2D,rt,Kt,jt,pt,yt,$t,Lt,ue);b.pixelStorei(b.UNPACK_ROW_LENGTH,Qt),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,Ge),b.pixelStorei(b.UNPACK_SKIP_PIXELS,ii),b.pixelStorei(b.UNPACK_SKIP_ROWS,Ue),b.pixelStorei(b.UNPACK_SKIP_IMAGES,Vi),rt===0&&I.generateMipmaps&&b.generateMipmap(ve),at.unbindTexture()},this.copyTextureToTexture3D=function(M,I,z=null,H=null,N=0){return M.isTexture!==!0&&(Mi("WebGLRenderer: copyTextureToTexture3D function signature has changed."),z=arguments[0]||null,H=arguments[1]||null,M=arguments[2],I=arguments[3],N=arguments[4]||0),Mi('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(M,I,z,H,N)},this.initRenderTarget=function(M){gt.get(M).__webglFramebuffer===void 0&&T.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?T.setTextureCube(M,0):M.isData3DTexture?T.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?T.setTexture2DArray(M,0):T.setTexture2D(M,0),at.unbindTexture()},this.resetState=function(){P=0,C=0,R=null,at.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return pn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=Jt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Jt._getUnpackColorSpace()}}const Kn=Le-1,Bc=16.25,fn=.72,cs=.42,ls=fn+.41*cs,du=ls+.25;function Gn(i,t){return{x:t-Kn/2,z:i-Kn/2}}function K0(){const i=document.createElement("canvas");i.width=i.height=256;const t=i.getContext("2d");t.fillStyle="#141a22",t.fillRect(0,0,256,256);for(let n=0;n<1700;n++){const r=20+Math.floor(Math.random()*20);t.fillStyle=`rgba(${r+6}, ${r+10}, ${r+15}, .16)`,t.fillRect(Math.random()*256,Math.random()*256,1,1)}const e=new ju(i);return e.wrapS=e.wrapT=Ui,e.repeat.set(7,7),e}function Z0(){const i=new im,t=i.load("images/wood.jpg"),e=i.load("images/wood_normal.jpg");return t.colorSpace=Re,t.wrapS=t.wrapT=Ui,e.wrapS=e.wrapT=Ui,t.repeat.set(1.6,1.6),e.repeat.set(1.6,1.6),t.center.set(.5,.5),e.center.set(.5,.5),t.rotation=Math.PI/2,e.rotation=Math.PI/2,t.anisotropy=4,e.anisotropy=4,{color:t,normal:e}}function $0(){const i=document.createElement("canvas");i.width=i.height=128;const t=i.getContext("2d"),e=t.createRadialGradient(64,64,8,64,64,64);return e.addColorStop(0,"rgba(13, 13, 13, 0.56)"),e.addColorStop(.5,"rgba(13, 13, 13, 0.46)"),e.addColorStop(.82,"rgba(13, 13, 13, 0.2)"),e.addColorStop(1,"rgba(13, 13, 13, 0)"),t.fillStyle=e,t.fillRect(0,0,128,128),new ju(i)}function ph(i=Bc){const t=new Pc,e=i/2,n=.35;return t.moveTo(-e+n,-e),t.lineTo(e-n,-e),t.quadraticCurveTo(e,-e,e,-e+n),t.lineTo(e,e-n),t.quadraticCurveTo(e,e,e-n,e),t.lineTo(-e+n,e),t.quadraticCurveTo(-e,e,-e,e-n),t.lineTo(-e,-e+n),t.quadraticCurveTo(-e,-e,-e+n,-e),t}function J0(){const i=ph(),t=new Lc(i,{depth:.68,bevelEnabled:!0,bevelThickness:.12,bevelSize:.1,bevelSegments:4});return t.rotateX(-Math.PI/2),t}function j0(){const i=Bc-.2,t=new Dc(ph(i)),e=t.getAttribute("position"),n=[];for(let r=0;r<e.count;r++)n.push((e.getX(r)+i/2)/i,(e.getY(r)+i/2)/i);return t.setAttribute("uv",new re(n,2)),t.rotateX(-Math.PI/2),t}function Q0(){const i=new Yn,t=new qn({color:2166792}),e=new Jn(Kn,.018,.038),n=new Jn(.038,.018,Kn);for(let r=0;r<Le;r++){const s=r-Kn/2,o=new he(e,t);o.position.set(0,fn+.012,s),i.add(o);const a=new he(n,t);a.position.set(s,fn+.012,0),i.add(a)}return i}function tx(){const i=new Y0({antialias:!0,powerPreference:"high-performance"});i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.outputColorSpace=Re,i.toneMapping=Ru,i.toneMappingExposure=1.12,i.shadowMap.enabled=!0,i.shadowMap.type=bu,document.getElementById("app").prepend(i.domElement);const t=new gp;t.background=new Xt("#0e131a"),t.fog=new Ac("#0e131a",30,65);const e=new Fe(38,1,.1,100);t.add(e);const n=new he(new _r(80,80),new Si({map:K0(),color:10134444,roughness:.96}));n.rotation.x=-Math.PI/2,n.position.y=-.46,n.receiveShadow=!0,t.add(n);const r=new he(J0(),new Si({color:7225887,roughness:.5,metalness:.02}));r.position.y=-.1,r.castShadow=!1,r.receiveShadow=!0,t.add(r);const s=Z0(),o=new he(j0(),new Si({map:s.color,normalMap:s.normal,normalScale:new ct(.7,.7),color:16777215,roughness:.5,side:je})),a=o.material;a.onBeforeCompile=Q=>{Q.fragmentShader=Q.fragmentShader.replace("#include <map_fragment>",`#include <map_fragment>
|
|
3828
3866
|
float woodLuminance = dot(diffuseColor.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
3829
3867
|
diffuseColor.rgb = mix(vec3(woodLuminance), diffuseColor.rgb, 0.72);
|
|
3830
|
-
diffuseColor.rgb *= vec3(0.96, 1.0, 1.03);`)},o.position.y=cn,o.receiveShadow=!0,t.add(o);const c=uv();t.add(c);const l=new Vn({color:3810326});for(const[Q,j]of[[3,3],[3,11],[7,7],[11,3],[11,11]]){const ut=new le(new Xr(.11,16),l),vt=zn(Q,j);ut.rotation.x=-Math.PI/2,ut.position.set(vt.x,cn+.02,vt.z),t.add(ut)}const u=new Jc({color:1053979,roughness:.18,clearcoat:.8,clearcoatRoughness:.1}),h=new Jc({color:15985368,roughness:.24,clearcoat:.65,clearcoatRoughness:.16}),f=new $a(.41,28,18),d=new Xr(.44,32),g=new Vn({map:av(),transparent:!0,opacity:.95,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1}),v=[],m=[],p=new Wn,b=new Vn({color:16777215,transparent:!0,opacity:.86,depthTest:!1}),T=new le(new qr(.43,.47,32),b);T.rotation.x=-Math.PI/2,p.add(T),p.position.y=cn+.025,p.renderOrder=4,t.add(p);const S=new le(new qr(.14,.2,32),new Vn({color:14703941,transparent:!0,opacity:.95,depthTest:!1}));S.rotation.x=-Math.PI/2,S.position.y=cn+.035,S.renderOrder=5,S.visible=!1,t.add(S);const L=new Wn,C=new le(new Za(.055,.055,1,18),new gi({color:16777215,emissive:16777215,emissiveIntensity:1.5,roughness:.3}));L.add(C),L.visible=!1,t.add(L);const R=[];for(let Q=0;Q<5;Q++){const j=new le(new Qa(.48,.026,8,32),new gi({color:16777215,emissive:16777215,emissiveIntensity:1.5}));j.rotation.x=-Math.PI/2,j.visible=!1,t.add(j),R.push(j)}const D=new xd(16771010,2.2);D.position.set(-5,20,5),D.castShadow=!0,D.shadow.mapSize.set(1024,1024),D.shadow.camera.left=-15,D.shadow.camera.right=15,D.shadow.camera.top=15,D.shadow.camera.bottom=-15,D.shadow.bias=-.001,D.shadow.normalBias=.02,t.add(D),t.add(new md(14083056,2037523,.65));const y=new _d(6200266,18,35,2);y.position.set(7,8,-11),t.add(y);const M=new Sd,w=new at,H=new xn(new P(0,1,0),-cn),O=new P;let V=0,X=.45,G=20;const K=new P,k=()=>{const Q=X<.001,j=Math.sin(X)*G;e.up.set(0,Q?0:1,Q?-1:0),e.position.set(K.x+Math.sin(V)*j,K.y+(Q?G:Math.cos(X)*G),K.z+Math.cos(V)*j),e.lookAt(K)},ct=(Q,j)=>{V-=Q*.008,X=Hn(X-j*.006,0,1.15),k()},pt=(Q,j)=>{const ut=new P().setFromMatrixColumn(e.matrixWorld,0);ut.y=0,ut.normalize();const vt=new P;e.getWorldDirection(vt),vt.y=0,vt.lengthSq()>1e-4?vt.normalize():vt.set(0,0,-1);const Rt=G*.0012;K.addScaledVector(ut,-Q*Rt),K.addScaledVector(vt,j*Rt),k()},Mt=()=>{const Q=window.innerWidth,j=window.innerHeight;i.setSize(Q,j),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.aspect=Q/j;const ut=Q/j;G=ic/2/Math.tan(Qh.degToRad(e.fov)/2)*Math.max(1,1/ut)*1.12,k(),e.updateProjectionMatrix()},Ft=(Q,j)=>{if(w.x=Q/window.innerWidth*2-1,w.y=-(j/window.innerHeight)*2+1,M.setFromCamera(w,e),!M.ray.intersectPlane(H,O))return null;const ut=Math.round(O.x+Xn/2),vt=Math.round(O.z+Xn/2);return vt<0||vt>=ge||ut<0||ut>=ge?null:{row:vt,column:ut}},Zt=(Q,j,ut,vt)=>{const{x:Rt,z:Vt}=zn(j,ut),J=new le(d,g);J.rotation.x=-Math.PI/2,J.position.set(Rt+.09,cn+.006,Vt-.09),J.renderOrder=1,t.add(J),m.push(J);const et=new le(f,Q===Ke?u:h);return et.position.set(Rt,Zr+(vt?1.1:0),Vt),et.scale.set(1,Yr,1),et.castShadow=!0,et.receiveShadow=!0,et.userData.dropStart=vt?performance.now():0,t.add(et),v.push(et),et},Y=()=>{for(const Q of v)t.remove(Q);for(const Q of m)t.remove(Q);v.length=0,m.length=0,S.visible=!1,L.visible=!1;for(const Q of R)Q.visible=!1},st=Q=>{if(Q.length<2)return;const j=zn(Q[0][0],Q[0][1]),ut=zn(Q[Q.length-1][0],Q[Q.length-1][1]),vt=ut.x-j.x,Rt=ut.z-j.z,Vt=Math.hypot(vt,Rt);L.position.set((j.x+ut.x)/2,wl,(j.z+ut.z)/2),C.scale.set(1,.001,1),L.userData.winStart=performance.now(),L.userData.winLength=Vt+.55,C.quaternion.setFromUnitVectors(new P(0,1,0),new P(vt,0,Rt).normalize()),L.visible=!0,Q.slice(0,5).forEach(([J,et],A)=>{const bt=zn(J,et);R[A].position.set(bt.x,wl,bt.z),R[A].scale.setScalar(.001),R[A].visible=!0})};return Mt(),{renderer:i,scene:t,camera:e,cursor:p,lastMark:S,winGroup:L,winBar:C,winRings:R,addStone:Zt,clearStones:Y,updateWinLine:st,pickCell:Ft,orbit:ct,pan:pt,resize:Mt}}function fv(i,t){const e=1+Math.sin(t*.005)*.055;if(i.cursor.scale.set(e,1,e),i.winGroup.visible){const n=i.winGroup.userData.winStart;if(n){const s=Hn((t-n)/1e3,0,1),o=1-Math.pow(1-s,3),a=i.winGroup.userData.winLength;i.winBar.scale.y=a*o,i.winRings.forEach((c,l)=>{const u=Hn((s-l*.08)*4,0,1);c.scale.setScalar(Hn(u,.001,1))}),s>=1&&(i.winGroup.userData.winStart=0)}const r=1.2+Math.sin(t*.006)*.55;i.winBar.material.emissiveIntensity=r;for(const s of i.winRings)s.material.emissiveIntensity=r}if(i.lastMark.visible){const n=1+Math.sin(t*.007)*.1;i.lastMark.scale.set(n,n,1)}for(const n of i.scene.children){const r=n.userData.dropStart;if(!r)continue;const s=Hn((t-r)/320,0,1),o=1-Math.pow(1-s,3);n.position.y=Zr+1.1*(1-o),n.scale.y=Yr+Math.sin(s*Math.PI)*.06,s>=1&&(n.userData.dropStart=0,n.position.y=Zr,n.scale.y=Yr)}}var Do={exports:{}},Uo={exports:{}},Io={exports:{}},No={exports:{}},Fo={exports:{}},Oo={exports:{}},Bo={exports:{}},zo={exports:{}},Ho={exports:{}},ko={exports:{}};(function(i,t){var e=Object.prototype.toString;t=function(n){return e.call(n)},i.exports=t})(ko,ko.exports);var jn=ko.exports;(function(i,t){var e=jn;t=function(n){return e(n)==="[object Number]"},i.exports=t})(Ho,Ho.exports);var yu=Ho.exports,Go={exports:{}};(function(i,t){var e=jn;t=function(n){var r=e(n);return r==="[object Function]"||r==="[object GeneratorFunction]"||r==="[object AsyncFunction]"},i.exports=t})(Go,Go.exports);var Ii=Go.exports;(function(i,t){var e=yu,n=Ii,r=Math.pow(2,53)-1;t=function(s){if(!s)return!1;var o=s.length;return e(o)&&o>=0&&o<=r&&!n(s)},i.exports=t})(zo,zo.exports);var $r=zo.exports,Vo={exports:{}},Wo={exports:{}};(function(i,t){var e=Object.prototype.hasOwnProperty;t=function(n,r){return e.call(n,r)},i.exports=t})(Wo,Wo.exports);var rc=Wo.exports;(function(i,t){var e=rc;Object.keys?t=Object.keys:t=function(n){var r=[];for(var s in n)e(n,s)&&r.push(s);return r},i.exports=t})(Vo,Vo.exports);var $n=Vo.exports,Xo={exports:{}};(function(i,t){var e=nr;t=function(n,r,s){if(e(r))return n;switch(s??3){case 1:return function(o){return n.call(r,o)};case 3:return function(o,a,c){return n.call(r,o,a,c)};case 4:return function(o,a,c,l){return n.call(r,o,a,c,l)}}return function(){return n.apply(r,arguments)}},i.exports=t})(Xo,Xo.exports);var Eu=Xo.exports;(function(i,t){var e=$r,n=$n,r=Eu;t=function(s,o,a){o=r(o,a);var c,l;if(e(s))for(c=0,l=s.length;c<l;c++)o(s[c],c,s);else{var u=n(s);for(c=0,l=u.length;c<l;c++)o(s[u[c]],u[c],s)}return s},i.exports=t})(Bo,Bo.exports);var Qr=Bo.exports;(function(i,t){var e=nr,n=Qr;t=function(r,s){return function(o){return n(arguments,function(a,c){if(c!==0){var l=r(a);n(l,function(u){(!s||e(o[u]))&&(o[u]=a[u])})}}),o}},i.exports=t})(Oo,Oo.exports);var sc=Oo.exports,qo={exports:{}},Yo={exports:{}},Zo={exports:{}};(function(i,t){t=function(e){var n=typeof e;return!!e&&(n==="function"||n==="object")},i.exports=t})(Zo,Zo.exports);var Ni=Zo.exports;(function(i,t){var e=Ni,n=Ii,r=Object.getPrototypeOf,s={}.constructor;t=function(o){if(e(o)){if(r)return r(o);var a=o.__proto__;if(a||a===null)return a;if(n(o.constructor))return o.constructor.prototype;if(o instanceof s)return s.prototype}},i.exports=t})(Yo,Yo.exports);var dv=Yo.exports,Jo={exports:{}},Ko={exports:{}},jo={exports:{}},$o={exports:{}};(function(i,t){var e=jn;Array.isArray?t=Array.isArray:t=function(n){return e(n)==="[object Array]"},i.exports=t})($o,$o.exports);var Fi=$o.exports,Qo={exports:{}},ta={exports:{}};(function(i,t){var e=$n,n=sc;t=n(e),i.exports=t})(ta,ta.exports);var pv=ta.exports,ea={exports:{}};(function(i,t){var e=$n;t=function(n,r){var s=e(r),o=s.length;if(n==null)return!o;n=Object(n);for(var a=0;a<o;a++){var c=s[a];if(r[c]!==n[c]||!(c in n))return!1}return!0},i.exports=t})(ea,ea.exports);var mv=ea.exports;(function(i,t){var e=pv,n=mv;t=function(r){return r=e({},r),function(s){return n(s,r)}},i.exports=t})(Qo,Qo.exports);var gv=Qo.exports,na={exports:{}};(function(i,t){t=function(e){return e},i.exports=t})(na,na.exports);var _v=na.exports,ia={exports:{}},ra={exports:{}},sa={exports:{}};(function(i,t){var e=rc,n=Fi;t=function(o,a){if(n(o))return o;if(a&&e(a,o))return[o];var c=[];return o.replace(r,function(l,u,h,f){c.push(h?f.replace(s,"$1"):u||l)}),c};var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g;i.exports=t})(sa,sa.exports);var vv=sa.exports;(function(i,t){var e=nr,n=vv;t=function(r,s){s=n(s,r);var o;for(o=s.shift();!e(o);){if(r=r[o],r==null)return;o=s.shift()}return r},i.exports=t})(ra,ra.exports);var Tu=ra.exports;(function(i,t){var e=Fi,n=Tu;t=function(s){return e(s)?function(o){return n(o,s)}:r(s)};function r(s){return function(o){return o==null?void 0:o[s]}}i.exports=t})(ia,ia.exports);var xv=ia.exports;(function(i,t){var e=Ii,n=Ni,r=Fi,s=Eu,o=gv,a=_v,c=xv;t=function(l,u,h){return l==null?a:e(l)?s(l,u,h):n(l)&&!r(l)?o(l):c(l)},i.exports=t})(jo,jo.exports);var Au=jo.exports;(function(i,t){var e=Au,n=Qr;t=function(r,s,o){var a=[];return s=e(s,o),n(r,function(c,l,u){s(c,l,u)&&a.push(c)}),a},i.exports=t})(Ko,Ko.exports);var Mv=Ko.exports;(function(i,t){var e=Mv;t=function(r,s){return s=s||n,e(r,function(o,a,c){for(var l=c.length;++a<l;)if(s(o,c[a]))return!1;return!0})};function n(r,s){return r===s}i.exports=t})(Jo,Jo.exports);var Sv=Jo.exports;(function(i,t){var e=$n,n=dv,r=Sv,s=Object.getOwnPropertyNames,o=Object.getOwnPropertySymbols;t=function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=c.prototype,u=l===void 0?!0:l,h=c.unenumerable,f=h===void 0?!1:h,d=c.symbol,g=d===void 0?!1:d,v=[];if((f||g)&&s){var m=e;f&&s&&(m=s);do v=v.concat(m(a)),g&&o&&(v=v.concat(o(a)));while(u&&(a=n(a))&&a!==Object.prototype);v=r(v)}else if(u)for(var p in a)v.push(p);else v=e(a);return v},i.exports=t})(qo,qo.exports);var bu=qo.exports;(function(i,t){var e=sc,n=bu;t=e(n),i.exports=t})(Fo,Fo.exports);var wu=Fo.exports,oa={exports:{}},aa={exports:{}};(function(i,t){var e=Au,n=$n,r=$r;t=function(s,o,a){o=e(o,a);for(var c=!r(s)&&n(s),l=(c||s).length,u=Array(l),h=0;h<l;h++){var f=c?c[h]:h;u[h]=o(s[f],f,s)}return u},i.exports=t})(aa,aa.exports);var yv=aa.exports,ca={exports:{}};(function(i,t){var e=jn;t=function(n){return e(n)==="[object String]"},i.exports=t})(ca,ca.exports);var oc=ca.exports;(function(i,t){var e=$r,n=yv,r=Fi,s=oc;t=function(o){return o?r(o)?o:e(o)&&!s(o)?n(o):[o]:[]},i.exports=t})(oa,oa.exports);var ac=oa.exports,la={exports:{}},ua={exports:{}};(function(i,t){var e=Ni;t=function(r){if(!e(r))return{};if(n)return n(r);function s(){}return s.prototype=r,new s};var n=Object.create;i.exports=t})(ua,ua.exports);var Ev=ua.exports;(function(i,t){var e=Ev;t=function(n,r){n.prototype=e(r.prototype)},i.exports=t})(la,la.exports);var Tv=la.exports,ha={exports:{}};(function(i,t){var e=Ii;t=typeof wx<"u"&&e(wx.openLocation),i.exports=t})(ha,ha.exports);var Av=ha.exports;(function(i,t){var e=wu,n=ac,r=Tv,s=Tu,o=Av;t=function(l,u){return c.extend(l,u)};function a(l,u,h){h=h||{};var f=u.className||s(u,"initialize.name")||"";delete u.className;var d=function(){var g=n(arguments);return this.initialize?this.initialize.apply(this,g)||this:this};if(!o)try{d=new Function("toArr","return function "+f+"(){var args = toArr(arguments);return this.initialize ? this.initialize.apply(this, args) || this : this;};")(n)}catch{}return r(d,l),d.prototype.constructor=d,d.extend=function(g,v){return a(d,g,v)},d.inherits=function(g){r(d,g)},d.methods=function(g){return e(d.prototype,g),d},d.statics=function(g){return e(d,g),d},d.methods(u).statics(h),d}var c=t.Base=a(Object,{className:"Base",callSuper:function(l,u,h){var f=l.prototype[u];return f.apply(this,h)},toString:function(){return this.constructor.name}});i.exports=t})(No,No.exports);var bv=No.exports,fa={exports:{}};(function(i,t){t=function(e,n,r){var s=e.length;n==null?n=0:n<0?n=Math.max(s+n,0):n=Math.min(n,s),r==null?r=s:r<0?r=Math.max(s+r,0):r=Math.min(r,s);for(var o=[];n<r;)o.push(e[n++]);return o},i.exports=t})(fa,fa.exports);var wv=fa.exports,da={exports:{}},pa={exports:{}},ma={exports:{}};(function(i,t){t=function(e,n){return n=n==null?e.length-1:+n,function(){var r=Math.max(arguments.length-n,0),s=new Array(r),o;for(o=0;o<r;o++)s[o]=arguments[o+n];switch(n){case 0:return e.call(this,s);case 1:return e.call(this,arguments[0],s);case 2:return e.call(this,arguments[0],arguments[1],s)}var a=new Array(n+1);for(o=0;o<n;o++)a[o]=arguments[o];return a[n]=s,e.apply(this,a)}},i.exports=t})(ma,ma.exports);var Rv=ma.exports;(function(i,t){var e=Rv,n=ac;t=e(function(r,s){return function(){var o=[];return o=o.concat(s),o=o.concat(n(arguments)),r.apply(this,o)}}),i.exports=t})(pa,pa.exports);var Cv=pa.exports,ga={exports:{}};(function(i,t){t=function(e,n){var r;return function(){return--e>0&&(r=n.apply(this,arguments)),e<=1&&(n=null),r}},i.exports=t})(ga,ga.exports);var Pv=ga.exports;(function(i,t){var e=Cv,n=Pv;t=e(n,2),i.exports=t})(da,da.exports);var Lv=da.exports,_a={exports:{}};(function(i,t){var e=Ni,n=Fi,r=wu;t=function(s){return e(s)?n(s)?s.slice():r({},s):s},i.exports=t})(_a,_a.exports);var Dv=_a.exports;(function(i,t){var e=bv,n=rc,r=Qr,s=wv,o=Lv,a=Dv;t=e({initialize:function(){this._events=this._events||{}},on:function(c,l){return this._events[c]=this._events[c]||[],this._events[c].push(l),this},off:function(c,l){var u=this._events;if(n(u,c)){var h=u[c].indexOf(l);return h>-1&&u[c].splice(h,1),this}},once:function(c,l){return this.on(c,o(l)),this},emit:function(c){var l=this;if(n(this._events,c)){var u=s(arguments,1),h=a(this._events[c]);return r(h,function(f){return f.apply(l,u)},this),this}},removeAllListeners:function(c){return c?delete this._events[c]:this._events={},this}},{mixin:function(c){r(["on","off","once","emit","removeAllListeners"],function(l){c[l]=t.prototype[l]}),c._events=c._events||{}}}),i.exports=t})(Io,Io.exports);var Uv=Io.exports;(function(i,t){var e=Uv,n=oc,r=Ni,s=Qr,o=ac;t=e.extend({initialize:function(c){this.callSuper(e,"initialize",arguments),this._data=c||{},this.save(this._data)},set:function(a,c){var l;n(a)?(l={},l[a]=c):r(a)&&(l=a);var u=this;s(l,function(h,f){var d=u._data[f];u._data[f]=h,u.emit("change",f,h,d)}),this.save(this._data)},get:function(a){var c=this._data;if(n(a))return c[a];var l={};return s(a,function(u){l[u]=c[u]}),l},remove:function(a){a=o(a);var c=this._data;s(a,function(l){delete c[l]}),this.save(c)},clear:function(){this._data={},this.save(this._data)},each:function(a){s(this._data,a)},save:function(a){this._data=a}}),i.exports=t})(Uo,Uo.exports);var Iv=Uo.exports,va={exports:{}},xa={exports:{}};(function(i,t){var e=$n;t={getItem:function(c){return(r[c]?n[c]:this[c])||null},setItem:function(c,l){r[c]?n[c]=l:this[c]=l},removeItem:function(c){r[c]?delete n[c]:delete this[c]},key:function(c){var l=s();return c>=0&&c<l.length?l[c]:null},clear:function(){for(var c=o(),l=0,u;u=c[l];l++)delete this[u];c=a();for(var h=0,f;f=c[h];h++)delete n[f]}},Object.defineProperty(t,"length",{enumerable:!1,configurable:!0,get:function(){return s().length}});var n={},r={getItem:1,setItem:1,removeItem:1,key:1,clear:1,length:1};function s(){return o().concat(a())}function o(){return e(t).filter(function(c){return!r[c]})}function a(){return e(n)}i.exports=t})(xa,xa.exports);var Nv=xa.exports;(function(i,t){var e=Nv;t=function(n){n=n||"local";var r;switch(n){case"local":r=window.localStorage;break;case"session":r=window.sessionStorage;break}try{var s="test-localStorage-"+Date.now();r.setItem(s,s);var o=r.getItem(s);if(r.removeItem(s),o!==s)throw new Error}catch{return e}return r},i.exports=t})(va,va.exports);var Fv=va.exports,Ma={exports:{}},Sa={exports:{}};(function(i,t){var e=jn;t=function(n){return e(n)==="[object Arguments]"},i.exports=t})(Sa,Sa.exports);var Ov=Sa.exports;(function(i,t){var e=$r,n=Fi,r=oc,s=Ov,o=$n;t=function(a){return a==null?!0:e(a)&&(n(a)||r(a)||s(a))?a.length===0:o(a).length===0},i.exports=t})(Ma,Ma.exports);var Bv=Ma.exports,ya={exports:{}},Ea={exports:{}},Ta={exports:{}};(function(i,t){var e=yu;t=function(n){return e(n)&&n!==+n},i.exports=t})(Ta,Ta.exports);var zv=Ta.exports,Aa={exports:{}},ba={exports:{}};(function(i,t){t=function(e){return e==null?"":e.toString()},i.exports=t})(ba,ba.exports);var Ru=ba.exports;(function(i,t){var e=Ru;t=function(n){return e(n).toLocaleLowerCase()},i.exports=t})(Aa,Aa.exports);var Hv=Aa.exports,wa={exports:{}};(function(i,t){var e=Ii;t=function(n){return n==null?!1:n._isBuffer?!0:n.constructor&&e(n.constructor.isBuffer)&&n.constructor.isBuffer(n)},i.exports=t})(wa,wa.exports);var kv=wa.exports;(function(i,t){var e=jn,n=zv,r=Hv,s=kv;t=function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,l;return a===null&&(l="Null"),a===void 0&&(l="Undefined"),n(a)&&(l="NaN"),s(a)&&(l="Buffer"),l||(l=e(a).match(o),l&&(l=l[1])),l?c?r(l):l:""};var o=/^\[object\s+(.*?)]$/;i.exports=t})(Ea,Ea.exports);var Gv=Ea.exports,Ra={exports:{}};(function(i,t){t=function(e){return e.length<1?e:e[0].toUpperCase()+e.slice(1)},i.exports=t})(Ra,Ra.exports);var Vv=Ra.exports,Ca={exports:{}};(function(i,t){var e=jn;t=function(n){return e(n)==="[object RegExp]"},i.exports=t})(Ca,Ca.exports);var Wv=Ca.exports;(function(i,t){var e=Gv,n=Vv,r=Ru,s=nr,o=Ii,a=Wv;t=function(l,u){return JSON.stringify(l,c(),u)};function c(){var l=[],u=[];return function(h,f){if(l.length>0){var d=l.indexOf(this);d>-1?(l.splice(d+1),u.splice(d,1/0,h)):(l.push(this),u.push(h));var g=l.indexOf(f);g>-1&&(l[0]===f?f="[Circular ~]":f="[Circular ~."+u.slice(0,g).join(".")+"]")}else l.push(f);return a(f)||o(f)?f="["+n(e(f))+" "+r(f)+"]":s(f)&&(f=null),f}}i.exports=t})(ya,ya.exports);var Xv=ya.exports,Pa={exports:{}};(function(i,t){var e=sc,n=bu;t=e(n,!0),i.exports=t})(Pa,Pa.exports);var qv=Pa.exports;(function(i,t){var e=Iv,n=Fv,r=Bv,s=Xv,o=qv,a=Ni,c=n("local");t=e.extend({initialize:function(u,h){this._name=u,h=h||{};var f=c.getItem(u);try{f=JSON.parse(f)}catch{f={}}a(f)||(f={}),h=o(f,h),this.callSuper(e,"initialize",[h])},save:function(l){if(r(l))return c.removeItem(this._name);c.setItem(this._name,s(l))}}),i.exports=t})(Do,Do.exports);var Yv=Do.exports;const Zv=Rl(Yv),Jv="tinker-gomoku",ts=new Zv(Jv);function Kv(i){return i==="pvp"||i==="pve"}function jv(i){return i==="easy"||i==="normal"||i==="hard"}function $v(){const i=ts.get("mode");return Kv(i)?i:"pvp"}function Qv(i){ts.set("mode",i)}function t0(){const i=ts.get("difficulty");return jv(i)?i:"normal"}function e0(i){ts.set("difficulty",i)}const Cu={en:{mode:"MODE",local:"LOCAL 2P",computer:"VS CPU",difficulty:"DIFFICULTY",easy:"EASY",normal:"NORMAL",hard:"HARD",start:"START MATCH",playAgain:"PLAY AGAIN",changeMode:"CHANGE MODE",sound:"Sound",soundOff:"Sound off",menu:"Menu",black:"Black to move",white:"White to move",cpuThinking:"Computer is thinking",yourMove:"Your move · Black",blackWins:"Black wins",whiteWins:"White wins",draw:"A quiet draw",full:"The board is full. No line prevailed."},"zh-CN":{mode:"模式",local:"本地双人",computer:"电脑对战",difficulty:"难度",easy:"简单",normal:"普通",hard:"困难",start:"开始对局",playAgain:"再来一局",changeMode:"更换模式",sound:"声音",soundOff:"声音已关",menu:"菜单",black:"黑棋回合",white:"白棋回合",cpuThinking:"电脑思考中",yourMove:"你的回合 · 黑棋",blackWins:"黑棋获胜",whiteWins:"白棋获胜",draw:"和棋",full:"棋盘已满,双方未能连成五子。"}};async function n0(){if(typeof tinker<"u")try{return await tinker.getLanguage()==="zh-CN"?"zh-CN":"en"}catch{}return navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en"}function i0(){return{menu:document.getElementById("menu"),result:document.getElementById("result"),turnPill:document.getElementById("turnPill"),turnStone:document.getElementById("turnStone"),turnText:document.getElementById("turnText"),resultTitle:document.getElementById("resultTitle"),resultText:document.getElementById("resultText"),soundButton:document.querySelector("#soundButton"),menuButton:document.querySelector("#menuButton"),difficultySetting:document.getElementById("difficultySetting"),startButton:document.querySelector("#startButton"),againButton:document.querySelector("#againButton"),resultMenuButton:document.querySelector("#resultMenuButton")}}function r0(i,t){i.menu.classList.toggle("hidden",!t),i.result.classList.add("hidden")}function cc(i,t){document.querySelectorAll("[data-mode]").forEach(e=>{e.classList.toggle("selected",e.dataset.mode===t)}),i.difficultySetting.classList.toggle("disabled",t!=="pve")}function Pu(i){document.querySelectorAll("[data-difficulty]").forEach(t=>{t.classList.toggle("selected",t.dataset.difficulty===i)})}function Lu(i,t,e){const n=t.phase==="thinking";let r=t.turn===Ke?e.black:e.white;t.mode==="pve"&&(r=n?e.cpuThinking:t.turn===Ke?e.yourMove:e.cpuThinking),i.turnText.textContent=r,i.turnStone.className=`turn-stone ${t.turn===Ke?"black":"white"}`,i.turnPill.classList.toggle("thinking",n)}function s0(i,t,e,n){const r=Cu[e];document.documentElement.lang=e,document.querySelectorAll("[data-i18n]").forEach(s=>{const o=s.dataset.i18n;r[o]&&(s.textContent=r[o])}),i.soundButton.setAttribute("aria-label",t.sound?r.sound:r.soundOff),i.soundButton.setAttribute("aria-pressed",String(t.sound)),i.soundButton.classList.toggle("muted",!t.sound),i.menuButton.textContent=r.menu,n(r)}const me=hv(),Ei=new qu,Re=i0(),Nt=Ku($v(),t0());let lc="en";const Du=()=>Cu[lc];let Zi,Ji,xi=0;function Uu(){Zi!==void 0&&(window.clearTimeout(Zi),Zi=void 0),Ji!==void 0&&(window.clearTimeout(Ji),Ji=void 0)}const Iu=()=>s0(Re,Nt,lc,i=>Lu(Re,Nt,i)),es=()=>Lu(Re,Nt,Du()),uc=i=>r0(Re,i);function ns(i,t){Nt.cursor.row=Hn(i,0,ge-1),Nt.cursor.column=Hn(t,0,ge-1);const e=zn(Nt.cursor.row,Nt.cursor.column);me.cursor.position.x=e.x,me.cursor.position.z=e.z}function o0(){Uu(),xi++,Nt.board=Da(),Nt.turn=Ke,Nt.phase="play",ns(7,7),me.clearStones(),uc(!1),es(),Ei.unlock()}function a0(){Uu(),xi++,Nt.phase="menu",Nt.board=Da(),me.clearStones(),uc(!0),es()}function La(i){const t=Du();Nt.phase="over",me.cursor.visible=!1,Re.result.classList.remove("hidden"),i===0?(Re.resultText.hidden=!1,Re.resultTitle.textContent=t.draw,Re.resultText.textContent=t.full):(Re.resultText.hidden=!0,Re.resultTitle.textContent=i===Ke?t.blackWins:t.whiteWins),es()}function Nu(i,t){if(Nt.phase!=="play"||Nt.board[yn(i,t)]!==qe)return;const e=Nt.turn;Nt.board[yn(i,t)]=e,me.addStone(e,i,t,!0);const n=zn(i,t);me.lastMark.position.set(n.x,me.cursor.position.y+.04,n.z),me.lastMark.visible=!0,Ei.unlock(),Ei.play();const r=Zu(Nt.board,i,t);if(r){me.updateWinLine(r),Nt.phase="over";const s=xi;Ji=window.setTimeout(()=>{Ji=void 0,Nt.phase==="over"&&xi===s&&La(e)},2e3);return}if(Yu(Nt.board)){La(0);return}if(Nt.turn=Ua(e),Nt.mode==="pve"&&Nt.turn!==Ke){Nt.phase="thinking";const s=xi;Zi=window.setTimeout(()=>{Zi=void 0,xi===s&&c0()},380)}es()}function c0(){if(Nt.phase!=="thinking")return;const i=Ju(Nt.board,Cl,Nt.difficulty);if(!i){La(0);return}ns(i.row,i.column),Nt.phase="play",Nu(i.row,i.column)}function l0(i,t){Nt.phase!=="play"&&Nt.phase!=="thinking"||ns(Nt.cursor.row+i,Nt.cursor.column+t)}const u0=ju(me,Re,{getPhase:()=>Nt.phase,getCursor:()=>Nt.cursor,setCursor:ns,moveCursor:l0,placeStone:(i,t)=>Nu(i,t),startMatch:o0,openMenu:a0,setMode:i=>{Nt.mode=i,Qv(i),cc(Re,i)},setDifficulty:i=>{Nt.difficulty=i,e0(i),Pu(i)},toggleSound:()=>{Nt.sound=!Nt.sound,Ei.setEnabled(Nt.sound),Ei.unlock(),Iu()},unlockAudio:()=>Ei.unlock()});function Fu(i){requestAnimationFrame(Fu),u0.pollGamepad();const t=Nt.phase==="play"||Nt.phase==="thinking";me.cursor.visible=t,fv(me,i),me.renderer.render(me.scene,me.camera)}window.addEventListener("resize",me.resize);n0().then(i=>{lc=i,cc(Re,Nt.mode),Iu()});uc(!0);cc(Re,Nt.mode);Pu(Nt.difficulty);me.cursor.visible=!1;requestAnimationFrame(Fu);
|
|
3868
|
+
diffuseColor.rgb *= vec3(0.96, 1.0, 1.03);`)},o.position.y=fn,o.receiveShadow=!0,t.add(o);const c=Q0();t.add(c);const l=new qn({color:3810326});for(const[Q,J]of[[3,3],[3,11],[7,7],[11,3],[11,11]]){const ht=new he(new os(.11,16),l),xt=Gn(Q,J);ht.rotation.x=-Math.PI/2,ht.position.set(xt.x,fn+.02,xt.z),t.add(ht)}const u=new Nl({color:1053979,roughness:.18,clearcoat:.8,clearcoatRoughness:.1}),h=new Nl({color:15985368,roughness:.24,clearcoat:.65,clearcoatRoughness:.16}),f=new Uc(.41,28,18),d=new os(.44,32),g=new qn({map:$0(),transparent:!0,opacity:.95,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1}),v=[],m=[],p=new Yn,A=new qn({color:16777215,transparent:!0,opacity:.86,depthTest:!1}),y=new he(new as(.43,.47,32),A);y.rotation.x=-Math.PI/2,p.add(y),p.position.y=fn+.025,p.renderOrder=4,t.add(p);const S=new he(new as(.14,.2,32),new qn({color:14703941,transparent:!0,opacity:.95,depthTest:!1}));S.rotation.x=-Math.PI/2,S.position.y=fn+.035,S.renderOrder=5,S.visible=!1,t.add(S);const L=new Yn,P=new he(new Cc(.055,.055,1,18),new Si({color:16777215,emissive:16777215,emissiveIntensity:1.5,roughness:.3}));L.add(P),L.visible=!1,t.add(L);const C=[];for(let Q=0;Q<5;Q++){const J=new he(new Ic(.48,.026,8,32),new Si({color:16777215,emissive:16777215,emissiveIntensity:1.5}));J.rotation.x=-Math.PI/2,J.visible=!1,t.add(J),C.push(J)}const R=new cm(16771010,2.2);R.position.set(-5,20,5),R.castShadow=!0,R.shadow.mapSize.set(1024,1024),R.shadow.camera.left=-15,R.shadow.camera.right=15,R.shadow.camera.top=15,R.shadow.camera.bottom=-15,R.shadow.bias=-.001,R.shadow.normalBias=.02,t.add(R),t.add(new rm(14083056,2037523,.65));const E=new om(6200266,18,35,2);E.position.set(7,8,-11),t.add(E);const _=new um,w=new ct,B=new yn(new D(0,1,0),-fn),F=new D;let k=0,X=.45,G=20;const $=new D,V=()=>{const Q=X<.001,J=Math.sin(X)*G;e.up.set(0,Q?0:1,Q?-1:0),e.position.set($.x+Math.sin(k)*J,$.y+(Q?G:Math.cos(X)*G),$.z+Math.cos(k)*J),e.lookAt($)},lt=(Q,J)=>{k-=Q*.008,X=An(X-J*.006,0,1.15),V()},mt=(Q,J)=>{const ht=new D().setFromMatrixColumn(e.matrixWorld,0);ht.y=0,ht.normalize();const xt=new D;e.getWorldDirection(xt),xt.y=0,xt.lengthSq()>1e-4?xt.normalize():xt.set(0,0,-1);const Ct=G*.0012;$.addScaledVector(ht,-Q*Ct),$.addScaledVector(xt,J*Ct),V()},St=()=>{const Q=window.innerWidth,J=window.innerHeight;i.setSize(Q,J),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.aspect=Q/J;const ht=Q/J;G=Bc/2/Math.tan(Gd.degToRad(e.fov)/2)*Math.max(1,1/ht)*1.12,V(),e.updateProjectionMatrix()},Ot=(Q,J)=>{if(w.x=Q/window.innerWidth*2-1,w.y=-(J/window.innerHeight)*2+1,_.setFromCamera(w,e),!_.ray.intersectPlane(B,F))return null;const ht=Math.round(F.x+Kn/2),xt=Math.round(F.z+Kn/2);return xt<0||xt>=Le||ht<0||ht>=Le?null:{row:xt,column:ht}},Zt=(Q,J,ht,xt)=>{const{x:Ct,z:Wt}=Gn(J,ht),Z=new he(d,g);Z.rotation.x=-Math.PI/2,Z.position.set(Ct+.09,fn+.006,Wt-.09),Z.renderOrder=1,t.add(Z),m.push(Z);const et=new he(f,Q===Ze?u:h);return et.position.set(Ct,ls+(xt?1.1:0),Wt),et.scale.set(1,cs,1),et.castShadow=!0,et.receiveShadow=!0,et.userData.dropStart=xt?performance.now():0,t.add(et),v.push(et),et},Y=()=>{for(const Q of v)t.remove(Q);for(const Q of m)t.remove(Q);v.length=0,m.length=0,S.visible=!1,L.visible=!1;for(const Q of C)Q.visible=!1},ot=Q=>{if(Q.length<2)return;const J=Gn(Q[0][0],Q[0][1]),ht=Gn(Q[Q.length-1][0],Q[Q.length-1][1]),xt=ht.x-J.x,Ct=ht.z-J.z,Wt=Math.hypot(xt,Ct);L.position.set((J.x+ht.x)/2,du,(J.z+ht.z)/2),P.scale.set(1,.001,1),L.userData.winStart=performance.now(),L.userData.winLength=Wt+.55,P.quaternion.setFromUnitVectors(new D(0,1,0),new D(xt,0,Ct).normalize()),L.visible=!0,Q.slice(0,5).forEach(([Z,et],b)=>{const wt=Gn(Z,et);C[b].position.set(wt.x,du,wt.z),C[b].scale.setScalar(.001),C[b].visible=!0})};return St(),{renderer:i,scene:t,camera:e,cursor:p,lastMark:S,winGroup:L,winBar:P,winRings:C,addStone:Zt,clearStones:Y,updateWinLine:ot,pickCell:Ot,orbit:lt,pan:mt,resize:St}}function ex(i,t){const e=1+Math.sin(t*.005)*.055;if(i.cursor.scale.set(e,1,e),i.winGroup.visible){const n=i.winGroup.userData.winStart;if(n){const s=An((t-n)/1e3,0,1),o=1-Math.pow(1-s,3),a=i.winGroup.userData.winLength;i.winBar.scale.y=a*o,i.winRings.forEach((c,l)=>{const u=An((s-l*.08)*4,0,1);c.scale.setScalar(An(u,.001,1))}),s>=1&&(i.winGroup.userData.winStart=0)}const r=1.2+Math.sin(t*.006)*.55;i.winBar.material.emissiveIntensity=r;for(const s of i.winRings)s.material.emissiveIntensity=r}if(i.lastMark.visible){const n=1+Math.sin(t*.007)*.1;i.lastMark.scale.set(n,n,1)}for(const n of i.scene.children){const r=n.userData.dropStart;if(!r)continue;const s=An((t-r)/320,0,1),o=1-Math.pow(1-s,3);n.position.y=ls+1.1*(1-o),n.scale.y=cs+Math.sin(s*Math.PI)*.06,s>=1&&(n.userData.dropStart=0,n.position.y=ls,n.scale.y=cs)}}var Pa={exports:{}},La={exports:{}},Da={exports:{}},Ua={exports:{}},Ia={exports:{}},Na={exports:{}},Fa={exports:{}};(function(i,t){var e=ei,n=ti,r=Object.getPrototypeOf,s={}.constructor;t=function(o){if(e(o)){if(r)return r(o);var a=o.__proto__;if(a||a===null)return a;if(n(o.constructor))return o.constructor.prototype;if(o instanceof s)return s.prototype}},i.exports=t})(Fa,Fa.exports);var nx=Fa.exports,Oa={exports:{}};(function(i,t){var e=dc;t=function(r,s){return s=s||n,e(r,function(o,a,c){for(var l=c.length;++a<l;)if(s(o,c[a]))return!1;return!0})};function n(r,s){return r===s}i.exports=t})(Oa,Oa.exports);var ix=Oa.exports;(function(i,t){var e=Ln,n=nx,r=ix,s=Object.getOwnPropertyNames,o=Object.getOwnPropertySymbols;t=function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=c.prototype,u=l===void 0?!0:l,h=c.unenumerable,f=h===void 0?!1:h,d=c.symbol,g=d===void 0?!1:d,v=[];if((f||g)&&s){var m=e;f&&s&&(m=s);do v=v.concat(m(a)),g&&o&&(v=v.concat(o(a)));while(u&&(a=n(a))&&a!==Object.prototype);v=r(v)}else if(u)for(var p in a)v.push(p);else v=e(a);return v},i.exports=t})(Na,Na.exports);var mh=Na.exports;(function(i,t){var e=fc,n=mh;t=e(n),i.exports=t})(Ia,Ia.exports);var gh=Ia.exports,Ba={exports:{}};(function(i,t){var e=hr,n=hs,r=zi,s=fs;t=function(o){return o?r(o)?o:e(o)&&!s(o)?n(o):[o]:[]},i.exports=t})(Ba,Ba.exports);var zc=Ba.exports,za={exports:{}},Ha={exports:{}};(function(i,t){var e=ei;t=function(r){if(!e(r))return{};if(n)return n(r);function s(){}return s.prototype=r,new s};var n=Object.create;i.exports=t})(Ha,Ha.exports);var rx=Ha.exports;(function(i,t){var e=rx;t=function(n,r){n.prototype=e(r.prototype)},i.exports=t})(za,za.exports);var sx=za.exports,ka={exports:{}};(function(i,t){var e=ti;t=typeof wx<"u"&&e(wx.openLocation),i.exports=t})(ka,ka.exports);var ox=ka.exports;(function(i,t){var e=gh,n=zc,r=sx,s=gu,o=ox;t=function(l,u){return c.extend(l,u)};function a(l,u,h){h=h||{};var f=u.className||s(u,"initialize.name")||"";delete u.className;var d=function(){var g=n(arguments);return this.initialize?this.initialize.apply(this,g)||this:this};if(!o)try{d=new Function("toArr","return function "+f+"(){var args = toArr(arguments);return this.initialize ? this.initialize.apply(this, args) || this : this;};")(n)}catch{}return r(d,l),d.prototype.constructor=d,d.extend=function(g,v){return a(d,g,v)},d.inherits=function(g){r(d,g)},d.methods=function(g){return e(d.prototype,g),d},d.statics=function(g){return e(d,g),d},d.methods(u).statics(h),d}var c=t.Base=a(Object,{className:"Base",callSuper:function(l,u,h){var f=l.prototype[u];return f.apply(this,h)},toString:function(){return this.constructor.name}});i.exports=t})(Ua,Ua.exports);var ax=Ua.exports,Va={exports:{}};(function(i,t){t=function(e,n,r){var s=e.length;n==null?n=0:n<0?n=Math.max(s+n,0):n=Math.min(n,s),r==null?r=s:r<0?r=Math.max(s+r,0):r=Math.min(r,s);for(var o=[];n<r;)o.push(e[n++]);return o},i.exports=t})(Va,Va.exports);var cx=Va.exports,Ga={exports:{}},Wa={exports:{}},Xa={exports:{}};(function(i,t){t=function(e,n){return n=n==null?e.length-1:+n,function(){var r=Math.max(arguments.length-n,0),s=new Array(r),o;for(o=0;o<r;o++)s[o]=arguments[o+n];switch(n){case 0:return e.call(this,s);case 1:return e.call(this,arguments[0],s);case 2:return e.call(this,arguments[0],arguments[1],s)}var a=new Array(n+1);for(o=0;o<n;o++)a[o]=arguments[o];return a[n]=s,e.apply(this,a)}},i.exports=t})(Xa,Xa.exports);var lx=Xa.exports;(function(i,t){var e=lx,n=zc;t=e(function(r,s){return function(){var o=[];return o=o.concat(s),o=o.concat(n(arguments)),r.apply(this,o)}}),i.exports=t})(Wa,Wa.exports);var ux=Wa.exports,qa={exports:{}};(function(i,t){t=function(e,n){var r;return function(){return--e>0&&(r=n.apply(this,arguments)),e<=1&&(n=null),r}},i.exports=t})(qa,qa.exports);var hx=qa.exports;(function(i,t){var e=ux,n=hx;t=e(n,2),i.exports=t})(Ga,Ga.exports);var fx=Ga.exports,Ya={exports:{}};(function(i,t){var e=ei,n=zi,r=gh;t=function(s){return e(s)?n(s)?s.slice():r({},s):s},i.exports=t})(Ya,Ya.exports);var dx=Ya.exports;(function(i,t){var e=ax,n=lc,r=fr,s=cx,o=fx,a=dx;t=e({initialize:function(){this._events=this._events||{}},on:function(c,l){return this._events[c]=this._events[c]||[],this._events[c].push(l),this},off:function(c,l){var u=this._events;if(n(u,c)){var h=u[c].indexOf(l);return h>-1&&u[c].splice(h,1),this}},once:function(c,l){return this.on(c,o(l)),this},emit:function(c){var l=this;if(n(this._events,c)){var u=s(arguments,1),h=a(this._events[c]);return r(h,function(f){return f.apply(l,u)},this),this}},removeAllListeners:function(c){return c?delete this._events[c]:this._events={},this}},{mixin:function(c){r(["on","off","once","emit","removeAllListeners"],function(l){c[l]=t.prototype[l]}),c._events=c._events||{}}}),i.exports=t})(Da,Da.exports);var px=Da.exports;(function(i,t){var e=px,n=fs,r=ei,s=fr,o=zc;t=e.extend({initialize:function(c){this.callSuper(e,"initialize",arguments),this._data=c||{},this.save(this._data)},set:function(a,c){var l;n(a)?(l={},l[a]=c):r(a)&&(l=a);var u=this;s(l,function(h,f){var d=u._data[f];u._data[f]=h,u.emit("change",f,h,d)}),this.save(this._data)},get:function(a){var c=this._data;if(n(a))return c[a];var l={};return s(a,function(u){l[u]=c[u]}),l},remove:function(a){a=o(a);var c=this._data;s(a,function(l){delete c[l]}),this.save(c)},clear:function(){this._data={},this.save(this._data)},each:function(a){s(this._data,a)},save:function(a){this._data=a}}),i.exports=t})(La,La.exports);var mx=La.exports,Ka={exports:{}},Za={exports:{}};(function(i,t){var e=Ln;t={getItem:function(c){return(r[c]?n[c]:this[c])||null},setItem:function(c,l){r[c]?n[c]=l:this[c]=l},removeItem:function(c){r[c]?delete n[c]:delete this[c]},key:function(c){var l=s();return c>=0&&c<l.length?l[c]:null},clear:function(){for(var c=o(),l=0,u;u=c[l];l++)delete this[u];c=a();for(var h=0,f;f=c[h];h++)delete n[f]}},Object.defineProperty(t,"length",{enumerable:!1,configurable:!0,get:function(){return s().length}});var n={},r={getItem:1,setItem:1,removeItem:1,key:1,clear:1,length:1};function s(){return o().concat(a())}function o(){return e(t).filter(function(c){return!r[c]})}function a(){return e(n)}i.exports=t})(Za,Za.exports);var gx=Za.exports;(function(i,t){var e=gx;t=function(n){n=n||"local";var r;switch(n){case"local":r=window.localStorage;break;case"session":r=window.sessionStorage;break}try{var s="test-localStorage-"+Date.now();r.setItem(s,s);var o=r.getItem(s);if(r.removeItem(s),o!==s)throw new Error}catch{return e}return r},i.exports=t})(Ka,Ka.exports);var _x=Ka.exports,$a={exports:{}},Ja={exports:{}};(function(i,t){var e=Qn;t=function(n){return e(n)==="[object Arguments]"},i.exports=t})(Ja,Ja.exports);var vx=Ja.exports;(function(i,t){var e=hr,n=zi,r=fs,s=vx,o=Ln;t=function(a){return a==null?!0:e(a)&&(n(a)||r(a)||s(a))?a.length===0:o(a).length===0},i.exports=t})($a,$a.exports);var xx=$a.exports,ja={exports:{}},Qa={exports:{}},tc={exports:{}};(function(i,t){var e=cc;t=function(n){return e(n)&&n!==+n},i.exports=t})(tc,tc.exports);var Mx=tc.exports,ec={exports:{}},nc={exports:{}};(function(i,t){t=function(e){return e==null?"":e.toString()},i.exports=t})(nc,nc.exports);var _h=nc.exports;(function(i,t){var e=_h;t=function(n){return e(n).toLocaleLowerCase()},i.exports=t})(ec,ec.exports);var Sx=ec.exports,ic={exports:{}};(function(i,t){var e=ti;t=function(n){return n==null?!1:n._isBuffer?!0:n.constructor&&e(n.constructor.isBuffer)&&n.constructor.isBuffer(n)},i.exports=t})(ic,ic.exports);var Ex=ic.exports;(function(i,t){var e=Qn,n=Mx,r=Sx,s=Ex;t=function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,l;return a===null&&(l="Null"),a===void 0&&(l="Undefined"),n(a)&&(l="NaN"),s(a)&&(l="Buffer"),l||(l=e(a).match(o),l&&(l=l[1])),l?c?r(l):l:""};var o=/^\[object\s+(.*?)]$/;i.exports=t})(Qa,Qa.exports);var yx=Qa.exports,rc={exports:{}};(function(i,t){t=function(e){return e.length<1?e:e[0].toUpperCase()+e.slice(1)},i.exports=t})(rc,rc.exports);var Tx=rc.exports,sc={exports:{}};(function(i,t){var e=Qn;t=function(n){return e(n)==="[object RegExp]"},i.exports=t})(sc,sc.exports);var Ax=sc.exports;(function(i,t){var e=yx,n=Tx,r=_h,s=Bi,o=ti,a=Ax;t=function(l,u){return JSON.stringify(l,c(),u)};function c(){var l=[],u=[];return function(h,f){if(l.length>0){var d=l.indexOf(this);d>-1?(l.splice(d+1),u.splice(d,1/0,h)):(l.push(this),u.push(h));var g=l.indexOf(f);g>-1&&(l[0]===f?f="[Circular ~]":f="[Circular ~."+u.slice(0,g).join(".")+"]")}else l.push(f);return a(f)||o(f)?f="["+n(e(f))+" "+r(f)+"]":s(f)&&(f=null),f}}i.exports=t})(ja,ja.exports);var bx=ja.exports,oc={exports:{}};(function(i,t){var e=fc,n=mh;t=e(n,!0),i.exports=t})(oc,oc.exports);var Rx=oc.exports;(function(i,t){var e=mx,n=_x,r=xx,s=bx,o=Rx,a=ei,c=n("local");t=e.extend({initialize:function(u,h){this._name=u,h=h||{};var f=c.getItem(u);try{f=JSON.parse(f)}catch{f={}}a(f)||(f={}),h=o(f,h),this.callSuper(e,"initialize",[h])},save:function(l){if(r(l))return c.removeItem(this._name);c.setItem(this._name,s(l))}}),i.exports=t})(Pa,Pa.exports);var Cx=Pa.exports;const Px=nn(Cx),Lx="tinker-gomoku",gs=new Px(Lx);function Dx(i){return i==="pvp"||i==="pve"}function Ux(i){return i==="easy"||i==="normal"||i==="hard"}function Ix(){const i=gs.get("mode");return Dx(i)?i:"pvp"}function Nx(i){gs.set("mode",i)}function Fx(){const i=gs.get("difficulty");return Ux(i)?i:"normal"}function Ox(i){gs.set("difficulty",i)}const vh={en:{mode:"MODE",local:"LOCAL 2P",computer:"VS CPU",difficulty:"DIFFICULTY",easy:"EASY",normal:"NORMAL",hard:"HARD",start:"START MATCH",playAgain:"PLAY AGAIN",changeMode:"CHANGE MODE",sound:"Sound",soundOff:"Sound off",menu:"Menu",black:"Black to move",white:"White to move",cpuThinking:"Computer is thinking",yourMove:"Your move · Black",blackWins:"Black wins",whiteWins:"White wins",draw:"A quiet draw",full:"The board is full. No line prevailed."},"zh-CN":{mode:"模式",local:"本地双人",computer:"电脑对战",difficulty:"难度",easy:"简单",normal:"普通",hard:"困难",start:"开始对局",playAgain:"再来一局",changeMode:"更换模式",sound:"声音",soundOff:"声音已关",menu:"菜单",black:"黑棋回合",white:"白棋回合",cpuThinking:"电脑思考中",yourMove:"你的回合 · 黑棋",blackWins:"黑棋获胜",whiteWins:"白棋获胜",draw:"和棋",full:"棋盘已满,双方未能连成五子。"}};async function Bx(){if(typeof tinker<"u")try{return await tinker.getLanguage()==="zh-CN"?"zh-CN":"en"}catch{}return navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en"}function zx(){return{menu:document.getElementById("menu"),result:document.getElementById("result"),turnPill:document.getElementById("turnPill"),turnStone:document.getElementById("turnStone"),turnText:document.getElementById("turnText"),resultTitle:document.getElementById("resultTitle"),resultText:document.getElementById("resultText"),soundButton:document.querySelector("#soundButton"),menuButton:document.querySelector("#menuButton"),difficultySetting:document.getElementById("difficultySetting"),startButton:document.querySelector("#startButton"),againButton:document.querySelector("#againButton"),resultMenuButton:document.querySelector("#resultMenuButton")}}function Hx(i,t){i.menu.classList.toggle("hidden",!t),i.result.classList.add("hidden")}function Hc(i,t){document.querySelectorAll("[data-mode]").forEach(e=>{e.classList.toggle("selected",e.dataset.mode===t)}),i.difficultySetting.classList.toggle("disabled",t!=="pve")}function xh(i){document.querySelectorAll("[data-difficulty]").forEach(t=>{t.classList.toggle("selected",t.dataset.difficulty===i)})}function Mh(i,t,e){const n=t.phase==="thinking";let r=t.turn===Ze?e.black:e.white;t.mode==="pve"&&(r=n?e.cpuThinking:t.turn===Ze?e.yourMove:e.cpuThinking),i.turnText.textContent=r,i.turnStone.className=`turn-stone ${t.turn===Ze?"black":"white"}`,i.turnPill.classList.toggle("thinking",n)}function kx(i,t,e,n){const r=vh[e];document.documentElement.lang=e,document.querySelectorAll("[data-i18n]").forEach(s=>{const o=s.dataset.i18n;r[o]&&(s.textContent=r[o])}),i.soundButton.setAttribute("aria-label",t.sound?r.sound:r.soundOff),i.soundButton.setAttribute("aria-pressed",String(t.sound)),i.soundButton.classList.toggle("muted",!t.sound),i.menuButton.textContent=r.menu,n(r)}const _e=tx(),Ci=new Nh,Ce=zx(),It=Hf(Ix(),Fx());let kc="en";const Sh=()=>vh[kc];let nr,ir,Ti=0;function Eh(){nr!==void 0&&(window.clearTimeout(nr),nr=void 0),ir!==void 0&&(window.clearTimeout(ir),ir=void 0)}const yh=()=>kx(Ce,It,kc,i=>Mh(Ce,It,i)),_s=()=>Mh(Ce,It,Sh()),Vc=i=>Hx(Ce,i);function vs(i,t){It.cursor.row=An(i,0,Le-1),It.cursor.column=An(t,0,Le-1);const e=Gn(It.cursor.row,It.cursor.column);_e.cursor.position.x=e.x,_e.cursor.position.z=e.z}function Vx(){Eh(),Ti++,It.board=hc(),It.history=[],It.turn=Ze,It.phase="play",vs(7,7),_e.clearStones(),Vc(!1),_s(),Ci.unlock()}function Gx(){Eh(),Ti++,It.phase="menu",It.board=hc(),It.history=[],_e.clearStones(),Vc(!0),_s()}function ac(i){const t=Sh();It.phase="over",_e.cursor.visible=!1,Ce.result.classList.remove("hidden"),i===0?(Ce.resultText.hidden=!1,Ce.resultTitle.textContent=t.draw,Ce.resultText.textContent=t.full):(Ce.resultText.hidden=!0,Ce.resultTitle.textContent=i===Ze?t.blackWins:t.whiteWins),_s()}function Th(i,t){if(It.phase!=="play"||It.board[$i(i,t)]!==uc)return;const e=It.turn;It.board[$i(i,t)]=e,It.history.push({row:i,column:t,stone:e}),_e.addStone(e,i,t,!0);const n=Gn(i,t);_e.lastMark.position.set(n.x,_e.cursor.position.y+.04,n.z),_e.lastMark.visible=!0,Ci.unlock(),Ci.play();const r=kh(It.board,i,t);if(r){_e.updateWinLine(r),It.phase="over";const s=Ti;ir=window.setTimeout(()=>{ir=void 0,It.phase==="over"&&Ti===s&&ac(e)},2e3);return}if(Hh(It.board)){ac(0);return}if(It.turn=zh(e),It.mode==="pve"&&It.turn!==Ze){It.phase="thinking";const s=Ti;nr=window.setTimeout(()=>{nr=void 0,Ti===s&&Wx()},380)}_s()}function Wx(){if(It.phase!=="thinking")return;const i=zf(It.history,mu,It.difficulty);if(!i){ac(0);return}vs(i.row,i.column),It.phase="play",Th(i.row,i.column)}function Xx(i,t){It.phase!=="play"&&It.phase!=="thinking"||vs(It.cursor.row+i,It.cursor.column+t)}const qx=kf(_e,Ce,{getPhase:()=>It.phase,getCursor:()=>It.cursor,setCursor:vs,moveCursor:Xx,placeStone:(i,t)=>Th(i,t),startMatch:Vx,openMenu:Gx,setMode:i=>{It.mode=i,Nx(i),Hc(Ce,i)},setDifficulty:i=>{It.difficulty=i,Ox(i),xh(i)},toggleSound:()=>{It.sound=!It.sound,Ci.setEnabled(It.sound),Ci.unlock(),yh()},unlockAudio:()=>Ci.unlock()});function Ah(i){requestAnimationFrame(Ah),qx.pollGamepad();const t=It.phase==="play"||It.phase==="thinking";_e.cursor.visible=t,ex(_e,i),_e.renderer.render(_e.scene,_e.camera)}window.addEventListener("resize",_e.resize);Bx().then(i=>{kc=i,Hc(Ce,It.mode),yh()});Vc(!0);Hc(Ce,It.mode);xh(It.difficulty);_e.cursor.visible=!1;requestAnimationFrame(Ah);
|