diff --git a/example/bundle/assets/BufferGeometryUtils-Cscy-pCt.js b/example/bundle/assets/BufferGeometryUtils-Cscy-pCt.js new file mode 100644 index 00000000..0e89a79a --- /dev/null +++ b/example/bundle/assets/BufferGeometryUtils-Cscy-pCt.js @@ -0,0 +1 @@ +import{f as j,B as D,bl as O,bg as H,bf as C}from"./ExtendedTriangle-Chm2bbkR.js";function N(r,c=!1){const n=r[0].index!==null,m=new Set(Object.keys(r[0].attributes)),s=new Set(Object.keys(r[0].morphAttributes)),g={},t={},d=r[0].morphTargetsRelative,u=new j;let a=0;for(let e=0;e{const E=new A.array.constructor(A.count*A.itemSize);a[h][x]=new A.constructor(E,A.itemSize,A.normalized)}))}const i=c*.5,p=Math.log10(1/c),T=Math.pow(10,p),M=i*T;for(let b=0;b{const f=n[3]-n[0],c=n[4]-n[1],m=n[5]-n[2],u=2*(f*c+c*m+m*f);e.nodeCount++,s?(e.leafNodeCount++,e.depth.min=Math.min(i,e.depth.min),e.depth.max=Math.max(i,e.depth.max),e.tris.min=Math.min(a,e.tris.min),e.tris.max=Math.max(a,e.tris.max),e.surfaceAreaScore+=u*y*a):(e.splits[t]++,e.surfaceAreaScore+=u*l)},o),e.tris.min===1/0&&(e.tris.min=0,e.tris.max=0),e.depth.min===1/0&&(e.depth.min=0,e.depth.max=0),e}function S(r){return r._roots.map((o,e)=>d(r,e))}function I(r){const o=new Set,e=[r];let i=0;for(;e.length;){const s=e.pop();if(!o.has(s)){o.add(s);for(let n in s){if(!Object.hasOwn(s,n))continue;i+=h(n);const t=s[n];t&&(typeof t=="object"||typeof t=="function")?x(t)||p()&&t instanceof SharedArrayBuffer||t instanceof ArrayBuffer?i+=t.byteLength:e.push(t):i+=h(t)}}}return i}export{I as e,S as g}; diff --git a/example/bundle/assets/ExtendedTriangle-Chm2bbkR.js b/example/bundle/assets/ExtendedTriangle-Chm2bbkR.js new file mode 100644 index 00000000..32886bf0 --- /dev/null +++ b/example/bundle/assets/ExtendedTriangle-Chm2bbkR.js @@ -0,0 +1,3818 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(i){if(i.ep)return;i.ep=!0;const r=e(i);fetch(i.href,r)}})();/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ca="166",Ng={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Fg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},vc=0,Qa=1,Mc=2,El=1,yc=2,rn=3,wn=0,we=1,on=2,Tn=0,fi=1,to=2,eo=3,no=4,Sc=5,Hn=100,Ec=101,bc=102,Tc=103,Ac=104,wc=200,Rc=201,Cc=202,Pc=203,qr=204,Yr=205,Ic=206,Lc=207,Dc=208,Uc=209,Nc=210,Fc=211,Oc=212,Bc=213,zc=214,Vc=0,Hc=1,kc=2,Os=3,Gc=4,Wc=5,Xc=6,qc=7,Pa=0,Yc=1,Kc=2,An=0,jc=1,$c=2,Zc=3,Jc=4,Qc=5,th=6,eh=7,io="attached",nh="detached",bl=300,_i=301,xi=302,Kr=303,jr=304,js=306,$r=1e3,cn=1001,Zr=1002,be=1003,ih=1004,$i=1005,Ee=1006,cr=1007,En=1008,dn=1009,Tl=1010,Al=1011,zi=1012,Ia=1013,Rn=1014,Ue=1015,ki=1016,La=1017,Da=1018,vi=1020,wl=35902,Rl=1021,Cl=1022,Te=1023,Pl=1024,Il=1025,pi=1026,Mi=1027,Ua=1028,$s=1029,Ll=1030,Na=1031,Fa=1033,Is=33776,Ls=33777,Ds=33778,Us=33779,Jr=35840,Qr=35841,ta=35842,ea=35843,na=36196,ia=37492,sa=37496,ra=37808,aa=37809,oa=37810,la=37811,ca=37812,ha=37813,ua=37814,da=37815,fa=37816,pa=37817,ma=37818,ga=37819,_a=37820,xa=37821,Ns=36492,va=36494,Ma=36495,Dl=36283,ya=36284,Sa=36285,Ea=36286,sh=2200,rh=2201,ah=2202,Bs=2300,ba=2301,hr=2302,hi=2400,ui=2401,zs=2402,Oa=2500,oh=2501,Og=0,Bg=1,zg=2,lh=3200,ch=3201,Gi=0,hh=1,Sn="",Ke="srgb",In="srgb-linear",Ba="display-p3",Zs="display-p3-linear",Vs="linear",Jt="srgb",Hs="rec709",ks="p3",Vg=0,qn=7680,Hg=34055,kg=34056,Gg=517,so=519,uh=512,dh=513,fh=514,Ul=515,ph=516,mh=517,gh=518,_h=519,Ta=35044,Wg=35048,ro="300 es",hn=2e3,Gs=2001;class Wn{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 i=this._listeners[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let r=0,a=i.length;r>8&255]+_e[s>>16&255]+_e[s>>24&255]+"-"+_e[t&255]+_e[t>>8&255]+"-"+_e[t>>16&15|64]+_e[t>>24&255]+"-"+_e[e&63|128]+_e[e>>8&255]+"-"+_e[e>>16&255]+_e[e>>24&255]+_e[n&255]+_e[n>>8&255]+_e[n>>16&255]+_e[n>>24&255]).toLowerCase()}function he(s,t,e){return Math.max(t,Math.min(e,s))}function za(s,t){return(s%t+t)%t}function xh(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function vh(s,t,e){return s!==t?(e-s)/(t-s):0}function Bi(s,t,e){return(1-e)*s+e*t}function Mh(s,t,e,n){return Bi(s,t,1-Math.exp(-e*n))}function yh(s,t=1){return t-Math.abs(za(s,t*2)-t)}function Sh(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function Eh(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function bh(s,t){return s+Math.floor(Math.random()*(t-s+1))}function Th(s,t){return s+Math.random()*(t-s)}function Ah(s){return s*(.5-Math.random())}function wh(s){s!==void 0&&(ao=s);let t=ao+=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 Rh(s){return s*Oi}function Ch(s){return s*yi}function Ph(s){return(s&s-1)===0&&s!==0}function Ih(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Lh(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Dh(s,t,e,n,i){const r=Math.cos,a=Math.sin,o=r(e/2),l=a(e/2),c=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),p=r((n-t)/2),g=a((n-t)/2);switch(i){case"XYX":s.set(o*h,l*u,l*d,o*c);break;case"YZY":s.set(l*d,o*h,l*u,o*c);break;case"ZXZ":s.set(l*u,l*d,o*h,o*c);break;case"XZX":s.set(o*h,l*g,l*p,o*c);break;case"YXY":s.set(l*p,o*h,l*g,o*c);break;case"ZYZ":s.set(l*g,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ke(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Yt(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Xg={DEG2RAD:Oi,RAD2DEG:yi,generateUUID:We,clamp:he,euclideanModulo:za,mapLinear:xh,inverseLerp:vh,lerp:Bi,damp:Mh,pingpong:yh,smoothstep:Sh,smootherstep:Eh,randInt:bh,randFloat:Th,randFloatSpread:Ah,seededRandom:wh,degToRad:Rh,radToDeg:Ch,isPowerOfTwo:Ph,ceilPowerOfTwo:Ih,floorPowerOfTwo:Lh,setQuaternionFromProperEuler:Dh,normalize:Yt,denormalize:ke};class Tt{constructor(t=0,e=0){Tt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(he(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Dt{constructor(t,e,n,i,r,a,o,l,c){Dt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,l,c)}set(t,e,n,i,r,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],_=i[0],m=i[3],f=i[6],y=i[1],x=i[4],b=i[7],L=i[2],T=i[5],A=i[8];return r[0]=a*_+o*y+l*L,r[3]=a*m+o*x+l*T,r[6]=a*f+o*b+l*A,r[1]=c*_+h*y+u*L,r[4]=c*m+h*x+u*T,r[7]=c*f+h*b+u*A,r[2]=d*_+p*y+g*L,r[5]=d*m+p*x+g*T,r[8]=d*f+p*b+g*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+i*r*c-i*a*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*r,p=c*r-a*l,g=e*u+n*d+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return t[0]=u*_,t[1]=(i*c-h*n)*_,t[2]=(o*n-i*a)*_,t[3]=d*_,t[4]=(h*e-i*l)*_,t[5]=(i*r-o*e)*_,t[6]=p*_,t[7]=(n*l-c*e)*_,t[8]=(a*e-n*r)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-i*c,i*l,-i*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(ur.makeScale(t,e)),this}rotate(t){return this.premultiply(ur.makeRotation(-t)),this}translate(t,e){return this.premultiply(ur.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const ur=new Dt;function Nl(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}function Vi(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Uh(){const s=Vi("canvas");return s.style.display="block",s}const oo={};function Va(s){s in oo||(oo[s]=!0,console.warn(s))}function Nh(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const lo=new Dt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),co=new Dt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Zi={[In]:{transfer:Vs,primaries:Hs,toReference:s=>s,fromReference:s=>s},[Ke]:{transfer:Jt,primaries:Hs,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[Zs]:{transfer:Vs,primaries:ks,toReference:s=>s.applyMatrix3(co),fromReference:s=>s.applyMatrix3(lo)},[Ba]:{transfer:Jt,primaries:ks,toReference:s=>s.convertSRGBToLinear().applyMatrix3(co),fromReference:s=>s.applyMatrix3(lo).convertLinearToSRGB()}},Fh=new Set([In,Zs]),Xt={enabled:!0,_workingColorSpace:In,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!Fh.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,t,e){if(this.enabled===!1||t===e||!t||!e)return s;const n=Zi[t].toReference,i=Zi[e].fromReference;return i(n(s))},fromWorkingColorSpace:function(s,t){return this.convert(s,this._workingColorSpace,t)},toWorkingColorSpace:function(s,t){return this.convert(s,t,this._workingColorSpace)},getPrimaries:function(s){return Zi[s].primaries},getTransfer:function(s){return s===Sn?Vs:Zi[s].transfer}};function mi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function dr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Yn;class Oh{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Yn===void 0&&(Yn=Vi("canvas")),Yn.width=t.width,Yn.height=t.height;const n=Yn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Yn}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=Vi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==bl)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case $r:t.x=t.x-Math.floor(t.x);break;case cn:t.x=t.x<0?0:1;break;case Zr: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 $r:t.y=t.y-Math.floor(t.y);break;case cn:t.y=t.y<0?0:1;break;case Zr: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++}}Me.DEFAULT_IMAGE=null;Me.DEFAULT_MAPPING=bl;Me.DEFAULT_ANISOTROPY=1;class Zt{constructor(t=0,e=0,n=0,i=1){Zt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=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,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],g=l[9],_=l[2],m=l[6],f=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,b=(p+1)/2,L=(f+1)/2,T=(h+d)/4,A=(u+_)/4,I=(g+m)/4;return x>b&&x>L?x<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(x),i=T/n,r=A/n):b>L?b<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(b),n=T/i,r=I/i):L<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(L),n=A/r,i=I/r),this.set(n,i,r,e),this}let y=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(m-g)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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 Vh extends Wn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Zt(0,0,t,e),this.scissorTest=!1,this.viewport=new Zt(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ee,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new Me(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o=0?1:-1,x=1-f*f;if(x>Number.EPSILON){const L=Math.sqrt(x),T=Math.atan2(L,f*y);m=Math.sin(m*T)/L,o=Math.sin(o*T)/L}const b=o*y;if(l=l*m+d*b,c=c*m+p*b,h=h*m+g*b,u=u*m+_*b,m===1-o){const L=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=L,c*=L,h*=L,u*=L}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=r[a],d=r[a+1],p=r[a+2],g=r[a+3];return t[e]=o*g+h*u+l*p-c*d,t[e+1]=l*g+h*d+c*u-o*p,t[e+2]=c*g+h*p+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(r/2),d=l(n/2),p=l(i/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"YZX":this._x=d*h*u+c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u-d*p*g;break;case"XZY":this._x=d*h*u-c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(a-i)*p}else if(n>o&&n>u){const p=2*Math.sqrt(1+n-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(r+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-n-u);this._w=(r-c)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+u-n-o);this._w=(a-i)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.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(he(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 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,i=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+i*c-r*l,this._y=i*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*t._w+n*t._x+i*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*n+e*this._x,this._y=p*i+e*this._y,this._z=p*r+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,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(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class R{constructor(t=0,e=0,n=0){R.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(ho.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ho.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=i+l*u+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,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 pr.copy(this).projectOnVector(t),this.sub(pr)}reflect(t){return this.sub(pr.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(he(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,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 pr=new R,ho=new un;class Ne{constructor(t=new R(1/0,1/0,1/0),e=new R(-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;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,ze),ze.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),Qi.subVectors(this.max,wi),Kn.subVectors(t.a,wi),jn.subVectors(t.b,wi),$n.subVectors(t.c,wi),pn.subVectors(jn,Kn),mn.subVectors($n,jn),Dn.subVectors(Kn,$n);let e=[0,-pn.z,pn.y,0,-mn.z,mn.y,0,-Dn.z,Dn.y,pn.z,0,-pn.x,mn.z,0,-mn.x,Dn.z,0,-Dn.x,-pn.y,pn.x,0,-mn.y,mn.x,0,-Dn.y,Dn.x,0];return!mr(e,Kn,jn,$n,Qi)||(e=[1,0,0,0,1,0,0,0,1],!mr(e,Kn,jn,$n,Qi))?!1:(ts.crossVectors(pn,mn),e=[ts.x,ts.y,ts.z],mr(e,Kn,jn,$n,Qi))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ze).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ze).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:(Je[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Je[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Je[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Je[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Je[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Je[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Je[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Je[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Je),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 Je=[new R,new R,new R,new R,new R,new R,new R,new R],ze=new R,Ji=new Ne,Kn=new R,jn=new R,$n=new R,pn=new R,mn=new R,Dn=new R,wi=new R,Qi=new R,ts=new R,Un=new R;function mr(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){Un.fromArray(s,r);const o=i.x*Math.abs(Un.x)+i.y*Math.abs(Un.y)+i.z*Math.abs(Un.z),l=t.dot(Un),c=e.dot(Un),h=n.dot(Un);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Hh=new Ne,Ri=new R,gr=new R;class Re{constructor(t=new R,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):Hh.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;rthis.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;Ri.subVectors(t,this.center);const e=Ri.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Ri,i/n),this.radius+=i}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):(gr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ri.copy(t.center).add(gr)),this.expandByPoint(Ri.copy(t.center).sub(gr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Qe=new R,_r=new R,es=new R,gn=new R,xr=new R,ns=new R,vr=new R;class Wi{constructor(t=new R,e=new R(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,Qe)),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=Qe.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Qe.copy(this.origin).addScaledVector(this.direction,e),Qe.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){_r.copy(t).add(e).multiplyScalar(.5),es.copy(e).sub(t).normalize(),gn.copy(this.origin).sub(_r);const r=t.distanceTo(e)*.5,a=-this.direction.dot(es),o=gn.dot(this.direction),l=-gn.dot(es),c=gn.lengthSq(),h=Math.abs(1-a*a);let u,d,p,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,p=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),p=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),p=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),p=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(_r).addScaledVector(es,d),p}intersectSphere(t,e){Qe.subVectors(t.center,this.origin);const n=Qe.dot(this.direction),i=Qe.dot(Qe)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,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,i,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Qe)!==null}intersectTriangle(t,e,n,i,r){xr.subVectors(e,t),ns.subVectors(n,t),vr.crossVectors(xr,ns);let a=this.direction.dot(vr),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;gn.subVectors(this.origin,t);const l=o*this.direction.dot(ns.crossVectors(gn,ns));if(l<0)return null;const c=o*this.direction.dot(xr.cross(gn));if(c<0||l+c>a)return null;const h=-o*gn.dot(vr);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Rt{constructor(t,e,n,i,r,a,o,l,c,h,u,d,p,g,_,m){Rt.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,i,r,a,o,l,c,h,u,d,p,g,_,m)}set(t,e,n,i,r,a,o,l,c,h,u,d,p,g,_,m){const f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=i,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=g,f[11]=_,f[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 Rt().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,i=1/Zn.setFromMatrixColumn(t,0).length(),r=1/Zn.setFromMatrixColumn(t,1).length(),a=1/Zn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,p=a*u,g=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=p+g*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=g+p*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,p=l*u,g=c*h,_=c*u;e[0]=d+_*o,e[4]=g*o-p,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=_+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,p=l*u,g=c*h,_=c*u;e[0]=d-_*o,e[4]=-a*u,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,p=a*u,g=o*h,_=o*u;e[0]=l*h,e[4]=g*c-p,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=p*c-g,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,p=a*c,g=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=g*u+p,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=p*u+g,e[10]=d-_*u}else if(t.order==="XZY"){const d=a*l,p=a*c,g=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=a*h,e[9]=p*u-g,e[2]=g*u-p,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(kh,t,Gh)}lookAt(t,e,n){const i=this.elements;return Ie.subVectors(t,e),Ie.lengthSq()===0&&(Ie.z=1),Ie.normalize(),_n.crossVectors(n,Ie),_n.lengthSq()===0&&(Math.abs(n.z)===1?Ie.x+=1e-4:Ie.z+=1e-4,Ie.normalize(),_n.crossVectors(n,Ie)),_n.normalize(),is.crossVectors(Ie,_n),i[0]=_n.x,i[4]=is.x,i[8]=Ie.x,i[1]=_n.y,i[5]=is.y,i[9]=Ie.y,i[2]=_n.z,i[6]=is.z,i[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,i=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],_=n[6],m=n[10],f=n[14],y=n[3],x=n[7],b=n[11],L=n[15],T=i[0],A=i[4],I=i[8],S=i[12],v=i[1],C=i[5],z=i[9],B=i[13],H=i[2],Y=i[6],k=i[10],Z=i[14],G=i[3],ct=i[7],pt=i[11],mt=i[15];return r[0]=a*T+o*v+l*H+c*G,r[4]=a*A+o*C+l*Y+c*ct,r[8]=a*I+o*z+l*k+c*pt,r[12]=a*S+o*B+l*Z+c*mt,r[1]=h*T+u*v+d*H+p*G,r[5]=h*A+u*C+d*Y+p*ct,r[9]=h*I+u*z+d*k+p*pt,r[13]=h*S+u*B+d*Z+p*mt,r[2]=g*T+_*v+m*H+f*G,r[6]=g*A+_*C+m*Y+f*ct,r[10]=g*I+_*z+m*k+f*pt,r[14]=g*S+_*B+m*Z+f*mt,r[3]=y*T+x*v+b*H+L*G,r[7]=y*A+x*C+b*Y+L*ct,r[11]=y*I+x*z+b*k+L*pt,r[15]=y*S+x*B+b*Z+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],i=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],p=t[14],g=t[3],_=t[7],m=t[11],f=t[15];return g*(+r*l*u-i*c*u-r*o*d+n*c*d+i*o*p-n*l*p)+_*(+e*l*p-e*c*d+r*a*d-i*a*p+i*c*h-r*l*h)+m*(+e*c*u-e*o*p-r*a*u+n*a*p+r*o*h-n*c*h)+f*(-i*o*h-e*l*u+e*o*d+i*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],g=t[12],_=t[13],m=t[14],f=t[15],y=u*m*c-_*d*c+_*l*p-o*m*p-u*l*f+o*d*f,x=g*d*c-h*m*c-g*l*p+a*m*p+h*l*f-a*d*f,b=h*_*c-g*u*c+g*o*p-a*_*p-h*o*f+a*u*f,L=g*u*l-h*_*l-g*o*d+a*_*d+h*o*m-a*u*m,T=e*y+n*x+i*b+r*L;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return t[0]=y*A,t[1]=(_*d*r-u*m*r-_*i*p+n*m*p+u*i*f-n*d*f)*A,t[2]=(o*m*r-_*l*r+_*i*c-n*m*c-o*i*f+n*l*f)*A,t[3]=(u*l*r-o*d*r-u*i*c+n*d*c+o*i*p-n*l*p)*A,t[4]=x*A,t[5]=(h*m*r-g*d*r+g*i*p-e*m*p-h*i*f+e*d*f)*A,t[6]=(g*l*r-a*m*r-g*i*c+e*m*c+a*i*f-e*l*f)*A,t[7]=(a*d*r-h*l*r+h*i*c-e*d*c-a*i*p+e*l*p)*A,t[8]=b*A,t[9]=(g*u*r-h*_*r-g*n*p+e*_*p+h*n*f-e*u*f)*A,t[10]=(a*_*r-g*o*r+g*n*c-e*_*c-a*n*f+e*o*f)*A,t[11]=(h*o*r-a*u*r-h*n*c+e*u*c+a*n*p-e*o*p)*A,t[12]=L*A,t[13]=(h*_*i-g*u*i+g*n*d-e*_*d-h*n*m+e*u*m)*A,t[14]=(g*o*i-a*_*i-g*n*l+e*_*l+a*n*m-e*o*m)*A,t[15]=(a*u*i-h*o*i+h*n*l-e*u*l-a*n*d+e*o*d)*A,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,u=o+o,d=r*c,p=r*h,g=r*u,_=a*h,m=a*u,f=o*u,y=l*c,x=l*h,b=l*u,L=n.x,T=n.y,A=n.z;return i[0]=(1-(_+f))*L,i[1]=(p+b)*L,i[2]=(g-x)*L,i[3]=0,i[4]=(p-b)*T,i[5]=(1-(d+f))*T,i[6]=(m+y)*T,i[7]=0,i[8]=(g+x)*A,i[9]=(m-y)*A,i[10]=(1-(d+_))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=Zn.set(i[0],i[1],i[2]).length();const a=Zn.set(i[4],i[5],i[6]).length(),o=Zn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],Ve.copy(this);const c=1/r,h=1/a,u=1/o;return Ve.elements[0]*=c,Ve.elements[1]*=c,Ve.elements[2]*=c,Ve.elements[4]*=h,Ve.elements[5]*=h,Ve.elements[6]*=h,Ve.elements[8]*=u,Ve.elements[9]*=u,Ve.elements[10]*=u,e.setFromRotationMatrix(Ve),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,r,a,o=hn){const l=this.elements,c=2*r/(e-t),h=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let p,g;if(o===hn)p=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===Gs)p=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=hn){const l=this.elements,c=1/(e-t),h=1/(n-i),u=1/(a-r),d=(e+t)*c,p=(n+i)*h;let g,_;if(o===hn)g=(a+r)*u,_=-2*u;else if(o===Gs)g=r*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Zn=new R,Ve=new Rt,kh=new R(0,0,0),Gh=new R(1,1,1),_n=new R,is=new R,Ie=new R,uo=new Rt,fo=new un;class Xe{constructor(t=0,e=0,n=0,i=Xe.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(he(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-he(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(he(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-he(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(he(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-he(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),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 uo.makeRotationFromQuaternion(t),this.setFromRotationMatrix(uo,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return fo.setFromEuler(this),this.setFromQuaternion(fo,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}}Xe.DEFAULT_ORDER="XYZ";class Ha{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}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;n0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){He.subVectors(i,e),en.subVectors(n,e),yr.subVectors(t,e);const a=He.dot(He),o=He.dot(en),l=He.dot(yr),c=en.dot(en),h=en.dot(yr),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,p=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-p-g,g,p)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,nn)===null?!1:nn.x>=0&&nn.y>=0&&nn.x+nn.y<=1}static getInterpolation(t,e,n,i,r,a,o,l){return this.getBarycoord(t,e,n,i,nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,nn.x),l.addScaledVector(a,nn.y),l.addScaledVector(o,nn.z),l)}static isFrontFacing(t,e,n,i){return He.subVectors(n,e),en.subVectors(t,e),He.cross(en).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return He.subVectors(this.c,this.b),en.subVectors(this.a,this.b),He.cross(en).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ge.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ge.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Ge.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Ge.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ge.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,o;ti.subVectors(i,n),ei.subVectors(r,n),Sr.subVectors(t,n);const l=ti.dot(Sr),c=ei.dot(Sr);if(l<=0&&c<=0)return e.copy(n);Er.subVectors(t,i);const h=ti.dot(Er),u=ei.dot(Er);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(ti,a);br.subVectors(t,r);const p=ti.dot(br),g=ei.dot(br);if(g>=0&&p<=g)return e.copy(r);const _=p*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(ei,o);const m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return vo.subVectors(r,i),o=(u-h)/(u-h+(p-g)),e.copy(i).addScaledVector(vo,o);const f=1/(m+_+d);return a=_*f,o=d*f,e.copy(n).addScaledVector(ti,a).addScaledVector(ei,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const zl={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},xn={h:0,s:0,l:0},rs={h:0,s:0,l:0};function Tr(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}class Mt{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 i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ke){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Xt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Xt.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Xt.workingColorSpace){if(t=za(t,1),e=he(e,0,1),n=he(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Tr(a,r,t+1/3),this.g=Tr(a,r,t),this.b=Tr(a,r,t-1/3)}return Xt.toWorkingColorSpace(this,i),this}setStyle(t,e=Ke){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,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=Ke){const n=zl[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=mi(t.r),this.g=mi(t.g),this.b=mi(t.b),this}copyLinearToSRGB(t){return this.r=dr(t.r),this.g=dr(t.g),this.b=dr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ke){return Xt.fromWorkingColorSpace(xe.copy(this),t),Math.round(he(xe.r*255,0,255))*65536+Math.round(he(xe.g*255,0,255))*256+Math.round(he(xe.b*255,0,255))}getHexString(t=Ke){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xt.workingColorSpace){Xt.fromWorkingColorSpace(xe.copy(this),e);const n=xe.r,i=xe.g,r=xe.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(i-r)/u+(i0!=t>0&&this.version++,this._alphaTest=t}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 i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.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!==fi&&(n.blending=this.blending),this.side!==wn&&(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!==qr&&(n.blendSrc=this.blendSrc),this.blendDst!==Yr&&(n.blendDst=this.blendDst),this.blendEquation!==Hn&&(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!==Os&&(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!==so&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==qn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==qn&&(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 i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(e){const r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}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 i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].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.")}onBeforeRender(){console.warn("Material: onBeforeRender() has been removed.")}}class Vl extends qe{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mt(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 Xe,this.combine=Pa,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 ln=jh();function jh(){const s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;!(c&8388608);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,r[l]=c|h}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function $h(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=he(s,-65504,65504),ln.floatView[0]=s;const t=ln.uint32View[0],e=t>>23&511;return ln.baseTable[e]+((t&8388607)>>ln.shiftTable[e])}function Zh(s){const t=s>>10;return ln.uint32View[0]=ln.mantissaTable[ln.offsetTable[t]+(s&1023)]+ln.exponentTable[t],ln.floatView[0]}const Yg={toHalfFloat:$h,fromHalfFloat:Zh},le=new R,as=new Tt;class pe{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=Ta,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ue,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Va("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);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 l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u0&&(i[l]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.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 i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const r=t.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,p=u.length;d0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r(t.far-t.near)**2))&&(Mo.copy(r).invert(),Nn.copy(t.ray).applyMatrix4(Mo),!(n.boundingBox!==null&&Nn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Nn)))}_computeIntersections(t,e,n){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],f=a[m.materialIndex],y=Math.max(m.start,p.start),x=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let b=y,L=x;be.far?null:{distance:c,point:fs.clone(),object:s}}function ps(s,t,e,n,i,r,a,o,l,c){s.getVertexPosition(o,ii),s.getVertexPosition(l,si),s.getVertexPosition(c,ri);const h=Qh(s,t,e,n,ii,si,ri,ds);if(h){i&&(cs.fromBufferAttribute(i,o),hs.fromBufferAttribute(i,l),us.fromBufferAttribute(i,c),h.uv=Ge.getInterpolation(ds,ii,si,ri,cs,hs,us,new Tt)),r&&(cs.fromBufferAttribute(r,o),hs.fromBufferAttribute(r,l),us.fromBufferAttribute(r,c),h.uv1=Ge.getInterpolation(ds,ii,si,ri,cs,hs,us,new Tt)),a&&(So.fromBufferAttribute(a,o),Eo.fromBufferAttribute(a,l),bo.fromBufferAttribute(a,c),h.normal=Ge.getInterpolation(ds,ii,si,ri,So,Eo,bo,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new R,materialIndex:0};Ge.getNormal(ii,si,ri,u.normal),h.face=u}return h}class Xi extends ce{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,p=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,i,a,2),g("x","z","y",1,-1,t,n,-e,i,a,3),g("x","y","z",1,-1,t,e,n,i,r,4),g("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new Vt(c,3)),this.setAttribute("normal",new Vt(h,3)),this.setAttribute("uv",new Vt(u,2));function g(_,m,f,y,x,b,L,T,A,I,S){const v=b/A,C=L/I,z=b/2,B=L/2,H=T/2,Y=A+1,k=I+1;let Z=0,G=0;const ct=new R;for(let pt=0;pt0?1:-1,h.push(ct.x,ct.y,ct.z),u.push(Ot/A),u.push(1-pt/I),Z+=1}}for(let pt=0;pt0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Wl extends ie{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=hn}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 vn=new R,To=new Tt,Ao=new Tt;class De extends Wl{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=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=yi*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Oi*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return yi*2*Math.atan(Math.tan(Oi*.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){vn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(vn.x,vn.y).multiplyScalar(-t/vn.z),vn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vn.x,vn.y).multiplyScalar(-t/vn.z)}getViewSize(t,e){return this.getViewBounds(t,To,Ao),e.subVectors(Ao,To)}setViewOffset(t,e,n,i,r,a){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=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Oi*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,e-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,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 ai=-90,oi=1;class su extends ie{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new De(ai,oi,t,e);i.layers=this.layers,this.add(i);const r=new De(ai,oi,t,e);r.layers=this.layers,this.add(r);const a=new De(ai,oi,t,e);a.layers=this.layers,this.add(a);const o=new De(ai,oi,t,e);o.layers=this.layers,this.add(o);const l=new De(ai,oi,t,e);l.layers=this.layers,this.add(l);const c=new De(ai,oi,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,l]=e;for(const c of e)this.remove(c);if(t===hn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Gs)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,a),t.setRenderTarget(n,2,i),t.render(e,o),t.setRenderTarget(n,3,i),t.render(e,l),t.setRenderTarget(n,4,i),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(u,d,p),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Xl extends Me{constructor(t,e,n,i,r,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:_i,super(t,e,n,i,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ru extends Cn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Xl(i,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:Ee}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:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new Xi(5,5,5),r=new Pn({name:"CubemapFromEquirect",uniforms:Si(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:we,blending:Tn});r.uniforms.tEquirect.value=e;const a=new Ae(i,r),o=e.minFilter;return e.minFilter===En&&(e.minFilter=Ee),new su(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}}const Rr=new R,au=new R,ou=new Dt;class an{constructor(t=new R(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Rr.subVectors(n,e).cross(au.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Rr),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||ou.getNormalMatrix(t),i=this.coplanarPoint(Rr).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Fn=new Re,ms=new R;class Js{constructor(t=new an,e=new an,n=new an,i=new an,r=new an,a=new an){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),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=hn){const n=this.planes,i=t.elements,r=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],d=i[7],p=i[8],g=i[9],_=i[10],m=i[11],f=i[12],y=i[13],x=i[14],b=i[15];if(n[0].setComponents(l-r,d-c,m-p,b-f).normalize(),n[1].setComponents(l+r,d+c,m+p,b+f).normalize(),n[2].setComponents(l+a,d+h,m+g,b+y).normalize(),n[3].setComponents(l-a,d-h,m-g,b-y).normalize(),n[4].setComponents(l-o,d-u,m-_,b-x).normalize(),e===hn)n[5].setComponents(l+o,d+u,m+_,b+x).normalize();else if(e===Gs)n[5].setComponents(o,u,_,x).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(),Fn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Fn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fn)}intersectsSprite(t){return Fn.center.set(0,0,0),Fn.radius=.7071067811865476,Fn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fn)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,ms.y=i.normal.y>0?t.max.y:t.min.y,ms.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ms)<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)}}function ql(){let s=null,t=!1,e=null,n=null;function i(r,a){e(r,a),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function lu(s){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=s.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=s.SHORT;else if(c instanceof Uint32Array)p=s.UNSIGNED_INT;else if(c instanceof Int32Array)p=s.INT;else if(c instanceof Int8Array)p=s.BYTE;else if(c instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l._updateRange,d=l.updateRanges;if(s.bindBuffer(c,o),u.count===-1&&d.length===0&&s.bufferSubData(c,0,h),d.length!==0){for(let p=0,g=d.length;p 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,Tu=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,Au=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,wu=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,Ru=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,Cu=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,Pu=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,Iu=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,Lu=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,Du=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Uu=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,Nu=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Fu=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Ou=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Bu=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,zu="gl_FragColor = linearToOutputTexel( gl_FragColor );",Vu=` +const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( + vec3( 0.8224621, 0.177538, 0.0 ), + vec3( 0.0331941, 0.9668058, 0.0 ), + vec3( 0.0170827, 0.0723974, 0.9105199 ) +); +const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( + vec3( 1.2249401, - 0.2249404, 0.0 ), + vec3( - 0.0420569, 1.0420571, 0.0 ), + vec3( - 0.0196376, - 0.0786361, 1.0982735 ) +); +vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { + return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); +} +vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { + return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); +} +vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferOETF( in vec4 value ) { + 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 ); +} +vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return sRGBTransferOETF( value ); +}`,Hu=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,ku=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,Gu=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Wu=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Xu=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,qu=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Yu=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Ku=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,ju=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,$u=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,Zu=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Ju=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Qu=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,td=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,ed=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,nd=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,id=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,sd=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,rd=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ad=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,od=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,ld=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,cd=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,hd=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,ud=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,dd=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,fd=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,pd=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,md=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,gd=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,_d=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,xd=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,vd=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,Md=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,yd=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,Sd=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,Ed=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,bd=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,Td=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,Ad=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,wd=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,Rd=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Cd=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Pd=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,Id=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,Ld=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,Dd=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Ud=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Nd=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,Fd=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Od=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,Bd=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,zd=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Vd=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Hd=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,kd=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Gd=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,Wd=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,Xd=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,qd=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,Yd=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Kd=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,jd=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,$d=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Zd=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,Jd=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Qd=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tf=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,ef=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,nf=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,sf=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + + #else + + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,rf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,af=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,of=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,lf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const cf=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,hf=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,uf=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,df=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ff=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,pf=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,mf=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,gf=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`,_f=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,xf=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,vf=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,Mf=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,yf=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Sf=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Ef=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,bf=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,Tf=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Af=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,wf=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,Rf=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,Cf=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,Pf=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,If=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Lf=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Df=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Uf=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Nf=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Ff=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Of=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Bf=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,zf=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Vf=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,Hf=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,kf=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Lt={alphahash_fragment:cu,alphahash_pars_fragment:hu,alphamap_fragment:uu,alphamap_pars_fragment:du,alphatest_fragment:fu,alphatest_pars_fragment:pu,aomap_fragment:mu,aomap_pars_fragment:gu,batching_pars_vertex:_u,batching_vertex:xu,begin_vertex:vu,beginnormal_vertex:Mu,bsdfs:yu,iridescence_fragment:Su,bumpmap_pars_fragment:Eu,clipping_planes_fragment:bu,clipping_planes_pars_fragment:Tu,clipping_planes_pars_vertex:Au,clipping_planes_vertex:wu,color_fragment:Ru,color_pars_fragment:Cu,color_pars_vertex:Pu,color_vertex:Iu,common:Lu,cube_uv_reflection_fragment:Du,defaultnormal_vertex:Uu,displacementmap_pars_vertex:Nu,displacementmap_vertex:Fu,emissivemap_fragment:Ou,emissivemap_pars_fragment:Bu,colorspace_fragment:zu,colorspace_pars_fragment:Vu,envmap_fragment:Hu,envmap_common_pars_fragment:ku,envmap_pars_fragment:Gu,envmap_pars_vertex:Wu,envmap_physical_pars_fragment:ed,envmap_vertex:Xu,fog_vertex:qu,fog_pars_vertex:Yu,fog_fragment:Ku,fog_pars_fragment:ju,gradientmap_pars_fragment:$u,lightmap_pars_fragment:Zu,lights_lambert_fragment:Ju,lights_lambert_pars_fragment:Qu,lights_pars_begin:td,lights_toon_fragment:nd,lights_toon_pars_fragment:id,lights_phong_fragment:sd,lights_phong_pars_fragment:rd,lights_physical_fragment:ad,lights_physical_pars_fragment:od,lights_fragment_begin:ld,lights_fragment_maps:cd,lights_fragment_end:hd,logdepthbuf_fragment:ud,logdepthbuf_pars_fragment:dd,logdepthbuf_pars_vertex:fd,logdepthbuf_vertex:pd,map_fragment:md,map_pars_fragment:gd,map_particle_fragment:_d,map_particle_pars_fragment:xd,metalnessmap_fragment:vd,metalnessmap_pars_fragment:Md,morphinstance_vertex:yd,morphcolor_vertex:Sd,morphnormal_vertex:Ed,morphtarget_pars_vertex:bd,morphtarget_vertex:Td,normal_fragment_begin:Ad,normal_fragment_maps:wd,normal_pars_fragment:Rd,normal_pars_vertex:Cd,normal_vertex:Pd,normalmap_pars_fragment:Id,clearcoat_normal_fragment_begin:Ld,clearcoat_normal_fragment_maps:Dd,clearcoat_pars_fragment:Ud,iridescence_pars_fragment:Nd,opaque_fragment:Fd,packing:Od,premultiplied_alpha_fragment:Bd,project_vertex:zd,dithering_fragment:Vd,dithering_pars_fragment:Hd,roughnessmap_fragment:kd,roughnessmap_pars_fragment:Gd,shadowmap_pars_fragment:Wd,shadowmap_pars_vertex:Xd,shadowmap_vertex:qd,shadowmask_pars_fragment:Yd,skinbase_vertex:Kd,skinning_pars_vertex:jd,skinning_vertex:$d,skinnormal_vertex:Zd,specularmap_fragment:Jd,specularmap_pars_fragment:Qd,tonemapping_fragment:tf,tonemapping_pars_fragment:ef,transmission_fragment:nf,transmission_pars_fragment:sf,uv_pars_fragment:rf,uv_pars_vertex:af,uv_vertex:of,worldpos_vertex:lf,background_vert:cf,background_frag:hf,backgroundCube_vert:uf,backgroundCube_frag:df,cube_vert:ff,cube_frag:pf,depth_vert:mf,depth_frag:gf,distanceRGBA_vert:_f,distanceRGBA_frag:xf,equirect_vert:vf,equirect_frag:Mf,linedashed_vert:yf,linedashed_frag:Sf,meshbasic_vert:Ef,meshbasic_frag:bf,meshlambert_vert:Tf,meshlambert_frag:Af,meshmatcap_vert:wf,meshmatcap_frag:Rf,meshnormal_vert:Cf,meshnormal_frag:Pf,meshphong_vert:If,meshphong_frag:Lf,meshphysical_vert:Df,meshphysical_frag:Uf,meshtoon_vert:Nf,meshtoon_frag:Ff,points_vert:Of,points_frag:Bf,shadow_vert:zf,shadow_frag:Vf,sprite_vert:Hf,sprite_frag:kf},it={common:{diffuse:{value:new Mt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Dt},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Dt}},envmap:{envMap:{value:null},envMapRotation:{value:new Dt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Dt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Dt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Dt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Dt},normalScale:{value:new Tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Dt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Dt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Dt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Dt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Mt(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 Mt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0},uvTransform:{value:new Dt}},sprite:{diffuse:{value:new Mt(16777215)},opacity:{value:1},center:{value:new Tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Dt},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0}}},je={basic:{uniforms:Se([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.fog]),vertexShader:Lt.meshbasic_vert,fragmentShader:Lt.meshbasic_frag},lambert:{uniforms:Se([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new Mt(0)}}]),vertexShader:Lt.meshlambert_vert,fragmentShader:Lt.meshlambert_frag},phong:{uniforms:Se([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new Mt(0)},specular:{value:new Mt(1118481)},shininess:{value:30}}]),vertexShader:Lt.meshphong_vert,fragmentShader:Lt.meshphong_frag},standard:{uniforms:Se([it.common,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.roughnessmap,it.metalnessmap,it.fog,it.lights,{emissive:{value:new Mt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Lt.meshphysical_vert,fragmentShader:Lt.meshphysical_frag},toon:{uniforms:Se([it.common,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.gradientmap,it.fog,it.lights,{emissive:{value:new Mt(0)}}]),vertexShader:Lt.meshtoon_vert,fragmentShader:Lt.meshtoon_frag},matcap:{uniforms:Se([it.common,it.bumpmap,it.normalmap,it.displacementmap,it.fog,{matcap:{value:null}}]),vertexShader:Lt.meshmatcap_vert,fragmentShader:Lt.meshmatcap_frag},points:{uniforms:Se([it.points,it.fog]),vertexShader:Lt.points_vert,fragmentShader:Lt.points_frag},dashed:{uniforms:Se([it.common,it.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Lt.linedashed_vert,fragmentShader:Lt.linedashed_frag},depth:{uniforms:Se([it.common,it.displacementmap]),vertexShader:Lt.depth_vert,fragmentShader:Lt.depth_frag},normal:{uniforms:Se([it.common,it.bumpmap,it.normalmap,it.displacementmap,{opacity:{value:1}}]),vertexShader:Lt.meshnormal_vert,fragmentShader:Lt.meshnormal_frag},sprite:{uniforms:Se([it.sprite,it.fog]),vertexShader:Lt.sprite_vert,fragmentShader:Lt.sprite_frag},background:{uniforms:{uvTransform:{value:new Dt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Lt.background_vert,fragmentShader:Lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Dt}},vertexShader:Lt.backgroundCube_vert,fragmentShader:Lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Lt.cube_vert,fragmentShader:Lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Lt.equirect_vert,fragmentShader:Lt.equirect_frag},distanceRGBA:{uniforms:Se([it.common,it.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Lt.distanceRGBA_vert,fragmentShader:Lt.distanceRGBA_frag},shadow:{uniforms:Se([it.lights,it.fog,{color:{value:new Mt(0)},opacity:{value:1}}]),vertexShader:Lt.shadow_vert,fragmentShader:Lt.shadow_frag}};je.physical={uniforms:Se([je.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Dt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Dt},clearcoatNormalScale:{value:new Tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Dt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Dt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Dt},sheen:{value:0},sheenColor:{value:new Mt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Dt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Dt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Dt},transmissionSamplerSize:{value:new Tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Dt},attenuationDistance:{value:0},attenuationColor:{value:new Mt(0)},specularColor:{value:new Mt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Dt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Dt},anisotropyVector:{value:new Tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Dt}}]),vertexShader:Lt.meshphysical_vert,fragmentShader:Lt.meshphysical_frag};const gs={r:0,b:0,g:0},On=new Xe,Gf=new Rt;function Wf(s,t,e,n,i,r,a){const o=new Mt(0);let l=r===!0?0:1,c,h,u=null,d=0,p=null;function g(y){let x=y.isScene===!0?y.background:null;return x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x)),x}function _(y){let x=!1;const b=g(y);b===null?f(o,l):b&&b.isColor&&(f(b,1),x=!0);const L=s.xr.getEnvironmentBlendMode();L==="additive"?n.buffers.color.setClear(0,0,0,1,a):L==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(s.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(y,x){const b=g(x);b&&(b.isCubeTexture||b.mapping===js)?(h===void 0&&(h=new Ae(new Xi(1,1,1),new Pn({name:"BackgroundCubeMaterial",uniforms:Si(je.backgroundCube.uniforms),vertexShader:je.backgroundCube.vertexShader,fragmentShader:je.backgroundCube.fragmentShader,side:we,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(L,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),On.copy(x.backgroundRotation),On.x*=-1,On.y*=-1,On.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(On.y*=-1,On.z*=-1),h.material.uniforms.envMap.value=b,h.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Gf.makeRotationFromEuler(On)),h.material.toneMapped=Xt.getTransfer(b.colorSpace)!==Jt,(u!==b||d!==b.version||p!==s.toneMapping)&&(h.material.needsUpdate=!0,u=b,d=b.version,p=s.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new Ae(new Qs(2,2),new Pn({name:"BackgroundMaterial",uniforms:Si(je.background.uniforms),vertexShader:je.background.vertexShader,fragmentShader:je.background.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=Xt.getTransfer(b.colorSpace)!==Jt,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(u!==b||d!==b.version||p!==s.toneMapping)&&(c.material.needsUpdate=!0,u=b,d=b.version,p=s.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function f(y,x){y.getRGB(gs,Gl(s)),n.buffers.color.setClear(gs.r,gs.g,gs.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),l=x,f(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,f(o,l)},render:_,addToRenderList:m}}function Xf(s,t){const e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(v,C,z,B,H){let Y=!1;const k=u(B,z,C);r!==k&&(r=k,c(r.object)),Y=p(v,B,z,H),Y&&g(v,B,z,H),H!==null&&t.update(H,s.ELEMENT_ARRAY_BUFFER),(Y||a)&&(a=!1,b(v,C,z,B),H!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(H).buffer))}function l(){return s.createVertexArray()}function c(v){return s.bindVertexArray(v)}function h(v){return s.deleteVertexArray(v)}function u(v,C,z){const B=z.wireframe===!0;let H=n[v.id];H===void 0&&(H={},n[v.id]=H);let Y=H[C.id];Y===void 0&&(Y={},H[C.id]=Y);let k=Y[B];return k===void 0&&(k=d(l()),Y[B]=k),k}function d(v){const C=[],z=[],B=[];for(let H=0;H=0){const pt=H[G];let mt=Y[G];if(mt===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(mt=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(mt=v.instanceColor)),pt===void 0||pt.attribute!==mt||mt&&pt.data!==mt.data)return!0;k++}return r.attributesNum!==k||r.index!==B}function g(v,C,z,B){const H={},Y=C.attributes;let k=0;const Z=z.getAttributes();for(const G in Z)if(Z[G].location>=0){let pt=Y[G];pt===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(pt=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(pt=v.instanceColor));const mt={};mt.attribute=pt,pt&&pt.data&&(mt.data=pt.data),H[G]=mt,k++}r.attributes=H,r.attributesNum=k,r.index=B}function _(){const v=r.newAttributes;for(let C=0,z=v.length;C=0){let ct=H[Z];if(ct===void 0&&(Z==="instanceMatrix"&&v.instanceMatrix&&(ct=v.instanceMatrix),Z==="instanceColor"&&v.instanceColor&&(ct=v.instanceColor)),ct!==void 0){const pt=ct.normalized,mt=ct.itemSize,Ot=t.get(ct);if(Ot===void 0)continue;const jt=Ot.buffer,W=Ot.type,J=Ot.bytesPerElement,ut=W===s.INT||W===s.UNSIGNED_INT||ct.gpuType===Ia;if(ct.isInterleavedBufferAttribute){const ot=ct.data,Ct=ot.stride,Ut=ct.offset;if(ot.isInstancedInterleavedBuffer){for(let Ft=0;Ft0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_TEXTURE_SIZE),_=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),f=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),y=s.getParameter(s.MAX_VARYING_VECTORS),x=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),b=p>0,L=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:p,maxTextureSize:g,maxCubemapSize:_,maxAttributes:m,maxVertexUniforms:f,maxVaryings:y,maxFragmentUniforms:x,vertexTextures:b,maxSamples:L}}function Kf(s){const t=this;let e=null,n=0,i=!1,r=!1;const a=new an,o=new Dt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const p=u.length!==0||d||n!==0||i;return i=d,n=u.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,p){const g=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,f=s.get(u);if(!i||g===null||g.length===0||r&&!m)r?h(null):c();else{const y=r?0:n,x=y*4;let b=f.clippingState||null;l.value=b,b=h(g,d,x,p);for(let L=0;L!==x;++L)b[L]=e[L];f.clippingState=b,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,p,g){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const f=p+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(m===null||m.length0){const c=new ru(l.height);return c.fromEquirectangularTexture(s,a),t.set(a,c),a.addEventListener("dispose",i),e(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}class Yl extends Wl{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,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,i,r,a){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=i,this.view.width=r,this.view.height=a,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,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,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}}const di=4,wo=[.125,.215,.35,.446,.526,.582],kn=20,Cr=new Yl,Ro=new Mt;let Pr=null,Ir=0,Lr=0,Dr=!1;const Vn=(1+Math.sqrt(5))/2,li=1/Vn,Co=[new R(-Vn,li,0),new R(Vn,li,0),new R(-li,0,Vn),new R(li,0,Vn),new R(0,Vn,-li),new R(0,Vn,li),new R(-1,1,-1),new R(1,1,-1),new R(-1,1,1),new R(1,1,1)];class Po{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,i=100){Pr=this._renderer.getRenderTarget(),Ir=this._renderer.getActiveCubeFace(),Lr=this._renderer.getActiveMipmapLevel(),Dr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Do(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Lo(),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;t2?x:0,x,x),h.setRenderTarget(i),_&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===_i||t.mapping===xi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Do()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Lo());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new Ae(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;const l=this._cubeSize;_s(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,Cr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;rkn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${kn}`);const f=[];let y=0;for(let A=0;Ax-di?i-x+di:0),T=4*(this._cubeSize-b);_s(e,L,T,3*b,2*b),l.setRenderTarget(e),l.render(u,Cr)}}function $f(s){const t=[],e=[],n=[];let i=s;const r=s-di+1+wo.length;for(let a=0;as-di?l=wo[a-s+di-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,g=6,_=3,m=2,f=1,y=new Float32Array(_*g*p),x=new Float32Array(m*g*p),b=new Float32Array(f*g*p);for(let T=0;T2?0:-1,S=[A,I,0,A+2/3,I,0,A+2/3,I+1,0,A,I,0,A+2/3,I+1,0,A,I+1,0];y.set(S,_*g*T),x.set(d,m*g*T);const v=[T,T,T,T,T,T];b.set(v,f*g*T)}const L=new ce;L.setAttribute("position",new pe(y,_)),L.setAttribute("uv",new pe(x,m)),L.setAttribute("faceIndex",new pe(b,f)),t.push(L),i>di&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Io(s,t,e){const n=new Cn(s,t,e);return n.texture.mapping=js,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function _s(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function Zf(s,t,e){const n=new Float32Array(kn),i=new R(0,1,0);return new Pn({name:"SphericalGaussianBlur",defines:{n:kn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:ka(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:Tn,depthTest:!1,depthWrite:!1})}function Lo(){return new Pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ka(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:Tn,depthTest:!1,depthWrite:!1})}function Do(){return new Pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ka(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:Tn,depthTest:!1,depthWrite:!1})}function ka(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function Jf(s){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Kr||l===jr,h=l===_i||l===xi;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new Po(s)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const p=o.image;return c&&p&&p.height>0||h&&p&&i(p)?(e===null&&(e=new Po(s)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function i(o){let l=0;const c=6;for(let h=0;ht.maxTextureSize&&(L=Math.ceil(b/t.maxTextureSize),b=t.maxTextureSize);const T=new Float32Array(b*L*4*u),A=new Ol(T,b,L,u);A.type=Ue,A.needsUpdate=!0;const I=x*4;for(let v=0;v0)return s;const i=t*e;let r=No[i];if(r===void 0&&(r=new Float32Array(i),No[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function ue(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e":" "} ${o}: ${e[a]}`)}return n.join(` +`)}function Jp(s){const t=Xt.getPrimaries(Xt.workingColorSpace),e=Xt.getPrimaries(s);let n;switch(t===e?n="":t===ks&&e===Hs?n="LinearDisplayP3ToLinearSRGB":t===Hs&&e===ks&&(n="LinearSRGBToLinearDisplayP3"),s){case In:case Zs:return[n,"LinearTransferOETF"];case Ke:case Ba:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[n,"LinearTransferOETF"]}}function ko(s,t,e){const n=s.getShaderParameter(t,s.COMPILE_STATUS),i=s.getShaderInfoLog(t).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const a=parseInt(r[1]);return e.toUpperCase()+` + +`+i+` + +`+Zp(s.getShaderSource(t),a)}else return i}function Qp(s,t){const e=Jp(t);return`vec4 ${s}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function tm(s,t){let e;switch(t){case jc:e="Linear";break;case $c:e="Reinhard";break;case Zc:e="OptimizedCineon";break;case Jc:e="ACESFilmic";break;case th:e="AgX";break;case eh:e="Neutral";break;case Qc:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function em(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fi).join(` +`)}function nm(s){const t=[];for(const e in s){const n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` +`)}function im(s,t){const e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Aa(s){return s.replace(sm,am)}const rm=new Map;function am(s,t){let e=Lt[t];if(e===void 0){const n=rm.get(t);if(n!==void 0)e=Lt[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 Aa(e)}const om=/#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 Xo(s){return s.replace(om,lm)}function lm(s,t,e,n){let i="";for(let r=parseInt(t);r0&&(m+=` +`),f=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Fi).join(` +`),f.length>0&&(f+=` +`)):(m=[qo(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 "+h:"",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 "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","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",` +`].filter(Fi).join(` +`),f=[qo(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 "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",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 "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==An?"#define TONE_MAPPING":"",e.toneMapping!==An?Lt.tonemapping_pars_fragment:"",e.toneMapping!==An?tm("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Lt.colorspace_pars_fragment,Qp("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Fi).join(` +`)),a=Aa(a),a=Go(a,e),a=Wo(a,e),o=Aa(o),o=Go(o,e),o=Wo(o,e),a=Xo(a),o=Xo(o),e.isRawShaderMaterial!==!0&&(y=`#version 300 es +`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,f=["#define varying in",e.glslVersion===ro?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===ro?"":"#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(` +`)+` +`+f);const x=y+m+a,b=y+f+o,L=Ho(i,i.VERTEX_SHADER,x),T=Ho(i,i.FRAGMENT_SHADER,b);i.attachShader(_,L),i.attachShader(_,T),e.index0AttributeName!==void 0?i.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function A(C){if(s.debug.checkShaderErrors){const z=i.getProgramInfoLog(_).trim(),B=i.getShaderInfoLog(L).trim(),H=i.getShaderInfoLog(T).trim();let Y=!0,k=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(Y=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,L,T);else{const Z=ko(i,L,"vertex"),G=ko(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+` + +Material Name: `+C.name+` +Material Type: `+C.type+` + +Program Info Log: `+z+` +`+Z+` +`+G)}else z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",z):(B===""||H==="")&&(k=!1);k&&(C.diagnostics={runnable:Y,programLog:z,vertexShader:{log:B,prefix:m},fragmentShader:{log:H,prefix:f}})}i.deleteShader(L),i.deleteShader(T),I=new Fs(i,_),S=im(i,_)}let I;this.getUniforms=function(){return I===void 0&&A(this),I};let S;this.getAttributes=function(){return S===void 0&&A(this),S};let v=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=i.getProgramParameter(_,jp)),v},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=$p++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=L,this.fragmentShader=T,this}let mm=0;class gm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 _m(t),e.set(t,n)),n}}class _m{constructor(t){this.id=mm++,this.code=t,this.usedTimes=0}}function xm(s,t,e,n,i,r,a){const o=new Ha,l=new gm,c=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures;let p=i.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 _(S){return c.add(S),S===0?"uv":`uv${S}`}function m(S,v,C,z,B){const H=z.fog,Y=B.geometry,k=S.isMeshStandardMaterial?z.environment:null,Z=(S.isMeshStandardMaterial?e:t).get(S.envMap||k),G=Z&&Z.mapping===js?Z.image.height:null,ct=g[S.type];S.precision!==null&&(p=i.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));const pt=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,mt=pt!==void 0?pt.length:0;let Ot=0;Y.morphAttributes.position!==void 0&&(Ot=1),Y.morphAttributes.normal!==void 0&&(Ot=2),Y.morphAttributes.color!==void 0&&(Ot=3);let jt,W,J,ut;if(ct){const Ht=je[ct];jt=Ht.vertexShader,W=Ht.fragmentShader}else jt=S.vertexShader,W=S.fragmentShader,l.update(S),J=l.getVertexShaderID(S),ut=l.getFragmentShaderID(S);const ot=s.getRenderTarget(),Ct=B.isInstancedMesh===!0,Ut=B.isBatchedMesh===!0,Ft=!!S.map,te=!!S.matcap,P=!!Z,se=!!S.aoMap,qt=!!S.lightMap,$t=!!S.bumpMap,_t=!!S.normalMap,re=!!S.displacementMap,At=!!S.emissiveMap,Pt=!!S.metalnessMap,w=!!S.roughnessMap,M=S.anisotropy>0,V=S.clearcoat>0,j=S.dispersion>0,$=S.iridescence>0,K=S.sheen>0,xt=S.transmission>0,st=M&&!!S.anisotropyMap,lt=V&&!!S.clearcoatMap,It=V&&!!S.clearcoatNormalMap,Q=V&&!!S.clearcoatRoughnessMap,at=$&&!!S.iridescenceMap,Bt=$&&!!S.iridescenceThicknessMap,bt=K&&!!S.sheenColorMap,ht=K&&!!S.sheenRoughnessMap,wt=!!S.specularMap,Nt=!!S.specularColorMap,Qt=!!S.specularIntensityMap,D=xt&&!!S.transmissionMap,tt=xt&&!!S.thicknessMap,X=!!S.gradientMap,q=!!S.alphaMap,nt=S.alphaTest>0,yt=!!S.alphaHash,zt=!!S.extensions;let ae=An;S.toneMapped&&(ot===null||ot.isXRRenderTarget===!0)&&(ae=s.toneMapping);const me={shaderID:ct,shaderType:S.type,shaderName:S.name,vertexShader:jt,fragmentShader:W,defines:S.defines,customVertexShaderID:J,customFragmentShaderID:ut,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:Ut,batchingColor:Ut&&B._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&B.instanceColor!==null,instancingMorph:Ct&&B.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:ot===null?s.outputColorSpace:ot.isXRRenderTarget===!0?ot.texture.colorSpace:In,alphaToCoverage:!!S.alphaToCoverage,map:Ft,matcap:te,envMap:P,envMapMode:P&&Z.mapping,envMapCubeUVHeight:G,aoMap:se,lightMap:qt,bumpMap:$t,normalMap:_t,displacementMap:d&&re,emissiveMap:At,normalMapObjectSpace:_t&&S.normalMapType===hh,normalMapTangentSpace:_t&&S.normalMapType===Gi,metalnessMap:Pt,roughnessMap:w,anisotropy:M,anisotropyMap:st,clearcoat:V,clearcoatMap:lt,clearcoatNormalMap:It,clearcoatRoughnessMap:Q,dispersion:j,iridescence:$,iridescenceMap:at,iridescenceThicknessMap:Bt,sheen:K,sheenColorMap:bt,sheenRoughnessMap:ht,specularMap:wt,specularColorMap:Nt,specularIntensityMap:Qt,transmission:xt,transmissionMap:D,thicknessMap:tt,gradientMap:X,opaque:S.transparent===!1&&S.blending===fi&&S.alphaToCoverage===!1,alphaMap:q,alphaTest:nt,alphaHash:yt,combine:S.combine,mapUv:Ft&&_(S.map.channel),aoMapUv:se&&_(S.aoMap.channel),lightMapUv:qt&&_(S.lightMap.channel),bumpMapUv:$t&&_(S.bumpMap.channel),normalMapUv:_t&&_(S.normalMap.channel),displacementMapUv:re&&_(S.displacementMap.channel),emissiveMapUv:At&&_(S.emissiveMap.channel),metalnessMapUv:Pt&&_(S.metalnessMap.channel),roughnessMapUv:w&&_(S.roughnessMap.channel),anisotropyMapUv:st&&_(S.anisotropyMap.channel),clearcoatMapUv:lt&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:It&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:at&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:Bt&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:bt&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:ht&&_(S.sheenRoughnessMap.channel),specularMapUv:wt&&_(S.specularMap.channel),specularColorMapUv:Nt&&_(S.specularColorMap.channel),specularIntensityMapUv:Qt&&_(S.specularIntensityMap.channel),transmissionMapUv:D&&_(S.transmissionMap.channel),thicknessMapUv:tt&&_(S.thicknessMap.channel),alphaMapUv:q&&_(S.alphaMap.channel),vertexTangents:!!Y.attributes.tangent&&(_t||M),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,pointsUvs:B.isPoints===!0&&!!Y.attributes.uv&&(Ft||q),fog:!!H,useFog:S.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:B.isSkinnedMesh===!0,morphTargets:Y.morphAttributes.position!==void 0,morphNormals:Y.morphAttributes.normal!==void 0,morphColors:Y.morphAttributes.color!==void 0,morphTargetsCount:mt,morphTextureStride:Ot,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:s.shadowMap.enabled&&C.length>0,shadowMapType:s.shadowMap.type,toneMapping:ae,decodeVideoTexture:Ft&&S.map.isVideoTexture===!0&&Xt.getTransfer(S.map.colorSpace)===Jt,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===on,flipSided:S.side===we,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:zt&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(zt&&S.extensions.multiDraw===!0||Ut)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return me.vertexUv1s=c.has(1),me.vertexUv2s=c.has(2),me.vertexUv3s=c.has(3),c.clear(),me}function f(S){const v=[];if(S.shaderID?v.push(S.shaderID):(v.push(S.customVertexShaderID),v.push(S.customFragmentShaderID)),S.defines!==void 0)for(const C in S.defines)v.push(C),v.push(S.defines[C]);return S.isRawShaderMaterial===!1&&(y(v,S),x(v,S),v.push(s.outputColorSpace)),v.push(S.customProgramCacheKey),v.join()}function y(S,v){S.push(v.precision),S.push(v.outputColorSpace),S.push(v.envMapMode),S.push(v.envMapCubeUVHeight),S.push(v.mapUv),S.push(v.alphaMapUv),S.push(v.lightMapUv),S.push(v.aoMapUv),S.push(v.bumpMapUv),S.push(v.normalMapUv),S.push(v.displacementMapUv),S.push(v.emissiveMapUv),S.push(v.metalnessMapUv),S.push(v.roughnessMapUv),S.push(v.anisotropyMapUv),S.push(v.clearcoatMapUv),S.push(v.clearcoatNormalMapUv),S.push(v.clearcoatRoughnessMapUv),S.push(v.iridescenceMapUv),S.push(v.iridescenceThicknessMapUv),S.push(v.sheenColorMapUv),S.push(v.sheenRoughnessMapUv),S.push(v.specularMapUv),S.push(v.specularColorMapUv),S.push(v.specularIntensityMapUv),S.push(v.transmissionMapUv),S.push(v.thicknessMapUv),S.push(v.combine),S.push(v.fogExp2),S.push(v.sizeAttenuation),S.push(v.morphTargetsCount),S.push(v.morphAttributeCount),S.push(v.numDirLights),S.push(v.numPointLights),S.push(v.numSpotLights),S.push(v.numSpotLightMaps),S.push(v.numHemiLights),S.push(v.numRectAreaLights),S.push(v.numDirLightShadows),S.push(v.numPointLightShadows),S.push(v.numSpotLightShadows),S.push(v.numSpotLightShadowsWithMaps),S.push(v.numLightProbes),S.push(v.shadowMapType),S.push(v.toneMapping),S.push(v.numClippingPlanes),S.push(v.numClipIntersection),S.push(v.depthPacking)}function x(S,v){o.disableAll(),v.supportsVertexTextures&&o.enable(0),v.instancing&&o.enable(1),v.instancingColor&&o.enable(2),v.instancingMorph&&o.enable(3),v.matcap&&o.enable(4),v.envMap&&o.enable(5),v.normalMapObjectSpace&&o.enable(6),v.normalMapTangentSpace&&o.enable(7),v.clearcoat&&o.enable(8),v.iridescence&&o.enable(9),v.alphaTest&&o.enable(10),v.vertexColors&&o.enable(11),v.vertexAlphas&&o.enable(12),v.vertexUv1s&&o.enable(13),v.vertexUv2s&&o.enable(14),v.vertexUv3s&&o.enable(15),v.vertexTangents&&o.enable(16),v.anisotropy&&o.enable(17),v.alphaHash&&o.enable(18),v.batching&&o.enable(19),v.dispersion&&o.enable(20),v.batchingColor&&o.enable(21),S.push(o.mask),o.disableAll(),v.fog&&o.enable(0),v.useFog&&o.enable(1),v.flatShading&&o.enable(2),v.logarithmicDepthBuffer&&o.enable(3),v.skinning&&o.enable(4),v.morphTargets&&o.enable(5),v.morphNormals&&o.enable(6),v.morphColors&&o.enable(7),v.premultipliedAlpha&&o.enable(8),v.shadowMapEnabled&&o.enable(9),v.doubleSided&&o.enable(10),v.flipSided&&o.enable(11),v.useDepthPacking&&o.enable(12),v.dithering&&o.enable(13),v.transmission&&o.enable(14),v.sheen&&o.enable(15),v.opaque&&o.enable(16),v.pointsUvs&&o.enable(17),v.decodeVideoTexture&&o.enable(18),v.alphaToCoverage&&o.enable(19),S.push(o.mask)}function b(S){const v=g[S.type];let C;if(v){const z=je[v];C=eu.clone(z.uniforms)}else C=S.uniforms;return C}function L(S,v){let C;for(let z=0,B=h.length;z0?n.push(f):p.transparent===!0?i.push(f):e.push(f)}function l(u,d,p,g,_,m){const f=a(u,d,p,g,_,m);p.transmission>0?n.unshift(f):p.transparent===!0?i.unshift(f):e.unshift(f)}function c(u,d){e.length>1&&e.sort(u||Mm),n.length>1&&n.sort(d||Yo),i.length>1&&i.sort(d||Yo)}function h(){for(let u=t,d=s.length;u=r.length?(a=new Ko,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function Sm(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new R,color:new Mt};break;case"SpotLight":e={position:new R,direction:new R,color:new Mt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new Mt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new Mt,groundColor:new Mt};break;case"RectAreaLight":e={color:new Mt,position:new R,halfWidth:new R,halfHeight:new R};break}return s[t.id]=e,e}}}function Em(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}let bm=0;function Tm(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function Am(s){const t=new Sm,e=Em(),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 c=0;c<9;c++)n.probe.push(new R);const i=new R,r=new Rt,a=new Rt;function o(c){let h=0,u=0,d=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let p=0,g=0,_=0,m=0,f=0,y=0,x=0,b=0,L=0,T=0,A=0;c.sort(Tm);for(let S=0,v=c.length;S0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=it.LTC_FLOAT_1,n.rectAreaLTC2=it.LTC_FLOAT_2):(n.rectAreaLTC1=it.LTC_HALF_1,n.rectAreaLTC2=it.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const I=n.hash;(I.directionalLength!==p||I.pointLength!==g||I.spotLength!==_||I.rectAreaLength!==m||I.hemiLength!==f||I.numDirectionalShadows!==y||I.numPointShadows!==x||I.numSpotShadows!==b||I.numSpotMaps!==L||I.numLightProbes!==A)&&(n.directional.length=p,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=b,n.spotShadowMap.length=b,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=b+L-T,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=A,I.directionalLength=p,I.pointLength=g,I.spotLength=_,I.rectAreaLength=m,I.hemiLength=f,I.numDirectionalShadows=y,I.numPointShadows=x,I.numSpotShadows=b,I.numSpotMaps=L,I.numLightProbes=A,n.version=bm++)}function l(c,h){let u=0,d=0,p=0,g=0,_=0;const m=h.matrixWorldInverse;for(let f=0,y=c.length;f=a.length?(o=new jo(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class Rm extends qe{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=lh,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 Cm extends qe{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 Pm=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Im=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function Lm(s,t,e){let n=new Js;const i=new Tt,r=new Tt,a=new Zt,o=new Rm({depthPacking:ch}),l=new Cm,c={},h=e.maxTextureSize,u={[wn]:we,[we]:wn,[on]:on},d=new Pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Tt},radius:{value:4}},vertexShader:Pm,fragmentShader:Im}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new ce;g.setAttribute("position",new pe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ae(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=El;let f=this.type;this.render=function(T,A,I){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const S=s.getRenderTarget(),v=s.getActiveCubeFace(),C=s.getActiveMipmapLevel(),z=s.state;z.setBlending(Tn),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const B=f!==rn&&this.type===rn,H=f===rn&&this.type!==rn;for(let Y=0,k=T.length;Yh||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/ct.x),i.x=r.x*ct.x,G.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/ct.y),i.y=r.y*ct.y,G.mapSize.y=r.y)),G.map===null||B===!0||H===!0){const mt=this.type!==rn?{minFilter:be,magFilter:be}:{};G.map!==null&&G.map.dispose(),G.map=new Cn(i.x,i.y,mt),G.map.texture.name=Z.name+".shadowMap",G.camera.updateProjectionMatrix()}s.setRenderTarget(G.map),s.clear();const pt=G.getViewportCount();for(let mt=0;mt0||A.map&&A.alphaTest>0){const z=v.uuid,B=A.uuid;let H=c[z];H===void 0&&(H={},c[z]=H);let Y=H[B];Y===void 0&&(Y=v.clone(),H[B]=Y,A.addEventListener("dispose",L)),v=Y}if(v.visible=A.visible,v.wireframe=A.wireframe,S===rn?v.side=A.shadowSide!==null?A.shadowSide:A.side:v.side=A.shadowSide!==null?A.shadowSide:u[A.side],v.alphaMap=A.alphaMap,v.alphaTest=A.alphaTest,v.map=A.map,v.clipShadows=A.clipShadows,v.clippingPlanes=A.clippingPlanes,v.clipIntersection=A.clipIntersection,v.displacementMap=A.displacementMap,v.displacementScale=A.displacementScale,v.displacementBias=A.displacementBias,v.wireframeLinewidth=A.wireframeLinewidth,v.linewidth=A.linewidth,I.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const z=s.properties.get(v);z.light=I}return v}function b(T,A,I,S,v){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&v===rn)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const B=t.update(T),H=T.material;if(Array.isArray(H)){const Y=B.groups;for(let k=0,Z=Y.length;k=1):Z.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=k>=2);let G=null,ct={};const pt=s.getParameter(s.SCISSOR_BOX),mt=s.getParameter(s.VIEWPORT),Ot=new Zt().fromArray(pt),jt=new Zt().fromArray(mt);function W(D,tt,X,q){const nt=new Uint8Array(4),yt=s.createTexture();s.bindTexture(D,yt),s.texParameteri(D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(D,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let zt=0;zt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Tt,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(w,M){return p?new OffscreenCanvas(w,M):Vi("canvas")}function _(w,M,V){let j=1;const $=Pt(w);if(($.width>V||$.height>V)&&(j=V/Math.max($.width,$.height)),j<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){const K=Math.floor(j*$.width),xt=Math.floor(j*$.height);u===void 0&&(u=g(K,xt));const st=M?g(K,xt):u;return st.width=K,st.height=xt,st.getContext("2d").drawImage(w,0,0,K,xt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+K+"x"+xt+")."),st}else return"data"in w&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),w;return w}function m(w){return w.generateMipmaps&&w.minFilter!==be&&w.minFilter!==Ee}function f(w){s.generateMipmap(w)}function y(w,M,V,j,$=!1){if(w!==null){if(s[w]!==void 0)return s[w];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let K=M;if(M===s.RED&&(V===s.FLOAT&&(K=s.R32F),V===s.HALF_FLOAT&&(K=s.R16F),V===s.UNSIGNED_BYTE&&(K=s.R8)),M===s.RED_INTEGER&&(V===s.UNSIGNED_BYTE&&(K=s.R8UI),V===s.UNSIGNED_SHORT&&(K=s.R16UI),V===s.UNSIGNED_INT&&(K=s.R32UI),V===s.BYTE&&(K=s.R8I),V===s.SHORT&&(K=s.R16I),V===s.INT&&(K=s.R32I)),M===s.RG&&(V===s.FLOAT&&(K=s.RG32F),V===s.HALF_FLOAT&&(K=s.RG16F),V===s.UNSIGNED_BYTE&&(K=s.RG8)),M===s.RG_INTEGER&&(V===s.UNSIGNED_BYTE&&(K=s.RG8UI),V===s.UNSIGNED_SHORT&&(K=s.RG16UI),V===s.UNSIGNED_INT&&(K=s.RG32UI),V===s.BYTE&&(K=s.RG8I),V===s.SHORT&&(K=s.RG16I),V===s.INT&&(K=s.RG32I)),M===s.RGB&&V===s.UNSIGNED_INT_5_9_9_9_REV&&(K=s.RGB9_E5),M===s.RGBA){const xt=$?Vs:Xt.getTransfer(j);V===s.FLOAT&&(K=s.RGBA32F),V===s.HALF_FLOAT&&(K=s.RGBA16F),V===s.UNSIGNED_BYTE&&(K=xt===Jt?s.SRGB8_ALPHA8:s.RGBA8),V===s.UNSIGNED_SHORT_4_4_4_4&&(K=s.RGBA4),V===s.UNSIGNED_SHORT_5_5_5_1&&(K=s.RGB5_A1)}return(K===s.R16F||K===s.R32F||K===s.RG16F||K===s.RG32F||K===s.RGBA16F||K===s.RGBA32F)&&t.get("EXT_color_buffer_float"),K}function x(w,M){let V;return w?M===null||M===Rn||M===vi?V=s.DEPTH24_STENCIL8:M===Ue?V=s.DEPTH32F_STENCIL8:M===zi&&(V=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Rn||M===vi?V=s.DEPTH_COMPONENT24:M===Ue?V=s.DEPTH_COMPONENT32F:M===zi&&(V=s.DEPTH_COMPONENT16),V}function b(w,M){return m(w)===!0||w.isFramebufferTexture&&w.minFilter!==be&&w.minFilter!==Ee?Math.log2(Math.max(M.width,M.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?M.mipmaps.length:1}function L(w){const M=w.target;M.removeEventListener("dispose",L),A(M),M.isVideoTexture&&h.delete(M)}function T(w){const M=w.target;M.removeEventListener("dispose",T),S(M)}function A(w){const M=n.get(w);if(M.__webglInit===void 0)return;const V=w.source,j=d.get(V);if(j){const $=j[M.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(w),Object.keys(j).length===0&&d.delete(V)}n.remove(w)}function I(w){const M=n.get(w);s.deleteTexture(M.__webglTexture);const V=w.source,j=d.get(V);delete j[M.__cacheKey],a.memory.textures--}function S(w){const M=n.get(w);if(w.depthTexture&&w.depthTexture.dispose(),w.isWebGLCubeRenderTarget)for(let j=0;j<6;j++){if(Array.isArray(M.__webglFramebuffer[j]))for(let $=0;$=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+i.maxTextures),v+=1,w}function B(w){const M=[];return M.push(w.wrapS),M.push(w.wrapT),M.push(w.wrapR||0),M.push(w.magFilter),M.push(w.minFilter),M.push(w.anisotropy),M.push(w.internalFormat),M.push(w.format),M.push(w.type),M.push(w.generateMipmaps),M.push(w.premultiplyAlpha),M.push(w.flipY),M.push(w.unpackAlignment),M.push(w.colorSpace),M.join()}function H(w,M){const V=n.get(w);if(w.isVideoTexture&&re(w),w.isRenderTargetTexture===!1&&w.version>0&&V.__version!==w.version){const j=w.image;if(j===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(j.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{jt(V,w,M);return}}e.bindTexture(s.TEXTURE_2D,V.__webglTexture,s.TEXTURE0+M)}function Y(w,M){const V=n.get(w);if(w.version>0&&V.__version!==w.version){jt(V,w,M);return}e.bindTexture(s.TEXTURE_2D_ARRAY,V.__webglTexture,s.TEXTURE0+M)}function k(w,M){const V=n.get(w);if(w.version>0&&V.__version!==w.version){jt(V,w,M);return}e.bindTexture(s.TEXTURE_3D,V.__webglTexture,s.TEXTURE0+M)}function Z(w,M){const V=n.get(w);if(w.version>0&&V.__version!==w.version){W(V,w,M);return}e.bindTexture(s.TEXTURE_CUBE_MAP,V.__webglTexture,s.TEXTURE0+M)}const G={[$r]:s.REPEAT,[cn]:s.CLAMP_TO_EDGE,[Zr]:s.MIRRORED_REPEAT},ct={[be]:s.NEAREST,[ih]:s.NEAREST_MIPMAP_NEAREST,[$i]:s.NEAREST_MIPMAP_LINEAR,[Ee]:s.LINEAR,[cr]:s.LINEAR_MIPMAP_NEAREST,[En]:s.LINEAR_MIPMAP_LINEAR},pt={[uh]:s.NEVER,[_h]:s.ALWAYS,[dh]:s.LESS,[Ul]:s.LEQUAL,[fh]:s.EQUAL,[gh]:s.GEQUAL,[ph]:s.GREATER,[mh]:s.NOTEQUAL};function mt(w,M){if(M.type===Ue&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Ee||M.magFilter===cr||M.magFilter===$i||M.magFilter===En||M.minFilter===Ee||M.minFilter===cr||M.minFilter===$i||M.minFilter===En)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(w,s.TEXTURE_WRAP_S,G[M.wrapS]),s.texParameteri(w,s.TEXTURE_WRAP_T,G[M.wrapT]),(w===s.TEXTURE_3D||w===s.TEXTURE_2D_ARRAY)&&s.texParameteri(w,s.TEXTURE_WRAP_R,G[M.wrapR]),s.texParameteri(w,s.TEXTURE_MAG_FILTER,ct[M.magFilter]),s.texParameteri(w,s.TEXTURE_MIN_FILTER,ct[M.minFilter]),M.compareFunction&&(s.texParameteri(w,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(w,s.TEXTURE_COMPARE_FUNC,pt[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===be||M.minFilter!==$i&&M.minFilter!==En||M.type===Ue&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){const V=t.get("EXT_texture_filter_anisotropic");s.texParameterf(w,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,i.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function Ot(w,M){let V=!1;w.__webglInit===void 0&&(w.__webglInit=!0,M.addEventListener("dispose",L));const j=M.source;let $=d.get(j);$===void 0&&($={},d.set(j,$));const K=B(M);if(K!==w.__cacheKey){$[K]===void 0&&($[K]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,V=!0),$[K].usedTimes++;const xt=$[w.__cacheKey];xt!==void 0&&($[w.__cacheKey].usedTimes--,xt.usedTimes===0&&I(M)),w.__cacheKey=K,w.__webglTexture=$[K].texture}return V}function jt(w,M,V){let j=s.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(j=s.TEXTURE_2D_ARRAY),M.isData3DTexture&&(j=s.TEXTURE_3D);const $=Ot(w,M),K=M.source;e.bindTexture(j,w.__webglTexture,s.TEXTURE0+V);const xt=n.get(K);if(K.version!==xt.__version||$===!0){e.activeTexture(s.TEXTURE0+V);const st=Xt.getPrimaries(Xt.workingColorSpace),lt=M.colorSpace===Sn?null:Xt.getPrimaries(M.colorSpace),It=M.colorSpace===Sn||st===lt?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,It);let Q=_(M.image,!1,i.maxTextureSize);Q=At(M,Q);const at=r.convert(M.format,M.colorSpace),Bt=r.convert(M.type);let bt=y(M.internalFormat,at,Bt,M.colorSpace,M.isVideoTexture);mt(j,M);let ht;const wt=M.mipmaps,Nt=M.isVideoTexture!==!0,Qt=xt.__version===void 0||$===!0,D=K.dataReady,tt=b(M,Q);if(M.isDepthTexture)bt=x(M.format===Mi,M.type),Qt&&(Nt?e.texStorage2D(s.TEXTURE_2D,1,bt,Q.width,Q.height):e.texImage2D(s.TEXTURE_2D,0,bt,Q.width,Q.height,0,at,Bt,null));else if(M.isDataTexture)if(wt.length>0){Nt&&Qt&&e.texStorage2D(s.TEXTURE_2D,tt,bt,wt[0].width,wt[0].height);for(let X=0,q=wt.length;X0){const nt=$o(ht.width,ht.height,M.format,M.type);for(const yt of M.layerUpdates){const zt=ht.data.subarray(yt*nt/ht.data.BYTES_PER_ELEMENT,(yt+1)*nt/ht.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,X,0,0,yt,ht.width,ht.height,1,at,zt,0,0)}M.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,X,0,0,0,ht.width,ht.height,Q.depth,at,ht.data,0,0)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,X,bt,ht.width,ht.height,Q.depth,0,ht.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Nt?D&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,X,0,0,0,ht.width,ht.height,Q.depth,at,Bt,ht.data):e.texImage3D(s.TEXTURE_2D_ARRAY,X,bt,ht.width,ht.height,Q.depth,0,at,Bt,ht.data)}else{Nt&&Qt&&e.texStorage2D(s.TEXTURE_2D,tt,bt,wt[0].width,wt[0].height);for(let X=0,q=wt.length;X0){const X=$o(Q.width,Q.height,M.format,M.type);for(const q of M.layerUpdates){const nt=Q.data.subarray(q*X/Q.data.BYTES_PER_ELEMENT,(q+1)*X/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,q,Q.width,Q.height,1,at,Bt,nt)}M.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,at,Bt,Q.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,bt,Q.width,Q.height,Q.depth,0,at,Bt,Q.data);else if(M.isData3DTexture)Nt?(Qt&&e.texStorage3D(s.TEXTURE_3D,tt,bt,Q.width,Q.height,Q.depth),D&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,at,Bt,Q.data)):e.texImage3D(s.TEXTURE_3D,0,bt,Q.width,Q.height,Q.depth,0,at,Bt,Q.data);else if(M.isFramebufferTexture){if(Qt)if(Nt)e.texStorage2D(s.TEXTURE_2D,tt,bt,Q.width,Q.height);else{let X=Q.width,q=Q.height;for(let nt=0;nt>=1,q>>=1}}else if(wt.length>0){if(Nt&&Qt){const X=Pt(wt[0]);e.texStorage2D(s.TEXTURE_2D,tt,bt,X.width,X.height)}for(let X=0,q=wt.length;X0&&tt++;const q=Pt(at[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,tt,wt,q.width,q.height)}for(let q=0;q<6;q++)if(Q){Nt?D&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,at[q].width,at[q].height,bt,ht,at[q].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,wt,at[q].width,at[q].height,0,bt,ht,at[q].data);for(let nt=0;nt>K),at=Math.max(1,M.height>>K);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?e.texImage3D($,K,lt,Q,at,M.depth,0,xt,st,null):e.texImage2D($,K,lt,Q,at,0,xt,st,null)}e.bindFramebuffer(s.FRAMEBUFFER,w),_t(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,j,$,n.get(V).__webglTexture,0,$t(M)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,j,$,n.get(V).__webglTexture,K),e.bindFramebuffer(s.FRAMEBUFFER,null)}function ut(w,M,V){if(s.bindRenderbuffer(s.RENDERBUFFER,w),M.depthBuffer){const j=M.depthTexture,$=j&&j.isDepthTexture?j.type:null,K=x(M.stencilBuffer,$),xt=M.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=$t(M);_t(M)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,st,K,M.width,M.height):V?s.renderbufferStorageMultisample(s.RENDERBUFFER,st,K,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,K,M.width,M.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,xt,s.RENDERBUFFER,w)}else{const j=M.textures;for(let $=0;$1;if(xt||(j.__webglTexture===void 0&&(j.__webglTexture=s.createTexture()),j.__version=M.version,a.memory.textures++),K){V.__webglFramebuffer=[];for(let st=0;st<6;st++)if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer[st]=[];for(let lt=0;lt0){V.__webglFramebuffer=[];for(let st=0;st0&&_t(w)===!1){V.__webglMultisampledFramebuffer=s.createFramebuffer(),V.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let st=0;st<$.length;st++){const lt=$[st];V.__webglColorRenderbuffer[st]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,V.__webglColorRenderbuffer[st]);const It=r.convert(lt.format,lt.colorSpace),Q=r.convert(lt.type),at=y(lt.internalFormat,It,Q,lt.colorSpace,w.isXRRenderTarget===!0),Bt=$t(w);s.renderbufferStorageMultisample(s.RENDERBUFFER,Bt,at,w.width,w.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+st,s.RENDERBUFFER,V.__webglColorRenderbuffer[st])}s.bindRenderbuffer(s.RENDERBUFFER,null),w.depthBuffer&&(V.__webglDepthRenderbuffer=s.createRenderbuffer(),ut(V.__webglDepthRenderbuffer,w,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(K){e.bindTexture(s.TEXTURE_CUBE_MAP,j.__webglTexture),mt(s.TEXTURE_CUBE_MAP,M);for(let st=0;st<6;st++)if(M.mipmaps&&M.mipmaps.length>0)for(let lt=0;lt0)for(let lt=0;lt0){if(_t(w)===!1){const M=w.textures,V=w.width,j=w.height;let $=s.COLOR_BUFFER_BIT;const K=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,xt=n.get(w),st=M.length>1;if(st)for(let lt=0;lt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function re(w){const M=a.render.frame;h.get(w)!==M&&(h.set(w,M),w.update())}function At(w,M){const V=w.colorSpace,j=w.format,$=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||V!==In&&V!==Sn&&(Xt.getTransfer(V)===Jt?(j!==Te||$!==dn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",V)),M}function Pt(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(c.width=w.naturalWidth||w.width,c.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(c.width=w.displayWidth,c.height=w.displayHeight):(c.width=w.width,c.height=w.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=C,this.setTexture2D=H,this.setTexture2DArray=Y,this.setTexture3D=k,this.setTextureCube=Z,this.rebindTextures=Ut,this.setupRenderTarget=Ft,this.updateRenderTargetMipmap=te,this.updateMultisampleRenderTarget=qt,this.setupDepthRenderbuffer=Ct,this.setupFrameBufferTexture=J,this.useMultisampledRTT=_t}function Fm(s,t){function e(n,i=Sn){let r;const a=Xt.getTransfer(i);if(n===dn)return s.UNSIGNED_BYTE;if(n===La)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Da)return s.UNSIGNED_SHORT_5_5_5_1;if(n===wl)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Tl)return s.BYTE;if(n===Al)return s.SHORT;if(n===zi)return s.UNSIGNED_SHORT;if(n===Ia)return s.INT;if(n===Rn)return s.UNSIGNED_INT;if(n===Ue)return s.FLOAT;if(n===ki)return s.HALF_FLOAT;if(n===Rl)return s.ALPHA;if(n===Cl)return s.RGB;if(n===Te)return s.RGBA;if(n===Pl)return s.LUMINANCE;if(n===Il)return s.LUMINANCE_ALPHA;if(n===pi)return s.DEPTH_COMPONENT;if(n===Mi)return s.DEPTH_STENCIL;if(n===Ua)return s.RED;if(n===$s)return s.RED_INTEGER;if(n===Ll)return s.RG;if(n===Na)return s.RG_INTEGER;if(n===Fa)return s.RGBA_INTEGER;if(n===Is||n===Ls||n===Ds||n===Us)if(a===Jt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Is)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ls)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ds)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Us)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Is)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ls)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ds)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Us)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Jr||n===Qr||n===ta||n===ea)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Jr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ta)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ea)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===na||n===ia||n===sa)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===na||n===ia)return a===Jt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===sa)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ra||n===aa||n===oa||n===la||n===ca||n===ha||n===ua||n===da||n===fa||n===pa||n===ma||n===ga||n===_a||n===xa)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===ra)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===aa)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===oa)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===la)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ca)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ha)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ua)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===da)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===fa)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===pa)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ma)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ga)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===_a)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===xa)return a===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ns||n===va||n===Ma)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Ns)return a===Jt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===va)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ma)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Dl||n===ya||n===Sa||n===Ea)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ns)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ya)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Sa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ea)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===vi?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}class Om extends De{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class xs extends ie{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Bm={type:"move"};class Nr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xs,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 xs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),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 i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const _ of t.hand.values()){const m=e.getJointPose(_,n),f=this._getHandJoint(c,_);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Bm)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new xs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const zm=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Vm=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class Hm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const i=new Me,r=t.properties.get(i);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new Pn({vertexShader:zm,fragmentShader:Vm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ae(new Qs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class km extends Wn{constructor(t,e){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,g=null;const _=new Hm,m=e.getContextAttributes();let f=null,y=null;const x=[],b=[],L=new Tt;let T=null;const A=new De;A.layers.enable(1),A.viewport=new Zt;const I=new De;I.layers.enable(2),I.viewport=new Zt;const S=[A,I],v=new Om;v.layers.enable(1),v.layers.enable(2);let C=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let J=x[W];return J===void 0&&(J=new Nr,x[W]=J),J.getTargetRaySpace()},this.getControllerGrip=function(W){let J=x[W];return J===void 0&&(J=new Nr,x[W]=J),J.getGripSpace()},this.getHand=function(W){let J=x[W];return J===void 0&&(J=new Nr,x[W]=J),J.getHandSpace()};function B(W){const J=b.indexOf(W.inputSource);if(J===-1)return;const ut=x[J];ut!==void 0&&(ut.update(W.inputSource,W.frame,c||a),ut.dispatchEvent({type:W.type,data:W.inputSource}))}function H(){i.removeEventListener("select",B),i.removeEventListener("selectstart",B),i.removeEventListener("selectend",B),i.removeEventListener("squeeze",B),i.removeEventListener("squeezestart",B),i.removeEventListener("squeezeend",B),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",Y);for(let W=0;W=0&&(b[ot]=null,x[ot].disconnect(ut))}for(let J=0;J=b.length){b.push(ut),ot=Ut;break}else if(b[Ut]===null){b[Ut]=ut,ot=Ut;break}if(ot===-1)break}const Ct=x[ot];Ct&&Ct.connect(ut)}}const k=new R,Z=new R;function G(W,J,ut){k.setFromMatrixPosition(J.matrixWorld),Z.setFromMatrixPosition(ut.matrixWorld);const ot=k.distanceTo(Z),Ct=J.projectionMatrix.elements,Ut=ut.projectionMatrix.elements,Ft=Ct[14]/(Ct[10]-1),te=Ct[14]/(Ct[10]+1),P=(Ct[9]+1)/Ct[5],se=(Ct[9]-1)/Ct[5],qt=(Ct[8]-1)/Ct[0],$t=(Ut[8]+1)/Ut[0],_t=Ft*qt,re=Ft*$t,At=ot/(-qt+$t),Pt=At*-qt;J.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Pt),W.translateZ(At),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const w=Ft+At,M=te+At,V=_t-Pt,j=re+(ot-Pt),$=P*te/M*w,K=se*te/M*w;W.projectionMatrix.makePerspective(V,j,$,K,w,M),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}function ct(W,J){J===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(J.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;_.texture!==null&&(W.near=_.depthNear,W.far=_.depthFar),v.near=I.near=A.near=W.near,v.far=I.far=A.far=W.far,(C!==v.near||z!==v.far)&&(i.updateRenderState({depthNear:v.near,depthFar:v.far}),C=v.near,z=v.far,A.near=C,A.far=z,I.near=C,I.far=z,A.updateProjectionMatrix(),I.updateProjectionMatrix(),W.updateProjectionMatrix());const J=W.parent,ut=v.cameras;ct(v,J);for(let ot=0;ot0&&(m.alphaTest.value=f.alphaTest);const y=t.get(f),x=y.envMap,b=y.envMapRotation;x&&(m.envMap.value=x,Bn.copy(b),Bn.x*=-1,Bn.y*=-1,Bn.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Bn.y*=-1,Bn.z*=-1),m.envMapRotation.value.setFromMatrix4(Gm.makeRotationFromEuler(Bn)),m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,y,x){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*y,m.scale.value=x*.5,f.map&&(m.map.value=f.map,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,y){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===we&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function _(m,f){const y=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Xm(s,t,e,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const b=x.program;n.uniformBlockBinding(y,b)}function c(y,x){let b=i[y.id];b===void 0&&(g(y),b=h(y),i[y.id]=b,y.addEventListener("dispose",m));const L=x.program;n.updateUBOMapping(y,L);const T=t.render.frame;r[y.id]!==T&&(d(y),r[y.id]=T)}function h(y){const x=u();y.__bindingPointIndex=x;const b=s.createBuffer(),L=y.__size,T=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,b),s.bufferData(s.UNIFORM_BUFFER,L,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,x,b),b}function u(){for(let y=0;y0&&(b+=L-T),y.__size=b,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){const x=y.target;x.removeEventListener("dispose",m);const b=a.indexOf(x.__bindingPointIndex);a.splice(b,1),s.deleteBuffer(i[x.id]),delete i[x.id],delete r[x.id]}function f(){for(const y in i)s.deleteBuffer(i[y]);a=[],i={},r={}}return{bind:l,update:c,dispose:f}}class jg{constructor(t={}){const{canvas:e=Uh(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!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=a;const p=new Uint32Array(4),g=new Int32Array(4);let _=null,m=null;const f=[],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=Ke,this.toneMapping=An,this.toneMappingExposure=1;const x=this;let b=!1,L=0,T=0,A=null,I=-1,S=null;const v=new Zt,C=new Zt;let z=null;const B=new Mt(0);let H=0,Y=e.width,k=e.height,Z=1,G=null,ct=null;const pt=new Zt(0,0,Y,k),mt=new Zt(0,0,Y,k);let Ot=!1;const jt=new Js;let W=!1,J=!1;const ut=new Rt,ot=new R,Ct=new Zt,Ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ft=!1;function te(){return A===null?Z:1}let P=n;function se(E,U){return e.getContext(E,U)}try{const E={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ca}`),e.addEventListener("webglcontextlost",X,!1),e.addEventListener("webglcontextrestored",q,!1),e.addEventListener("webglcontextcreationerror",nt,!1),P===null){const U="webgl2";if(P=se(U,E),P===null)throw se(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let qt,$t,_t,re,At,Pt,w,M,V,j,$,K,xt,st,lt,It,Q,at,Bt,bt,ht,wt,Nt,Qt;function D(){qt=new Qf(P),qt.init(),wt=new Fm(P,qt),$t=new Yf(P,qt,t,wt),_t=new Dm(P),re=new np(P),At=new vm,Pt=new Nm(P,qt,_t,At,$t,wt,re),w=new jf(x),M=new Jf(x),V=new lu(P),Nt=new Xf(P,V),j=new tp(P,V,re,Nt),$=new sp(P,j,V,re),Bt=new ip(P,$t,Pt),It=new Kf(At),K=new xm(x,w,M,qt,$t,Nt,It),xt=new Wm(x,At),st=new ym,lt=new wm(qt),at=new Wf(x,w,M,_t,$,d,l),Q=new Lm(x,$,$t),Qt=new Xm(P,re,$t,_t),bt=new qf(P,qt,re),ht=new ep(P,qt,re),re.programs=K.programs,x.capabilities=$t,x.extensions=qt,x.properties=At,x.renderLists=st,x.shadowMap=Q,x.state=_t,x.info=re}D();const tt=new km(x,P);this.xr=tt,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const E=qt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=qt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(E){E!==void 0&&(Z=E,this.setSize(Y,k,!1))},this.getSize=function(E){return E.set(Y,k)},this.setSize=function(E,U,F=!0){if(tt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=E,k=U,e.width=Math.floor(E*Z),e.height=Math.floor(U*Z),F===!0&&(e.style.width=E+"px",e.style.height=U+"px"),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(Y*Z,k*Z).floor()},this.setDrawingBufferSize=function(E,U,F){Y=E,k=U,Z=F,e.width=Math.floor(E*F),e.height=Math.floor(U*F),this.setViewport(0,0,E,U)},this.getCurrentViewport=function(E){return E.copy(v)},this.getViewport=function(E){return E.copy(pt)},this.setViewport=function(E,U,F,O){E.isVector4?pt.set(E.x,E.y,E.z,E.w):pt.set(E,U,F,O),_t.viewport(v.copy(pt).multiplyScalar(Z).round())},this.getScissor=function(E){return E.copy(mt)},this.setScissor=function(E,U,F,O){E.isVector4?mt.set(E.x,E.y,E.z,E.w):mt.set(E,U,F,O),_t.scissor(C.copy(mt).multiplyScalar(Z).round())},this.getScissorTest=function(){return Ot},this.setScissorTest=function(E){_t.setScissorTest(Ot=E)},this.setOpaqueSort=function(E){G=E},this.setTransparentSort=function(E){ct=E},this.getClearColor=function(E){return E.copy(at.getClearColor())},this.setClearColor=function(){at.setClearColor.apply(at,arguments)},this.getClearAlpha=function(){return at.getClearAlpha()},this.setClearAlpha=function(){at.setClearAlpha.apply(at,arguments)},this.clear=function(E=!0,U=!0,F=!0){let O=0;if(E){let N=!1;if(A!==null){const et=A.texture.format;N=et===Fa||et===Na||et===$s}if(N){const et=A.texture.type,rt=et===dn||et===Rn||et===zi||et===vi||et===La||et===Da,dt=at.getClearColor(),ft=at.getClearAlpha(),St=dt.r,Et=dt.g,vt=dt.b;rt?(p[0]=St,p[1]=Et,p[2]=vt,p[3]=ft,P.clearBufferuiv(P.COLOR,0,p)):(g[0]=St,g[1]=Et,g[2]=vt,g[3]=ft,P.clearBufferiv(P.COLOR,0,g))}else O|=P.COLOR_BUFFER_BIT}U&&(O|=P.DEPTH_BUFFER_BIT),F&&(O|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(O)},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",X,!1),e.removeEventListener("webglcontextrestored",q,!1),e.removeEventListener("webglcontextcreationerror",nt,!1),st.dispose(),lt.dispose(),At.dispose(),w.dispose(),M.dispose(),$.dispose(),Nt.dispose(),Qt.dispose(),K.dispose(),tt.dispose(),tt.removeEventListener("sessionstart",Ye),tt.removeEventListener("sessionend",qa),Ln.stop()};function X(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function q(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const E=re.autoReset,U=Q.enabled,F=Q.autoUpdate,O=Q.needsUpdate,N=Q.type;D(),re.autoReset=E,Q.enabled=U,Q.autoUpdate=F,Q.needsUpdate=O,Q.type=N}function nt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function yt(E){const U=E.target;U.removeEventListener("dispose",yt),zt(U)}function zt(E){ae(E),At.remove(E)}function ae(E){const U=At.get(E).programs;U!==void 0&&(U.forEach(function(F){K.releaseProgram(F)}),E.isShaderMaterial&&K.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,F,O,N,et){U===null&&(U=Ut);const rt=N.isMesh&&N.matrixWorld.determinant()<0,dt=mc(E,U,F,O,N);_t.setMaterial(O,rt);let ft=F.index,St=1;if(O.wireframe===!0){if(ft=j.getWireframeAttribute(F),ft===void 0)return;St=2}const Et=F.drawRange,vt=F.attributes.position;let kt=Et.start*St,ee=(Et.start+Et.count)*St;et!==null&&(kt=Math.max(kt,et.start*St),ee=Math.min(ee,(et.start+et.count)*St)),ft!==null?(kt=Math.max(kt,0),ee=Math.min(ee,ft.count)):vt!=null&&(kt=Math.max(kt,0),ee=Math.min(ee,vt.count));const ne=ee-kt;if(ne<0||ne===1/0)return;Nt.setup(N,O,dt,F,ft);let Ce,Gt=bt;if(ft!==null&&(Ce=V.get(ft),Gt=ht,Gt.setIndex(Ce)),N.isMesh)O.wireframe===!0?(_t.setLineWidth(O.wireframeLinewidth*te()),Gt.setMode(P.LINES)):Gt.setMode(P.TRIANGLES);else if(N.isLine){let gt=O.linewidth;gt===void 0&&(gt=1),_t.setLineWidth(gt*te()),N.isLineSegments?Gt.setMode(P.LINES):N.isLineLoop?Gt.setMode(P.LINE_LOOP):Gt.setMode(P.LINE_STRIP)}else N.isPoints?Gt.setMode(P.POINTS):N.isSprite&&Gt.setMode(P.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)Gt.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(qt.get("WEBGL_multi_draw"))Gt.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const gt=N._multiDrawStarts,ge=N._multiDrawCounts,Wt=N._multiDrawCount,Be=ft?V.get(ft).bytesPerElement:1,Xn=At.get(O).currentProgram.getUniforms();for(let Pe=0;Pe{function et(){if(O.forEach(function(rt){At.get(rt).currentProgram.isReady()&&O.delete(rt)}),O.size===0){N(E);return}setTimeout(et,10)}qt.get("KHR_parallel_shader_compile")!==null?et():setTimeout(et,10)})};let Ht=null;function Ze(E){Ht&&Ht(E)}function Ye(){Ln.stop()}function qa(){Ln.start()}const Ln=new ql;Ln.setAnimationLoop(Ze),typeof self<"u"&&Ln.setContext(self),this.setAnimationLoop=function(E){Ht=E,tt.setAnimationLoop(E),E===null?Ln.stop():Ln.start()},tt.addEventListener("sessionstart",Ye),tt.addEventListener("sessionend",qa),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(U),U=tt.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,U,A),m=lt.get(E,y.length),m.init(U),y.push(m),ut.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),jt.setFromProjectionMatrix(ut),J=this.localClippingEnabled,W=It.init(this.clippingPlanes,J),_=st.get(E,f.length),_.init(),f.push(_),tt.enabled===!0&&tt.isPresenting===!0){const et=x.xr.getDepthSensingMesh();et!==null&&rr(et,U,-1/0,x.sortObjects)}rr(E,U,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(G,ct),Ft=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,Ft&&at.addToRenderList(_,E),this.info.render.frame++,W===!0&&It.beginShadows();const F=m.state.shadowsArray;Q.render(F,E,U),W===!0&&It.endShadows(),this.info.autoReset===!0&&this.info.reset();const O=_.opaque,N=_.transmissive;if(m.setupLights(),U.isArrayCamera){const et=U.cameras;if(N.length>0)for(let rt=0,dt=et.length;rt0&&Ka(O,N,E,U),Ft&&at.render(E),Ya(_,E,U);A!==null&&(Pt.updateMultisampleRenderTarget(A),Pt.updateRenderTargetMipmap(A)),E.isScene===!0&&E.onAfterRender(x,E,U),Nt.resetDefaultState(),I=-1,S=null,y.pop(),y.length>0?(m=y[y.length-1],W===!0&&It.setGlobalState(x.clippingPlanes,m.state.camera)):m=null,f.pop(),f.length>0?_=f[f.length-1]:_=null};function rr(E,U,F,O){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)F=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLight)m.pushLight(E),E.castShadow&&m.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||jt.intersectsSprite(E)){O&&Ct.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ut);const rt=$.update(E),dt=E.material;dt.visible&&_.push(E,rt,dt,F,Ct.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||jt.intersectsObject(E))){const rt=$.update(E),dt=E.material;if(O&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ct.copy(E.boundingSphere.center)):(rt.boundingSphere===null&&rt.computeBoundingSphere(),Ct.copy(rt.boundingSphere.center)),Ct.applyMatrix4(E.matrixWorld).applyMatrix4(ut)),Array.isArray(dt)){const ft=rt.groups;for(let St=0,Et=ft.length;St0&&Ki(N,U,F),et.length>0&&Ki(et,U,F),rt.length>0&&Ki(rt,U,F),_t.buffers.depth.setTest(!0),_t.buffers.depth.setMask(!0),_t.buffers.color.setMask(!0),_t.setPolygonOffset(!1)}function Ka(E,U,F,O){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[O.id]===void 0&&(m.state.transmissionRenderTarget[O.id]=new Cn(1,1,{generateMipmaps:!0,type:qt.has("EXT_color_buffer_half_float")||qt.has("EXT_color_buffer_float")?ki:dn,minFilter:En,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xt.workingColorSpace}));const et=m.state.transmissionRenderTarget[O.id],rt=O.viewport||v;et.setSize(rt.z,rt.w);const dt=x.getRenderTarget();x.setRenderTarget(et),x.getClearColor(B),H=x.getClearAlpha(),H<1&&x.setClearColor(16777215,.5),Ft?at.render(F):x.clear();const ft=x.toneMapping;x.toneMapping=An;const St=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),m.setupLightsView(O),W===!0&&It.setGlobalState(x.clippingPlanes,O),Ki(E,F,O),Pt.updateMultisampleRenderTarget(et),Pt.updateRenderTargetMipmap(et),qt.has("WEBGL_multisampled_render_to_texture")===!1){let Et=!1;for(let vt=0,kt=U.length;vt0),vt=!!F.morphAttributes.position,kt=!!F.morphAttributes.normal,ee=!!F.morphAttributes.color;let ne=An;O.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(ne=x.toneMapping);const Ce=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,Gt=Ce!==void 0?Ce.length:0,gt=At.get(O),ge=m.state.lights;if(W===!0&&(J===!0||E!==S)){const Fe=E===S&&O.id===I;It.setState(O,E,Fe)}let Wt=!1;O.version===gt.__version?(gt.needsLights&>.lightsStateVersion!==ge.state.version||gt.outputColorSpace!==dt||N.isBatchedMesh&>.batching===!1||!N.isBatchedMesh&>.batching===!0||N.isBatchedMesh&>.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&>.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&>.instancing===!1||!N.isInstancedMesh&>.instancing===!0||N.isSkinnedMesh&>.skinning===!1||!N.isSkinnedMesh&>.skinning===!0||N.isInstancedMesh&>.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&>.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&>.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&>.instancingMorph===!1&&N.morphTexture!==null||gt.envMap!==ft||O.fog===!0&>.fog!==et||gt.numClippingPlanes!==void 0&&(gt.numClippingPlanes!==It.numPlanes||gt.numIntersection!==It.numIntersection)||gt.vertexAlphas!==St||gt.vertexTangents!==Et||gt.morphTargets!==vt||gt.morphNormals!==kt||gt.morphColors!==ee||gt.toneMapping!==ne||gt.morphTargetsCount!==Gt)&&(Wt=!0):(Wt=!0,gt.__version=O.version);let Be=gt.currentProgram;Wt===!0&&(Be=ji(O,U,N));let Xn=!1,Pe=!1,ar=!1;const oe=Be.getUniforms(),fn=gt.uniforms;if(_t.useProgram(Be.program)&&(Xn=!0,Pe=!0,ar=!0),O.id!==I&&(I=O.id,Pe=!0),Xn||S!==E){oe.setValue(P,"projectionMatrix",E.projectionMatrix),oe.setValue(P,"viewMatrix",E.matrixWorldInverse);const Fe=oe.map.cameraPosition;Fe!==void 0&&Fe.setValue(P,ot.setFromMatrixPosition(E.matrixWorld)),$t.logarithmicDepthBuffer&&oe.setValue(P,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&oe.setValue(P,"isOrthographic",E.isOrthographicCamera===!0),S!==E&&(S=E,Pe=!0,ar=!0)}if(N.isSkinnedMesh){oe.setOptional(P,N,"bindMatrix"),oe.setOptional(P,N,"bindMatrixInverse");const Fe=N.skeleton;Fe&&(Fe.boneTexture===null&&Fe.computeBoneTexture(),oe.setValue(P,"boneTexture",Fe.boneTexture,Pt))}N.isBatchedMesh&&(oe.setOptional(P,N,"batchingTexture"),oe.setValue(P,"batchingTexture",N._matricesTexture,Pt),oe.setOptional(P,N,"batchingIdTexture"),oe.setValue(P,"batchingIdTexture",N._indirectTexture,Pt),oe.setOptional(P,N,"batchingColorTexture"),N._colorsTexture!==null&&oe.setValue(P,"batchingColorTexture",N._colorsTexture,Pt));const or=F.morphAttributes;if((or.position!==void 0||or.normal!==void 0||or.color!==void 0)&&Bt.update(N,F,Be),(Pe||gt.receiveShadow!==N.receiveShadow)&&(gt.receiveShadow=N.receiveShadow,oe.setValue(P,"receiveShadow",N.receiveShadow)),O.isMeshGouraudMaterial&&O.envMap!==null&&(fn.envMap.value=ft,fn.flipEnvMap.value=ft.isCubeTexture&&ft.isRenderTargetTexture===!1?-1:1),O.isMeshStandardMaterial&&O.envMap===null&&U.environment!==null&&(fn.envMapIntensity.value=U.environmentIntensity),Pe&&(oe.setValue(P,"toneMappingExposure",x.toneMappingExposure),gt.needsLights&&gc(fn,ar),et&&O.fog===!0&&xt.refreshFogUniforms(fn,et),xt.refreshMaterialUniforms(fn,O,Z,k,m.state.transmissionRenderTarget[E.id]),Fs.upload(P,$a(gt),fn,Pt)),O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(Fs.upload(P,$a(gt),fn,Pt),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&oe.setValue(P,"center",N.center),oe.setValue(P,"modelViewMatrix",N.modelViewMatrix),oe.setValue(P,"normalMatrix",N.normalMatrix),oe.setValue(P,"modelMatrix",N.matrixWorld),O.isShaderMaterial||O.isRawShaderMaterial){const Fe=O.uniformsGroups;for(let lr=0,xc=Fe.length;lr0&&Pt.useMultisampledRTT(E)===!1?N=At.get(E).__webglMultisampledFramebuffer:Array.isArray(Et)?N=Et[F]:N=Et,v.copy(E.viewport),C.copy(E.scissor),z=E.scissorTest}else v.copy(pt).multiplyScalar(Z).floor(),C.copy(mt).multiplyScalar(Z).floor(),z=Ot;if(_t.bindFramebuffer(P.FRAMEBUFFER,N)&&O&&_t.drawBuffers(E,N),_t.viewport(v),_t.scissor(C),_t.setScissorTest(z),et){const ft=At.get(E.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+U,ft.__webglTexture,F)}else if(rt){const ft=At.get(E.texture),St=U||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,ft.__webglTexture,F||0,St)}I=-1},this.readRenderTargetPixels=function(E,U,F,O,N,et,rt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let dt=At.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&rt!==void 0&&(dt=dt[rt]),dt){_t.bindFramebuffer(P.FRAMEBUFFER,dt);try{const ft=E.texture,St=ft.format,Et=ft.type;if(!$t.textureFormatReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!$t.textureTypeReadable(Et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-O&&F>=0&&F<=E.height-N&&P.readPixels(U,F,O,N,wt.convert(St),wt.convert(Et),et)}finally{const ft=A!==null?At.get(A).__webglFramebuffer:null;_t.bindFramebuffer(P.FRAMEBUFFER,ft)}}},this.readRenderTargetPixelsAsync=async function(E,U,F,O,N,et,rt){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let dt=At.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&rt!==void 0&&(dt=dt[rt]),dt){_t.bindFramebuffer(P.FRAMEBUFFER,dt);try{const ft=E.texture,St=ft.format,Et=ft.type;if(!$t.textureFormatReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!$t.textureTypeReadable(Et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(U>=0&&U<=E.width-O&&F>=0&&F<=E.height-N){const vt=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,vt),P.bufferData(P.PIXEL_PACK_BUFFER,et.byteLength,P.STREAM_READ),P.readPixels(U,F,O,N,wt.convert(St),wt.convert(Et),0),P.flush();const kt=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);await Nh(P,kt,4);try{P.bindBuffer(P.PIXEL_PACK_BUFFER,vt),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,et)}finally{P.deleteBuffer(vt),P.deleteSync(kt)}return et}}finally{const ft=A!==null?At.get(A).__webglFramebuffer:null;_t.bindFramebuffer(P.FRAMEBUFFER,ft)}}},this.copyFramebufferToTexture=function(E,U=null,F=0){E.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),U=arguments[0]||null,E=arguments[1]);const O=Math.pow(2,-F),N=Math.floor(E.image.width*O),et=Math.floor(E.image.height*O),rt=U!==null?U.x:0,dt=U!==null?U.y:0;Pt.setTexture2D(E,0),P.copyTexSubImage2D(P.TEXTURE_2D,F,0,0,rt,dt,N,et),_t.unbindTexture()},this.copyTextureToTexture=function(E,U,F=null,O=null,N=0){E.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),O=arguments[0]||null,E=arguments[1],U=arguments[2],N=arguments[3]||0,F=null);let et,rt,dt,ft,St,Et;F!==null?(et=F.max.x-F.min.x,rt=F.max.y-F.min.y,dt=F.min.x,ft=F.min.y):(et=E.image.width,rt=E.image.height,dt=0,ft=0),O!==null?(St=O.x,Et=O.y):(St=0,Et=0);const vt=wt.convert(U.format),kt=wt.convert(U.type);Pt.setTexture2D(U,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,U.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,U.unpackAlignment);const ee=P.getParameter(P.UNPACK_ROW_LENGTH),ne=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Ce=P.getParameter(P.UNPACK_SKIP_PIXELS),Gt=P.getParameter(P.UNPACK_SKIP_ROWS),gt=P.getParameter(P.UNPACK_SKIP_IMAGES),ge=E.isCompressedTexture?E.mipmaps[N]:E.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,ge.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,ge.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,dt),P.pixelStorei(P.UNPACK_SKIP_ROWS,ft),E.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,N,St,Et,et,rt,vt,kt,ge.data):E.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,N,St,Et,ge.width,ge.height,vt,ge.data):P.texSubImage2D(P.TEXTURE_2D,N,St,Et,et,rt,vt,kt,ge),P.pixelStorei(P.UNPACK_ROW_LENGTH,ee),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,ne),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ce),P.pixelStorei(P.UNPACK_SKIP_ROWS,Gt),P.pixelStorei(P.UNPACK_SKIP_IMAGES,gt),N===0&&U.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),_t.unbindTexture()},this.copyTextureToTexture3D=function(E,U,F=null,O=null,N=0){E.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),F=arguments[0]||null,O=arguments[1]||null,E=arguments[2],U=arguments[3],N=arguments[4]||0);let et,rt,dt,ft,St,Et,vt,kt,ee;const ne=E.isCompressedTexture?E.mipmaps[N]:E.image;F!==null?(et=F.max.x-F.min.x,rt=F.max.y-F.min.y,dt=F.max.z-F.min.z,ft=F.min.x,St=F.min.y,Et=F.min.z):(et=ne.width,rt=ne.height,dt=ne.depth,ft=0,St=0,Et=0),O!==null?(vt=O.x,kt=O.y,ee=O.z):(vt=0,kt=0,ee=0);const Ce=wt.convert(U.format),Gt=wt.convert(U.type);let gt;if(U.isData3DTexture)Pt.setTexture3D(U,0),gt=P.TEXTURE_3D;else if(U.isDataArrayTexture||U.isCompressedArrayTexture)Pt.setTexture2DArray(U,0),gt=P.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,U.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,U.unpackAlignment);const ge=P.getParameter(P.UNPACK_ROW_LENGTH),Wt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Be=P.getParameter(P.UNPACK_SKIP_PIXELS),Xn=P.getParameter(P.UNPACK_SKIP_ROWS),Pe=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,ne.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,ne.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,ft),P.pixelStorei(P.UNPACK_SKIP_ROWS,St),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Et),E.isDataTexture||E.isData3DTexture?P.texSubImage3D(gt,N,vt,kt,ee,et,rt,dt,Ce,Gt,ne.data):U.isCompressedArrayTexture?P.compressedTexSubImage3D(gt,N,vt,kt,ee,et,rt,dt,Ce,ne.data):P.texSubImage3D(gt,N,vt,kt,ee,et,rt,dt,Ce,Gt,ne),P.pixelStorei(P.UNPACK_ROW_LENGTH,ge),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Wt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Be),P.pixelStorei(P.UNPACK_SKIP_ROWS,Xn),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Pe),N===0&&U.generateMipmaps&&P.generateMipmap(gt),_t.unbindTexture()},this.initRenderTarget=function(E){At.get(E).__webglFramebuffer===void 0&&Pt.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?Pt.setTextureCube(E,0):E.isData3DTexture?Pt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Pt.setTexture2DArray(E,0):Pt.setTexture2D(E,0),_t.unbindTexture()},this.resetState=function(){L=0,T=0,A=null,_t.reset(),Nt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Ba?"display-p3":"srgb",e.unpackColorSpace=Xt.workingColorSpace===Zs?"display-p3":"srgb"}}class Ql{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Mt(t),this.near=e,this.far=n}clone(){return new Ql(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $g extends ie{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 Xe,this.environmentIntensity=1,this.environmentRotation=new Xe,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}}class Zg{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Ta,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=We()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Va("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const a=i[this.index];r.push(a),this.index++,a.start=t.start,a.count=t.count,a.z=e,a.index=n}reset(){this.list.length=0,this.index=0}}const Mn=new Rt,Br=new Rt,Qm=new Rt,tg=new Mt(1,1,1),al=new Rt,zr=new Js,ys=new Ne,zn=new Re,Di=new R,ol=new R,eg=new R,Vr=new Jm,ve=new Ae,Ss=[];function ng(s,t,e=0){const n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){const i=s.count;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new pe(r,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ne);const t=this._geometryCount,e=this.boundingBox,n=this._drawInfo;e.makeEmpty();for(let i=0;i=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:t});const e=this._drawInfo.length-1,n=this._matricesTexture,i=n.image.data;Qm.toArray(i,e*16),n.needsUpdate=!0;const r=this._colorsTexture;return r&&(tg.toArray(r.image.data,e*4),r.needsUpdate=!0),e}addGeometry(t,e=-1,n=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(r=a[a.length-1]),e===-1?i.vertexCount=t.getAttribute("position").count:i.vertexCount=e,r===null?i.vertexStart=0:i.vertexStart=r.vertexStart+r.vertexCount;const c=t.getIndex(),h=c!==null;if(h&&(n===-1?i.indexCount=c.count:i.indexCount=n,r===null?i.indexStart=0:i.indexStart=r.indexStart+r.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._geometryCount;return this._geometryCount++,a.push(i),o.push({start:h?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Ne,sphereInitialized:!1,sphere:new Re}),this.setGeometryAt(u,t),u}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),a=e.getIndex(),o=this._reservedRanges[t];if(i&&a.count>o.indexCount||e.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in n.attributes){const g=e.getAttribute(p),_=n.getAttribute(p);ng(g,_,l);const m=g.itemSize;for(let f=g.count,y=c;f=this._geometryCount)return null;const n=this._bounds[t],i=n.box,r=this.geometry;if(n.boxInitialized===!1){i.makeEmpty();const a=r.index,o=r.attributes.position,l=this._drawRanges[t];for(let c=l.start,h=l.start+l.count;c=this._geometryCount)return null;const n=this._bounds[t],i=n.sphere,r=this.geometry;if(n.sphereInitialized===!1){i.makeEmpty(),this.getBoundingBoxAt(t,ys),ys.getCenter(i.center);const a=r.index,o=r.attributes.position,l=this._drawRanges[t];let c=0;for(let h=l.start,u=l.start+l.count;h=n.length||n[t].active===!1?this:(e.toArray(r,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){const n=this._drawInfo,i=this._matricesTexture.image.data;return t>=n.length||n[t].active===!1?null:e.fromArray(i,t*16)}setColorAt(t,e){this._colorsTexture===null&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._drawInfo;return t>=r.length||r[t].active===!1?this:(e.toArray(i,t*4),n.needsUpdate=!0,this)}getColorAt(t,e){const n=this._colorsTexture.image.data,i=this._drawInfo;return t>=i.length||i[t].active===!1?null:e.fromArray(n,t*4)}setVisibleAt(t,e){const n=this._drawInfo;return t>=n.length||n[t].active===!1||n[t].visible===e?this:(n[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){const e=this._drawInfo;return t>=e.length||e[t].active===!1?!1:e[t].visible}raycast(t,e){const n=this._drawInfo,i=this._drawRanges,r=this.matrixWorld,a=this.geometry;ve.material=this.material,ve.geometry.index=a.index,ve.geometry.attributes=a.attributes,ve.geometry.boundingBox===null&&(ve.geometry.boundingBox=new Ne),ve.geometry.boundingSphere===null&&(ve.geometry.boundingSphere=new Re);for(let o=0,l=n.length;o({...e})),this._reservedRanges=t._reservedRanges.map(e=>({...e})),this._drawInfo=t._drawInfo.map(e=>({...e})),this._bounds=t._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,u=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,g=p.image.data;d&&(al.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),zr.setFromProjectionMatrix(al,t.coordinateSystem));let _=0;if(this.sortObjects){Br.copy(this.matrixWorld).invert(),Di.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Br),ol.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Br);for(let y=0,x=l.length;y0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;rn)return;Hr.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Hr);if(!(lt.far))return{distance:l,point:cl.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,object:s}}const hl=new R,ul=new R;class er extends nc{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,r=e.count;i0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;ri.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,object:a})}}class ic extends ce{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],p=[];let g=0;const _=[],m=n/2;let f=0;y(),a===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new Vt(u,3)),this.setAttribute("normal",new Vt(d,3)),this.setAttribute("uv",new Vt(p,2));function y(){const b=new R,L=new R;let T=0;const A=(e-t)/n;for(let I=0;I<=r;I++){const S=[],v=I/r,C=v*(e-t)+t;for(let z=0;z<=i;z++){const B=z/i,H=B*l+o,Y=Math.sin(H),k=Math.cos(H);L.x=C*Y,L.y=-v*n+m,L.z=C*k,u.push(L.x,L.y,L.z),b.set(Y,A,k).normalize(),d.push(b.x,b.y,b.z),p.push(B,1-v),S.push(g++)}_.push(S)}for(let I=0;I.9&&A<.1&&(x<.2&&(a[y+0]+=1),b<.2&&(a[y+2]+=1),L<.2&&(a[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function p(y,x){const b=y*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function g(){const y=new R,x=new R,b=new R,L=new R,T=new Tt,A=new Tt,I=new Tt;for(let S=0,v=0;S0)&&p.push(x,b,T),(f!==n-1||l0!=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 r_ extends qe{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Mt(16777215),this.specular=new Mt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Gi,this.normalScale=new Tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xe,this.combine=Pa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class a_ extends qe{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Gi,this.normalScale=new Tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class o_ extends qe{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Mt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Gi,this.normalScale=new Tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}function ws(s,t,e){return!s||!e&&s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function rg(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function ag(s){function t(i,r){return s[i]-s[r]}const e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function pl(s,t,e){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=e[r]*t;for(let l=0;l!==t;++l)i[a++]=s[o+l]}return i}function hc(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push.apply(e,a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}class ir{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let a;n:{i:if(!(t=r)){const o=e[1];t=r)break e}a=n,n=0;break n}break t}for(;n>>1;te;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(i!==void 0&&rg(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===hr,r=t.length-1;let a=1;for(let o=1;o0){t[a]=t[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}$e.prototype.TimeBufferType=Float32Array;$e.prototype.ValueBufferType=Float32Array;$e.prototype.DefaultInterpolation=ba;class bi extends $e{constructor(t,e,n){super(t,e,n)}}bi.prototype.ValueTypeName="bool";bi.prototype.ValueBufferType=Array;bi.prototype.DefaultInterpolation=Bs;bi.prototype.InterpolantFactoryMethodLinear=void 0;bi.prototype.InterpolantFactoryMethodSmooth=void 0;class dc extends $e{}dc.prototype.ValueTypeName="color";class qs extends $e{}qs.prototype.ValueTypeName="number";class cg extends ir{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(i-e);let c=t*o;for(let h=c+o;c!==h;c+=4)un.slerpFlat(r,0,a,c-o,a,c,l);return r}}class sr extends $e{InterpolantFactoryMethodLinear(t){return new cg(this.times,this.values,this.getValueSize(),t)}}sr.prototype.ValueTypeName="quaternion";sr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ti extends $e{constructor(t,e,n){super(t,e,n)}}Ti.prototype.ValueTypeName="string";Ti.prototype.ValueBufferType=Array;Ti.prototype.DefaultInterpolation=Bs;Ti.prototype.InterpolantFactoryMethodLinear=void 0;Ti.prototype.InterpolantFactoryMethodSmooth=void 0;class Ys extends $e{}Ys.prototype.ValueTypeName="vector";class ml{constructor(t="",e=-1,n=[],i=Oa){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=We(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(ug(n[a]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let r=0,a=n.length;r!==a;++r)e.push($e.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,a=[];for(let o=0;o1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,p,g,_){if(p.length!==0){const m=[],f=[];hc(p,m,f,g),m.length!==0&&_.push(new u(d,m,f))}},i=[],r=t.name||"default",a=t.fps||30,o=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u{e&&e(r),this.manager.itemEnd(t)},0),r;if(sn[t]!==void 0){sn[t].push({onLoad:e,onProgress:n,onError:i});return}sn[t]=[],sn[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=sn[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,g=p!==0;let _=0;const m=new ReadableStream({start(f){y();function y(){u.read().then(({done:x,value:b})=>{if(x)f.close();else{_+=b.byteLength;const L=new ProgressEvent("progress",{lengthComputable:g,loaded:_,total:p});for(let T=0,A=h.length;T{f.error(x)})}}});return new Response(m)}else throw new pg(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(g=>p.decode(g))}}}).then(c=>{bn.add(t,c);const h=sn[t];delete sn[t];for(let u=0,d=h.length;u{const h=sn[t];if(h===void 0)throw this.manager.itemError(t),c;delete sn[t];for(let u=0,d=h.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class gg extends Ai{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=bn.get(t);if(a!==void 0)return r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0),a;const o=Vi("img");function l(){h(),bn.add(t,this),e&&e(this),r.manager.itemEnd(t)}function c(u){h(),i&&i(u),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(t),o.src=t,o}}class l_ extends Ai{constructor(t){super(t)}load(t,e,n,i){const r=this,a=new gi,o=new mg(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(t,function(l){let c;try{c=r.parse(l)}catch(h){if(i!==void 0)i(h);else{console.error(h);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:cn,a.wrapT=c.wrapT!==void 0?c.wrapT:cn,a.magFilter=c.magFilter!==void 0?c.magFilter:Ee,a.minFilter=c.minFilter!==void 0?c.minFilter:Ee,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=En),c.mipmapCount===1&&(a.minFilter=Ee),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,e&&e(a,c)},n,i),a}}class c_ extends Ai{constructor(t){super(t)}load(t,e,n,i){const r=new Me,a=new gg(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){r.image=o,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}}class Yi extends ie{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Mt(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 h_ extends Yi{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ie.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Mt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const kr=new Rt,gl=new R,_l=new R;class Ga{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Tt(512,512),this.map=null,this.mapPass=null,this.matrix=new Rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Js,this._frameExtents=new Tt(1,1),this._viewportCount=1,this._viewports=[new Zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;gl.setFromMatrixPosition(t.matrixWorld),e.position.copy(gl),_l.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(_l),e.updateMatrixWorld(),kr.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kr),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(kr)}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}}class _g extends Ga{constructor(){super(new De(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=yi*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class u_ extends Yi{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ie.DEFAULT_UP),this.updateMatrix(),this.target=new ie,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new _g}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const xl=new Rt,Ni=new R,Gr=new R;class xg extends Ga{constructor(){super(new De(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Tt(4,2),this._viewportCount=6,this._viewports=[new Zt(2,1,1,1),new Zt(0,1,1,1),new Zt(3,1,1,1),new Zt(1,1,1,1),new Zt(3,0,1,1),new Zt(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Ni.setFromMatrixPosition(t.matrixWorld),n.position.copy(Ni),Gr.copy(n.position),Gr.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Gr),n.updateMatrixWorld(),i.makeTranslation(-Ni.x,-Ni.y,-Ni.z),xl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xl)}}class d_ extends Yi{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new xg}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 vg extends Ga{constructor(){super(new Yl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class f_ extends Yi{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ie.DEFAULT_UP),this.updateMatrix(),this.target=new ie,this.shadow=new vg}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class p_ extends Yi{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class m_{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=bn.get(t);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(c=>{e&&e(c),r.manager.itemEnd(t)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return bn.add(t,c),e&&e(c),r.manager.itemEnd(t),c}).catch(function(c){i&&i(c),bn.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)});bn.add(t,l),r.manager.itemStart(t)}}class __{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vl(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=vl();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function vl(){return(typeof performance>"u"?Date:performance).now()}class Mg{constructor(t,e,n){this.binding=t,this.valueSize=n;let i,r,a;switch(e){case"quaternion":i=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,r=t*i+i;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==i;++o)n[r+o]=n[o];a=e}else{a+=e;const o=e/a;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=a}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const l=e*this._origIndex;this._mixBufferRegion(n,i,l,1-r,e)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){o.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,a=i;r!==a;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let a=0;a!==r;++a)t[e+a]=t[n+a]}_slerp(t,e,n,i){un.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const a=this._workIndex*r;un.multiplyQuaternionsFlat(t,a,t,e,t,n),un.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,r){const a=1-i;for(let o=0;o!==r;++o){const l=e+o;t[l]=t[l]*a+t[n+o]*i}}_lerpAdditive(t,e,n,i,r){for(let a=0;a!==r;++a){const o=e+a;t[o]=t[o]+t[n+a]*i}}}const Wa="\\[\\]\\.:\\/",yg=new RegExp("["+Wa+"]","g"),Xa="[^"+Wa+"]",Sg="[^"+Wa.replace("\\.","")+"]",Eg=/((?:WC+[\/:])*)/.source.replace("WC",Xa),bg=/(WCOD+)?/.source.replace("WCOD",Sg),Tg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xa),Ag=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xa),wg=new RegExp("^"+Eg+bg+Tg+Ag+"$"),Rg=["material","materials","bones","map"];class Cg{constructor(t,e,n){const i=n||Kt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class Kt{constructor(t,e,n){this.path=e,this.parsedPath=n||Kt.parseTrackName(e),this.node=Kt.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Kt.Composite(t,e,n):new Kt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(yg,"")}static parseTrackName(t){const e=wg.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);Rg.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(r){for(let a=0;a0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case oh:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Oa:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const a=n===ah;if(t===0)return r===-1?i:a&&(r&1)===1?e-i:i;if(n===sh){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(r===-1&&(t>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=e||i<0){const o=Math.floor(i/e);i-=e*o,r+=Math.abs(o);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(r&1)===1)return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=ui,i.endingEnd=ui):(t?i.endingStart=this.zeroSlopeAtStart?ui:hi:i.endingStart=zs,e?i.endingEnd=this.zeroSlopeAtEnd?ui:hi:i.endingEnd=zs)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,l[0]=e,o[1]=r+t,l[1]=n,this}}const Ig=new Float32Array(1);class x_ extends Wn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,a=t._propertyBindings,o=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==r;++u){const d=i[u],p=d.name;let g=h[p];if(g!==void 0)++g.referenceCount,a[u]=g;else{if(g=a[u],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,l,p));continue}const _=e&&e._propertyBindings[u].binding.parsedPath;g=new Mg(Kt.create(n,p,_),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,l,p),a[u]=g}o[u].resultBuffer=g.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const n=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,n)}const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const r=e[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const r=e[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,r,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(t){this.time=0;for(let e=0;ei?l:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,a=e.length;ri?l:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}Ks.prototype.setFromBox=function(){const s=new R;return function(e,n){const i=n.min,r=n.max;let a=1/0,o=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){s.x=i.x*l+r.x*(1-l),s.y=i.y*c+r.y*(1-c),s.z=i.z*h+r.z*(1-h);const u=e.dot(s);a=Math.min(u,a),o=Math.max(u,o)}this.min=a,this.max=o}}();const Lg=function(){const s=new R,t=new R,e=new R;return function(i,r,a){const o=i.start,l=s,c=r.start,h=t;e.subVectors(o,c),s.subVectors(i.end,i.start),t.subVectors(r.end,r.start);const u=e.dot(h),d=h.dot(l),p=h.dot(h),g=e.dot(l),m=l.dot(l)*p-d*d;let f,y;m!==0?f=(u*d-g*p)/m:f=0,y=(u+f*d)/p,a.x=f,a.y=y}}(),pc=function(){const s=new Tt,t=new R,e=new R;return function(i,r,a,o){Lg(i,r,s);let l=s.x,c=s.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,a),r.at(c,o);return}else if(l>=0&&l<=1){c<0?r.at(0,o):r.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(c>=0&&c<=1){l<0?i.at(0,a):i.at(1,a),r.closestPointToPoint(a,!0,o);return}else{let h;l<0?h=i.start:h=i.end;let u;c<0?u=r.start:u=r.end;const d=t,p=e;if(i.closestPointToPoint(u,!0,t),r.closestPointToPoint(h,!0,e),d.distanceToSquared(u)<=p.distanceToSquared(h)){a.copy(d),o.copy(u);return}else{a.copy(h),o.copy(p);return}}}}(),Dg=function(){const s=new R,t=new R,e=new an,n=new Gn;return function(r,a){const{radius:o,center:l}=r,{a:c,b:h,c:u}=a;if(n.start=c,n.end=h,n.closestPointToPoint(l,!0,s).distanceTo(l)<=o||(n.start=c,n.end=u,n.closestPointToPoint(l,!0,s).distanceTo(l)<=o)||(n.start=h,n.end=u,n.closestPointToPoint(l,!0,s).distanceTo(l)<=o))return!0;const _=a.getPlane(e);if(Math.abs(_.distanceToPoint(l))<=o){const f=_.projectPoint(l,t);if(a.containsPoint(f))return!0}return!1}}(),Ug=1e-15;function Xr(s){return Math.abs(s)new R),this.satBounds=new Array(4).fill().map(()=>new Ks),this.points=[this.a,this.b,this.c],this.sphere=new Re,this.plane=new an,this.needsUpdate=!0}intersectsSphere(t){return Dg(t,this)}update(){const t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,a=this.satBounds,o=r[0],l=a[0];this.getNormal(o),l.setFromPoints(o,i);const c=r[1],h=a[1];c.subVectors(t,e),h.setFromPoints(c,i);const u=r[2],d=a[2];u.subVectors(e,n),d.setFromPoints(u,i);const p=r[3],g=a[3];p.subVectors(n,t),g.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}}Hi.prototype.closestPointToSegment=function(){const s=new R,t=new R,e=new Gn;return function(i,r=null,a=null){const{start:o,end:l}=i,c=this.points;let h,u=1/0;for(let d=0;d<3;d++){const p=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[p]),pc(e,i,s,t),h=s.distanceToSquared(t),h=2){(b===1?f.start:f.end).copy(p),x=2;break}if(x++,x===2&&b===-1)break}}return x}return function(m,f=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(s.copy(m),s.update(),m=s);const x=this.plane,b=m.plane;if(Math.abs(x.normal.dot(b.normal))>1-1e-10){const L=this.satBounds,T=this.satAxes;e[0]=m.a,e[1]=m.b,e[2]=m.c;for(let S=0;S<4;S++){const v=L[S],C=T[S];if(n.setFromPoints(C,e),v.isSeparated(n))return!1}const A=m.satBounds,I=m.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){const v=A[S],C=I[S];if(n.setFromPoints(C,t),v.isSeparated(n))return!1}for(let S=0;S<4;S++){const v=T[S];for(let C=0;C<4;C++){const z=I[C];if(r.crossVectors(v,z),n.setFromPoints(r,t),i.setFromPoints(r,e),n.isSeparated(i))return!1}}return f&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}else{const L=g(this,b,u);if(L===1&&m.containsPoint(u.end))return f&&(f.start.copy(u.end),f.end.copy(u.end)),!0;if(L!==2)return!1;const T=g(m,x,d);if(T===1&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(T!==2)return!1;if(u.delta(o),d.delta(l),o.dot(l)<0){let B=d.start;d.start=d.end,d.end=B}const A=u.start.dot(o),I=u.end.dot(o),S=d.start.dot(o),v=d.end.dot(o),C=I0?f.start.copy(u.start):f.start.copy(d.start),c.subVectors(u.end,d.end),c.dot(o)<0?f.end.copy(u.end):f.end.copy(d.end)),!0)}}}();Hi.prototype.distanceToPoint=function(){const s=new R;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();Hi.prototype.distanceToTriangle=function(){const s=new R,t=new R,e=["a","b","c"],n=new Gn,i=new Gn;return function(a,o=null,l=null){const c=o||l?n:null;if(this.intersectsTriangle(a,c))return(o||l)&&(o&&c.getCenter(o),l&&c.getCenter(l)),0;let h=1/0;for(let u=0;u<3;u++){let d;const p=e[u],g=a[p];this.closestPointToPoint(g,s),d=g.distanceToSquared(s),d=166,g=new V,w=new R,T=new W,A=M.prototype.raycast,F=p!==null?p.prototype.raycast:null,B=new R,s=new M,m=[];function D(e,t){this.isBatchedMesh?O.call(this,e,t):j.call(this,e,t)}function O(e,t){if(this.boundsTrees){const r=this.boundsTrees,o=this._drawInfo,n=this._drawRanges,i=this.matrixWorld;s.material=this.material,s.geometry=this.geometry;const l=s.geometry.boundsTree,h=s.geometry.drawRange;s.geometry.boundingSphere===null&&(s.geometry.boundingSphere=new x);for(let a=0,u=o.length;a=2.0 are supported."));return}const c=new Pt(s,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(r,n)}parseAsync(t,e){const r=this;return new Promise(function(n,s){r.parse(t,e,n,s)})}}function st(){let d={};return{get:function(t){return d[t]},add:function(t,e){d[t]=e},remove:function(t){delete d[t]},removeAll:function(){d={}}}}const A={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class rt{constructor(t){this.parser=t,this.name=A.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let r=0,n=e.length;r=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,s.source,i)}}class Tt{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,s=n.textures[t];if(!s.extensions||!s.extensions[e])return null;const i=s.extensions[e],a=n.images[i.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(t,i.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Rt{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,s=n.textures[t];if(!s.extensions||!s.extensions[e])return null;const i=s.extensions[e],a=n.images[i.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(t,i.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class xt{constructor(t){this.name=A.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,r=e.bufferViews[t];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,f=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(l,u,f,n.mode,n.filter).then(function(h){return h.buffer}):i.ready.then(function(){const h=new ArrayBuffer(l*u);return i.decodeGltfBuffer(new Uint8Array(h),l,u,f,n.mode,n.filter),h})})}else return null}}class Et{constructor(t){this.name=A.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,r=e.nodes[t];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=e.meshes[r.mesh];for(const c of n.primitives)if(c.mode!==_.TRIANGLES&&c.mode!==_.TRIANGLE_STRIP&&c.mode!==_.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=r.extensions[this.name].attributes,a=[],o={};for(const c in i)a.push(this.parser.getDependency("accessor",i[c]).then(l=>(o[c]=l,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(const p of u){const T=new v,m=new F,g=new pe,x=new F(1,1,1),E=new Ee(p.geometry,p.material,f);for(let R=0;R0||d.search(/^data\:image\/jpeg/)===0?"image/jpeg":d.search(/\.webp($|\?)/i)>0||d.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Dt=new v;class Pt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new st,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,n=-1,s=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=r&&o?parseInt(o[1],10):-1,s=a.indexOf("Firefox")>-1,i=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||s&&i<98?this.textureLoader=new Le(this.options.manager):this.textureLoader=new Se(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ae(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const r=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(i){const a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:r,userData:{}};return O(s,a,n),b(a,n),Promise.all(r._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],r=this.json.meshes||[];for(let n=0,s=e.length;n{const o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(const[c,l]of i.children.entries())s(l,a.children[c])};return s(r,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let r=0;r=2&&m.setY(N,w[L*o+1]),o>=3&&m.setZ(N,w[L*o+2]),o>=4&&m.setW(N,w[L*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(t){const e=this.json,r=this.options,s=e.textures[t].source,i=e.images[s];let a=this.textureLoader;if(i.uri){const o=r.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(t,s,a)}loadTextureImage(t,e,r){const n=this,s=this.json,i=s.textures[t],a=s.images[e],o=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,r).then(function(l){l.flipY=!1,l.name=i.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const f=(s.samplers||{})[i.sampler]||{};return l.magFilter=re[f.magFilter]||le,l.minFilter=re[f.minFilter]||fe,l.wrapS=ie[f.wrapS]||W,l.wrapT=ie[f.wrapT]||W,n.associations.set(l,{textures:t}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const r=this,n=this.json,s=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const i=n.images[t],a=self.URL||self.webkitURL;let o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=r.getDependency("bufferView",i.bufferView).then(function(u){c=!0;const f=new Blob([u],{type:i.mimeType});return o=a.createObjectURL(f),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(o).then(function(u){return new Promise(function(f,h){let p=f;e.isImageBitmapLoader===!0&&(p=function(T){const m=new J(T);m.needsUpdate=!0,f(m)}),e.load(G.resolveURL(u,s.path),p,void 0,h)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),b(u,i),u.userData.mimeType=i.mimeType||Ft(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[t]=l,l}assignTexture(t,e,r,n){const s=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(i=i.clone(),i.channel=r.texCoord),s.extensions[A.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[A.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=s.associations.get(i);i=s.extensions[A.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),t[e]=i,i})}assignFinalMaterial(t){const e=t.geometry;let r=t.material;const n=e.attributes.tangent===void 0,s=e.attributes.color!==void 0,i=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new be,K.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,o.sizeAttenuation=!1,this.cache.add(a,o)),r=o}else if(t.isLine){const a="LineBasicMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new ye,K.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,this.cache.add(a,o)),r=o}if(n||s||i){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=r.clone(),s&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(r))),r=o}t.material=r}getMaterialType(){return de}loadMaterial(t){const e=this,r=this.json,n=this.extensions,s=r.materials[t];let i;const a={},o=s.extensions||{},c=[];if(o[A.KHR_MATERIALS_UNLIT]){const u=n[A.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),c.push(u.extendParams(a,s,e))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new C(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],y),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,B)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}s.doubleSided===!0&&(a.side=we);const l=s.alphaMode||z.OPAQUE;if(l===z.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===z.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==H&&(c.push(e.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new ce(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&i!==H&&(c.push(e.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==H){const u=s.emissiveFactor;a.emissive=new C().setRGB(u[0],u[1],u[2],y)}return s.emissiveTexture!==void 0&&i!==H&&c.push(e.assignTexture(a,"emissiveMap",s.emissiveTexture,B)),Promise.all(c).then(function(){const u=new i(a);return s.name&&(u.name=s.name),b(u,s),e.associations.set(u,{materials:t}),s.extensions&&O(n,u,s),u})}createUniqueName(t){const e=Ne.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,r=this.extensions,n=this.primitiveCache;function s(a){return r[A.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return oe(o,a,e)})}const i=[];for(let a=0,o=t.length;a0&&Ot(g,s),g.name=e.createUniqueName(s.name||"mesh_"+t),b(g,s),m.extensions&&O(n,g,m),e.assignFinalMaterial(g),u.push(g)}for(let h=0,p=u.length;h1?l=new V:c.length===1?l=c[0]:l=new ue,l!==c[0])for(let u=0,f=c.length;u{const u=new Map;for(const[f,h]of n.associations)(f instanceof K||f instanceof J)&&u.set(f,h);return l.traverse(f=>{const h=n.associations.get(f);h!=null&&u.set(f,h)}),u};return n.associations=c(s),s})}_createAnimationTracks(t,e,r,n,s){const i=[],a=t.name?t.name:t.uuid,o=[];I[s.path]===I.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(I[s.path]){case I.weights:c=ee;break;case I.rotation:c=te;break;case I.position:case I.scale:c=$;break;default:switch(r.itemSize){case 1:c=ee;break;case 2:case 3:default:c=$;break}break}const l=n.interpolation!==void 0?wt[n.interpolation]:he,u=this._getArrayFromAccessor(r);for(let f=0,h=o.length;f{throw e.message?new Error(`${this.name}: Could not create Web Worker with error "${e.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...r){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const e=this.runTask(this.worker,...r);return e.finally(()=>{this.running=!1}),e}dispose(){this.worker.terminate(),this.worker=null}}class m extends k{constructor(){const r=new Worker(new URL(""+new URL("generateMeshBVH.worker-DKxcelnu.js",import.meta.url).href,import.meta.url),{type:"module"});super(r),this.name="GenerateMeshBVHWorker"}runTask(r,e,s={}){return new Promise((h,a)=>{if(e.getAttribute("position").isInterleavedBufferAttribute||e.index&&e.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");r.onerror=n=>{a(new Error(`GenerateMeshBVHWorker: ${n.message}`))},r.onmessage=n=>{const{data:o}=n;if(o.error)a(new Error(o.error)),r.onmessage=null;else if(o.serialized){const{serialized:t,position:B}=o,d=x.deserialize(t,e,{setIndex:!1}),w=Object.assign({setBoundingBox:!0},s);if(e.attributes.position.array=B,t.index)if(e.index)e.index.array=t.index;else{const c=new g(t.index,1,!1);e.setIndex(c)}w.setBoundingBox&&(e.boundingBox=d.getBoundingBox(new p)),s.onProgress&&s.onProgress(o.progress),h(d),r.onmessage=null}else s.onProgress&&s.onProgress(o.progress)};const i=e.index?e.index.array:null,u=e.attributes.position.array,l=[u];i&&l.push(i),r.postMessage({index:i,position:u,options:{...s,onProgress:null,includedProgressCallback:!!s.onProgress,groups:[...e.groups]}},l.map(n=>n.buffer).filter(n=>typeof SharedArrayBuffer>"u"||!(n instanceof SharedArrayBuffer)))})}}export{m as G,k as W}; diff --git a/example/bundle/assets/MeshBVH-CPVAl5W3.js b/example/bundle/assets/MeshBVH-CPVAl5W3.js new file mode 100644 index 00000000..0c1d84c2 --- /dev/null +++ b/example/bundle/assets/MeshBVH-CPVAl5W3.js @@ -0,0 +1 @@ +import{B as _n,V as z,j as G,bm as bt,aP as ft,L as un,bn as zn,a as j,x as Pt,u as _t,s as Dn,n as Fn,r as pn}from"./ExtendedTriangle-Chm2bbkR.js";const Pn=0,Rn=1,vn=2,Ri=0,vi=1,yn=2,It=1.25,xn=1,dt=6*4+4+4,Xt=65535,Nn=Math.pow(2,-24),jt=Symbol("SKIP_GENERATION");function Vn(i){return i.index?i.index.count:i.attributes.position.count}function ut(i){return Vn(i)/3}function $n(i,n=ArrayBuffer){return i>65535?new Uint32Array(new n(4*i)):new Uint16Array(new n(2*i))}function kn(i,n){if(!i.index){const t=i.attributes.position.count,e=n.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=$n(t,e);i.setIndex(new _n(s,1));for(let c=0;co-u);for(let o=0;or.offset-l.offset),s=e[e.length-1];s.count=Math.min(t-s.offset,s.count);let c=0;return e.forEach(({count:r})=>c+=r),t!==c}function Yt(i,n,t,e,s){let c=1/0,r=1/0,l=1/0,o=-1/0,u=-1/0,f=-1/0,p=1/0,a=1/0,y=1/0,d=-1/0,b=-1/0,g=-1/0;for(let h=n*6,x=(n+t)*6;ho&&(o=T),md&&(d=m);const B=i[h+2],P=i[h+3],S=B-P,M=B+P;Su&&(u=M),Bb&&(b=B);const U=i[h+4],_=i[h+5],C=U-_,L=U+_;Cf&&(f=L),Ug&&(g=U)}e[0]=c,e[1]=r,e[2]=l,e[3]=o,e[4]=u,e[5]=f,s[0]=p,s[1]=a,s[2]=y,s[3]=d,s[4]=b,s[5]=g}function Xn(i,n=null,t=null,e=null){const s=i.attributes.position,c=i.index?i.index.array:null,r=ut(i),l=s.normalized;let o;n===null?(o=new Float32Array(r*6*4),t=0,e=r):(o=n,t=t||0,e=e||r);const u=s.array,f=s.offset||0;let p=3;s.isInterleavedBufferAttribute&&(p=s.data.stride);const a=["getX","getY","getZ"];for(let y=t;yP&&(P=A),T>P&&(P=T);const S=(P-B)/2,M=m*2;o[b+M+0]=B+S,o[b+M+1]=S+(Math.abs(B)+S)*Nn}}return o}function F(i,n,t){return t.min.x=n[i],t.min.y=n[i+1],t.min.z=n[i+2],t.max.x=n[i+3],t.max.y=n[i+4],t.max.z=n[i+5],t}function An(i){let n=-1,t=-1/0;for(let e=0;e<3;e++){const s=i[e+3]-i[e];s>t&&(t=s,n=e)}return n}function mn(i,n){n.set(i)}function hn(i,n,t){let e,s;for(let c=0;c<3;c++){const r=c+3;e=i[c],s=n[c],t[c]=es?e:s}}function Mt(i,n,t){for(let e=0;e<3;e++){const s=n[i+2*e],c=n[i+2*e+1],r=s-c,l=s+c;rt[e+3]&&(t[e+3]=l)}}function xt(i){const n=i[3]-i[0],t=i[4]-i[1],e=i[5]-i[2];return 2*(n*t+t*e+e*n)}const Y=32,Hn=(i,n)=>i.candidate-n.candidate,K=new Array(Y).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),St=new Float32Array(6);function In(i,n,t,e,s,c){let r=-1,l=0;if(c===Pn)r=An(n),r!==-1&&(l=(n[r]+n[r+3])/2);else if(c===Rn)r=An(i),r!==-1&&(l=jn(t,e,s,r));else if(c===vn){const o=xt(i);let u=It*s;const f=e*6,p=(e+s)*6;for(let a=0;a<3;a++){const y=n[a],g=(n[a+3]-y)/Y;if(s=B.candidate?Mt(w,t,B.rightCacheBounds):(Mt(w,t,B.leftCacheBounds),B.count++)}}for(let w=0;w=Y&&(T=Y-1);const B=K[T];B.count++,Mt(m,t,B.bounds)}const h=K[Y-1];mn(h.bounds,h.rightCacheBounds);for(let m=Y-2;m>=0;m--){const w=K[m],A=K[m+1];hn(w.bounds,A.rightCacheBounds,w.rightCacheBounds)}let x=0;for(let m=0;m=o;)l--;if(r=o;)l--;if(rKn)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Bt[t+6]=u/4,u=nn(u,l),Bt[t+7]=o,u}}function Jn(i,n){const t=(i.index?i.index.count:i.attributes.position.count)/3,e=t>2**16,s=e?4:2,c=n?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),r=e?new Uint32Array(c):new Uint16Array(c);for(let l=0,o=r.length;l=c&&(h=!0,r&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(a))),B<=l||S>=c)return m(T+B),A.offset=T,A.count=B,A;const M=In(A.boundingData,P,n,T,B,o);if(M.axis===-1)return m(T+B),A.offset=T,A.count=B,A;const U=d(p,y,n,T,B,M);if(U===T||U===T+B)m(T+B),A.offset=T,A.count=B;else{A.splitAxis=M.axis;const _=new Zt,C=T,L=U-T;A.left=_,Yt(n,C,L,_.boundingData,g),w(_,C,L,g,S+1);const E=new Zt,R=U,Z=B-L;A.right=E,Yt(n,R,Z,E.boundingData,g),w(E,R,Z,g,S+1)}return A}}function Gn(i,n){const t=i.geometry;n.indirect&&(i._indirectBuffer=Jn(t,n.useSharedArrayBuffer),qn(t,n.range)&&!n.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),i._indirectBuffer||kn(t,n);const e=n.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Xn(t),c=n.indirect?Mn(t,n.range):Sn(t,n.range);i._roots=c.map(r=>{const l=Qn(i,s,r.offset,r.count,n),o=tn(l),u=new e(dt*o);return Wn(0,l,u),u})}class N{constructor(n,t,e){this.isOrientedBox=!0,this.min=new z,this.max=new z,this.matrix=new G,this.invMatrix=new G,this.points=new Array(8).fill().map(()=>new z),this.satAxes=new Array(3).fill().map(()=>new z),this.satBounds=new Array(3).fill().map(()=>new bt),this.alignedSatBounds=new Array(3).fill().map(()=>new bt),this.needsUpdate=!1,n&&this.min.copy(n),t&&this.max.copy(t),e&&this.matrix.copy(e)}set(n,t,e){this.min.copy(n),this.max.copy(t),this.matrix.copy(e),this.needsUpdate=!0}copy(n){this.min.copy(n.min),this.max.copy(n.max),this.matrix.copy(n.matrix),this.needsUpdate=!0}}N.prototype.update=function(){return function(){const n=this.matrix,t=this.min,e=this.max,s=this.points;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){const a=1*u|2*f|4*p,y=s[a];y.x=u?e.x:t.x,y.y=f?e.y:t.y,y.z=p?e.z:t.z,y.applyMatrix4(n)}const c=this.satBounds,r=this.satAxes,l=s[0];for(let u=0;u<3;u++){const f=r[u],p=c[u],a=1<new un),t=new Array(12).fill().map(()=>new un),e=new z,s=new z;return function(r,l=0,o=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||u)&&(r.getCenter(s),this.closestPointToPoint(s,e),r.closestPointToPoint(e,s),o&&o.copy(e),u&&u.copy(s)),0;const f=l*l,p=r.min,a=r.max,y=this.points;let d=1/0;for(let g=0;g<8;g++){const h=y[g];s.copy(h).clamp(p,a);const x=h.distanceToSquared(s);if(xnew ft)}}const H=new On;class ti{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const n=[];let t=null;this.setBuffer=e=>{t&&n.push(t),t=e,this.float32Array=new Float32Array(e),this.uint16Array=new Uint16Array(e),this.uint32Array=new Uint32Array(e)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,n.length!==0&&this.setBuffer(n.pop())}}}const D=new ti;let J,at;const O=[],Ct=new fn(()=>new j);function ni(i,n,t,e,s,c){J=Ct.getPrimitive(),at=Ct.getPrimitive(),O.push(J,at),D.setBuffer(i._roots[n]);const r=en(0,i.geometry,t,e,s,c);D.clearBuffer(),Ct.releasePrimitive(J),Ct.releasePrimitive(at),O.pop(),O.pop();const l=O.length;return l>0&&(at=O[l-1],J=O[l-2]),r}function en(i,n,t,e,s=null,c=0,r=0){const{float32Array:l,uint16Array:o,uint32Array:u}=D;let f=i*2;if(V(f,o)){const a=$(i,u),y=k(f,o);return F(i,l,J),e(a,y,!1,r,c+i,J)}else{let M=function(_){const{uint16Array:C,uint32Array:L}=D;let E=_*2;for(;!V(E,C);)_=q(_),E=_*2;return $(_,L)},U=function(_){const{uint16Array:C,uint32Array:L}=D;let E=_*2;for(;!V(E,C);)_=X(_,L),E=_*2;return $(_,L)+k(E,C)};const a=q(i),y=X(i,u);let d=a,b=y,g,h,x,m;if(s&&(x=J,m=at,F(d,l,x),F(b,l,m),g=s(x),h=s(m),h(At.copy(n).clamp(f.min,f.max),At.distanceToSquared(n)),intersectsBounds:(f,p,a)=>a{f.closestPointToPoint(n,At);const a=n.distanceToSquared(At);return al?null:{distance:u,point:s.clone()}}function si(i,n,t,e,s,c,r,l,o,u,f){tt.fromBufferAttribute(n,c),nt.fromBufferAttribute(n,r),it.fromBufferAttribute(n,l);const p=ei(i,tt,nt,it,zt,o,u,f);if(p){e&&(Ut.fromBufferAttribute(e,c),Lt.fromBufferAttribute(e,r),Et.fromBufferAttribute(e,l),p.uv=Pt.getInterpolation(zt,tt,nt,it,Ut,Lt,Et,new _t)),s&&(Ut.fromBufferAttribute(s,c),Lt.fromBufferAttribute(s,r),Et.fromBufferAttribute(s,l),p.uv1=Pt.getInterpolation(zt,tt,nt,it,Ut,Lt,Et,new _t)),t&&(gn.fromBufferAttribute(t,c),wn.fromBufferAttribute(t,r),Bn.fromBufferAttribute(t,l),p.normal=Pt.getInterpolation(zt,tt,nt,it,gn,wn,Bn,new z),p.normal.dot(i.direction)>0&&p.normal.multiplyScalar(-1));const a={a:c,b:r,c:l,normal:new z,materialIndex:0};Pt.getNormal(tt,nt,it,a.normal),p.face=a,p.faceIndex=c}return p}function Ht(i,n,t,e,s,c,r){const l=e*3;let o=l+0,u=l+1,f=l+2;const p=i.index;i.index&&(o=p.getX(o),u=p.getX(u),f=p.getX(f));const{position:a,normal:y,uv:d,uv1:b}=i.attributes,g=si(t,a,y,d,b,o,u,f,n,c,r);return g?(g.faceIndex=e,s&&s.push(g),g):null}function v(i,n,t,e){const s=i.a,c=i.b,r=i.c;let l=n,o=n+1,u=n+2;t&&(l=t.getX(l),o=t.getX(o),u=t.getX(u)),s.x=e.getX(l),s.y=e.getY(l),s.z=e.getZ(l),c.x=e.getX(o),c.y=e.getY(o),c.z=e.getZ(o),r.x=e.getX(u),r.y=e.getY(u),r.z=e.getZ(u)}function ri(i,n,t,e,s,c,r,l){const{geometry:o,_indirectBuffer:u}=i;for(let f=e,p=e+s;fT&&(T=_),CB&&(B=C),LP&&(P=L)}return o[a+0]!==m||o[a+1]!==w||o[a+2]!==A||o[a+3]!==T||o[a+4]!==B||o[a+5]!==P?(o[a+0]=m,o[a+1]=w,o[a+2]=A,o[a+3]=T,o[a+4]=B,o[a+5]=P,!0):!1}else{const h=a+8,x=r[a+6],m=h+y,w=x+y;let A=d,T=!1,B=!1;n?A||(T=n.has(m),B=n.has(w),A=!T&&!B):(T=!0,B=!0);const P=A||T,S=A||B;let M=!1;P&&(M=p(h,y,A));let U=!1;S&&(U=p(x,y,A));const _=M||U;if(_)for(let C=0;C<3;C++){const L=h+C,E=x+C,R=o[L],Z=o[L+3],pt=o[E],yt=o[E+3];o[a+C]=Ryt?Z:yt}return _}}}function Q(i,n,t,e,s){let c,r,l,o,u,f;const p=1/t.direction.x,a=1/t.direction.y,y=1/t.direction.z,d=t.origin.x,b=t.origin.y,g=t.origin.z;let h=n[i],x=n[i+3],m=n[i+1],w=n[i+3+1],A=n[i+2],T=n[i+3+2];return p>=0?(c=(h-d)*p,r=(x-d)*p):(c=(x-d)*p,r=(h-d)*p),a>=0?(l=(m-b)*a,o=(w-b)*a):(l=(w-b)*a,o=(m-b)*a),c>o||l>r||((l>c||isNaN(c))&&(c=l),(o=0?(u=(A-g)*y,f=(T-g)*y):(u=(T-g)*y,f=(A-g)*y),c>f||u>r)?!1:((u>c||c!==c)&&(c=u),(f=e)}function ai(i,n,t,e,s,c,r,l){const{geometry:o,_indirectBuffer:u}=i;for(let f=e,p=e+s;f=0;let b,g;d?(b=q(i),g=X(i,o)):(b=X(i,o),g=q(i));const x=Q(b,r,e,s,c)?rn(b,n,t,e,s,c):null;if(x){const A=x.point[a];if(d?A<=r[g+p]:A>=r[g+p+3])return x}const w=Q(g,r,e,s,c)?rn(g,n,t,e,s,c):null;return x&&w?x.distance<=w.distance?x:w:x||w||null}}const Dt=new j,et=new ft,st=new ft,mt=new G,dn=new N,Ft=new N;function Ai(i,n,t,e){D.setBuffer(i._roots[n]);const s=on(0,i,t,e);return D.clearBuffer(),s}function on(i,n,t,e,s=null){const{float32Array:c,uint16Array:r,uint32Array:l}=D;let o=i*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),dn.set(t.boundingBox.min,t.boundingBox.max,e),s=dn),V(o,r)){const f=n.geometry,p=f.index,a=f.attributes.position,y=t.index,d=t.attributes.position,b=$(i,l),g=k(o,r);if(mt.copy(e).invert(),t.boundsTree)return F(i,c,Ft),Ft.matrix.copy(mt),Ft.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Ft.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(e),x.b.applyMatrix4(e),x.c.applyMatrix4(e),x.needsUpdate=!0;for(let m=b*3,w=(g+b)*3;mWt.distanceToBox(A),intersectsBounds:(A,T,B)=>B{if(n.boundsTree)return n.boundsTree.shapecast({boundsTraverseOrder:P=>ht.distanceToBox(P),intersectsBounds:(P,S,M)=>M{for(let M=P,U=P+S;MT&&(T=L),EB&&(B=E),RP&&(P=R)}}return o[a+0]!==m||o[a+1]!==w||o[a+2]!==A||o[a+3]!==T||o[a+4]!==B||o[a+5]!==P?(o[a+0]=m,o[a+1]=w,o[a+2]=A,o[a+3]=T,o[a+4]=B,o[a+5]=P,!0):!1}else{const h=a+8,x=r[a+6],m=h+y,w=x+y;let A=d,T=!1,B=!1;n?A||(T=n.has(m),B=n.has(w),A=!T&&!B):(T=!0,B=!0);const P=A||T,S=A||B;let M=!1;P&&(M=p(h,y,A));let U=!1;S&&(U=p(x,y,A));const _=M||U;if(_)for(let C=0;C<3;C++){const L=h+C,E=x+C,R=o[L],Z=o[L+3],pt=o[E],yt=o[E+3];o[a+C]=Ryt?Z:yt}return _}}}function Ti(i,n,t,e,s,c,r){D.setBuffer(i._roots[n]),cn(0,i,t,e,s,c,r),D.clearBuffer()}function cn(i,n,t,e,s,c,r){const{float32Array:l,uint16Array:o,uint32Array:u}=D,f=i*2;if(V(f,o)){const a=$(i,u),y=k(f,o);ai(n,t,e,a,y,s,c,r)}else{const a=q(i);Q(a,l,e,c,r)&&cn(a,n,t,e,s,c,r);const y=X(i,u);Q(y,l,e,c,r)&&cn(y,n,t,e,s,c,r)}}const bi=["x","y","z"];function _i(i,n,t,e,s,c){D.setBuffer(i._roots[n]);const r=ln(0,i,t,e,s,c);return D.clearBuffer(),r}function ln(i,n,t,e,s,c){const{float32Array:r,uint16Array:l,uint32Array:o}=D;let u=i*2;if(V(u,l)){const p=$(i,o),a=k(u,l);return fi(n,t,e,p,a,s,c)}else{const p=Cn(i,o),a=bi[p],d=e.direction[a]>=0;let b,g;d?(b=q(i),g=X(i,o)):(b=X(i,o),g=q(i));const x=Q(b,r,e,s,c)?ln(b,n,t,e,s,c):null;if(x){const A=x.point[a];if(d?A<=r[g+p]:A>=r[g+p+3])return x}const w=Q(g,r,e,s,c)?ln(g,n,t,e,s,c):null;return x&&w?x.distance<=w.distance?x:w:x||w||null}}const vt=new j,rt=new ft,ot=new ft,gt=new G,Tn=new N,Nt=new N;function Pi(i,n,t,e){D.setBuffer(i._roots[n]);const s=an(0,i,t,e);return D.clearBuffer(),s}function an(i,n,t,e,s=null){const{float32Array:c,uint16Array:r,uint32Array:l}=D;let o=i*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Tn.set(t.boundingBox.min,t.boundingBox.max,e),s=Tn),V(o,r)){const f=n.geometry,p=f.index,a=f.attributes.position,y=t.index,d=t.attributes.position,b=$(i,l),g=k(o,r);if(gt.copy(e).invert(),t.boundsTree)return F(i,c,Nt),Nt.matrix.copy(gt),Nt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Nt.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(e),x.b.applyMatrix4(e),x.c.applyMatrix4(e),x.needsUpdate=!0;for(let m=b,w=g+b;mJt.distanceToBox(A),intersectsBounds:(A,T,B)=>B{if(n.boundsTree){const B=n.boundsTree;return B.shapecast({boundsTraverseOrder:P=>wt.distanceToBox(P),intersectsBounds:(P,S,M)=>M{for(let M=P,U=P+S;Mnew j),ct=new j,lt=new j,Qt=new j,Gt=new j;let Ot=!1;function zi(i,n,t,e){if(Ot)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Ot=!0;const s=i._roots,c=n._roots;let r,l=0,o=0;const u=new G().copy(t).invert();for(let f=0,p=s.length;fo.slice()),index:r?r.array.slice():null,indirectBuffer:c?c.slice():null}:l={roots:s,index:r?r.array:null,indirectBuffer:c},l}static deserialize(n,t,e={}){e={setIndex:!0,indirect:!!n.indirectBuffer,...e};const{index:s,roots:c,indirectBuffer:r}=n,l=new En(t,{...e,[jt]:!0});if(l._roots=c,l._indirectBuffer=r||null,e.setIndex){const o=t.getIndex();if(o===null){const u=new _n(n.index,1,!1);t.setIndex(u)}else o.array!==s&&(o.array.set(s),o.needsUpdate=!0)}return l}get indirect(){return!!this._indirectBuffer}constructor(n,t={}){if(n.isBufferGeometry){if(n.index&&n.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Di,[jt]:!1},t),t.useSharedArrayBuffer&&!Ei())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=n,this._roots=null,this._indirectBuffer=null,t[jt]||(Gn(this,t),!n.boundingBox&&t.setBoundingBox&&(n.boundingBox=this.getBoundingBox(new j))),this.resolveTriangleIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e}refit(n=null){return(this.indirect?di:li)(this,n)}traverse(n,t=0){const e=this._roots[t],s=new Uint32Array(e),c=new Uint16Array(e);r(0);function r(l,o=0){const u=l*2,f=c[u+15]===Xt;if(f){const p=s[l+6],a=c[u+14];n(o,f,new Float32Array(e,l*4,6),p,a)}else{const p=l+dt/4,a=s[l+6],y=s[l+7];n(o,f,new Float32Array(e,l*4,6),y)||(r(p,o+1),r(a,o+1))}}}raycast(n,t=pn,e=0,s=1/0){const c=this._roots,r=this.geometry,l=[],o=t.isMaterial,u=Array.isArray(t),f=r.groups,p=o?t.side:t,a=this.indirect?Ti:pi;for(let y=0,d=c.length;yp(a,y,d,b,g)?!0:e(a,y,this,l,d,b,t)}else r||(l?r=(p,a,y,d)=>e(p,a,this,l,y,d,t):r=(p,a,y)=>y);let o=!1,u=0;const f=this._roots;for(let p=0,a=f.length;p{const b=this.resolveTriangleIndex(d);v(r,b*3,l,o)}:d=>{v(r,d*3,l,o)},f=H.getPrimitive(),p=n.geometry.index,a=n.geometry.attributes.position,y=n.indirect?d=>{const b=n.resolveTriangleIndex(d);v(f,b*3,p,a)}:d=>{v(f,d*3,p,a)};if(c){const d=(b,g,h,x,m,w,A,T)=>{for(let B=h,P=h+x;B$t.intersectsBox(e),intersectsTriangle:e=>$t.intersectsTriangle(e)})}intersectsSphere(n){return this.shapecast({intersectsBounds:t=>n.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(n)})}closestPointToGeometry(n,t,e={},s={},c=0,r=1/0){return(this.indirect?Li:Bi)(this,n,t,e,s,c,r)}closestPointToPoint(n,t={},e=0,s=1/0){return ii(this,n,t,e,s)}getBoundingBox(n){return n.makeEmpty(),this._roots.forEach(e=>{F(0,new Float32Array(e),bn),n.union(bn)}),n}}export{Rn as A,dt as B,Pn as C,vi as I,En as M,Ri as N,$ as O,X as R,vn as S,It as T,yn as a,Vn as b,Vi as c,V as d,kn as e,k as f,$n as g,Cn as h,Ei as i,Ni as j,xn as k,F as l}; diff --git a/example/bundle/assets/MeshBVHHelper-jLfel8l5.js b/example/bundle/assets/MeshBVHHelper-jLfel8l5.js new file mode 100644 index 00000000..b76f2d33 --- /dev/null +++ b/example/bundle/assets/MeshBVHHelper-jLfel8l5.js @@ -0,0 +1 @@ +import{G as _,q as E,c as P,j as W,O as H,M as j,f as F,B as b,a as T}from"./ExtendedTriangle-Chm2bbkR.js";import{l as z,M as L}from"./MeshBVH-CPVAl5W3.js";const w=new T,B=new W;class O extends H{get isMesh(){return!this.displayEdges}get isLineSegments(){return this.displayEdges}get isLine(){return this.displayEdges}getVertexPosition(...t){return j.prototype.getVertexPosition.call(this,...t)}constructor(t,e,i=10,s=0){super(),this.material=e,this.geometry=new F,this.name="MeshBVHRootHelper",this.depth=i,this.displayParents=!1,this.bvh=t,this.displayEdges=!0,this._group=s}raycast(){}update(){const t=this.geometry,e=this.bvh,i=this._group;if(t.dispose(),this.visible=!1,e){const s=this.depth-1,a=this.displayParents;let o=0;e.traverse((n,y)=>{if(n>=s||y)return o++,!0;a&&o++},i);let p=0;const h=new Float32Array(8*3*o);e.traverse((n,y,u)=>{const d=n>=s||y;if(d||a){z(0,u,w);const{min:g,max:f}=w;for(let m=-1;m<=1;m+=2){const v=m<0?g.x:f.x;for(let x=-1;x<=1;x+=2){const I=x<0?g.y:f.y;for(let M=-1;M<=1;M+=2){const V=M<0?g.z:f.z;h[p+0]=v,h[p+1]=I,h[p+2]=V,p+=3}}}return d}},i);let l,r;this.displayEdges?r=new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):r=new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),h.length>65535?l=new Uint32Array(r.length*o):l=new Uint16Array(r.length*o);const c=r.length;for(let n=0;ni;){const s=this._roots.pop();s.geometry.dispose(),this.remove(s)}for(let s=0;s=this._roots.length){const c=new O(e,o,a,s);this.add(c),this._roots.push(c)}const r=this._roots[s];r.bvh=e,r.depth=a,r.displayParents=h,r.displayEdges=l,r.material=l?o:p,r.update()}}updateMatrixWorld(...t){const e=this.mesh,i=this.parent;e!==null&&(e.updateWorldMatrix(!0,!1),i?this.matrix.copy(i.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,B),this.matrix.multiply(B)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new A(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,i=t.length;eMath.PI&&(h-=d),f<-Math.PI?f+=d:f>Math.PI&&(f-=d),h<=f?s.theta=Math.max(h,Math.min(f,s.theta)):s.theta=s.theta>(h+f)/2?Math.max(h,s.theta):Math.min(f,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(j,e.dampingFactor):e.target.add(j),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor);let z=!1;if(e.zoomToCursor&&K||e.object.isOrthographicCamera)s.radius=B(s.radius);else{const b=s.radius;s.radius=B(s.radius*E),z=b!=s.radius}if(t.setFromSpherical(s),t.applyQuaternion(n),ge.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(p.theta*=1-e.dampingFactor,p.phi*=1-e.dampingFactor,j.multiplyScalar(1-e.dampingFactor)):(p.set(0,0,0),j.set(0,0,0)),e.zoomToCursor&&K){let b=null;if(e.object.isPerspectiveCamera){const _=t.length();b=B(_*E);const Z=_-b;e.object.position.addScaledVector($,Z),e.object.updateMatrixWorld(),z=!!Z}else if(e.object.isOrthographicCamera){const _=new u(y.x,y.y,0);_.unproject(e.object);const Z=e.object.zoom;e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/E)),e.object.updateProjectionMatrix(),z=Z!==e.object.zoom;const Ee=new u(y.x,y.y,0);Ee.unproject(e.object),e.object.position.sub(Ee).add(_),e.object.updateMatrixWorld(),b=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;b!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(b).add(e.object.position):(X.origin.copy(e.object.position),X.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(X.direction))V||8*(1-l.dot(e.object.quaternion))>V||g.distanceToSquared(e.target)>V?(e.dispatchEvent(we),i.copy(e.object.position),l.copy(e.object.quaternion),g.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",be),e.domElement.removeEventListener("pointerdown",de),e.domElement.removeEventListener("pointercancel",Y),e.domElement.removeEventListener("wheel",me),e.domElement.removeEventListener("pointermove",Q),e.domElement.removeEventListener("pointerup",Y),e.domElement.getRootNode().removeEventListener("keydown",pe,{capture:!0}),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",v),e._domElementKeyEvents=null)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let r=a.NONE;const V=1e-6,s=new Te,p=new Te;let E=1;const j=new u,P=new m,T=new m,A=new m,w=new m,O=new m,L=new m,D=new m,R=new m,M=new m,$=new u,y=new m;let K=!1;const c=[],I={};let W=!1;function Ae(t){return t!==null?2*Math.PI/60*e.autoRotateSpeed*t:2*Math.PI/60/60*e.autoRotateSpeed}function H(t){const o=Math.abs(t*.01);return Math.pow(.95,e.zoomSpeed*o)}function C(t){p.theta-=t}function U(t){p.phi-=t}const ee=function(){const t=new u;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),j.add(t)}}(),te=function(){const t=new u;return function(n,i){e.screenSpacePanning===!0?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(n),j.add(t)}}(),x=function(){const t=new u;return function(n,i){const l=e.domElement;if(e.object.isPerspectiveCamera){const g=e.object.position;t.copy(g).sub(e.target);let d=t.length();d*=Math.tan(e.object.fov/2*Math.PI/180),ee(2*n*d/l.clientHeight,e.object.matrix),te(2*i*d/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(ee(n*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),te(i*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function G(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?E/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function oe(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?E*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function q(t,o){if(!e.zoomToCursor)return;K=!0;const n=e.domElement.getBoundingClientRect(),i=t-n.left,l=o-n.top,g=n.width,d=n.height;y.x=i/g*2-1,y.y=-(l/d)*2+1,$.set(y.x,y.y,1).unproject(e.object).sub(e.object.position).normalize()}function B(t){return Math.max(e.minDistance,Math.min(e.maxDistance,t))}function ne(t){P.set(t.clientX,t.clientY)}function Le(t){q(t.clientX,t.clientX),D.set(t.clientX,t.clientY)}function ae(t){w.set(t.clientX,t.clientY)}function De(t){T.set(t.clientX,t.clientY),A.subVectors(T,P).multiplyScalar(e.rotateSpeed);const o=e.domElement;C(2*Math.PI*A.x/o.clientHeight),U(2*Math.PI*A.y/o.clientHeight),P.copy(T),e.update()}function Re(t){R.set(t.clientX,t.clientY),M.subVectors(R,D),M.y>0?G(H(M.y)):M.y<0&&oe(H(M.y)),D.copy(R),e.update()}function xe(t){O.set(t.clientX,t.clientY),L.subVectors(O,w).multiplyScalar(e.panSpeed),x(L.x,L.y),w.copy(O),e.update()}function Ne(t){q(t.clientX,t.clientY),t.deltaY<0?oe(H(t.deltaY)):t.deltaY>0&&G(H(t.deltaY)),e.update()}function ke(t){let o=!1;switch(t.code){case e.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?U(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(0,e.keyPanSpeed),o=!0;break;case e.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?U(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(0,-e.keyPanSpeed),o=!0;break;case e.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?C(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(e.keyPanSpeed,0),o=!0;break;case e.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?C(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(-e.keyPanSpeed,0),o=!0;break}o&&(t.preventDefault(),e.update())}function ie(t){if(c.length===1)P.set(t.pageX,t.pageY);else{const o=N(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);P.set(n,i)}}function se(t){if(c.length===1)w.set(t.pageX,t.pageY);else{const o=N(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);w.set(n,i)}}function re(t){const o=N(t),n=t.pageX-o.x,i=t.pageY-o.y,l=Math.sqrt(n*n+i*i);D.set(0,l)}function Se(t){e.enableZoom&&re(t),e.enablePan&&se(t)}function Ie(t){e.enableZoom&&re(t),e.enableRotate&&ie(t)}function ce(t){if(c.length==1)T.set(t.pageX,t.pageY);else{const n=N(t),i=.5*(t.pageX+n.x),l=.5*(t.pageY+n.y);T.set(i,l)}A.subVectors(T,P).multiplyScalar(e.rotateSpeed);const o=e.domElement;C(2*Math.PI*A.x/o.clientHeight),U(2*Math.PI*A.y/o.clientHeight),P.copy(T)}function le(t){if(c.length===1)O.set(t.pageX,t.pageY);else{const o=N(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);O.set(n,i)}L.subVectors(O,w).multiplyScalar(e.panSpeed),x(L.x,L.y),w.copy(O)}function ue(t){const o=N(t),n=t.pageX-o.x,i=t.pageY-o.y,l=Math.sqrt(n*n+i*i);R.set(0,l),M.set(0,Math.pow(R.y/D.y,e.zoomSpeed)),G(M.y),D.copy(R);const g=(t.pageX+o.x)*.5,d=(t.pageY+o.y)*.5;q(g,d)}function Ce(t){e.enableZoom&&ue(t),e.enablePan&&le(t)}function Ye(t){e.enableZoom&&ue(t),e.enableRotate&&ce(t)}function de(t){e.enabled!==!1&&(c.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",Q),e.domElement.addEventListener("pointerup",Y)),!Xe(t)&&(Ue(t),t.pointerType==="touch"?fe(t):ze(t)))}function Q(t){e.enabled!==!1&&(t.pointerType==="touch"?He(t):_e(t))}function Y(t){switch(Ze(t),c.length){case 0:e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",Q),e.domElement.removeEventListener("pointerup",Y),e.dispatchEvent(Oe),r=a.NONE;break;case 1:const o=c[0],n=I[o];fe({pointerId:o,pageX:n.x,pageY:n.y});break}}function ze(t){let o;switch(t.button){case 0:o=e.mouseButtons.LEFT;break;case 1:o=e.mouseButtons.MIDDLE;break;case 2:o=e.mouseButtons.RIGHT;break;default:o=-1}switch(o){case k.DOLLY:if(e.enableZoom===!1)return;Le(t),r=a.DOLLY;break;case k.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;ae(t),r=a.PAN}else{if(e.enableRotate===!1)return;ne(t),r=a.ROTATE}break;case k.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;ne(t),r=a.ROTATE}else{if(e.enablePan===!1)return;ae(t),r=a.PAN}break;default:r=a.NONE}r!==a.NONE&&e.dispatchEvent(J)}function _e(t){switch(r){case a.ROTATE:if(e.enableRotate===!1)return;De(t);break;case a.DOLLY:if(e.enableZoom===!1)return;Re(t);break;case a.PAN:if(e.enablePan===!1)return;xe(t);break}}function me(t){e.enabled===!1||e.enableZoom===!1||r!==a.NONE||(t.preventDefault(),e.dispatchEvent(J),Ne(Ke(t)),e.dispatchEvent(Oe))}function Ke(t){const o=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(o){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!W&&(n.deltaY*=10),n}function pe(t){t.key==="Control"&&(W=!0,e.domElement.getRootNode().addEventListener("keyup",he,{passive:!0,capture:!0}))}function he(t){t.key==="Control"&&(W=!1,e.domElement.getRootNode().removeEventListener("keyup",he,{passive:!0,capture:!0}))}function v(t){e.enabled===!1||e.enablePan===!1||ke(t)}function fe(t){switch(ye(t),c.length){case 1:switch(e.touches.ONE){case S.ROTATE:if(e.enableRotate===!1)return;ie(t),r=a.TOUCH_ROTATE;break;case S.PAN:if(e.enablePan===!1)return;se(t),r=a.TOUCH_PAN;break;default:r=a.NONE}break;case 2:switch(e.touches.TWO){case S.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Se(t),r=a.TOUCH_DOLLY_PAN;break;case S.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ie(t),r=a.TOUCH_DOLLY_ROTATE;break;default:r=a.NONE}break;default:r=a.NONE}r!==a.NONE&&e.dispatchEvent(J)}function He(t){switch(ye(t),r){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;ce(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;le(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ce(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ye(t),e.update();break;default:r=a.NONE}}function be(t){e.enabled!==!1&&t.preventDefault()}function Ue(t){c.push(t.pointerId)}function Ze(t){delete I[t.pointerId];for(let o=0;o=2&&t.setY(l,i.getY(o)),n>=3&&t.setZ(l,i.getZ(o)),n>=4&&t.setW(l,i.getW(o))}}else{const n=t.array,o=n.constructor,r=n.BYTES_PER_ELEMENT*i.itemSize*e;new o(n.buffer,r,i.array.length).set(i.array)}}function H(i,t,e){const n=i.elements,o=t.elements;for(let r=0,l=o.length;r{n.traverseVisible(o=>{o.isMesh&&e.push(o)})}),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map(()=>new W),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach(e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)}),t}generate(t=new W){let e=[];const{meshes:n,useGroups:o,_intermediateGeometry:r,_diffMap:l}=this;for(let s=0,a=n.length;sr+1e3&&(u.update(e*1e3/(n-r),100),r=n,e=0,h)){var l=performance.memory;h.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){f=this.end()},domElement:a,setMode:o}};P.Panel=function(m,a,i){var o=1/0,f=0,r=Math.round,e=r(window.devicePixelRatio||1),u=80*e,v=48*e,h=3*e,n=2*e,l=3*e,c=15*e,d=74*e,s=30*e,p=document.createElement("canvas");p.width=u,p.height=v,p.style.cssText="width:80px;height:48px";var t=p.getContext("2d");return t.font="bold "+9*e+"px Helvetica,Arial,sans-serif",t.textBaseline="top",t.fillStyle=i,t.fillRect(0,0,u,v),t.fillStyle=a,t.fillText(m,h,n),t.fillRect(l,c,d,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l,c,d,s),{dom:p,update:function(x,S){o=Math.min(o,x),f=Math.max(f,x),t.fillStyle=i,t.globalAlpha=1,t.fillRect(0,0,u,c),t.fillStyle=a,t.fillText(r(x)+" "+m+" ("+r(o)+"-"+r(f)+")",h,n),t.drawImage(p,l+e,c,d-e,s,l,c,d-e,s),t.fillRect(l+d-e,c,e,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l+d-e,c,e,r((1-x/S)*s))}}};export{P as S}; diff --git a/example/bundle/assets/TransformControls-CXlfLtXQ.js b/example/bundle/assets/TransformControls-CXlfLtXQ.js new file mode 100644 index 00000000..f8749b51 --- /dev/null +++ b/example/bundle/assets/TransformControls-CXlfLtXQ.js @@ -0,0 +1 @@ +import{R as gt,V as a,O as et,aq as M,j as ut,c as mt,q as vt,h as w,y as m,f as ot,af as st,M as n,aI as U,aj as I,b as Et,ai as q,m as It,n as Qt,a5 as Xt}from"./ExtendedTriangle-Chm2bbkR.js";const A=new gt,d=new a,Q=new a,h=new M,at={X:new a(1,0,0),Y:new a(0,1,0),Z:new a(0,0,1)},$={type:"change"},rt={type:"mouseDown",mode:null},lt={type:"mouseUp",mode:null},ht={type:"objectChange"};class qt extends et{constructor(i,s){super(),s===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),s=document),this.isTransformControls=!0,this.visible=!1,this.domElement=s,this.domElement.style.touchAction="none";const o=new zt;this._gizmo=o,this.add(o);const e=new Dt;this._plane=e,this.add(e);const l=this;function t(u,b){let H=b;Object.defineProperty(l,u,{get:function(){return H!==void 0?H:b},set:function(Y){H!==Y&&(H=Y,e[u]=Y,o[u]=Y,l.dispatchEvent({type:u+"-changed",value:Y}),l.dispatchEvent($))}}),l[u]=b,e[u]=b,o[u]=b}t("camera",i),t("object",void 0),t("enabled",!0),t("axis",null),t("mode","translate"),t("translationSnap",null),t("rotationSnap",null),t("scaleSnap",null),t("space","world"),t("size",1),t("dragging",!1),t("showX",!0),t("showY",!0),t("showZ",!0);const c=new a,y=new a,X=new M,T=new M,D=new a,j=new M,it=new a,C=new a,g=new a,v=0,S=new a;t("worldPosition",c),t("worldPositionStart",y),t("worldQuaternion",X),t("worldQuaternionStart",T),t("cameraPosition",D),t("cameraQuaternion",j),t("pointStart",it),t("pointEnd",C),t("rotationAxis",g),t("rotationAngle",v),t("eye",S),this._offset=new a,this._startNorm=new a,this._endNorm=new a,this._cameraScale=new a,this._parentPosition=new a,this._parentQuaternion=new M,this._parentQuaternionInv=new M,this._parentScale=new a,this._worldScaleStart=new a,this._worldQuaternionInv=new M,this._worldScale=new a,this._positionStart=new a,this._quaternionStart=new M,this._scaleStart=new a,this._getPointer=Yt.bind(this),this._onPointerDown=Zt.bind(this),this._onPointerHover=At.bind(this),this._onPointerMove=Tt.bind(this),this._onPointerUp=Ht.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(i){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(i)}pointerHover(i){if(this.object===void 0||this.dragging===!0)return;i!==null&&A.setFromCamera(i,this.camera);const s=tt(this._gizmo.picker[this.mode],A);s?this.axis=s.object.name:this.axis=null}pointerDown(i){if(!(this.object===void 0||this.dragging===!0||i!=null&&i.button!==0)&&this.axis!==null){i!==null&&A.setFromCamera(i,this.camera);const s=tt(this._plane,A,!0);s&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(s.point).sub(this.worldPositionStart)),this.dragging=!0,rt.mode=this.mode,this.dispatchEvent(rt)}}pointerMove(i){const s=this.axis,o=this.mode,e=this.object;let l=this.space;if(o==="scale"?l="local":(s==="E"||s==="XYZE"||s==="XYZ")&&(l="world"),e===void 0||s===null||this.dragging===!1||i!==null&&i.button!==-1)return;i!==null&&A.setFromCamera(i,this.camera);const t=tt(this._plane,A,!0);if(t){if(this.pointEnd.copy(t.point).sub(this.worldPositionStart),o==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),l==="local"&&s!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),s.indexOf("X")===-1&&(this._offset.x=0),s.indexOf("Y")===-1&&(this._offset.y=0),s.indexOf("Z")===-1&&(this._offset.z=0),l==="local"&&s!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),e.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(l==="local"&&(e.position.applyQuaternion(h.copy(this._quaternionStart).invert()),s.search("X")!==-1&&(e.position.x=Math.round(e.position.x/this.translationSnap)*this.translationSnap),s.search("Y")!==-1&&(e.position.y=Math.round(e.position.y/this.translationSnap)*this.translationSnap),s.search("Z")!==-1&&(e.position.z=Math.round(e.position.z/this.translationSnap)*this.translationSnap),e.position.applyQuaternion(this._quaternionStart)),l==="world"&&(e.parent&&e.position.add(d.setFromMatrixPosition(e.parent.matrixWorld)),s.search("X")!==-1&&(e.position.x=Math.round(e.position.x/this.translationSnap)*this.translationSnap),s.search("Y")!==-1&&(e.position.y=Math.round(e.position.y/this.translationSnap)*this.translationSnap),s.search("Z")!==-1&&(e.position.z=Math.round(e.position.z/this.translationSnap)*this.translationSnap),e.parent&&e.position.sub(d.setFromMatrixPosition(e.parent.matrixWorld))));else if(o==="scale"){if(s.search("XYZ")!==-1){let c=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(c*=-1),Q.set(c,c,c)}else d.copy(this.pointStart),Q.copy(this.pointEnd),d.applyQuaternion(this._worldQuaternionInv),Q.applyQuaternion(this._worldQuaternionInv),Q.divide(d),s.search("X")===-1&&(Q.x=1),s.search("Y")===-1&&(Q.y=1),s.search("Z")===-1&&(Q.z=1);e.scale.copy(this._scaleStart).multiply(Q),this.scaleSnap&&(s.search("X")!==-1&&(e.scale.x=Math.round(e.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),s.search("Y")!==-1&&(e.scale.y=Math.round(e.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),s.search("Z")!==-1&&(e.scale.z=Math.round(e.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const c=20/this.worldPosition.distanceTo(d.setFromMatrixPosition(this.camera.matrixWorld));let y=!1;s==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(d.copy(this.rotationAxis).cross(this.eye))*c):(s==="X"||s==="Y"||s==="Z")&&(this.rotationAxis.copy(at[s]),d.copy(at[s]),l==="local"&&d.applyQuaternion(this.worldQuaternion),d.cross(this.eye),d.length()===0?y=!0:this.rotationAngle=this._offset.dot(d.normalize())*c),(s==="E"||y)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),l==="local"&&s!=="E"&&s!=="XYZE"?(e.quaternion.copy(this._quaternionStart),e.quaternion.multiply(h.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),e.quaternion.copy(h.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),e.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent($),this.dispatchEvent(ht)}}pointerUp(i){i!==null&&i.button!==0||(this.dragging&&this.axis!==null&&(lt.mode=this.mode,this.dispatchEvent(lt)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(i){i.geometry&&i.geometry.dispose(),i.material&&i.material.dispose()})}attach(i){return this.object=i,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent($),this.dispatchEvent(ht),this.pointStart.copy(this.pointEnd))}getRaycaster(){return A}getMode(){return this.mode}setMode(i){this.mode=i}setTranslationSnap(i){this.translationSnap=i}setRotationSnap(i){this.rotationSnap=i}setScaleSnap(i){this.scaleSnap=i}setSize(i){this.size=i}setSpace(i){this.space=i}}function Yt(p){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:p.button};{const i=this.domElement.getBoundingClientRect();return{x:(p.clientX-i.left)/i.width*2-1,y:-(p.clientY-i.top)/i.height*2+1,button:p.button}}}function At(p){if(this.enabled)switch(p.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(p));break}}function Zt(p){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(p.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(p)),this.pointerDown(this._getPointer(p)))}function Tt(p){this.enabled&&this.pointerMove(this._getPointer(p))}function Ht(p){this.enabled&&(this.domElement.releasePointerCapture(p.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(p)))}function tt(p,i,s){const o=i.intersectObject(p,!0);for(let e=0;e.9&&(t.visible=!1)),this.axis==="Y"&&(h.setFromEuler(N.set(0,0,Math.PI/2)),t.quaternion.copy(o).multiply(h),Math.abs(r.copy(Z).applyQuaternion(o).dot(this.eye))>.9&&(t.visible=!1)),this.axis==="Z"&&(h.setFromEuler(N.set(0,Math.PI/2,0)),t.quaternion.copy(o).multiply(h),Math.abs(r.copy(O).applyQuaternion(o).dot(this.eye))>.9&&(t.visible=!1)),this.axis==="XYZE"&&(h.setFromEuler(N.set(0,Math.PI/2,0)),r.copy(this.rotationAxis),t.quaternion.setFromRotationMatrix(pt.lookAt(ct,r,Z)),t.quaternion.multiply(h),t.visible=this.dragging),this.axis==="E"&&(t.visible=!1)):t.name==="START"?(t.position.copy(this.worldPositionStart),t.visible=this.dragging):t.name==="END"?(t.position.copy(this.worldPosition),t.visible=this.dragging):t.name==="DELTA"?(t.position.copy(this.worldPositionStart),t.quaternion.copy(this.worldQuaternionStart),d.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),d.applyQuaternion(this.worldQuaternionStart.clone().invert()),t.scale.copy(d),t.visible=this.dragging):(t.quaternion.copy(o),this.dragging?t.position.copy(this.worldPositionStart):t.position.copy(this.worldPosition),this.axis&&(t.visible=this.axis.search(t.name)!==-1));continue}t.quaternion.copy(o),this.mode==="translate"||this.mode==="scale"?(t.name==="X"&&Math.abs(r.copy(R).applyQuaternion(o).dot(this.eye))>.99&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),t.name==="Y"&&Math.abs(r.copy(Z).applyQuaternion(o).dot(this.eye))>.99&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),t.name==="Z"&&Math.abs(r.copy(O).applyQuaternion(o).dot(this.eye))>.99&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),t.name==="XY"&&Math.abs(r.copy(O).applyQuaternion(o).dot(this.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),t.name==="YZ"&&Math.abs(r.copy(R).applyQuaternion(o).dot(this.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1),t.name==="XZ"&&Math.abs(r.copy(Z).applyQuaternion(o).dot(this.eye))<.2&&(t.scale.set(1e-10,1e-10,1e-10),t.visible=!1)):this.mode==="rotate"&&(V.copy(o),r.copy(this.eye).applyQuaternion(h.copy(o).invert()),t.name.search("E")!==-1&&t.quaternion.setFromRotationMatrix(pt.lookAt(this.eye,ct,Z)),t.name==="X"&&(h.setFromAxisAngle(R,Math.atan2(-r.y,r.z)),h.multiplyQuaternions(V,h),t.quaternion.copy(h)),t.name==="Y"&&(h.setFromAxisAngle(Z,Math.atan2(r.x,r.z)),h.multiplyQuaternions(V,h),t.quaternion.copy(h)),t.name==="Z"&&(h.setFromAxisAngle(O,Math.atan2(r.y,r.x)),h.multiplyQuaternions(V,h),t.quaternion.copy(h))),t.visible=t.visible&&(t.name.indexOf("X")===-1||this.showX),t.visible=t.visible&&(t.name.indexOf("Y")===-1||this.showY),t.visible=t.visible&&(t.name.indexOf("Z")===-1||this.showZ),t.visible=t.visible&&(t.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),t.material._color=t.material._color||t.material.color.clone(),t.material._opacity=t.material._opacity||t.material.opacity,t.material.color.copy(t.material._color),t.material.opacity=t.material._opacity,this.enabled&&this.axis&&(t.name===this.axis||this.axis.split("").some(function(y){return t.name===y}))&&(t.material.color.setHex(16776960),t.material.opacity=1)}super.updateMatrixWorld(i)}}class Dt extends n{constructor(){super(new It(1e5,1e5,2,2),new mt({visible:!1,wireframe:!0,side:Qt,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(i){let s=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(s="local"),J.copy(R).applyQuaternion(s==="local"?this.worldQuaternion:K),L.copy(Z).applyQuaternion(s==="local"?this.worldQuaternion:K),k.copy(O).applyQuaternion(s==="local"?this.worldQuaternion:K),r.copy(L),this.mode){case"translate":case"scale":switch(this.axis){case"X":r.copy(this.eye).cross(J),x.copy(J).cross(r);break;case"Y":r.copy(this.eye).cross(L),x.copy(L).cross(r);break;case"Z":r.copy(this.eye).cross(k),x.copy(k).cross(r);break;case"XY":x.copy(k);break;case"YZ":x.copy(J);break;case"XZ":r.copy(k),x.copy(L);break;case"XYZ":case"E":x.set(0,0,0);break}break;case"rotate":default:x.set(0,0,0)}x.length()===0?this.quaternion.copy(this.cameraQuaternion):(dt.lookAt(d.set(0,0,0),x,r),this.quaternion.setFromRotationMatrix(dt)),super.updateMatrixWorld(i)}}export{qt as T}; diff --git a/example/bundle/assets/_commonjsHelpers-Cpj98o6Y.js b/example/bundle/assets/_commonjsHelpers-Cpj98o6Y.js new file mode 100644 index 00000000..b285ce54 --- /dev/null +++ b/example/bundle/assets/_commonjsHelpers-Cpj98o6Y.js @@ -0,0 +1 @@ +var o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}export{o as c,l as g}; diff --git a/example/bundle/assets/asyncGenerate-vh0gQ6dI.js b/example/bundle/assets/asyncGenerate-vh0gQ6dI.js new file mode 100644 index 00000000..136ba644 --- /dev/null +++ b/example/bundle/assets/asyncGenerate-vh0gQ6dI.js @@ -0,0 +1,6 @@ +import{B as q,a as z,W as K,S as U,F as O,D as _,A as j,P as N,G as J,M as P,b as Q,c as X,T as Y,d as Z,C as ee,e as re}from"./ExtendedTriangle-Chm2bbkR.js";import{S as ne}from"./stats.min-GTpOrGrX.js";import{g as te}from"./lil-gui.module.min-Bc0DeA9g.js";import{i as A,e as oe,M as v,c as M,C as F,A as ae,S as ie}from"./MeshBVH-CPVAl5W3.js";import{G as se,W as de}from"./GenerateMeshBVHWorker-B43A4fin.js";import{M as H}from"./MeshBVHHelper-jLfel8l5.js";import"./_commonjsHelpers-Cpj98o6Y.js";const G=typeof navigator<"u"?navigator.hardwareConcurrency:4;class le extends de{constructor(){const o=new Worker(new URL(""+new URL("parallelMeshBVH.worker-3aq7SIs7.js",import.meta.url).href,import.meta.url),{type:"module"});if(super(o),this.name="ParallelMeshBVHWorker",this.maxWorkerCount=Math.max(G,4),!A())throw new Error("ParallelMeshBVHWorker: Shared Array Buffers are not supported.")}runTask(o,r,n={}){return new Promise((u,a)=>{if(!r.index&&!n.indirect&&oe(r,n),r.getAttribute("position").isInterleavedBufferAttribute||r.index&&r.index.isInterleavedBufferAttribute)throw new Error("ParallelMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");o.onerror=p=>{a(new Error(`ParallelMeshBVHWorker: ${p.message}`))},o.onmessage=p=>{const{data:f}=p;if(f.error)a(new Error(f.error)),o.onmessage=null;else if(f.serialized){const{serialized:x,position:$}=f,k=v.deserialize(x,r,{setIndex:!1}),D={setBoundingBox:!0,...n};if(r.attributes.position.array=$,x.index)if(r.index)r.index.array=x.index;else{const L=new q(x.index,1,!1);r.setIndex(L)}D.setBoundingBox&&(r.boundingBox=k.getBoundingBox(new z)),n.onProgress&&n.onProgress(f.progress),u(k),o.onmessage=null}else n.onProgress&&n.onProgress(f.progress)};const d=r.index?r.index.array:null,h=r.attributes.position.array;o.postMessage({operation:"BUILD_BVH",maxWorkerCount:this.maxWorkerCount,index:M(d,SharedArrayBuffer),position:M(h,SharedArrayBuffer),options:{...n,onProgress:null,includedProgressCallback:!!n.onProgress,groups:[...r.groups]}})})}}class ue{constructor(){if(A())return new le;{console.warn("ParallelMeshBVHWorker: SharedArrayBuffers not supported. Falling back to single-threaded GenerateMeshBVHWorker.");const o=new se;return o.maxWorkerCount=G,o}}}const C=typeof SharedArrayBuffer<"u",e={useWebWorker:!0,maxWorkerCount:C?navigator.hardwareConcurrency:1,strategy:F,radius:1,tube:.3,tubularSegments:500,radialSegments:500,p:3,q:5,displayHelper:!1,helperDepth:10};let m,c,w,i,V,g,t,s,S,y,W,E,I,B,b=!1;pe();R();function pe(){y=document.getElementById("output"),W=document.getElementById("loading-container"),E=document.querySelector("#loading-container .bar"),I=document.querySelector("#loading-container .text"),m=new K({antialias:!0}),m.setPixelRatio(window.devicePixelRatio),m.setSize(window.innerWidth,window.innerHeight),m.setClearColor(16763432,1),document.body.appendChild(m.domElement),w=new U,w.fog=new O(16763432,20,60);const o=new _(16777215,3);o.position.set(1,1,1),w.add(o),w.add(new j(11583173,2.5)),c=new N(75,window.innerWidth/window.innerHeight,.1,50),c.position.set(0,0,4),c.far=100,c.updateProjectionMatrix(),V=new re,S=new ne,document.body.appendChild(S.dom),s=new J,w.add(s);for(let a=0;a<400;a++){const d=new P(new Q(1,32,32),new X);d.position.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).multiplyScalar(70),d.scale.setScalar(Math.random()*.3+.1),s.add(d)}B=new ue,window.WORKER=B,g=new te;const r=g.addFolder("helper");r.add(e,"displayHelper").name("enabled").onChange(a=>{a&&t&&t.update()}),r.add(e,"helperDepth",1,50,1).onChange(a=>{t&&(t.depth=a,t.update())}),r.open();const n=g.addFolder("knot");n.add(e,"radius",.5,2,.01),n.add(e,"tube",.2,1.2,.01),n.add(e,"tubularSegments",50,2e3,1),n.add(e,"radialSegments",5,2e3,1),n.add(e,"p",1,10,1),n.add(e,"q",1,10,1),n.open();const u=g.addFolder("bvh");u.add(e,"useWebWorker"),u.add(e,"maxWorkerCount",1,16,1).disable(!C),u.add(e,"strategy",{CENTER:F,AVERAGE:ae,SAH:ie}),g.add({regenerateKnot:T},"regenerateKnot").name("regenerate"),T(),window.addEventListener("resize",function(){c.aspect=window.innerWidth/window.innerHeight,c.updateProjectionMatrix(),m.setSize(window.innerWidth,window.innerHeight)},!1)}function T(){if(b)return;b=!0,i&&(i.material.dispose(),i.geometry.dispose(),s.remove(i),s.remove(t));const l=window.performance.now(),o=window.performance.now();i=new P(new Y(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q),new Z({color:new ee(5093036),roughness:.75}));const r=window.performance.now()-o,n=window.performance.now(),u={strategy:e.strategy};let a;if(e.useWebWorker){const d=h=>{const p=(h*100).toFixed(0);W.style.visibility="visible",E.style.width=`${p}%`,I.innerText=`${p}%`};B.maxWorkerCount=e.maxWorkerCount,B.generate(i.geometry,{onProgress:d,...u}).then(h=>{W.style.visibility="hidden",i.geometry.boundsTree=h,s.add(i);const p=window.performance.now()-n;b=!1,t=new H(i,0),t.depth=e.helperDepth,e.displayHelper&&t.update(),s.add(t),y.textContent=`Geometry Generation Time : ${r.toFixed(3)}ms +BVH Generation Time : ${p.toFixed(3)}ms +Frame Stall Time : ${a.toFixed(3)} +SharedArrayBuffer Support : ${C}`}),a=window.performance.now()-l}else{i.geometry.boundsTree=new v(i.geometry,u),a=window.performance.now()-l,s.add(i);const d=window.performance.now()-n;b=!1,t=new H(i),t.depth=e.helperDepth,t.update(),s.add(t),y.textContent=`Geometry Generation Time : ${r.toFixed(3)}ms +BVH Generation Time : ${d.toFixed(3)}ms +Frame Stall Time : ${a.toFixed(3)}`}}function R(){S.update(),requestAnimationFrame(R);let l=V.getDelta();s.rotation.x+=.4*l,s.rotation.y+=.6*l,t&&(t.visible=e.displayHelper),m.render(w,c)} diff --git a/example/bundle/assets/batchedMesh-DnHPyMzR.js b/example/bundle/assets/batchedMesh-DnHPyMzR.js new file mode 100644 index 00000000..fae34ae6 --- /dev/null +++ b/example/bundle/assets/batchedMesh-DnHPyMzR.js @@ -0,0 +1 @@ +import{M as B,f as k,g as A,R as N,b as j,h as K,O as I,W as J,S as Q,F as U,D as X,A as Y,i as Z,P as _,T as R,c as F,V}from"./ExtendedTriangle-Chm2bbkR.js";import{S as $}from"./stats.min-GTpOrGrX.js";import{g as ee}from"./lil-gui.module.min-Bc0DeA9g.js";import{a as D,c as te,d as oe,b as ne,e as se}from"./ExtensionUtilities-0qN33-Z7.js";import{C as H,S as ae,A as re}from"./MeshBVH-CPVAl5W3.js";import"./_commonjsHelpers-Cpj98o6Y.js";B.prototype.raycast=D;k.prototype.computeBoundsTree=te;k.prototype.disposeBoundsTree=oe;A.prototype.raycast=D;A.prototype.computeBoundsTree=ne;A.prototype.disposeBoundsTree=se;const z=13621468,ie=2503224,P=14162784;let m,c,S,u,O,i,t;const M=[],d=new N,W=new j(.25,20,20),de=new K(.01,.01),p=25,e=new I;let T=null,h=0;const o={raycasters:{count:150,speed:1,near:0,far:p},mesh:{splitStrategy:H,useBoundsTree:!0,speed:1}};ce();y();v();function ce(){m=new J({antialias:!0}),m.setPixelRatio(window.devicePixelRatio),m.setSize(window.innerWidth,window.innerHeight),m.setClearColor(z,1),document.body.appendChild(m.domElement),c=new Q,c.fog=new U(z,40,100);const n=new X(16777215,1.5);n.position.set(1,1,1),c.add(n),c.add(new Y(16777215,1.2)),i=new I,O=new Z({color:ie}),i.scale.multiplyScalar(10),i.rotation.x=10.989999999999943,i.rotation.y=10.989999999999943,c.add(i),pe(),u=new _(75,window.innerWidth/window.innerHeight,.1,50),u.position.z=60,u.far=100,u.updateProjectionMatrix(),S=new $,document.body.appendChild(S.dom);const r=new ee,s=r.addFolder("Raycasters");s.add(o.raycasters,"count").min(1).max(1e3).step(1).onChange(()=>y()),s.add(o.raycasters,"speed").min(0).max(20),s.add(o.raycasters,"near").min(0).max(p).onChange(()=>y()),s.add(o.raycasters,"far").min(0).max(p).onChange(()=>y()),s.open();const a=r.addFolder("Mesh");a.add(o.mesh,"useBoundsTree").onChange(()=>y()),a.add(o.mesh,"splitStrategy",{CENTER:H,SAH:ae,AVERAGE:re}).onChange(()=>y()),a.add(o.mesh,"speed").min(0).max(20),a.open(),window.addEventListener("resize",function(){u.aspect=window.innerWidth/window.innerHeight,u.updateProjectionMatrix(),m.setSize(window.innerWidth,window.innerHeight)},!1)}function pe(){const r=new R(.5,.2,200,100,2,3),s=new R(.5,.2,200,100,3,4),a=new j(.5,100,100),l=r.attributes.position.count,x=s.attributes.position.count,g=a.attributes.position.count,C=l+x+g,G=r.index.count,E=s.index.count,w=a.index.count,f=G+E+w;t=new A(3,C,f,O);const b=t.addGeometry(r),L=t.addGeometry(s),q=t.addGeometry(a);t.addInstance(b),t.addInstance(L),t.addInstance(q),e.position.x=-1.5,e.updateMatrix(),t.setMatrixAt(0,e.matrix),e.position.x=0,e.updateMatrix(),t.setMatrixAt(1,e.matrix),e.position.x=1.5,e.updateMatrix(),t.setMatrixAt(2,e.matrix),t.rotation.x=Math.random()*10,t.rotation.y=Math.random()*10,i.add(t)}function me(n){t.getMatrixAt(0,e.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale),e.rotation.x+=3e-4*o.mesh.speed*n,e.rotation.y+=3e-4*o.mesh.speed*n,e.updateMatrix(),t.setMatrixAt(0,e.matrix),t.getMatrixAt(1,e.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale),e.rotation.x+=9e-4*o.mesh.speed*n,e.rotation.y+=9e-4*o.mesh.speed*n,e.updateMatrix(),t.setMatrixAt(1,e.matrix),t.getMatrixAt(2,e.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale),e.rotation.x+=5e-4*o.mesh.speed*n,e.rotation.y+=5e-4*o.mesh.speed*n,e.updateMatrix(),t.setMatrixAt(2,e.matrix)}function ue(){const n=new I,r=new F({color:P}),s=new B(W,r),a=new B(W,r);a.scale.multiplyScalar(.25),s.scale.multiplyScalar(.5);const l=new B(de,new F({color:P,transparent:!0,opacity:.5}));n.add(l),n.add(s),n.add(a),c.add(n),s.position.set(p,0,0),n.rotation.x=Math.random()*10,n.rotation.y=Math.random()*10,n.rotation.z=Math.random()*10;const x=new V,g=new V,C=Math.random()-.5,G=Math.random()-.5,E=Math.random()-.5;M.push({update:()=>{n.rotation.x+=C*1e-4*o.raycasters.speed*h,n.rotation.y+=G*1e-4*o.raycasters.speed*h,n.rotation.z+=E*1e-4*o.raycasters.speed*h,s.updateMatrixWorld(),x.setFromMatrixPosition(s.matrixWorld),g.copy(x).multiplyScalar(-1).normalize(),d.set(x,g),d.firstHitOnly=!0;const w=d.intersectObject(i,!0),f=w.length?w[0].distance:p;a.position.set(p-f,0,0);const b=w.length?f-d.near:f-d.near-(p-d.far);l.position.set(p-d.near-b/2,0,0),l.scale.set(1,b,1),l.rotation.z=Math.PI/2},remove:()=>{c.remove(n)}})}function y(){for(d.near=o.raycasters.near,d.far=o.raycasters.far;M.length>o.raycasters.count;)M.pop().remove();for(;M.lengthr.update()),m.render(c,u),T=n,S.end(),requestAnimationFrame(v)} diff --git a/example/bundle/assets/bvh_struct_definitions.glsl-Drzlg63W.js b/example/bundle/assets/bvh_struct_definitions.glsl-Drzlg63W.js new file mode 100644 index 00000000..bc8e42e1 --- /dev/null +++ b/example/bundle/assets/bvh_struct_definitions.glsl-Drzlg63W.js @@ -0,0 +1,297 @@ +import{U as A,K as T,ar as b,as as _,at as F,au as M,av as H,aw as z,ax as k,Q as w,ay as S,az as U,a9 as C,aA as E,aB as P,B as V}from"./ExtendedTriangle-Chm2bbkR.js";import{g as L,b as G,B,d as Y,f as W,O as q,R as K,h as j,j as X}from"./MeshBVH-CPVAl5W3.js";function Q(c){switch(c){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function Z(c){switch(c){case 1:return C;case 2:return U;case 3:return w;case 4:return w}}function N(c){switch(c){case 1:return P;case 2:return E;case 3:return S;case 4:return S}}class O extends T{constructor(){super(),this.minFilter=b,this.magFilter=b,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,d=e.itemSize,n=e.count;if(t!==null){if(d*n%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=n*d/t}const r=e.itemSize,x=e.count,y=e.normalized,l=e.array.constructor,i=l.BYTES_PER_ELEMENT;let v=this._forcedType,f=r;if(v===null)switch(l){case Float32Array:v=A;break;case Uint8Array:case Uint16Array:case Uint32Array:v=_;break;case Int8Array:case Int16Array:case Int32Array:v=F;break}let o,a,u,h,m=Q(r);switch(v){case A:u=1,a=Z(r),y&&i===1?(h=l,m+="8",l===Uint8Array?o=M:(o=z,m+="_SNORM")):(h=Float32Array,m+="32F",o=A);break;case F:m+=i*8+"I",u=y?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,a=N(r),i===1?(h=Int8Array,o=z):i===2?(h=Int16Array,o=k):(h=Int32Array,o=F);break;case _:m+=i*8+"UI",u=y?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,a=N(r),i===1?(h=Uint8Array,o=M):i===2?(h=Uint16Array,o=H):(h=Uint32Array,o=_);break}f===3&&(a===w||a===S)&&(f=4);const s=Math.ceil(Math.sqrt(x))||1,I=f*s*s,p=new h(I),R=e.normalized;e.normalized=!1;for(let g=0;g=2&&(p[D+1]=e.getY(g)/u),r>=3&&(p[D+2]=e.getZ(g)/u,f===4&&(p[D+3]=1)),r>=4&&(p[D+3]=e.getW(g)/u)}e.normalized=R,this.internalFormat=m,this.format=a,this.type=o,this.image.width=s,this.image.height=s,this.image.data=p,this.needsUpdate=!0,this.dispose(),e.itemSize=d,e.count=n}}class J extends O{constructor(){super(),this._forcedType=_}}class $ extends O{constructor(){super(),this._forcedType=A}}class re{constructor(){this.index=new J,this.position=new $,this.bvhBounds=new T,this.bvhContents=new T,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(te(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const d=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==d.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const n=L(G(t));this._cachedIndexAttr=new V(n,1,!1)}ee(t,d,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:d,bvhContents:n}=this;e&&e.dispose(),t&&t.dispose(),d&&d.dispose(),n&&n.dispose()}}function ee(c,e,t){const d=t.array,n=c.index?c.index.array:null;for(let r=0,x=e.length;r= dist; + +} + +bool intersectsTriangle( + vec3 rayOrigin, vec3 rayDirection, vec3 a, vec3 b, vec3 c, + out vec3 barycoord, out vec3 norm, out float dist, out float side +) { + + // https://stackoverflow.com/questions/42740765/intersection-between-line-and-triangle-in-3d + vec3 edge1 = b - a; + vec3 edge2 = c - a; + norm = cross( edge1, edge2 ); + + float det = - dot( rayDirection, norm ); + float invdet = 1.0 / det; + + vec3 AO = rayOrigin - a; + vec3 DAO = cross( AO, rayDirection ); + + vec4 uvt; + uvt.x = dot( edge2, DAO ) * invdet; + uvt.y = - dot( edge1, DAO ) * invdet; + uvt.z = dot( AO, norm ) * invdet; + uvt.w = 1.0 - uvt.x - uvt.y; + + // set the hit information + barycoord = uvt.wxy; // arranged in A, B, C order + dist = uvt.z; + side = sign( det ); + norm = side * normalize( norm ); + + // add an epsilon to avoid misses between triangles + uvt += vec4( TRI_INTERSECT_EPSILON ); + + return all( greaterThanEqual( uvt, vec4( 0.0 ) ) ); + +} + +bool intersectTriangles( + // geometry info and triangle range + sampler2D positionAttr, usampler2D indexAttr, uint offset, uint count, + + // ray + vec3 rayOrigin, vec3 rayDirection, + + // outputs + inout float minDistance, inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord, + inout float side, inout float dist +) { + + bool found = false; + vec3 localBarycoord, localNormal; + float localDist, localSide; + for ( uint i = offset, l = offset + count; i < l; i ++ ) { + + uvec3 indices = uTexelFetch1D( indexAttr, i ).xyz; + vec3 a = texelFetch1D( positionAttr, indices.x ).rgb; + vec3 b = texelFetch1D( positionAttr, indices.y ).rgb; + vec3 c = texelFetch1D( positionAttr, indices.z ).rgb; + + if ( + intersectsTriangle( rayOrigin, rayDirection, a, b, c, localBarycoord, localNormal, localDist, localSide ) + && localDist < minDistance + ) { + + found = true; + minDistance = localDist; + + faceIndices = uvec4( indices.xyz, i ); + faceNormal = localNormal; + + side = localSide; + barycoord = localBarycoord; + dist = localDist; + + } + + } + + return found; + +} + +bool intersectsBVHNodeBounds( vec3 rayOrigin, vec3 rayDirection, sampler2D bvhBounds, uint currNodeIndex, out float dist ) { + + uint cni2 = currNodeIndex * 2u; + vec3 boundsMin = texelFetch1D( bvhBounds, cni2 ).xyz; + vec3 boundsMax = texelFetch1D( bvhBounds, cni2 + 1u ).xyz; + return intersectsBounds( rayOrigin, rayDirection, boundsMin, boundsMax, dist ); + +} + +// use a macro to hide the fact that we need to expand the struct into separate fields +#define bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ) _bvhIntersectFirstHit( bvh.position, bvh.index, bvh.bvhBounds, bvh.bvhContents, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ) + +bool _bvhIntersectFirstHit( + // bvh info + sampler2D bvh_position, usampler2D bvh_index, sampler2D bvh_bvhBounds, usampler2D bvh_bvhContents, + + // ray + vec3 rayOrigin, vec3 rayDirection, + + // output variables split into separate variables due to output precision + inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord, + inout float side, inout float dist +) { + + // stack needs to be twice as long as the deepest tree we expect because + // we push both the left and right child onto the stack every traversal + int ptr = 0; + uint stack[ BVH_STACK_DEPTH ]; + stack[ 0 ] = 0u; + + float triangleDistance = INFINITY; + bool found = false; + while ( ptr > - 1 && ptr < BVH_STACK_DEPTH ) { + + uint currNodeIndex = stack[ ptr ]; + ptr --; + + // check if we intersect the current bounds + float boundsHitDistance; + if ( + ! intersectsBVHNodeBounds( rayOrigin, rayDirection, bvh_bvhBounds, currNodeIndex, boundsHitDistance ) + || boundsHitDistance > triangleDistance + ) { + + continue; + + } + + uvec2 boundsInfo = uTexelFetch1D( bvh_bvhContents, currNodeIndex ).xy; + bool isLeaf = bool( boundsInfo.x & 0xffff0000u ); + + if ( isLeaf ) { + + uint count = boundsInfo.x & 0x0000ffffu; + uint offset = boundsInfo.y; + + found = intersectTriangles( + bvh_position, bvh_index, offset, count, + rayOrigin, rayDirection, triangleDistance, + faceIndices, faceNormal, barycoord, side, dist + ) || found; + + } else { + + uint leftIndex = currNodeIndex + 1u; + uint splitAxis = boundsInfo.x & 0x0000ffffu; + uint rightIndex = boundsInfo.y; + + bool leftToRight = rayDirection[ splitAxis ] >= 0.0; + uint c1 = leftToRight ? leftIndex : rightIndex; + uint c2 = leftToRight ? rightIndex : leftIndex; + + // set c2 in the stack so we traverse it later. We need to keep track of a pointer in + // the stack while we traverse. The second pointer added is the one that will be + // traversed first + ptr ++; + stack[ ptr ] = c2; + + ptr ++; + stack[ ptr ] = c1; + + } + + } + + return found; + +} +`,se=` +struct BVH { + + usampler2D index; + sampler2D position; + + sampler2D bvhBounds; + usampler2D bvhContents; + +}; +`;export{$ as F,re as M,ae as a,se as b,oe as c}; diff --git a/example/bundle/assets/characterMovement-Cxz45xLI.js b/example/bundle/assets/characterMovement-Cxz45xLI.js new file mode 100644 index 00000000..45d9572b --- /dev/null +++ b/example/bundle/assets/characterMovement-Cxz45xLI.js @@ -0,0 +1 @@ +import{V as P,a as K,j as O,L as I,W as q,k as J,S as N,F as Q,D as U,H as X,P as Y,M as G,d as j,G as Z,e as _}from"./ExtendedTriangle-Chm2bbkR.js";import{R as $}from"./RoundedBoxGeometry-BW68IL6j.js";import{G as ee}from"./GLTFLoader-Dl6abS6P.js";import{O as te}from"./OrbitControls-lzJCl7xY.js";import{m as ae}from"./BufferGeometryUtils-Cscy-pCt.js";import{S as oe}from"./stats.min-GTpOrGrX.js";import{g as ie}from"./lil-gui.module.min-Bc0DeA9g.js";import{S as se}from"./StaticGeometryGenerator-8L97b6eW.js";import{M as re}from"./MeshBVH-CPVAl5W3.js";import{M as ne}from"./MeshBVHHelper-jLfel8l5.js";import"./_commonjsHelpers-Cpj98o6Y.js";const a={firstPerson:!1,displayCollider:!1,displayBVH:!1,visualizeDepth:10,gravity:-30,playerSpeed:10,physicsSteps:5,reset:F};let f,d,g,R,b,W,v,c,V,e,r,C=!1,z=!1,B=!1,H=!1,D=!1,h=new P,k=new P(0,1,0),w=new P,E=new P,M=new K,A=new O,y=new I;de();T();function de(){f=new q({antialias:!0}),f.setPixelRatio(window.devicePixelRatio),f.setSize(window.innerWidth,window.innerHeight),f.setClearColor(1251612,1),f.shadowMap.enabled=!0,f.shadowMap.type=J,document.body.appendChild(f.domElement),g=new N,g.fog=new Q(1251612,20,70);const t=new U(16777215,3);t.position.set(1,1.5,1).multiplyScalar(50),t.shadow.mapSize.setScalar(2048),t.shadow.bias=-1e-4,t.shadow.normalBias=.05,t.castShadow=!0;const i=t.shadow.camera;i.bottom=i.left=-30,i.top=30,i.right=45,g.add(t),g.add(new X(16777215,2241348,.4)),d=new Y(75,window.innerWidth/window.innerHeight,.1,50),d.position.set(10,10,-10),d.far=100,d.updateProjectionMatrix(),window.camera=d,R=new _,r=new te(d,f.domElement),W=new oe,document.body.appendChild(W.dom),le(),e=new G(new $(1,2,1,10,.5),new j),e.geometry.translate(0,-.5,0),e.capsuleInfo={radius:.5,segment:new I(new P,new P(0,-1,0))},e.castShadow=!0,e.receiveShadow=!0,e.material.shadowSide=2,g.add(e),F(),b=new ie,b.add(a,"firstPerson").onChange(n=>{n||d.position.sub(r.target).normalize().multiplyScalar(10).add(r.target)});const p=b.addFolder("Visualization");p.add(a,"displayCollider"),p.add(a,"displayBVH"),p.add(a,"visualizeDepth",1,20,1).onChange(n=>{V.depth=n,V.update()}),p.open();const s=b.addFolder("Player");s.add(a,"physicsSteps",0,30,1),s.add(a,"gravity",-100,100,.01).onChange(n=>{a.gravity=parseFloat(n)}),s.add(a,"playerSpeed",1,20),s.open(),b.add(a,"reset"),b.open(),window.addEventListener("resize",function(){d.aspect=window.innerWidth/window.innerHeight,d.updateProjectionMatrix(),f.setSize(window.innerWidth,window.innerHeight)},!1),window.addEventListener("keydown",function(n){switch(n.code){case"KeyW":z=!0;break;case"KeyS":B=!0;break;case"KeyD":D=!0;break;case"KeyA":H=!0;break;case"Space":C&&(h.y=10,C=!1);break}}),window.addEventListener("keyup",function(n){switch(n.code){case"KeyW":z=!1;break;case"KeyS":B=!1;break;case"KeyD":D=!1;break;case"KeyA":H=!1;break}})}function le(){new ee().load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/dungeon-warkarma/scene.gltf",l=>{const t=l.scene;t.scale.setScalar(.01);const i=new K;i.setFromObject(t),i.getCenter(t.position).negate(),t.updateMatrixWorld(!0);const p={};t.traverse(o=>{if(!(/Boss/.test(o.name)||/Enemie/.test(o.name)||/Shield/.test(o.name)||/Sword/.test(o.name)||/Character/.test(o.name)||/Gate/.test(o.name)||/Cube/.test(o.name)||o.material&&o.material.color.r===1)&&o.isMesh){const S=o.material.color.getHex();p[S]=p[S]||[],p[S].push(o)}}),v=new Z;for(const o in p){const S=p[o],x=[];if(S.forEach(u=>{if(u.material.emissive.r!==0)v.attach(u);else{const m=u.geometry.clone();m.applyMatrix4(u.matrixWorld),x.push(m)}}),x.length){const u=ae(x),m=new G(u,new j({color:parseInt(o),shadowSide:2}));m.castShadow=!0,m.receiveShadow=!0,m.material.shadowSide=2,v.add(m)}}const s=new se(v);s.attributes=["position"];const n=s.generate();n.boundsTree=new re(n),c=new G(n),c.material.wireframe=!0,c.material.opacity=.5,c.material.transparent=!0,V=new ne(c,a.visualizeDepth),g.add(V),g.add(c),g.add(v)})}function F(){h.set(0,0,0),e.position.set(15.75,-3,30),d.position.sub(r.target),r.target.copy(e.position),d.position.add(e.position),r.update()}function pe(l){C?h.y=l*a.gravity:h.y+=l*a.gravity,e.position.addScaledVector(h,l);const t=r.getAzimuthalAngle();z&&(w.set(0,0,-1).applyAxisAngle(k,t),e.position.addScaledVector(w,a.playerSpeed*l)),B&&(w.set(0,0,1).applyAxisAngle(k,t),e.position.addScaledVector(w,a.playerSpeed*l)),H&&(w.set(-1,0,0).applyAxisAngle(k,t),e.position.addScaledVector(w,a.playerSpeed*l)),D&&(w.set(1,0,0).applyAxisAngle(k,t),e.position.addScaledVector(w,a.playerSpeed*l)),e.updateMatrixWorld();const i=e.capsuleInfo;M.makeEmpty(),A.copy(c.matrixWorld).invert(),y.copy(i.segment),y.start.applyMatrix4(e.matrixWorld).applyMatrix4(A),y.end.applyMatrix4(e.matrixWorld).applyMatrix4(A),M.expandByPoint(y.start),M.expandByPoint(y.end),M.min.addScalar(-i.radius),M.max.addScalar(i.radius),c.geometry.boundsTree.shapecast({intersectsBounds:o=>o.intersectsBox(M),intersectsTriangle:o=>{const S=w,x=E,u=o.closestPointToSegment(y,S,x);if(uMath.abs(l*h.y*.25);const n=Math.max(0,s.length()-1e-5);s.normalize().multiplyScalar(n),e.position.add(s),C?h.set(0,0,0):(s.normalize(),h.addScaledVector(s,-s.dot(h))),d.position.sub(r.target),r.target.copy(e.position),d.position.add(e.position),e.position.y<-25&&F()}function T(){W.update(),requestAnimationFrame(T);const l=Math.min(R.getDelta(),.1);if(a.firstPerson?(r.maxPolarAngle=Math.PI,r.minDistance=1e-4,r.maxDistance=1e-4):(r.maxPolarAngle=Math.PI/2,r.minDistance=1,r.maxDistance=20),c){c.visible=a.displayCollider,V.visible=a.displayBVH;const t=a.physicsSteps;for(let i=0;i{const t=s.scene.children[0],H=t.geometry;t.material=new I,t.position.set(0,0,0),t.quaternion.identity();const E=t.clone();E.material=new ue({depthFunc:we}),E.renderOrder=1,d.scale.copy(t.scale),d.position.set(0,0,0),d.quaternion.identity(),t.updateMatrixWorld(!0);const $=new Set,y=new Map;g=t,g.updateMatrixWorld(!0),g.traverse(n=>{if(n.isMesh){if(y.has(n.material)){n.material=y.get(n.material);return}$.add(n.material);const e=n.material.clone();e.color.set(16777215),e.roughness=1,e.metalness=0,e.side=he,e.stencilWrite=!0,e.stencilFail=Z,e.stencilZFail=Z,e.stencilZPass=Z,e.clippingPlanes=C,y.set(n.material,e),n.material=e}}),y.clear(),W=g.clone(),W.traverse(n=>{if(n.isMesh){if(y.has(n.material)){n.material=y.get(n.material);return}const e=n.material.clone();e.color.set(16777215),e.roughness=1,e.metalness=0,e.colorWrite=!1,e.depthWrite=!1,e.side=ye,e.stencilWrite=!0,e.stencilFail=A,e.stencilZFail=A,e.stencilZPass=A,e.clippingPlanes=C,y.set(n.material,e),n.material=e}}),L=new Be(H,{maxLeafTris:3}),H.boundsTree=L,m=new z(H,new I({wireframe:!0,transparent:!0,opacity:.01,depthWrite:!1})),m.renderOrder=2,m.position.copy(t.position),m.rotation.copy(t.rotation),m.scale.copy(t.scale),f=new Ce(m,parseInt(a.helperDepth)),f.depth=parseInt(a.helperDepth),f.update();const F=new Me;F.add(g,W,E,m,f,d);const T=new ge;T.setFromObject(g),T.getCenter(F.position).multiplyScalar(-1),F.updateMatrixWorld(!0),M.add(F)}),w=new Fe,w.add(a,"invert"),w.add(a,"animate"),w.add(a,"animation",["SPIN","OSCILLATE"]).onChange(()=>{S=0}),w.add(a,"displayModel"),w.add(a,"useBVH");const x=w.addFolder("helper");x.add(a,"wireframeDisplay"),x.add(a,"helperDisplay"),x.add(a,"helperDepth",1,20,1).onChange(s=>{f&&(f.depth=parseInt(s),f.update())}),x.open(),w.open(),q=new De,document.body.appendChild(q.domElement),window.addEventListener("resize",function(){h.aspect=window.innerWidth/window.innerHeight,h.updateProjectionMatrix(),l.setSize(window.innerWidth,window.innerHeight),l.setPixelRatio(window.devicePixelRatio)},!1)}function U(){f&&(f.visible=a.helperDisplay,m.visible=a.wireframeDisplay,g.visible=a.displayModel,W.visible=a.displayModel),d.material.color.set(a.displayModel?44225:5099745).convertSRGBToLinear();const P=Math.min(X.getDelta(),.03);a.animate&&(S+=P,a.animation==="SPIN"?(r.rotation.x=.25*S,r.rotation.y=.25*S,r.rotation.z=.25*S,r.position.set(0,0,0)):(r.position.set(Math.sin(.25*S)*.325,0,0),r.rotation.set(0,Math.PI/2,0)),r.updateMatrixWorld());const u=C[0];if(u.normal.set(0,0,a.invert?1:-1),u.constant=0,u.applyMatrix4(r.matrixWorld),L&&(a.animate||!N)){N=!0,R.copy(m.matrixWorld).invert(),b.copy(u).applyMatrix4(R);let i=0;const p=d.geometry.attributes.position,D=window.performance.now();L.shapecast({intersectsBounds:s=>a.useBVH?b.intersectsBox(s):We,intersectsTriangle:s=>{let t=0;c.start.copy(s.a),c.end.copy(s.b),b.intersectLine(c,o)&&(p.setXYZ(i,o.x,o.y,o.z),i++,t++),c.start.copy(s.b),c.end.copy(s.c),b.intersectLine(c,o)&&(p.setXYZ(i,o.x,o.y,o.z),t++,i++),c.start.copy(s.c),c.end.copy(s.a),b.intersectLine(c,o)&&(p.setXYZ(i,o.x,o.y,o.z),t++,i++),t===3&&(V.fromBufferAttribute(p,i-3),G.fromBufferAttribute(p,i-2),B.fromBufferAttribute(p,i-1),B.equals(V)||B.equals(G)?(t--,i--):V.equals(G)&&(p.setXYZ(i-2,B),t--,i--)),t!==2&&(i-=t)}}),d.geometry.setDrawRange(0,i),d.position.copy(u.normal).multiplyScalar(-1e-5),p.needsUpdate=!0;const x=window.performance.now()-D;Y.innerText=`${parseFloat(x.toFixed(3))}ms`}q.update(),requestAnimationFrame(U),j.update(),l.render(M,h)} diff --git a/example/bundle/assets/collectTriangles-C-g4XsFb.js b/example/bundle/assets/collectTriangles-C-g4XsFb.js new file mode 100644 index 00000000..5a018aaf --- /dev/null +++ b/example/bundle/assets/collectTriangles-C-g4XsFb.js @@ -0,0 +1 @@ +import{M as L,f as W,u as N,W as P,S as G,F as I,D as j,A as F,T as U,B as V,o as X,d as D,b as Y,P as k,R as H,j as q,v as K,V as Z}from"./ExtendedTriangle-Chm2bbkR.js";import{S as _}from"./Stats-9dH8FB2H.js";import{g as J}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as Q}from"./OrbitControls-lzJCl7xY.js";import{I as R,a as $,N as ee}from"./MeshBVH-CPVAl5W3.js";import{a as te,c as ne,d as oe}from"./ExtensionUtilities-0qN33-Z7.js";L.prototype.raycast=te;W.prototype.computeBoundsTree=ne;W.prototype.disposeBoundsTree=oe;const d={size:.1,rotate:!0};let C,w,o,s,m,l,c,y=new N,x=-1,M=!1,B;function re(){s=new P({antialias:!0}),s.setPixelRatio(window.devicePixelRatio),s.setSize(window.innerWidth,window.innerHeight),s.setClearColor(1251612,1),document.body.appendChild(s.domElement),s.domElement.style.touchAction="none",w=new G,w.fog=new I(2503224/2,20,60);const E=new j(16777215,1.5);E.position.set(1,1,1),w.add(E),w.add(new F(16777215,1.2));const p=1,S=.4,T=800,u=400,h=new U(p,S,T,u).toNonIndexed(),g=new Uint8Array(h.attributes.position.count*3);g.fill(255);const a=new V(g,3,!0);a.setUsage(X),h.setAttribute("color",a);const b=new D({color:16777215,roughness:.3,metalness:0,vertexColors:!0});l=new L(h,b),l.geometry.computeBoundsTree(),w.add(l);const A=new Y(1,40,40),r=new D({color:15483002,roughness:.75,metalness:0,transparent:!0,opacity:.5,premultipliedAlpha:!0,emissive:15483002,emissiveIntensity:.5});c=new L(A,r),w.add(c),o=new k(75,window.innerWidth/window.innerHeight,.1,50),o.position.set(3,3,3),o.far=100,o.updateProjectionMatrix(),C=new _,document.body.appendChild(C.dom);const n=new J;n.add(d,"size").min(.1).max(1).step(.1),n.add(d,"rotate"),n.open(),window.addEventListener("resize",function(){o.aspect=window.innerWidth/window.innerHeight,o.updateProjectionMatrix(),s.setSize(window.innerWidth,window.innerHeight)},!1),window.addEventListener("pointermove",function(e){y.x=e.clientX/window.innerWidth*2-1,y.y=-(e.clientY/window.innerHeight)*2+1,M=!0}),window.addEventListener("pointerdown",function(e){y.x=e.clientX/window.innerWidth*2-1,y.y=-(e.clientY/window.innerHeight)*2+1,x=e.button;const t=new H;t.setFromCamera(y,o),t.firstHitOnly=!0;const i=t.intersectObject(l,!0);M=!0,m.enabled=i.length===0},!0),window.addEventListener("pointerup",function(e){x=-1,e.pointerType==="touch"&&(M=!1)},!0),window.addEventListener("contextmenu",function(e){e.preventDefault()}),window.addEventListener("wheel",function(e){let t=e.deltaY;e.deltaMode===1&&(t*=40),e.deltaMode===2&&(t*=40),d.size+=t*5e-4,d.size=Math.max(Math.min(d.size,1),.1),n.controllersRecursive().forEach(i=>i.updateDisplay())}),m=new Q(o,s.domElement),m.addEventListener("start",function(){this.active=!0}),m.addEventListener("end",function(){this.active=!1}),B=window.performance.now()}function O(){requestAnimationFrame(O),C.begin();const v=l.geometry,E=v.boundsTree,p=v.getAttribute("color"),S=v.index;if(m.active||!M)c.visible=!1;else{c.scale.setScalar(d.size);const u=new H;u.setFromCamera(y,o),u.firstHitOnly=!0;const h=u.intersectObject(l,!0);if(h.length){c.position.copy(h[0].point),m.enabled=!1,c.visible=!0;const g=new q;g.copy(l.matrixWorld).invert();const a=new K;a.center.copy(c.position).applyMatrix4(g),a.radius=d.size;const b=[],A=new Z;if(E.shapecast({intersectsBounds:r=>{const n=a.intersectsBox(r),{min:e,max:t}=r;if(n){for(let i=0;i<=1;i++)for(let f=0;f<=1;f++)for(let z=0;z<=1;z++)if(A.set(i===0?e.x:t.x,f===0?e.y:t.y,z===0?e.z:t.z),!a.containsPoint(A))return R;return $}return n?R:ee},intersectsTriangle:(r,n,e)=>{if(e||r.intersectsSphere(a)){const t=3*n;b.push(t,t+1,t+2)}return!1}}),x===0||x===2){let r=1,n=1,e=1;x===0&&(r=15/255,n=78/255,e=85/255);for(let t=0,i=b.length;t.5?oe.set(0,1,0):oe.set(1,0,0),be.crossVectors(o,oe).normalize(),We.crossVectors(o,be).normalize(),e.makeBasis(We,be,o)}function Ye(o,e,t){return t.addVectors(o,e).normalize()}function He(o,e,t){const n=o.dot(e)>0,r=o.dot(t)>0;return n===r}const Dt=new T,Le=new T,Wt=new T,Vt=new T,Et=new T(0,0,1),xe=Math.PI;function Ht(o,e,t,n,r,s){const m=Dt.set(e*o.x,t*o.y,o.z).normalize(),c=m.z<.9999?Le.crossVectors(m,Et).normalize():Le.set(1,0,0),i=Wt.crossVectors(c,m),l=1/(1+m.z),d=Math.sqrt(n),g=r1&&(b=1),r.lerpColors(qt,t.color,s).multiplyScalar(d*g/(4*Math.abs(e.z*o.z))).multiplyScalar(E.lerp(b,1,s)).multiplyScalar(e.z)}function Xt(o,e,t,n){const{ior:r}=t,{frontFace:s}=n,m=s?1/r:r,c=Math.min(o.z,1),i=Math.sqrt(1-c*c);let l=ue(c,m);return m*i>1?0:1/(1-l)}function Yt(o,e,t,n){const{roughness:r,ior:s}=t,{frontFace:m}=e,c=m?1/s:s;se.copy(o).multiplyScalar(-1),kt(se,new T(0,0,1),c,n),se.randomDirection().multiplyScalar(r),n.add(se)}function Qt(o,e,t,n,r){const{metalness:s,transmission:m}=t;r.copy(t.color).multiplyScalar(1-s).multiplyScalar(m)}function Ze(o,e,t,n){const{ior:r,metalness:s,transmission:m}=t,{frontFace:c}=n,i=c?1/r:r,l=Math.min(o.z,1),d=Math.sqrt(1-l*l);let g=ue(l,i);i*d>1&&(g=1);let u=0,M=0,I=0;e.z<0?I=Xt(o,e,t,n):(u=Ot(o,e,t,n),M=jt(o,e));const z=E.lerp(g,1,s),j=.5+.5*s;return u*m*z+I*m*(1-z)+u*(1-m)*j+M*(1-m)*(1-j)}function Je(o,e,t,n,r){e.z<0?Qt(o,e,t,n,r):(_t(o,e,t,n,r),r.multiplyScalar(1-t.transmission),Ut(o,e,t,n,Ge),r.add(Ge))}function Zt(o,e,t,n){const r=n.direction,{ior:s,metalness:m,transmission:c}=t,{frontFace:i}=e,l=i?1/s:s,d=Math.min(o.z,1),g=Math.sqrt(1-d*d);let b=ue(d,l);if(l*g>1&&(b=1),Math.random(){let i;c.scene.traverse(u=>{u.isMesh&&u.name==="Dragon"&&(i=u)}),i.material=new k,i.geometry.center().scale(.25,.25,.25).rotateX(Math.PI/2),i.position.set(0,0,0),i.scale.set(1,1,1),i.quaternion.identity();const{geometry:l,materials:d}=Fe([i],!0),g=new R(l,new k),b=new De;b.generate(l,{maxLeafTris:1,strategy:we}).then(u=>{D.Dragon={mesh:g,materials:d,floorHeight:i.geometry.boundingBox.min.y},l.boundsTree=u,b.dispose(),$.add(g)})}),D.Engine=null,new Re().setMeshoptDecoder(Ft).load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/internal-combustion-engine/model.gltf",c=>{const i=c.scene.children[0],l=i.geometry,d=new ve,g=l.attributes.position,b=l.attributes.normal,u=new he(new Float32Array(g.count*3),3,!1),M=new he(new Float32Array(b.count*3),3,!1),I=new T;for(let v=0,ie=g.count;v{D.Engine={mesh:z,materials:[new k],floorHeight:d.boundingBox.min.y},d.boundsTree=v,j.dispose(),$.add(z)})}),O=0,Ke=new wt;const o=new Ct;o.add(a,"model",Object.keys(D)).onChange(p);const e=o.addFolder("resolution");e.add(a.resolution,"resolutionScale",.1,1,.01).onChange(J),e.add(a.resolution,"smoothImageScaling").onChange(J),e.add(a.resolution,"stretchImage").onChange(J),e.open();const t=o.addFolder("path tracing");t.add(a.pathTracing,"pause"),t.add(a.pathTracing,"displayScanLine").onChange(c=>{L.style.visibility=c?"visible":"hidden"}),t.add(a.pathTracing,"antialiasing").onChange(p),t.add(a.pathTracing,"directLightSampling").onChange(p),t.add(a.pathTracing,"smoothNormals").onChange(p),t.add(a.pathTracing,"bounces",1,50,1).onChange(p),t.add(a.pathTracing,"filterGlossyFactor",0,1,.001).onChange(p),t.open();const n=o.addFolder("model");n.addColor(a.material,"color").onChange(p),n.addColor(a.material,"emissive").onChange(p),n.add(a.material,"emissiveIntensity",0,5,.001).onChange(p),n.add(a.material,"roughness",0,1,.001).onChange(p),n.add(a.material,"metalness",0,1,.001).onChange(p),n.add(a.material,"transmission",0,1,.001).onChange(p),n.add(a.material,"ior",1,2.5,.001).onChange(p),n.open();const r=o.addFolder("floor");r.add(a.floor,"enable").onChange(p),r.addColor(a.floor,"color").onChange(p),r.add(a.floor,"roughness",0,1,.001).onChange(p),r.add(a.floor,"metalness",0,1,.001).onChange(p),r.add(a.floor,"width",3,20,.001).onChange(p),r.add(a.floor,"height",3,20,.001).onChange(p);const s=o.addFolder("light");s.add(a.light,"enable").onChange(p),s.addColor(a.light,"color").onChange(p),s.add(a.light,"intensity",0,100,.001).onChange(p),s.add(a.light,"width",0,5,.001).onChange(p),s.add(a.light,"height",0,5,.001).onChange(p),s.add(a.light,"position",["Diagonal","Above","Below"]).onChange(p);const m=o.addFolder("environment");m.add(a.environment,"skyMode",["sky","sun","checkerboard"]).onChange(p),m.add(a.environment,"skyIntensity",0,5,.001).onChange(p),J()}function Fe(o,e=!0){const t=[],n=[];for(let s=0,m=o.length;snew ke),u=new T(0,0,1).transformDirection(y.matrixWorld),M=y.scale.x,I=y.scale.y,z=new gt;z.firstHitOnly=!0;const j=new ke,v={pdf:0,color:new te,direction:new T};let ie=performance.now();for(ot=performance.now(),Ie=0,fe=100,L.style.visibility=a.pathTracing.displayScanLine?"visible":"hidden",re.material.side=Z,ee.forEach(S=>{S.side=Z});;){let S=0,h=0;if(a.pathTracing.antialiasing){const f=O%Ee.length;[S,h]=Ee[f],S=S/Ve/o,h=h/Ve/e}for(let f=e-1;f>=0;f--)for(let x=0;x16&&(Ie+=F,fe=100*f/e,yield,ie=performance.now())}O++}function at(S,h,f){const x=S.object,P=x.geometry.attributes.position,V=x.geometry.attributes.normal,w=x.geometry.attributes.materialIndex,B=S.face,F=S.face.normal;if(m){const G=S.point;le.a.fromBufferAttribute(P,B.a),le.b.fromBufferAttribute(P,B.b),le.c.fromBufferAttribute(P,B.c),ce.fromBufferAttribute(V,B.a),_e.fromBufferAttribute(V,B.b),Oe.fromBufferAttribute(V,B.c),le.getBarycoord(G,de),d.setScalar(0).addScaledVector(ce,de.x).addScaledVector(_e,de.y).addScaledVector(Oe,de.z).normalize()}else d.copy(F);F.transformDirection(x.matrixWorld),d.transformDirection(x.matrixWorld);const C=F.dot(h.direction)<0;C||(d.multiplyScalar(-1),F.multiplyScalar(-1));let X=x.material;if(w){const G=w.getX(B.a);X=ee[G]}S.material=X,S.normal=d,S.geometryNormal=F,S.frontFace=C,S.filteredSurfaceRoughness=Math.min(Math.max(1e-6,X.roughness,f*a.pathTracing.filterGlossyFactor*5),1)}function rt(S,h){let f=S,x=0,P=0;i.set(16777215);for(let V=0;V.95){let x=(f-.95)/.05;x*=x,h.r=E.lerp(.5,10,x),h.g=E.lerp(.7,10,x),h.b=E.lerp(1,10,x)}h.multiplyScalar(r)}else{const f=(S.y+.5)/2;h.r=E.lerp(1,.5,f),h.g=E.lerp(1,.7,f),h.b=E.lerp(1,1,f),h.multiplyScalar(r)}}}function Ue(o){o=o||0;let e=o*.001;const t=Math.floor(e/60);e=e-t*60;const n=(t<10?"0":"")+t,r=(e<10?"0":"")+e.toFixed(3);return`${n}m ${r}s`}function nt(){requestAnimationFrame(nt);for(const e in D)D[e]&&(D[e].mesh.visible=!1);if(D[a.model]){const e=D[a.model];e.mesh.visible=!0,re=e.mesh,ee=e.materials,W.position.y=e.floorHeight,ee.forEach(n=>{n.ior===void 0&&(n.ior=1),n.transmission===void 0&&(n.transmission=0)});const t=ee[0];switch(t.color.set(a.material.color).convertSRGBToLinear(),t.emissive.set(a.material.emissive).convertSRGBToLinear(),t.emissiveIntensity=parseFloat(a.material.emissiveIntensity),t.ior=parseFloat(a.material.ior),t.metalness=parseFloat(a.material.metalness),t.transmission=parseFloat(a.material.transmission),t.roughness=Math.pow(parseFloat(a.material.roughness),2),a.light.position){case"Below":y.rotation.set(-Math.PI/2,0,0),y.position.set(0,e.floorHeight+.001,0);break;case"Above":y.rotation.set(Math.PI/2,0,0),y.position.set(0,2-.001,0);break;default:y.position.set(2,2,2),y.lookAt(0,0,0);break}}else re=null,ee=null,W.position.y=0;let o=0;ae>Se&&(o=Math.min((ae-Se)/($e-Se),1)),L.style.bottom=`${fe}%`,a.resolution.stretchImage?L.style.borderBottomWidth=`${Math.ceil(1/a.resolution.resolutionScale)}px`:L.style.borderBottomWidth="1px",A.render($,q),A.autoClear=!1,K.material.map=N,K.material.opacity=o,K.render(A),A.autoClear=!0,re&&!a.pathTracing.pause&&et.next(),N.needsUpdate=!0,A.compile(K._mesh),ae<$e&&(ae+=Ke.getDelta()*1e3),tt.innerText=`completed samples : ${O} +computation time : ${Ue(Ie)} +elapsed time : ${Ue(performance.now()-ot)}`} diff --git a/example/bundle/assets/diamond-BjoksmdR.js b/example/bundle/assets/diamond-BjoksmdR.js new file mode 100644 index 00000000..aa7d3637 --- /dev/null +++ b/example/bundle/assets/diamond-BjoksmdR.js @@ -0,0 +1,161 @@ +import{X as ne,Y as W,U as X,_ as V,$ as te,a0 as q,S as ie,P as oe,W as le,a1 as ce,a2 as se,a3 as me,a4 as de,u as fe,C as he,M as pe,e as ve}from"./ExtendedTriangle-Chm2bbkR.js";import{g as ge}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as ue}from"./OrbitControls-lzJCl7xY.js";import{G as ye}from"./GLTFLoader-Dl6abS6P.js";import{M as we,c as _e,b as be,a as Re}from"./bvh_struct_definitions.glsl-Drzlg63W.js";import{M as Me,S as Ee}from"./MeshBVH-CPVAl5W3.js";import"./BufferGeometryUtils-Cscy-pCt.js";class De extends ne{constructor(c){super(c),this.type=W}parse(c){const e=function(r,n){switch(r){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(n||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(n||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(n||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(n||""))}},f=` +`,h=function(r,n,o){n=n||1024;let m=r.pos,s=-1,a=0,d="",t=String.fromCharCode.apply(null,new Uint16Array(r.subarray(m,m+128)));for(;0>(s=t.indexOf(f))&&a=r.byteLength||!(d=h(r)))&&e(1,"no header found"),(t=d.match(n))||e(3,"bad initial token"),a.valid|=1,a.programtype=t[1],a.string+=d+` +`;d=h(r),d!==!1;){if(a.string+=d+` +`,d.charAt(0)==="#"){a.comments+=d+` +`;continue}if((t=d.match(o))&&(a.gamma=parseFloat(t[1])),(t=d.match(l))&&(a.exposure=parseFloat(t[1])),(t=d.match(m))&&(a.valid|=2,a.format=t[1]),(t=d.match(s))&&(a.valid|=4,a.height=parseInt(t[1],10),a.width=parseInt(t[2],10)),a.valid&2&&a.valid&4)break}return a.valid&2||e(3,"missing format specifier"),a.valid&4||e(3,"missing image size specifier"),a},S=function(r,n,o){const l=n;if(l<8||l>32767||r[0]!==2||r[1]!==2||r[2]&128)return new Uint8Array(r);l!==(r[2]<<8|r[3])&&e(3,"wrong scanline width");const m=new Uint8Array(4*n*o);m.length||e(4,"unable to allocate buffer space");let s=0,a=0;const d=4*l,t=new Uint8Array(4),C=new Uint8Array(d);let K=o;for(;K>0&&ar.byteLength&&e(1),t[0]=r[a++],t[1]=r[a++],t[2]=r[a++],t[3]=r[a++],(t[0]!=2||t[1]!=2||(t[2]<<8|t[3])!=l)&&e(3,"bad rgbe scanline format");let k=0,_;for(;k128;if(b&&(_-=128),(_===0||k+_>d)&&e(3,"bad scanline data"),b){const R=r[a++];for(let Q=0;Q<_;Q++)C[k++]=R}else C.set(r.subarray(a,a+_),k),k+=_,a+=_}const ae=l;for(let b=0;b=u+1e3&&(D.update(e*1e3/(f-u),100),u=f,e=0,A)){var h=performance.memory;A.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return f},update:function(){v=this.end()},domElement:c,setMode:g}};O.Panel=function(E,c,p){var g=1/0,v=0,u=Math.round,e=u(window.devicePixelRatio||1),D=80*e,L=48*e,A=3*e,f=2*e,h=3*e,w=15*e,S=74*e,x=30*e,I=document.createElement("canvas");I.width=D,I.height=L,I.style.cssText="width:80px;height:48px";var i=I.getContext("2d");return i.font="bold "+9*e+"px Helvetica,Arial,sans-serif",i.textBaseline="top",i.fillStyle=p,i.fillRect(0,0,D,L),i.fillStyle=c,i.fillText(E,A,f),i.fillRect(h,w,S,x),i.fillStyle=p,i.globalAlpha=.9,i.fillRect(h,w,S,x),{dom:I,update:function(y,z){g=Math.min(g,y),v=Math.max(v,y),i.fillStyle=p,i.globalAlpha=1,i.fillRect(0,0,D,w),i.fillStyle=c,i.fillText(u(y)+" "+E+" ("+u(g)+"-"+u(v)+")",A,f),i.drawImage(I,h+e,w,S-e,x,h,w,S-e,x),i.fillRect(h+S-e,w,e,x),i.fillStyle=p,i.globalAlpha=.9,i.fillRect(h+S-e,w,e,u((1-y/z)*x))}}};let U,G,P,F,Z,M,B,j,ee;const T={color:"#ffffff",bounces:3,ior:2.4,aberrationStrength:.01,fastChroma:!1,animate:!0};Se();async function Se(){U=new ie,G=new oe(75,window.innerWidth/window.innerHeight,.1,1e3),G.position.set(28,15,7),P=new le({antialias:!1}),P.setSize(window.innerWidth,window.innerHeight),P.toneMapping=ce,document.body.appendChild(P.domElement),Z=new ue(G,P.domElement),ee=new ve;const E=new De().loadAsync("https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/equirectangular/venice_sunset_1k.hdr"),c=new ye().loadAsync("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/diamond/diamond.glb");let p;[F,p]=await Promise.all([E,c]),F.mapping=se,F.generateMipmaps=!0,F.minFilter=me,F.magFilter=q,U.background=F;const g=new de({uniforms:{envMap:{value:F},bvh:{value:new we},projectionMatrixInv:{value:G.projectionMatrixInverse},viewMatrixInv:{value:G.matrixWorld},resolution:{value:new fe},bounces:{value:3},ior:{value:2.4},color:{value:new he(1,1,1)},fastChroma:{value:!1},aberrationStrength:{value:.01}},vertexShader:` + varying vec3 vWorldPosition; + varying vec3 vNormal; + uniform mat4 viewMatrixInv; + void main() { + + vWorldPosition = ( modelMatrix * vec4( position, 1.0 ) ).xyz; + vNormal = ( viewMatrixInv * vec4( normalMatrix * normal, 0.0 ) ).xyz; + gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4( position , 1.0 ); + + } + `,fragmentShader:` + #define RAY_OFFSET 0.001 + + #include + precision highp isampler2D; + precision highp usampler2D; + + ${_e} + ${be} + ${Re} + + varying vec3 vWorldPosition; + varying vec3 vNormal; + + uniform sampler2D envMap; + uniform float bounces; + uniform BVH bvh; + uniform float ior; + uniform vec3 color; + uniform bool fastChroma; + uniform mat4 projectionMatrixInv; + uniform mat4 viewMatrixInv; + uniform mat4 modelMatrix; + uniform vec2 resolution; + uniform float aberrationStrength; + + #include + + // performs an iterative bounce lookup modeling internal reflection and returns + // a final ray direction. + vec3 totalInternalReflection( vec3 incomingOrigin, vec3 incomingDirection, vec3 normal, float ior, mat4 modelMatrixInverse ) { + + vec3 rayOrigin = incomingOrigin; + vec3 rayDirection = incomingDirection; + + // refract the ray direction on the way into the diamond and adjust offset from + // the diamond surface for raytracing + rayDirection = refract( rayDirection, normal, 1.0 / ior ); + rayOrigin = vWorldPosition + rayDirection * RAY_OFFSET; + + // transform the ray into the local coordinates of the model + rayOrigin = ( modelMatrixInverse * vec4( rayOrigin, 1.0 ) ).xyz; + rayDirection = normalize( ( modelMatrixInverse * vec4( rayDirection, 0.0 ) ).xyz ); + + // perform multiple ray casts + for( float i = 0.0; i < bounces; i ++ ) { + + // results + uvec4 faceIndices = uvec4( 0u ); + vec3 faceNormal = vec3( 0.0, 0.0, 1.0 ); + vec3 barycoord = vec3( 0.0 ); + float side = 1.0; + float dist = 0.0; + + // perform the raycast + // the diamond is a water tight model so we assume we always hit a surface + bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ); + + // derive the new ray origin from the hit results + vec3 hitPos = rayOrigin + rayDirection * dist; + + // if we don't internally reflect then end the ray tracing and sample + vec3 refractedDirection = refract( rayDirection, faceNormal, ior ); + bool totalInternalReflection = length( refract( rayDirection, faceNormal, ior ) ) == 0.0; + if ( ! totalInternalReflection ) { + + rayDirection = refractedDirection; + break; + + } + + // otherwise reflect off the surface internally for another hit + rayDirection = reflect( rayDirection, faceNormal ); + rayOrigin = hitPos + rayDirection * RAY_OFFSET; + + } + + // return the final ray direction in world space + return normalize( ( modelMatrix * vec4( rayDirection, 0.0 ) ).xyz ); + } + + vec4 envSample( sampler2D envMap, vec3 rayDirection ) { + + vec2 uvv = equirectUv( rayDirection ); + return texture( envMap, uvv ); + + } + + void main() { + + mat4 modelMatrixInverse = inverse( modelMatrix ); + vec2 uv = gl_FragCoord.xy / resolution; + + vec3 normal = vNormal; + vec3 rayOrigin = cameraPosition; + vec3 rayDirection = normalize( vWorldPosition - cameraPosition ); + + if ( aberrationStrength != 0.0 ) { + + // perform chromatic aberration lookups + vec3 rayDirectionG = totalInternalReflection( rayOrigin, rayDirection, normal, max( ior, 1.0 ), modelMatrixInverse ); + vec3 rayDirectionR, rayDirectionB; + + if ( fastChroma ) { + + // fast chroma does a quick uv offset on lookup + rayDirectionR = normalize( rayDirectionG + 1.0 * vec3( aberrationStrength / 2.0 ) ); + rayDirectionB = normalize( rayDirectionG - 1.0 * vec3( aberrationStrength / 2.0 ) ); + + } else { + + // compared to a proper ray trace of diffracted rays + float iorR = max( ior * ( 1.0 - aberrationStrength ), 1.0 ); + float iorB = max( ior * ( 1.0 + aberrationStrength ), 1.0 ); + rayDirectionR = totalInternalReflection( + rayOrigin, rayDirection, normal, + iorR, modelMatrixInverse + ); + rayDirectionB = totalInternalReflection( + rayOrigin, rayDirection, normal, + iorB, modelMatrixInverse + ); + + } + + // get the color lookup + float r = envSample( envMap, rayDirectionR ).r; + float g = envSample( envMap, rayDirectionG ).g; + float b = envSample( envMap, rayDirectionB ).b; + gl_FragColor.rgb = vec3( r, g, b ) * color; + gl_FragColor.a = 1.0; + + } else { + + // no chromatic aberration lookups + rayDirection = totalInternalReflection( rayOrigin, rayDirection, normal, max( ior, 1.0 ), modelMatrixInverse ); + gl_FragColor.rgb = envSample( envMap, rayDirection ).rgb * color; + gl_FragColor.a = 1.0; + + } + + #include + #include + + } + `}),v=p.scene.children[0].children[0].children[0].children[0].children[0].geometry;v.scale(10,10,10);const u=new Me(v,{strategy:Ee,maxLeafTris:1});g.uniforms.bvh.value.updateFrom(u),M=new pe(v,g),U.add(M),B=new ge,B.add(T,"animate"),B.addColor(T,"color").name("Color").onChange(e=>{M.material.uniforms.color.value.set(e)}),B.add(T,"bounces",1,10,1).name("Bounces").onChange(e=>{M.material.uniforms.bounces.value=e}),B.add(T,"ior",1,5,.01).name("IOR").onChange(e=>{M.material.uniforms.ior.value=e}),B.add(T,"fastChroma").onChange(e=>{M.material.uniforms.fastChroma.value=e}),B.add(T,"aberrationStrength",0,.1,1e-4).onChange(e=>{M.material.uniforms.aberrationStrength.value=e}),j=new O,j.showPanel(0),document.body.appendChild(j.dom),re(),window.addEventListener("resize",function(){G.aspect=window.innerWidth/window.innerHeight,G.updateProjectionMatrix(),M.material.uniforms.resolution.value.set(window.innerWidth,window.innerHeight),P.setSize(window.innerWidth,window.innerHeight)},!1)}function re(){T.animate&&(M.rotation.y+=ee.getDelta()*.25),j.update(),Z.update(),P.render(U,G),requestAnimationFrame(re)} diff --git a/example/bundle/assets/distancecast-DCkQ5xF_.js b/example/bundle/assets/distancecast-DCkQ5xF_.js new file mode 100644 index 00000000..afb13273 --- /dev/null +++ b/example/bundle/assets/distancecast-DCkQ5xF_.js @@ -0,0 +1 @@ +import{M as z1,f as a0,B as G1,o as I1,C as D1,W as d0,k as c0,S as x0,F as f0,D as h0,A as u0,m as v0,d as Q1,n as r0,P as p0,G as n0,h as m0,b as y0,c as w0,y as z0,O as A0,j as q1,V as b0}from"./ExtendedTriangle-Chm2bbkR.js";import{S as M0}from"./Stats-9dH8FB2H.js";import{g as g0}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as C0}from"./OrbitControls-lzJCl7xY.js";import{T as F0}from"./TransformControls-CXlfLtXQ.js";import{g as S0}from"./_commonjsHelpers-Cpj98o6Y.js";import{M as P0}from"./MeshBVHHelper-jLfel8l5.js";import{a as B0,c as D0,d as T0}from"./ExtensionUtilities-0qN33-Z7.js";import"./MeshBVH-CPVAl5W3.js";class o0 extends z1{constructor(U,I,X=!1,Y=!1,D=1e4){const W=new a0;super(W,I);const e=this,T=new Float32Array(12*3),j=new Float32Array(12*3),R=new Float32Array(12*3);this.enableUvs=X,this.enableColors=Y,this.autoUpdate=!0,this.init=function(t){this.resolution=t,this.isolation=80,this.size=t,this.size2=this.size*this.size,this.size3=this.size2*this.size,this.halfsize=this.size/2,this.delta=2/this.size,this.yd=this.size,this.zd=this.size2,this.field=new Float32Array(this.size3),this.normal_cache=new Float32Array(this.size3*3),this.palette=new Float32Array(this.size3*3),this.count=0;const a=D*3;this.positionArray=new Float32Array(a*3);const r=new G1(this.positionArray,3);r.setUsage(I1),W.setAttribute("position",r),this.normalArray=new Float32Array(a*3);const s=new G1(this.normalArray,3);if(s.setUsage(I1),W.setAttribute("normal",s),this.enableUvs){this.uvArray=new Float32Array(a*2);const n=new G1(this.uvArray,2);n.setUsage(I1),W.setAttribute("uv",n)}if(this.enableColors){this.colorArray=new Float32Array(a*3);const n=new G1(this.colorArray,3);n.setUsage(I1),W.setAttribute("color",n)}};function C(t,a,r){return t+(a-t)*r}function p(t,a,r,s,n,o,i,c,l,f){const x=(r-i)/(c-i),u=e.normal_cache;T[a+0]=s+x*e.delta,T[a+1]=n,T[a+2]=o,j[a+0]=C(u[t+0],u[t+3],x),j[a+1]=C(u[t+1],u[t+4],x),j[a+2]=C(u[t+2],u[t+5],x),R[a+0]=C(e.palette[l*3+0],e.palette[f*3+0],x),R[a+1]=C(e.palette[l*3+1],e.palette[f*3+1],x),R[a+2]=C(e.palette[l*3+2],e.palette[f*3+2],x)}function h(t,a,r,s,n,o,i,c,l,f){const x=(r-i)/(c-i),u=e.normal_cache;T[a+0]=s,T[a+1]=n+x*e.delta,T[a+2]=o;const m=t+e.yd*3;j[a+0]=C(u[t+0],u[m+0],x),j[a+1]=C(u[t+1],u[m+1],x),j[a+2]=C(u[t+2],u[m+2],x),R[a+0]=C(e.palette[l*3+0],e.palette[f*3+0],x),R[a+1]=C(e.palette[l*3+1],e.palette[f*3+1],x),R[a+2]=C(e.palette[l*3+2],e.palette[f*3+2],x)}function w(t,a,r,s,n,o,i,c,l,f){const x=(r-i)/(c-i),u=e.normal_cache;T[a+0]=s,T[a+1]=n,T[a+2]=o+x*e.delta;const m=t+e.zd*3;j[a+0]=C(u[t+0],u[m+0],x),j[a+1]=C(u[t+1],u[m+1],x),j[a+2]=C(u[t+2],u[m+2],x),R[a+0]=C(e.palette[l*3+0],e.palette[f*3+0],x),R[a+1]=C(e.palette[l*3+1],e.palette[f*3+1],x),R[a+2]=C(e.palette[l*3+2],e.palette[f*3+2],x)}function v(t){const a=t*3;e.normal_cache[a]===0&&(e.normal_cache[a+0]=e.field[t-1]-e.field[t+1],e.normal_cache[a+1]=e.field[t-e.yd]-e.field[t+e.yd],e.normal_cache[a+2]=e.field[t-e.zd]-e.field[t+e.zd])}function d(t,a,r,s,n){const o=s+1,i=s+e.yd,c=s+e.zd,l=o+e.yd,f=o+e.zd,x=s+e.yd+e.zd,u=o+e.yd+e.zd;let m=0;const z=e.field[s],A=e.field[o],b=e.field[i],M=e.field[l],S=e.field[c],g=e.field[f],P=e.field[x],B=e.field[u];zthis.size-1&&(A=this.size-1);let b=Math.floor(u-f);b<1&&(b=1);let M=Math.floor(u+f);M>this.size-1&&(M=this.size-1);let S=Math.floor(m-f);S<1&&(S=1);let g=Math.floor(m+f);g>this.size-1&&(g=this.size-1);let P,B,F,k,V,H,L,N,J,K,Z;for(F=z;F0){this.field[k+P]+=Z*i;const G=Math.sqrt((P-m)*(P-m)+(B-u)*(B-u)+(F-x)*(F-x))/f,q=1-G*G*G*(G*(G*6-15)+10);this.palette[(k+P)*3+0]+=l.r*q,this.palette[(k+P)*3+1]+=l.g*q,this.palette[(k+P)*3+2]+=l.b*q}},this.addPlaneX=function(t,a){const r=this.size,s=this.yd,n=this.zd,o=this.field;let i,c,l,f,x,u,m,z=r*Math.sqrt(t/a);for(z>r&&(z=r),i=0;i0)for(c=0;cr&&(A=r),c=0;c0)for(m=c*s,i=0;ir&&(A=r),l=0;l0)for(m=n*l,c=0;c=s))for(let z=-1;z<=1;z+=2){const A=z+i;if(!(A<0||A>=s))for(let b=-1;b<=1;b+=2){const M=b+c;if(M<0||M>=s)continue;const S=n*M+s*A+m,g=r[S];x++,f+=t*(g-f)/x}}}a[l]=f}},this.reset=function(){for(let t=0;tD&&console.warn("THREE.MarchingCubes: Geometry buffers too small for rendering. Please create an instance with a higher poly count.")},this.onBeforeRender=function(){this.autoUpdate&&this.update()},this.init(U)}}o0.prototype.isMarchingCubes=!0;const k0=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]),R1=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);var e0={exports:{}};(function($,U){(function(){var I=.5*(Math.sqrt(3)-1),X=(3-Math.sqrt(3))/6,Y=1/3,D=1/6,W=(Math.sqrt(5)-1)/4,e=(5-Math.sqrt(5))/20;function T(p){var h;typeof p=="function"?h=p:p?h=R(p):h=Math.random,this.p=j(h),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(var w=0;w<512;w++)this.perm[w]=this.p[w&255],this.permMod12[w]=this.perm[w]%12}T.prototype={grad3:new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),grad4:new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),noise2D:function(p,h){var w=this.permMod12,v=this.perm,d=this.grad3,y=0,t=0,a=0,r=(p+h)*I,s=Math.floor(p+r),n=Math.floor(h+r),o=(s+n)*X,i=s-o,c=n-o,l=p-i,f=h-c,x,u;l>f?(x=1,u=0):(x=0,u=1);var m=l-x+X,z=f-u+X,A=l-1+2*X,b=f-1+2*X,M=s&255,S=n&255,g=.5-l*l-f*f;if(g>=0){var P=w[M+v[S]]*3;g*=g,y=g*g*(d[P]*l+d[P+1]*f)}var B=.5-m*m-z*z;if(B>=0){var F=w[M+x+v[S+u]]*3;B*=B,t=B*B*(d[F]*m+d[F+1]*z)}var k=.5-A*A-b*b;if(k>=0){var V=w[M+1+v[S+1]]*3;k*=k,a=k*k*(d[V]*A+d[V+1]*b)}return 70*(y+t+a)},noise3D:function(p,h,w){var v=this.permMod12,d=this.perm,y=this.grad3,t,a,r,s,n=(p+h+w)*Y,o=Math.floor(p+n),i=Math.floor(h+n),c=Math.floor(w+n),l=(o+i+c)*D,f=o-l,x=i-l,u=c-l,m=p-f,z=h-x,A=w-u,b,M,S,g,P,B;m>=z?z>=A?(b=1,M=0,S=0,g=1,P=1,B=0):m>=A?(b=1,M=0,S=0,g=1,P=0,B=1):(b=0,M=0,S=1,g=1,P=0,B=1):zM?P++:B++,b>S?P++:F++,b>g?P++:k++,M>S?B++:F++,M>g?B++:k++,S>g?F++:k++;var V,H,L,N,J,K,Z,G,q,c1,n1,u1;V=P>=3?1:0,H=B>=3?1:0,L=F>=3?1:0,N=k>=3?1:0,J=P>=2?1:0,K=B>=2?1:0,Z=F>=2?1:0,G=k>=2?1:0,q=P>=1?1:0,c1=B>=1?1:0,n1=F>=1?1:0,u1=k>=1?1:0;var s1=b-V+e,v1=M-H+e,o1=S-L+e,p1=g-N+e,l1=b-J+2*e,m1=M-K+2*e,H1=S-Z+2*e,L1=g-G+2*e,N1=b-q+3*e,O1=M-c1+3*e,X1=S-n1+3*e,Y1=g-u1+3*e,Z1=b-1+4*e,$1=M-1+4*e,J1=S-1+4*e,K1=g-1+4*e,A1=i&255,b1=c&255,M1=l&255,g1=f&255,C1=.6-b*b-M*M-S*S-g*g;if(C1<0)t=0;else{var k1=d[A1+d[b1+d[M1+d[g1]]]]%32*4;C1*=C1,t=C1*C1*(y[k1]*b+y[k1+1]*M+y[k1+2]*S+y[k1+3]*g)}var F1=.6-s1*s1-v1*v1-o1*o1-p1*p1;if(F1<0)a=0;else{var W1=d[A1+V+d[b1+H+d[M1+L+d[g1+N]]]]%32*4;F1*=F1,a=F1*F1*(y[W1]*s1+y[W1+1]*v1+y[W1+2]*o1+y[W1+3]*p1)}var S1=.6-l1*l1-m1*m1-H1*H1-L1*L1;if(S1<0)r=0;else{var j1=d[A1+J+d[b1+K+d[M1+Z+d[g1+G]]]]%32*4;S1*=S1,r=S1*S1*(y[j1]*l1+y[j1+1]*m1+y[j1+2]*H1+y[j1+3]*L1)}var P1=.6-N1*N1-O1*O1-X1*X1-Y1*Y1;if(P1<0)s=0;else{var E1=d[A1+q+d[b1+c1+d[M1+n1+d[g1+u1]]]]%32*4;P1*=P1,s=P1*P1*(y[E1]*N1+y[E1+1]*O1+y[E1+2]*X1+y[E1+3]*Y1)}var B1=.6-Z1*Z1-$1*$1-J1*J1-K1*K1;if(B1<0)n=0;else{var U1=d[A1+1+d[b1+1+d[M1+1+d[g1+1]]]]%32*4;B1*=B1,n=B1*B1*(y[U1]*Z1+y[U1+1]*$1+y[U1+2]*J1+y[U1+3]*K1)}return 27*(t+a+r+s+n)}};function j(p){var h,w=new Uint8Array(256);for(h=0;h<256;h++)w[h]=h;for(h=0;h<255;h++){var v=h+~~(p()*(256-h)),d=w[h];w[h]=w[v],w[v]=d}return w}T._buildPermutationTable=j;function R(){var p=0,h=0,w=0,v=1,d=C();p=d(" "),h=d(" "),w=d(" ");for(var y=0;y>>0,v-=p,v*=p,p=v>>>0,v-=p,p+=v*4294967296}return(p>>>0)*23283064365386963e-26}}U.SimplexNoise=T,$.exports=T})()})(e0,e0.exports);var W0=e0.exports;const j0=S0(W0);z1.prototype.raycast=B0;a0.prototype.computeBoundsTree=D0;a0.prototype.disposeBoundsTree=T0;const E={visualizeBounds:!1,visualBoundsDepth:10,volume:{display:1,hideWhileGenerating:!1,alwaysShowDistance:!0,surfaceOnly:!1,distance:1,resolution:100,radius:4},displayClosestPoint:!0};let V1,O,d1,t1,s0,i1,e1,Q,a1,x1,_,h1,r1,f1,w1,_1=!1;function E0(){t1=new d0({antialias:!0}),t1.setPixelRatio(window.devicePixelRatio),t1.setSize(window.innerWidth,window.innerHeight),t1.setClearColor(1251612,1),t1.shadowMap.enabled=!0,t1.shadowMap.type=c0,document.body.appendChild(t1.domElement),O=new x0,O.fog=new f0(2503224/2,10,45);const U=new h0(16777215,1.5);U.position.set(20,20,20),U.castShadow=!0,U.shadow.mapSize.set(2048,2048);const I=U.shadow.camera;I.left=I.bottom=-15,I.right=I.top=15,I.updateProjectionMatrix(),O.add(U),O.add(new u0(14743546,1.5));const X=50,Y=250,D=new v0(X,X,Y-1,Y-1),W=D.attributes.position,e=Math.floor(Math.random()*100),T=new j0(e);for(let d=0;d{s0.enabled=!d.value,d.value||(_1=!0)}),x1.addEventListener("objectChange",d=>{_1=!0}),O.add(x1);const R=new Q1({flatShading:!0,color:15277667,metalness:0,roughness:.35,transparent:!0,depthWrite:!1,opacity:.15,premultipliedAlpha:!0,side:r0});_=new o0(100,R,!1,!1,1e6),_.isolation=0,_.autoUpdate=!1,h1=new n0,h1.scale.multiplyScalar(5),h1.add(_),O.add(h1),r1=new z1(new y0(.025,20,20),new w0({color:15277667})),r1.castShadow=!0,O.add(r1),f1=r1.clone(),f1.castShadow=!0,O.add(f1);const C=new z1(new z0,r1.material);C.castShadow=!0,C.position.z=.5,w1=new A0,w1.add(C),O.add(w1),O.updateMatrixWorld(!0);const p=new g0({width:300});p.add(E,"visualizeBounds").onChange(()=>t0()),p.add(E,"visualBoundsDepth").min(1).max(40).step(1).onChange(()=>t0());const h=p.addFolder("distanceVisualization");h.add(E.volume,"display",{hide:0,"distance to terrain":1,"distance to mesh":2}).onChange(()=>{y1=!0}),h.add(E.volume,"hideWhileGenerating"),h.add(E.volume,"alwaysShowDistance"),h.add(E.volume,"surfaceOnly").onChange(()=>y1=!0),h.add(E.volume,"distance").min(0).max(2).step(.01).onChange(()=>y1=!0),h.add(E.volume,"radius").min(1).max(20).onChange(()=>y1=!0),h.add(E.volume,"resolution",5,200,1).onChange(()=>y1=!0),h.open(),p.add(x1,"mode",["translate","rotate"]);const w=p.addFolder("position");w.add(Q.position,"x").min(-5).max(5).step(.001).listen(),w.add(Q.position,"y").min(-5).max(5).step(.001).listen(),w.add(Q.position,"z").min(-5).max(5).step(.001).listen();const v=p.addFolder("rotation");v.add(Q.rotation,"x").min(-Math.PI).max(Math.PI).step(.001).listen(),v.add(Q.rotation,"y").min(-Math.PI).max(Math.PI).step(.001).listen(),v.add(Q.rotation,"z").min(-Math.PI).max(Math.PI).step(.001).listen(),p.open(),i0(),window.addEventListener("resize",function(){d1.aspect=window.innerWidth/window.innerHeight,d1.updateProjectionMatrix(),t1.setSize(window.innerWidth,window.innerHeight)},!1),window.addEventListener("keydown",function(d){switch(d.key){case"w":x1.mode="translate";break;case"e":x1.mode="rotate";break}p.controllersRecursive().forEach(y=>y.updateDisplay())})}function t0(){i1&&!E.visualizeBounds&&(O.remove(i1),i1=null),!i1&&E.visualizeBounds&&(i1=new P0(e1),O.add(i1)),i1&&(i1.depth=E.visualBoundsDepth)}function i0($){Q.updateMatrixWorld();const U=new q1().copy(e1.matrixWorld).invert().multiply(Q.matrixWorld),I=E.volume.distance,X=I,Y=$?I:0,D={},W={},T=!!e1.geometry.boundsTree.closestPointToGeometry(a1.geometry,U,D,W,Y,X)&&D.distance>8&255]+D[u>>16&255]+D[u>>24&255]+"-"+D[t&255]+D[t>>8&255]+"-"+D[t>>16&15|64]+D[t>>24&255]+"-"+D[i&63|128]+D[i>>8&255]+"-"+D[i>>16&255]+D[i>>24&255]+D[s&255]+D[s>>8&255]+D[s>>16&255]+D[s>>24&255]).toLowerCase()}function at(u,t,i){return Math.max(t,Math.min(i,u))}function Qt(u,t){switch(t.constructor){case Float32Array:return u;case Uint32Array:return u/4294967295;case Uint16Array:return u/65535;case Uint8Array:return u/255;case Int32Array:return Math.max(u/2147483647,-1);case Int16Array:return Math.max(u/32767,-1);case Int8Array:return Math.max(u/127,-1);default:throw new Error("Invalid component type.")}}function O(u,t){switch(t.constructor){case Float32Array:return u;case Uint32Array:return Math.round(u*4294967295);case Uint16Array:return Math.round(u*65535);case Uint8Array:return Math.round(u*255);case Int32Array:return Math.round(u*2147483647);case Int16Array:return Math.round(u*32767);case Int8Array:return Math.round(u*127);default:throw new Error("Invalid component type.")}}class v{constructor(t=0,i=0){v.prototype.isVector2=!0,this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const i=this.x,s=this.y,e=t.elements;return this.x=e[0]*i+e[3]*s+e[6],this.y=e[1]*i+e[4]*s+e[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this}clampLength(t,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(i,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const s=this.dot(t)/i;return Math.acos(at(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,s=this.y-t.y;return i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,s){return this.x=t.x+(i.x-t.x)*s,this.y=t.y+(i.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){const s=Math.cos(i),e=Math.sin(i),n=this.x-t.x,r=this.y-t.y;return this.x=n*s-r*e+t.x,this.y=n*e+r*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,i,s,e,n,r,a,o,h){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,i,s,e,n,r,a,o,h)}set(t,i,s,e,n,r,a,o,h){const c=this.elements;return c[0]=t,c[1]=e,c[2]=a,c[3]=i,c[4]=n,c[5]=o,c[6]=s,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const i=this.elements,s=t.elements;return i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],i[4]=s[4],i[5]=s[5],i[6]=s[6],i[7]=s[7],i[8]=s[8],this}extractBasis(t,i,s){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const s=t.elements,e=i.elements,n=this.elements,r=s[0],a=s[3],o=s[6],h=s[1],c=s[4],f=s[7],l=s[2],d=s[5],m=s[8],y=e[0],x=e[3],p=e[6],g=e[1],w=e[4],M=e[7],b=e[2],z=e[5],_=e[8];return n[0]=r*y+a*g+o*b,n[3]=r*x+a*w+o*z,n[6]=r*p+a*M+o*_,n[1]=h*y+c*g+f*b,n[4]=h*x+c*w+f*z,n[7]=h*p+c*M+f*_,n[2]=l*y+d*g+m*b,n[5]=l*x+d*w+m*z,n[8]=l*p+d*M+m*_,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){const t=this.elements,i=t[0],s=t[1],e=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8];return i*r*c-i*a*h-s*n*c+s*a*o+e*n*h-e*r*o}invert(){const t=this.elements,i=t[0],s=t[1],e=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],f=c*r-a*h,l=a*o-c*n,d=h*n-r*o,m=i*f+s*l+e*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return t[0]=f*y,t[1]=(e*h-c*s)*y,t[2]=(a*s-e*r)*y,t[3]=l*y,t[4]=(c*i-e*o)*y,t[5]=(e*n-a*i)*y,t[6]=d*y,t[7]=(s*o-h*i)*y,t[8]=(r*i-s*n)*y,this}transpose(){let t;const i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,s,e,n,r,a){const o=Math.cos(n),h=Math.sin(n);return this.set(s*o,s*h,-s*(o*r+h*a)+r+t,-e*h,e*o,-e*(-h*r+o*a)+a+i,0,0,1),this}scale(t,i){return this.premultiply(Oi.makeScale(t,i)),this}rotate(t){return this.premultiply(Oi.makeRotation(-t)),this}translate(t,i){return this.premultiply(Oi.makeTranslation(t,i)),this}makeTranslation(t,i){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,i,0,0,1),this}makeRotation(t){const i=Math.cos(t),s=Math.sin(t);return this.set(i,-s,0,s,i,0,0,0,1),this}makeScale(t,i){return this.set(t,0,0,0,i,0,0,0,1),this}equals(t){const i=this.elements,s=t.elements;for(let e=0;e<9;e++)if(i[e]!==s[e])return!1;return!0}fromArray(t,i=0){for(let s=0;s<9;s++)this.elements[s]=t[s+i];return this}toArray(t=[],i=0){const s=this.elements;return t[i]=s[0],t[i+1]=s[1],t[i+2]=s[2],t[i+3]=s[3],t[i+4]=s[4],t[i+5]=s[5],t[i+6]=s[6],t[i+7]=s[7],t[i+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Oi=new Bt;function re(u){for(let t=u.length-1;t>=0;--t)if(u[t]>=65535)return!0;return!1}function Ts(u){return document.createElementNS("http://www.w3.org/1999/xhtml",u)}const Ps={};function oe(u){u in Ps||(Ps[u]=!0,console.warn(u))}function Yi(u){return u<.04045?u*.0773993808:Math.pow(u*.9478672986+.0521327014,2.4)}let Et;class ae{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{Et===void 0&&(Et=Ts("canvas")),Et.width=t.width,Et.height=t.height;const s=Et.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),i=Et}return i.width>2048||i.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),i.toDataURL("image/jpeg",.6)):i.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 i=Ts("canvas");i.width=t.width,i.height=t.height;const s=i.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const e=s.getImageData(0,0,t.width,t.height),n=e.data;for(let r=0;r0&&(s.userData=this.userData),i||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Tt.DEFAULT_IMAGE=null,Tt.DEFAULT_MAPPING=300,Tt.DEFAULT_ANISOTROPY=1;class Kt{constructor(t=0,i=0,s=0,e=1){this.isQuaternion=!0,this._x=t,this._y=i,this._z=s,this._w=e}static slerpFlat(t,i,s,e,n,r,a){let o=s[e+0],h=s[e+1],c=s[e+2],f=s[e+3];const l=n[r+0],d=n[r+1],m=n[r+2],y=n[r+3];if(a===0){t[i+0]=o,t[i+1]=h,t[i+2]=c,t[i+3]=f;return}if(a===1){t[i+0]=l,t[i+1]=d,t[i+2]=m,t[i+3]=y;return}if(f!==y||o!==l||h!==d||c!==m){let x=1-a;const p=o*l+h*d+c*m+f*y,g=p>=0?1:-1,w=1-p*p;if(w>Number.EPSILON){const b=Math.sqrt(w),z=Math.atan2(b,p*g);x=Math.sin(x*z)/b,a=Math.sin(a*z)/b}const M=a*g;if(o=o*x+l*M,h=h*x+d*M,c=c*x+m*M,f=f*x+y*M,x===1-a){const b=1/Math.sqrt(o*o+h*h+c*c+f*f);o*=b,h*=b,c*=b,f*=b}}t[i]=o,t[i+1]=h,t[i+2]=c,t[i+3]=f}static multiplyQuaternionsFlat(t,i,s,e,n,r){const a=s[e],o=s[e+1],h=s[e+2],c=s[e+3],f=n[r],l=n[r+1],d=n[r+2],m=n[r+3];return t[i]=a*m+c*f+o*d-h*l,t[i+1]=o*m+c*l+h*f-a*d,t[i+2]=h*m+c*d+a*l-o*f,t[i+3]=c*m-a*f-o*l-h*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,i,s,e){return this._x=t,this._y=i,this._z=s,this._w=e,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,i=!0){const s=t._x,e=t._y,n=t._z,r=t._order,a=Math.cos,o=Math.sin,h=a(s/2),c=a(e/2),f=a(n/2),l=o(s/2),d=o(e/2),m=o(n/2);switch(r){case"XYZ":this._x=l*c*f+h*d*m,this._y=h*d*f-l*c*m,this._z=h*c*m+l*d*f,this._w=h*c*f-l*d*m;break;case"YXZ":this._x=l*c*f+h*d*m,this._y=h*d*f-l*c*m,this._z=h*c*m-l*d*f,this._w=h*c*f+l*d*m;break;case"ZXY":this._x=l*c*f-h*d*m,this._y=h*d*f+l*c*m,this._z=h*c*m+l*d*f,this._w=h*c*f-l*d*m;break;case"ZYX":this._x=l*c*f-h*d*m,this._y=h*d*f+l*c*m,this._z=h*c*m-l*d*f,this._w=h*c*f+l*d*m;break;case"YZX":this._x=l*c*f+h*d*m,this._y=h*d*f+l*c*m,this._z=h*c*m-l*d*f,this._w=h*c*f-l*d*m;break;case"XZY":this._x=l*c*f-h*d*m,this._y=h*d*f-l*c*m,this._z=h*c*m+l*d*f,this._w=h*c*f+l*d*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return i===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,i){const s=i/2,e=Math.sin(s);return this._x=t.x*e,this._y=t.y*e,this._z=t.z*e,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const i=t.elements,s=i[0],e=i[4],n=i[8],r=i[1],a=i[5],o=i[9],h=i[2],c=i[6],f=i[10],l=s+a+f;if(l>0){const d=.5/Math.sqrt(l+1);this._w=.25/d,this._x=(c-o)*d,this._y=(n-h)*d,this._z=(r-e)*d}else if(s>a&&s>f){const d=2*Math.sqrt(1+s-a-f);this._w=(c-o)/d,this._x=.25*d,this._y=(e+r)/d,this._z=(n+h)/d}else if(a>f){const d=2*Math.sqrt(1+a-s-f);this._w=(n-h)/d,this._x=(e+r)/d,this._y=.25*d,this._z=(o+c)/d}else{const d=2*Math.sqrt(1+f-s-a);this._w=(r-e)/d,this._x=(n+h)/d,this._y=(o+c)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,i){let s=t.dot(i)+1;return sMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(at(this.dot(t),-1,1)))}rotateTowards(t,i){const s=this.angleTo(t);if(s===0)return this;const e=Math.min(1,i/s);return this.slerp(t,e),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,i){const s=t._x,e=t._y,n=t._z,r=t._w,a=i._x,o=i._y,h=i._z,c=i._w;return this._x=s*c+r*a+e*h-n*o,this._y=e*c+r*o+n*a-s*h,this._z=n*c+r*h+s*o-e*a,this._w=r*c-s*a-e*o-n*h,this._onChangeCallback(),this}slerp(t,i){if(i===0)return this;if(i===1)return this.copy(t);const s=this._x,e=this._y,n=this._z,r=this._w;let a=r*t._w+s*t._x+e*t._y+n*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=r,this._x=s,this._y=e,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const d=1-i;return this._w=d*r+i*this._w,this._x=d*s+i*this._x,this._y=d*e+i*this._y,this._z=d*n+i*this._z,this.normalize(),this}const h=Math.sqrt(o),c=Math.atan2(h,a),f=Math.sin((1-i)*c)/h,l=Math.sin(i*c)/h;return this._w=r*f+this._w*l,this._x=s*f+this._x*l,this._y=e*f+this._y*l,this._z=n*f+this._z*l,this._onChangeCallback(),this}slerpQuaternions(t,i,s){return this.copy(t).slerp(i,s)}random(){const t=2*Math.PI*Math.random(),i=2*Math.PI*Math.random(),s=Math.random(),e=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(e*Math.sin(t),e*Math.cos(t),n*Math.sin(i),n*Math.cos(i))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,i=0){return this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t}fromBufferAttribute(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class A{constructor(t=0,i=0,s=0){A.prototype.isVector3=!0,this.x=t,this.y=i,this.z=s}set(t,i,s){return s===void 0&&(s=this.z),this.x=t,this.y=i,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return this.applyQuaternion(Cs.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(Cs.setFromAxisAngle(t,i))}applyMatrix3(t){const i=this.x,s=this.y,e=this.z,n=t.elements;return this.x=n[0]*i+n[3]*s+n[6]*e,this.y=n[1]*i+n[4]*s+n[7]*e,this.z=n[2]*i+n[5]*s+n[8]*e,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const i=this.x,s=this.y,e=this.z,n=t.elements,r=1/(n[3]*i+n[7]*s+n[11]*e+n[15]);return this.x=(n[0]*i+n[4]*s+n[8]*e+n[12])*r,this.y=(n[1]*i+n[5]*s+n[9]*e+n[13])*r,this.z=(n[2]*i+n[6]*s+n[10]*e+n[14])*r,this}applyQuaternion(t){const i=this.x,s=this.y,e=this.z,n=t.x,r=t.y,a=t.z,o=t.w,h=2*(r*e-a*s),c=2*(a*i-n*e),f=2*(n*s-r*i);return this.x=i+o*h+r*f-a*c,this.y=s+o*c+a*h-n*f,this.z=e+o*f+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const i=this.x,s=this.y,e=this.z,n=t.elements;return this.x=n[0]*i+n[4]*s+n[8]*e,this.y=n[1]*i+n[5]*s+n[9]*e,this.z=n[2]*i+n[6]*s+n[10]*e,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this}clampLength(t,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(i,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,s){return this.x=t.x+(i.x-t.x)*s,this.y=t.y+(i.y-t.y)*s,this.z=t.z+(i.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,i){const s=t.x,e=t.y,n=t.z,r=i.x,a=i.y,o=i.z;return this.x=e*o-n*a,this.y=n*r-s*o,this.z=s*a-e*r,this}projectOnVector(t){const i=t.lengthSq();if(i===0)return this.set(0,0,0);const s=t.dot(this)/i;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return $i.copy(this).projectOnVector(t),this.sub($i)}reflect(t){return this.sub($i.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const s=this.dot(t)/i;return Math.acos(at(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,s=this.y-t.y,e=this.z-t.z;return i*i+s*s+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,i,s){const e=Math.sin(i)*t;return this.x=e*Math.sin(s),this.y=Math.cos(i)*t,this.z=e*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,s){return this.x=t*Math.sin(i),this.y=s,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){const i=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),e=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=s,this.z=e,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,i=Math.random()*2-1,s=Math.sqrt(1-i*i);return this.x=s*Math.cos(t),this.y=i,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const $i=new A,Cs=new Kt;class W{constructor(t=new A(1/0,1/0,1/0),i=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=i}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromArray(t){this.makeEmpty();for(let i=0,s=t.length;ithis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,i){return i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,it),it.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let i,s;return t.normal.x>0?(i=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(i=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(i+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(i+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(i+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(i+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),i<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ti),pi.subVectors(this.max,ti),Ft.subVectors(t.a,ti),Ut.subVectors(t.b,ti),Rt.subVectors(t.c,ti),gt.subVectors(Ut,Ft),bt.subVectors(Rt,Ut),Pt.subVectors(Ft,Rt);let i=[0,-gt.z,gt.y,0,-bt.z,bt.y,0,-Pt.z,Pt.y,gt.z,0,-gt.x,bt.z,0,-bt.x,Pt.z,0,-Pt.x,-gt.y,gt.x,0,-bt.y,bt.x,0,-Pt.y,Pt.x,0];return!Hi(i,Ft,Ut,Rt,pi)||(i=[1,0,0,0,1,0,0,0,1],!Hi(i,Ft,Ut,Rt,pi))?!1:(yi.crossVectors(gt,bt),i=[yi.x,yi.y,yi.z],Hi(i,Ft,Ut,Rt,pi))}clampPoint(t,i){return i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,it).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(it).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ut[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ut[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ut[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ut[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ut[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ut[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ut[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ut[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ut),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 ut=[new A,new A,new A,new A,new A,new A,new A,new A],it=new A,mi=new W,Ft=new A,Ut=new A,Rt=new A,gt=new A,bt=new A,Pt=new A,ti=new A,pi=new A,yi=new A,Ct=new A;function Hi(u,t,i,s,e){for(let n=0,r=u.length-3;n<=r;n+=3){Ct.fromArray(u,n);const a=e.x*Math.abs(Ct.x)+e.y*Math.abs(Ct.y)+e.z*Math.abs(Ct.z),o=t.dot(Ct),h=i.dot(Ct),c=s.dot(Ct);if(Math.max(-Math.max(o,h,c),Math.min(o,h,c))>a)return!1}return!0}const ue=new W,ii=new A,ji=new A;class Es{constructor(t=new A,i=-1){this.isSphere=!0,this.center=t,this.radius=i}set(t,i){return this.center.copy(t),this.radius=i,this}setFromPoints(t,i){const s=this.center;i!==void 0?s.copy(i):ue.setFromPoints(t).getCenter(s);let e=0;for(let n=0,r=t.length;nthis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ii.subVectors(t,this.center);const i=ii.lengthSq();if(i>this.radius*this.radius){const s=Math.sqrt(i),e=(s-this.radius)*.5;this.center.addScaledVector(ii,e/s),this.radius+=e}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):(ji.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ii.copy(t.center).add(ji)),this.expandByPoint(ii.copy(t.center).sub(ji))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}class q{constructor(t,i,s,e,n,r,a,o,h,c,f,l,d,m,y,x){q.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,i,s,e,n,r,a,o,h,c,f,l,d,m,y,x)}set(t,i,s,e,n,r,a,o,h,c,f,l,d,m,y,x){const p=this.elements;return p[0]=t,p[4]=i,p[8]=s,p[12]=e,p[1]=n,p[5]=r,p[9]=a,p[13]=o,p[2]=h,p[6]=c,p[10]=f,p[14]=l,p[3]=d,p[7]=m,p[11]=y,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new q().fromArray(this.elements)}copy(t){const i=this.elements,s=t.elements;return i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],i[4]=s[4],i[5]=s[5],i[6]=s[6],i[7]=s[7],i[8]=s[8],i[9]=s[9],i[10]=s[10],i[11]=s[11],i[12]=s[12],i[13]=s[13],i[14]=s[14],i[15]=s[15],this}copyPosition(t){const i=this.elements,s=t.elements;return i[12]=s[12],i[13]=s[13],i[14]=s[14],this}setFromMatrix3(t){const i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,s){return t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,i,s){return this.set(t.x,i.x,s.x,0,t.y,i.y,s.y,0,t.z,i.z,s.z,0,0,0,0,1),this}extractRotation(t){const i=this.elements,s=t.elements,e=1/kt.setFromMatrixColumn(t,0).length(),n=1/kt.setFromMatrixColumn(t,1).length(),r=1/kt.setFromMatrixColumn(t,2).length();return i[0]=s[0]*e,i[1]=s[1]*e,i[2]=s[2]*e,i[3]=0,i[4]=s[4]*n,i[5]=s[5]*n,i[6]=s[6]*n,i[7]=0,i[8]=s[8]*r,i[9]=s[9]*r,i[10]=s[10]*r,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){const i=this.elements,s=t.x,e=t.y,n=t.z,r=Math.cos(s),a=Math.sin(s),o=Math.cos(e),h=Math.sin(e),c=Math.cos(n),f=Math.sin(n);if(t.order==="XYZ"){const l=r*c,d=r*f,m=a*c,y=a*f;i[0]=o*c,i[4]=-o*f,i[8]=h,i[1]=d+m*h,i[5]=l-y*h,i[9]=-a*o,i[2]=y-l*h,i[6]=m+d*h,i[10]=r*o}else if(t.order==="YXZ"){const l=o*c,d=o*f,m=h*c,y=h*f;i[0]=l+y*a,i[4]=m*a-d,i[8]=r*h,i[1]=r*f,i[5]=r*c,i[9]=-a,i[2]=d*a-m,i[6]=y+l*a,i[10]=r*o}else if(t.order==="ZXY"){const l=o*c,d=o*f,m=h*c,y=h*f;i[0]=l-y*a,i[4]=-r*f,i[8]=m+d*a,i[1]=d+m*a,i[5]=r*c,i[9]=y-l*a,i[2]=-r*h,i[6]=a,i[10]=r*o}else if(t.order==="ZYX"){const l=r*c,d=r*f,m=a*c,y=a*f;i[0]=o*c,i[4]=m*h-d,i[8]=l*h+y,i[1]=o*f,i[5]=y*h+l,i[9]=d*h-m,i[2]=-h,i[6]=a*o,i[10]=r*o}else if(t.order==="YZX"){const l=r*o,d=r*h,m=a*o,y=a*h;i[0]=o*c,i[4]=y-l*f,i[8]=m*f+d,i[1]=f,i[5]=r*c,i[9]=-a*c,i[2]=-h*c,i[6]=d*f+m,i[10]=l-y*f}else if(t.order==="XZY"){const l=r*o,d=r*h,m=a*o,y=a*h;i[0]=o*c,i[4]=-f,i[8]=h*c,i[1]=l*f+y,i[5]=r*c,i[9]=d*f-m,i[2]=m*f-d,i[6]=a*c,i[10]=y*f+l}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(fe,t,de)}lookAt(t,i,s){const e=this.elements;return Z.subVectors(t,i),Z.lengthSq()===0&&(Z.z=1),Z.normalize(),wt.crossVectors(s,Z),wt.lengthSq()===0&&(Math.abs(s.z)===1?Z.x+=1e-4:Z.z+=1e-4,Z.normalize(),wt.crossVectors(s,Z)),wt.normalize(),xi.crossVectors(Z,wt),e[0]=wt.x,e[4]=xi.x,e[8]=Z.x,e[1]=wt.y,e[5]=xi.y,e[9]=Z.y,e[2]=wt.z,e[6]=xi.z,e[10]=Z.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const s=t.elements,e=i.elements,n=this.elements,r=s[0],a=s[4],o=s[8],h=s[12],c=s[1],f=s[5],l=s[9],d=s[13],m=s[2],y=s[6],x=s[10],p=s[14],g=s[3],w=s[7],M=s[11],b=s[15],z=e[0],_=e[4],S=e[8],B=e[12],T=e[1],C=e[5],P=e[9],E=e[13],F=e[2],U=e[6],R=e[10],j=e[14],ht=e[3],lt=e[7],vi=e[11],Wi=e[15];return n[0]=r*z+a*T+o*F+h*ht,n[4]=r*_+a*C+o*U+h*lt,n[8]=r*S+a*P+o*R+h*vi,n[12]=r*B+a*E+o*j+h*Wi,n[1]=c*z+f*T+l*F+d*ht,n[5]=c*_+f*C+l*U+d*lt,n[9]=c*S+f*P+l*R+d*vi,n[13]=c*B+f*E+l*j+d*Wi,n[2]=m*z+y*T+x*F+p*ht,n[6]=m*_+y*C+x*U+p*lt,n[10]=m*S+y*P+x*R+p*vi,n[14]=m*B+y*E+x*j+p*Wi,n[3]=g*z+w*T+M*F+b*ht,n[7]=g*_+w*C+M*U+b*lt,n[11]=g*S+w*P+M*R+b*vi,n[15]=g*B+w*E+M*j+b*Wi,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){const t=this.elements,i=t[0],s=t[4],e=t[8],n=t[12],r=t[1],a=t[5],o=t[9],h=t[13],c=t[2],f=t[6],l=t[10],d=t[14],m=t[3],y=t[7],x=t[11],p=t[15];return m*(+n*o*f-e*h*f-n*a*l+s*h*l+e*a*d-s*o*d)+y*(+i*o*d-i*h*l+n*r*l-e*r*d+e*h*c-n*o*c)+x*(+i*h*f-i*a*d-n*r*f+s*r*d+n*a*c-s*h*c)+p*(-e*a*c-i*o*f+i*a*l+e*r*f-s*r*l+s*o*c)}transpose(){const t=this.elements;let i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,s){const e=this.elements;return t.isVector3?(e[12]=t.x,e[13]=t.y,e[14]=t.z):(e[12]=t,e[13]=i,e[14]=s),this}invert(){const t=this.elements,i=t[0],s=t[1],e=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],f=t[9],l=t[10],d=t[11],m=t[12],y=t[13],x=t[14],p=t[15],g=f*x*h-y*l*h+y*o*d-a*x*d-f*o*p+a*l*p,w=m*l*h-c*x*h-m*o*d+r*x*d+c*o*p-r*l*p,M=c*y*h-m*f*h+m*a*d-r*y*d-c*a*p+r*f*p,b=m*f*o-c*y*o-m*a*l+r*y*l+c*a*x-r*f*x,z=i*g+s*w+e*M+n*b;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/z;return t[0]=g*_,t[1]=(y*l*n-f*x*n-y*e*d+s*x*d+f*e*p-s*l*p)*_,t[2]=(a*x*n-y*o*n+y*e*h-s*x*h-a*e*p+s*o*p)*_,t[3]=(f*o*n-a*l*n-f*e*h+s*l*h+a*e*d-s*o*d)*_,t[4]=w*_,t[5]=(c*x*n-m*l*n+m*e*d-i*x*d-c*e*p+i*l*p)*_,t[6]=(m*o*n-r*x*n-m*e*h+i*x*h+r*e*p-i*o*p)*_,t[7]=(r*l*n-c*o*n+c*e*h-i*l*h-r*e*d+i*o*d)*_,t[8]=M*_,t[9]=(m*f*n-c*y*n-m*s*d+i*y*d+c*s*p-i*f*p)*_,t[10]=(r*y*n-m*a*n+m*s*h-i*y*h-r*s*p+i*a*p)*_,t[11]=(c*a*n-r*f*n-c*s*h+i*f*h+r*s*d-i*a*d)*_,t[12]=b*_,t[13]=(c*y*e-m*f*e+m*s*l-i*y*l-c*s*x+i*f*x)*_,t[14]=(m*a*e-r*y*e-m*s*o+i*y*o+r*s*x-i*a*x)*_,t[15]=(r*f*e-c*a*e+c*s*o-i*f*o-r*s*l+i*a*l)*_,this}scale(t){const i=this.elements,s=t.x,e=t.y,n=t.z;return i[0]*=s,i[4]*=e,i[8]*=n,i[1]*=s,i[5]*=e,i[9]*=n,i[2]*=s,i[6]*=e,i[10]*=n,i[3]*=s,i[7]*=e,i[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],e=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,s,e))}makeTranslation(t,i,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,i,0,0,1,s,0,0,0,1),this}makeRotationX(t){const i=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,i,-s,0,0,s,i,0,0,0,0,1),this}makeRotationY(t){const i=Math.cos(t),s=Math.sin(t);return this.set(i,0,s,0,0,1,0,0,-s,0,i,0,0,0,0,1),this}makeRotationZ(t){const i=Math.cos(t),s=Math.sin(t);return this.set(i,-s,0,0,s,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){const s=Math.cos(i),e=Math.sin(i),n=1-s,r=t.x,a=t.y,o=t.z,h=n*r,c=n*a;return this.set(h*r+s,h*a-e*o,h*o+e*a,0,h*a+e*o,c*a+s,c*o-e*r,0,h*o-e*a,c*o+e*r,n*o*o+s,0,0,0,0,1),this}makeScale(t,i,s){return this.set(t,0,0,0,0,i,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,i,s,e,n,r){return this.set(1,s,n,0,t,1,r,0,i,e,1,0,0,0,0,1),this}compose(t,i,s){const e=this.elements,n=i._x,r=i._y,a=i._z,o=i._w,h=n+n,c=r+r,f=a+a,l=n*h,d=n*c,m=n*f,y=r*c,x=r*f,p=a*f,g=o*h,w=o*c,M=o*f,b=s.x,z=s.y,_=s.z;return e[0]=(1-(y+p))*b,e[1]=(d+M)*b,e[2]=(m-w)*b,e[3]=0,e[4]=(d-M)*z,e[5]=(1-(l+p))*z,e[6]=(x+g)*z,e[7]=0,e[8]=(m+w)*_,e[9]=(x-g)*_,e[10]=(1-(l+y))*_,e[11]=0,e[12]=t.x,e[13]=t.y,e[14]=t.z,e[15]=1,this}decompose(t,i,s){const e=this.elements;let n=kt.set(e[0],e[1],e[2]).length();const r=kt.set(e[4],e[5],e[6]).length(),a=kt.set(e[8],e[9],e[10]).length();this.determinant()<0&&(n=-n),t.x=e[12],t.y=e[13],t.z=e[14],st.copy(this);const h=1/n,c=1/r,f=1/a;return st.elements[0]*=h,st.elements[1]*=h,st.elements[2]*=h,st.elements[4]*=c,st.elements[5]*=c,st.elements[6]*=c,st.elements[8]*=f,st.elements[9]*=f,st.elements[10]*=f,i.setFromRotationMatrix(st),s.x=n,s.y=r,s.z=a,this}makePerspective(t,i,s,e,n,r,a=2e3){const o=this.elements,h=2*n/(i-t),c=2*n/(s-e),f=(i+t)/(i-t),l=(s+e)/(s-e);let d,m;if(a===2e3)d=-(r+n)/(r-n),m=-2*r*n/(r-n);else if(a===2001)d=-r/(r-n),m=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return o[0]=h,o[4]=0,o[8]=f,o[12]=0,o[1]=0,o[5]=c,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=m,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,i,s,e,n,r,a=2e3){const o=this.elements,h=1/(i-t),c=1/(s-e),f=1/(r-n),l=(i+t)*h,d=(s+e)*c;let m,y;if(a===2e3)m=(r+n)*f,y=-2*f;else if(a===2001)m=n*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=y,o[14]=-m,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const i=this.elements,s=t.elements;for(let e=0;e<16;e++)if(i[e]!==s[e])return!1;return!0}fromArray(t,i=0){for(let s=0;s<16;s++)this.elements[s]=t[s+i];return this}toArray(t=[],i=0){const s=this.elements;return t[i]=s[0],t[i+1]=s[1],t[i+2]=s[2],t[i+3]=s[3],t[i+4]=s[4],t[i+5]=s[5],t[i+6]=s[6],t[i+7]=s[7],t[i+8]=s[8],t[i+9]=s[9],t[i+10]=s[10],t[i+11]=s[11],t[i+12]=s[12],t[i+13]=s[13],t[i+14]=s[14],t[i+15]=s[15],t}}const kt=new A,st=new q,fe=new A(0,0,0),de=new A(1,1,1),wt=new A,xi=new A,Z=new A,Fs=new q,Us=new Kt;class gi{constructor(t=0,i=0,s=0,e=gi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=i,this._z=s,this._order=e}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,i,s,e=this._order){return this._x=t,this._y=i,this._z=s,this._order=e,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,i=this._order,s=!0){const e=t.elements,n=e[0],r=e[4],a=e[8],o=e[1],h=e[5],c=e[9],f=e[2],l=e[6],d=e[10];switch(i){case"XYZ":this._y=Math.asin(at(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(l,h),this._z=0);break;case"YXZ":this._x=Math.asin(-at(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-f,n),this._z=0);break;case"ZXY":this._x=Math.asin(at(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-f,d),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-at(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(l,d),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(at(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-f,n)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-at(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(l,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,i,s){return Fs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Fs,i,s)}setFromVector3(t,i=this._order){return this.set(t.x,t.y,t.z,i)}reorder(t){return Us.setFromEuler(this),this.setFromQuaternion(Us,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}gi.DEFAULT_ORDER="XYZ";class me{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let i=0;i1){for(let s=0;s0&&(e.userData=this.userData),e.layers=this.layers.mask,e.matrix=this.matrix.toArray(),e.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(e.matrixAutoUpdate=!1),this.isInstancedMesh&&(e.type="InstancedMesh",e.count=this.count,e.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(e.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(e.type="BatchedMesh",e.perObjectFrustumCulled=this.perObjectFrustumCulled,e.sortObjects=this.sortObjects,e.drawRanges=this._drawRanges,e.reservedRanges=this._reservedRanges,e.visibility=this._visibility,e.active=this._active,e.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()})),e.maxInstanceCount=this._maxInstanceCount,e.maxVertexCount=this._maxVertexCount,e.maxIndexCount=this._maxIndexCount,e.geometryInitialized=this._geometryInitialized,e.geometryCount=this._geometryCount,e.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(e.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(e.boundingSphere={center:e.boundingSphere.center.toArray(),radius:e.boundingSphere.radius}),this.boundingBox!==null&&(e.boundingBox={min:e.boundingBox.min.toArray(),max:e.boundingBox.max.toArray()}));function n(a,o){return a[o.uuid]===void 0&&(a[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?e.background=this.background.toJSON():this.background.isTexture&&(e.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(e.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){e.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const o=a.shapes;if(Array.isArray(o))for(let h=0,c=o.length;h0){e.children=[];for(let a=0;a0){e.animations=[];for(let a=0;a0&&(s.geometries=a),o.length>0&&(s.materials=o),h.length>0&&(s.textures=h),c.length>0&&(s.images=c),f.length>0&&(s.shapes=f),l.length>0&&(s.skeletons=l),d.length>0&&(s.animations=d),m.length>0&&(s.nodes=m)}return s.object=e,s;function r(a){const o=[];for(const h in a){const c=a[h];delete c.metadata,o.push(c)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,i=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),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)),i===!0)for(let s=0;s0?e.multiplyScalar(1/Math.sqrt(n)):e.set(0,0,0)}static getBarycoord(t,i,s,e,n){et.subVectors(e,i),dt.subVectors(s,i),Ji.subVectors(t,i);const r=et.dot(et),a=et.dot(dt),o=et.dot(Ji),h=dt.dot(dt),c=dt.dot(Ji),f=r*h-a*a;if(f===0)return n.set(0,0,0),null;const l=1/f,d=(h*o-a*c)*l,m=(r*c-a*o)*l;return n.set(1-d-m,m,d)}static containsPoint(t,i,s,e){return this.getBarycoord(t,i,s,e,mt)===null?!1:mt.x>=0&&mt.y>=0&&mt.x+mt.y<=1}static getInterpolation(t,i,s,e,n,r,a,o){return this.getBarycoord(t,i,s,e,mt)===null?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(n,mt.x),o.addScaledVector(r,mt.y),o.addScaledVector(a,mt.z),o)}static isFrontFacing(t,i,s,e){return et.subVectors(s,i),dt.subVectors(t,i),et.cross(dt).dot(e)<0}set(t,i,s){return this.a.copy(t),this.b.copy(i),this.c.copy(s),this}setFromPointsAndIndices(t,i,s,e){return this.a.copy(t[i]),this.b.copy(t[s]),this.c.copy(t[e]),this}setFromAttributeAndIndices(t,i,s,e){return this.a.fromBufferAttribute(t,i),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,e),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 et.subVectors(this.c,this.b),dt.subVectors(this.a,this.b),et.cross(dt).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return nt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return nt.getBarycoord(t,this.a,this.b,this.c,i)}getInterpolation(t,i,s,e,n){return nt.getInterpolation(t,this.a,this.b,this.c,i,s,e,n)}containsPoint(t){return nt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return nt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){const s=this.a,e=this.b,n=this.c;let r,a;Vt.subVectors(e,s),Nt.subVectors(n,s),Qi.subVectors(t,s);const o=Vt.dot(Qi),h=Nt.dot(Qi);if(o<=0&&h<=0)return i.copy(s);Ki.subVectors(t,e);const c=Vt.dot(Ki),f=Nt.dot(Ki);if(c>=0&&f<=c)return i.copy(e);const l=o*f-c*h;if(l<=0&&o>=0&&c<=0)return r=o/(o-c),i.copy(s).addScaledVector(Vt,r);ts.subVectors(t,n);const d=Vt.dot(ts),m=Nt.dot(ts);if(m>=0&&d<=m)return i.copy(n);const y=d*h-o*m;if(y<=0&&h>=0&&m<=0)return a=h/(h-m),i.copy(s).addScaledVector(Nt,a);const x=c*m-d*f;if(x<=0&&f-c>=0&&d-m>=0)return Ns.subVectors(n,e),a=(f-c)/(f-c+(d-m)),i.copy(e).addScaledVector(Ns,a);const p=1/(x+y+l);return r=y*p,a=l*p,i.copy(s).addScaledVector(Vt,r).addScaledVector(Nt,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const I=new A,wi=new v;class ct{constructor(t,i,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=i,this.count=t!==void 0?t.length/i:0,this.normalized=s,this.usage=35044,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return oe("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,i,s){t*=this.itemSize,s*=i.itemSize;for(let e=0,n=this.itemSize;e0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const h in o)o[h]!==void 0&&(t[h]=o[h]);return t}t.data={attributes:{}};const i=this.index;i!==null&&(t.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});const s=this.attributes;for(const o in s){const h=s[o];t.data.attributes[o]=h.toJSON(t.data)}const e={};let n=!1;for(const o in this.morphAttributes){const h=this.morphAttributes[o],c=[];for(let f=0,l=h.length;f0&&(e[o]=c,n=!0)}n&&(t.data.morphAttributes=e,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));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 i={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone(i));const e=t.attributes;for(const h in e){const c=e[h];this.setAttribute(h,c.clone(i))}const n=t.morphAttributes;for(const h in n){const c=[],f=n[h];for(let l=0,d=f.length;l1?null:i.copy(t.start).addScaledVector(s,n)}intersectsLine(t){const i=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return i<0&&s>0||s<0&&i>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,i){const s=i||ze.getNormalMatrix(t),e=this.coplanarPoint(es).applyMatrix4(t),n=this.normal.applyMatrix3(s).normalize();return this.constant=-e.dot(n),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 Ds=new A,_i=new A;class pt{constructor(t=new A,i=new A){this.start=t,this.end=i}set(t,i){return this.start.copy(t),this.end.copy(i),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,i){return this.delta(i).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,i){Ds.subVectors(t,this.start),_i.subVectors(this.end,this.start);const s=_i.dot(_i);let n=_i.dot(Ds)/s;return i&&(n=at(n,0,1)),n}closestPointToPoint(t,i,s){const e=this.closestPointToPointParameter(t,i);return this.delta(s).multiplyScalar(e).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Bs}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Bs);const vs=0,Se=1,Be=2,Ws=2,ns=1.25,Xs=1,ni=6*4+4+4,Mi=65535,Te=Math.pow(2,-24),rs=Symbol("SKIP_GENERATION");function Pe(u){return u.index?u.index.count:u.attributes.position.count}function Dt(u){return Pe(u)/3}function Ce(u,t=ArrayBuffer){return u>65535?new Uint32Array(new t(4*u)):new Uint16Array(new t(2*u))}function Ee(u,t){if(!u.index){const i=u.attributes.position.count,s=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,e=Ce(i,s);u.setIndex(new ct(e,1));for(let n=0;no-h);for(let o=0;or.offset-a.offset),e=s[s.length-1];e.count=Math.min(i-e.offset,e.count);let n=0;return s.forEach(({count:r})=>n+=r),i!==n}function os(u,t,i,s,e){let n=1/0,r=1/0,a=1/0,o=-1/0,h=-1/0,c=-1/0,f=1/0,l=1/0,d=1/0,m=-1/0,y=-1/0,x=-1/0;for(let p=t*6,g=(t+i)*6;po&&(o=z),wm&&(m=w);const _=u[p+2],S=u[p+3],B=_-S,T=_+S;Bh&&(h=T),_y&&(y=_);const C=u[p+4],P=u[p+5],E=C-P,F=C+P;Ec&&(c=F),Cx&&(x=C)}s[0]=n,s[1]=r,s[2]=a,s[3]=o,s[4]=h,s[5]=c,e[0]=f,e[1]=l,e[2]=d,e[3]=m,e[4]=y,e[5]=x}function Ue(u,t=null,i=null,s=null){const e=u.attributes.position,n=u.index?u.index.array:null,r=Dt(u),a=e.normalized;let o;t===null?(o=new Float32Array(r*6*4),i=0,s=r):(o=t,i=i||0,s=s||r);const h=e.array,c=e.offset||0;let f=3;e.isInterleavedBufferAttribute&&(f=e.data.stride);const l=["getX","getY","getZ"];for(let d=i;dS&&(S=b),z>S&&(S=z);const B=(S-_)/2,T=w*2;o[y+T+0]=_+B,o[y+T+1]=B+(Math.abs(_)+B)*Te}}return o}function L(u,t,i){return i.min.x=t[u],i.min.y=t[u+1],i.min.z=t[u+2],i.max.x=t[u+3],i.max.y=t[u+4],i.max.z=t[u+5],i}function Zs(u){let t=-1,i=-1/0;for(let s=0;s<3;s++){const e=u[s+3]-u[s];e>i&&(i=e,t=s)}return t}function $s(u,t){t.set(u)}function Hs(u,t,i){let s,e;for(let n=0;n<3;n++){const r=n+3;s=u[n],e=t[n],i[n]=se?s:e}}function Ai(u,t,i){for(let s=0;s<3;s++){const e=t[u+2*s],n=t[u+2*s+1],r=e-n,a=e+n;ri[s+3]&&(i[s+3]=a)}}function ri(u){const t=u[3]-u[0],i=u[4]-u[1],s=u[5]-u[2];return 2*(t*i+i*s+s*t)}const yt=32,Re=(u,t)=>u.candidate-t.candidate,Mt=new Array(yt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zi=new Float32Array(6);function ke(u,t,i,s,e,n){let r=-1,a=0;if(n===vs)r=Zs(t),r!==-1&&(a=(t[r]+t[r+3])/2);else if(n===Se)r=Zs(u),r!==-1&&(a=Le(i,s,e,r));else if(n===Be){const o=ri(u);let h=ns*e;const c=s*6,f=(s+e)*6;for(let l=0;l<3;l++){const d=t[l],x=(t[l+3]-d)/yt;if(e=_.candidate?Ai(M,i,_.rightCacheBounds):(Ai(M,i,_.leftCacheBounds),_.count++)}}for(let M=0;M=yt&&(z=yt-1);const _=Mt[z];_.count++,Ai(w,i,_.bounds)}const p=Mt[yt-1];$s(p.bounds,p.rightCacheBounds);for(let w=yt-2;w>=0;w--){const M=Mt[w],b=Mt[w+1];Hs(M.bounds,b.rightCacheBounds,M.rightCacheBounds)}let g=0;for(let w=0;w=o;)a--;if(r=o;)a--;if(rNe)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return oi[i+6]=h/4,h=hs(h,a),oi[i+7]=o,h}}function De(u,t){const i=(u.index?u.index.count:u.attributes.position.count)/3,s=i>2**16,e=s?4:2,n=t?new SharedArrayBuffer(i*e):new ArrayBuffer(i*e),r=s?new Uint32Array(n):new Uint16Array(n);for(let a=0,o=r.length;a=n&&(p=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),_<=a||B>=n)return w(z+_),b.offset=z,b.count=_,b;const T=ke(b.boundingData,S,t,z,_,o);if(T.axis===-1)return w(z+_),b.offset=z,b.count=_,b;const C=m(f,d,t,z,_,T);if(C===z||C===z+_)w(z+_),b.offset=z,b.count=_;else{b.splitAxis=T.axis;const P=new as,E=z,F=C-z;b.left=P,os(t,E,F,P.boundingData,x),M(P,E,F,x,B+1);const U=new as,R=C,j=_-F;b.right=U,os(t,R,j,U.boundingData,x),M(U,R,j,x,B+1)}return b}}function We(u,t){const i=u.geometry;t.indirect&&(u._indirectBuffer=De(i,t.useSharedArrayBuffer),Fe(i,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),u._indirectBuffer||Ee(i,t);const s=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,e=Ue(i),n=t.indirect?Os(i,t.range):Ys(i,t.range);u._roots=n.map(r=>{const a=ve(u,e,r.offset,r.count,t),o=cs(a),h=new s(ni*o);return qe(0,a,h),h})}class xt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,i){let s=1/0,e=-1/0;for(let n=0,r=t.length;ne?o:e}this.min=s,this.max=e}setFromPoints(t,i){let s=1/0,e=-1/0;for(let n=0,r=i.length;ne?o:e}this.min=s,this.max=e}isSeparated(t){return this.min>t.max||t.min>this.max}}xt.prototype.setFromBox=function(){const u=new A;return function(i,s){const e=s.min,n=s.max;let r=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){u.x=e.x*o+n.x*(1-o),u.y=e.y*h+n.y*(1-h),u.z=e.z*c+n.z*(1-c);const f=i.dot(u);r=Math.min(f,r),a=Math.max(f,a)}this.min=r,this.max=a}}();const Xe=function(){const u=new A,t=new A,i=new A;return function(e,n,r){const a=e.start,o=u,h=n.start,c=t;i.subVectors(a,h),u.subVectors(e.end,e.start),t.subVectors(n.end,n.start);const f=i.dot(c),l=c.dot(o),d=c.dot(c),m=i.dot(o),x=o.dot(o)*d-l*l;let p,g;x!==0?p=(f*l-m*d)/x:p=0,g=(f+p*l)/d,r.x=p,r.y=g}}(),ls=function(){const u=new v,t=new A,i=new A;return function(e,n,r,a){Xe(e,n,u);let o=u.x,h=u.y;if(o>=0&&o<=1&&h>=0&&h<=1){e.at(o,r),n.at(h,a);return}else if(o>=0&&o<=1){h<0?n.at(0,a):n.at(1,a),e.closestPointToPoint(a,!0,r);return}else if(h>=0&&h<=1){o<0?e.at(0,r):e.at(1,r),n.closestPointToPoint(r,!0,a);return}else{let c;o<0?c=e.start:c=e.end;let f;h<0?f=n.start:f=n.end;const l=t,d=i;if(e.closestPointToPoint(f,!0,t),n.closestPointToPoint(c,!0,i),l.distanceToSquared(f)<=d.distanceToSquared(c)){r.copy(l),a.copy(f);return}else{r.copy(c),a.copy(d);return}}}}(),Oe=function(){const u=new A,t=new A,i=new qs,s=new pt;return function(n,r){const{radius:a,center:o}=n,{a:h,b:c,c:f}=r;if(s.start=h,s.end=c,s.closestPointToPoint(o,!0,u).distanceTo(o)<=a||(s.start=h,s.end=f,s.closestPointToPoint(o,!0,u).distanceTo(o)<=a)||(s.start=c,s.end=f,s.closestPointToPoint(o,!0,u).distanceTo(o)<=a))return!0;const y=r.getPlane(i);if(Math.abs(y.distanceToPoint(o))<=a){const p=y.projectPoint(o,t);if(r.containsPoint(p))return!0}return!1}}(),Ye=1e-15;function us(u){return Math.abs(u)new A),this.satBounds=new Array(4).fill().map(()=>new xt),this.points=[this.a,this.b,this.c],this.sphere=new Es,this.plane=new qs,this.needsUpdate=!0}intersectsSphere(t){return Oe(t,this)}update(){const t=this.a,i=this.b,s=this.c,e=this.points,n=this.satAxes,r=this.satBounds,a=n[0],o=r[0];this.getNormal(a),o.setFromPoints(a,e);const h=n[1],c=r[1];h.subVectors(t,i),c.setFromPoints(h,e);const f=n[2],l=r[2];f.subVectors(i,s),l.setFromPoints(f,e);const d=n[3],m=r[3];d.subVectors(s,t),m.setFromPoints(d,e),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}rt.prototype.closestPointToSegment=function(){const u=new A,t=new A,i=new pt;return function(e,n=null,r=null){const{start:a,end:o}=e,h=this.points;let c,f=1/0;for(let l=0;l<3;l++){const d=(l+1)%3;i.start.copy(h[l]),i.end.copy(h[d]),ls(i,e,u,t),c=u.distanceToSquared(t),c=2){(M===1?p.start:p.end).copy(d),w=2;break}if(w++,w===2&&M===-1)break}}return w}return function(x,p=null,g=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(u.copy(x),u.update(),x=u);const w=this.plane,M=x.plane;if(Math.abs(w.normal.dot(M.normal))>1-1e-10){const b=this.satBounds,z=this.satAxes;i[0]=x.a,i[1]=x.b,i[2]=x.c;for(let B=0;B<4;B++){const T=b[B],C=z[B];if(s.setFromPoints(C,i),T.isSeparated(s))return!1}const _=x.satBounds,S=x.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let B=0;B<4;B++){const T=_[B],C=S[B];if(s.setFromPoints(C,t),T.isSeparated(s))return!1}for(let B=0;B<4;B++){const T=z[B];for(let C=0;C<4;C++){const P=S[C];if(n.crossVectors(T,P),s.setFromPoints(n,t),e.setFromPoints(n,i),s.isSeparated(e))return!1}}return p&&(g||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{const b=m(this,M,f);if(b===1&&x.containsPoint(f.end))return p&&(p.start.copy(f.end),p.end.copy(f.end)),!0;if(b!==2)return!1;const z=m(x,w,l);if(z===1&&this.containsPoint(l.end))return p&&(p.start.copy(l.end),p.end.copy(l.end)),!0;if(z!==2)return!1;if(f.delta(a),l.delta(o),a.dot(o)<0){let E=l.start;l.start=l.end,l.end=E}const _=f.start.dot(a),S=f.end.dot(a),B=l.start.dot(a),T=l.end.dot(a),C=S0?p.start.copy(f.start):p.start.copy(l.start),h.subVectors(f.end,l.end),h.dot(a)<0?p.end.copy(f.end):p.end.copy(l.end)),!0)}}}(),rt.prototype.distanceToPoint=function(){const u=new A;return function(i){return this.closestPointToPoint(i,u),i.distanceTo(u)}}(),rt.prototype.distanceToTriangle=function(){const u=new A,t=new A,i=["a","b","c"],s=new pt,e=new pt;return function(r,a=null,o=null){const h=a||o?s:null;if(this.intersectsTriangle(r,h))return(a||o)&&(a&&h.getCenter(a),o&&h.getCenter(o)),0;let c=1/0;for(let f=0;f<3;f++){let l;const d=i[f],m=r[d];this.closestPointToPoint(m,u),l=m.distanceToSquared(u),lnew A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new xt),this.alignedSatBounds=new Array(3).fill().map(()=>new xt),this.needsUpdate=!1,t&&this.min.copy(t),i&&this.max.copy(i),s&&this.matrix.copy(s)}set(t,i,s){this.min.copy(t),this.max.copy(i),this.matrix.copy(s),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}X.prototype.update=function(){return function(){const t=this.matrix,i=this.min,s=this.max,e=this.points;for(let h=0;h<=1;h++)for(let c=0;c<=1;c++)for(let f=0;f<=1;f++){const l=1*h|2*c|4*f,d=e[l];d.x=h?s.x:i.x,d.y=c?s.y:i.y,d.z=f?s.z:i.z,d.applyMatrix4(t)}const n=this.satBounds,r=this.satAxes,a=e[0];for(let h=0;h<3;h++){const c=r[h],f=n[h],l=1<new pt),i=new Array(12).fill().map(()=>new pt),s=new A,e=new A;return function(r,a=0,o=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||h)&&(r.getCenter(e),this.closestPointToPoint(e,s),r.closestPointToPoint(s,e),o&&o.copy(s),h&&h.copy(e)),0;const c=a*a,f=r.min,l=r.max,d=this.points;let m=1/0;for(let x=0;x<8;x++){const p=d[x];e.copy(p).clamp(f,l);const g=p.distanceToSquared(e);if(gnew rt)}}const tt=new Ze;class $e{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let i=null;this.setBuffer=s=>{i&&t.push(i),i=s,this.float32Array=new Float32Array(s),this.uint16Array=new Uint16Array(s),this.uint32Array=new Uint32Array(s)},this.clearBuffer=()=>{i=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const k=new $e;let At,vt;const Wt=[],Bi=new fs(()=>new W);function He(u,t,i,s,e,n){At=Bi.getPrimitive(),vt=Bi.getPrimitive(),Wt.push(At,vt),k.setBuffer(u._roots[t]);const r=ds(0,u.geometry,i,s,e,n);k.clearBuffer(),Bi.releasePrimitive(At),Bi.releasePrimitive(vt),Wt.pop(),Wt.pop();const a=Wt.length;return a>0&&(vt=Wt[a-1],At=Wt[a-2]),r}function ds(u,t,i,s,e=null,n=0,r=0){const{float32Array:a,uint16Array:o,uint32Array:h}=k;let c=u*2;if(Y(c,o)){const l=H(u,h),d=J(c,o);return L(u,a,At),s(l,d,!1,r,n+u,At)}else{let T=function(P){const{uint16Array:E,uint32Array:F}=k;let U=P*2;for(;!Y(U,E);)P=Q(P),U=P*2;return H(P,F)},C=function(P){const{uint16Array:E,uint32Array:F}=k;let U=P*2;for(;!Y(U,E);)P=K(P,F),U=P*2;return H(P,F)+J(U,E)};const l=Q(u),d=K(u,h);let m=l,y=d,x,p,g,w;if(e&&(g=At,w=vt,L(m,a,g),L(y,a,w),x=e(g),p=e(w),p(ai.copy(t).clamp(c.min,c.max),ai.distanceToSquared(t)),intersectsBounds:(c,f,l)=>l{c.closestPointToPoint(t,ai);const l=t.distanceToSquared(ai);return la?null:{distance:h,point:e.clone()}}function Je(u,t,i,s,e,n,r,a,o,h,c){Xt.fromBufferAttribute(t,n),Ot.fromBufferAttribute(t,r),Yt.fromBufferAttribute(t,a);const f=Ge(u,Xt,Ot,Yt,Ei,o,h,c);if(f){s&&(Ti.fromBufferAttribute(s,n),Pi.fromBufferAttribute(s,r),Ci.fromBufferAttribute(s,a),f.uv=nt.getInterpolation(Ei,Xt,Ot,Yt,Ti,Pi,Ci,new v)),e&&(Ti.fromBufferAttribute(e,n),Pi.fromBufferAttribute(e,r),Ci.fromBufferAttribute(e,a),f.uv1=nt.getInterpolation(Ei,Xt,Ot,Yt,Ti,Pi,Ci,new v)),i&&(Qs.fromBufferAttribute(i,n),Ks.fromBufferAttribute(i,r),te.fromBufferAttribute(i,a),f.normal=nt.getInterpolation(Ei,Xt,Ot,Yt,Qs,Ks,te,new A),f.normal.dot(u.direction)>0&&f.normal.multiplyScalar(-1));const l={a:n,b:r,c:a,normal:new A,materialIndex:0};nt.getNormal(Xt,Ot,Yt,l.normal),f.face=l,f.faceIndex=n}return f}function Fi(u,t,i,s,e,n,r){const a=s*3;let o=a+0,h=a+1,c=a+2;const f=u.index;u.index&&(o=f.getX(o),h=f.getX(h),c=f.getX(c));const{position:l,normal:d,uv:m,uv1:y}=u.attributes,x=Je(i,l,d,m,y,o,h,c,t,n,r);return x?(x.faceIndex=s,e&&e.push(x),x):null}function V(u,t,i,s){const e=u.a,n=u.b,r=u.c;let a=t,o=t+1,h=t+2;i&&(a=i.getX(a),o=i.getX(o),h=i.getX(h)),e.x=s.getX(a),e.y=s.getY(a),e.z=s.getZ(a),n.x=s.getX(o),n.y=s.getY(o),n.z=s.getZ(o),r.x=s.getX(h),r.y=s.getY(h),r.z=s.getZ(h)}function Qe(u,t,i,s,e,n,r,a){const{geometry:o,_indirectBuffer:h}=u;for(let c=s,f=s+e;cz&&(z=P),E_&&(_=E),FS&&(S=F)}return o[l+0]!==w||o[l+1]!==M||o[l+2]!==b||o[l+3]!==z||o[l+4]!==_||o[l+5]!==S?(o[l+0]=w,o[l+1]=M,o[l+2]=b,o[l+3]=z,o[l+4]=_,o[l+5]=S,!0):!1}else{const p=l+8,g=r[l+6],w=p+d,M=g+d;let b=m,z=!1,_=!1;t?b||(z=t.has(w),_=t.has(M),b=!z&&!_):(z=!0,_=!0);const S=b||z,B=b||_;let T=!1;S&&(T=f(p,d,b));let C=!1;B&&(C=f(g,d,b));const P=T||C;if(P)for(let E=0;E<3;E++){const F=p+E,U=g+E,R=o[F],j=o[F+3],ht=o[U],lt=o[U+3];o[l+E]=Rlt?j:lt}return P}}}function zt(u,t,i,s,e){let n,r,a,o,h,c;const f=1/i.direction.x,l=1/i.direction.y,d=1/i.direction.z,m=i.origin.x,y=i.origin.y,x=i.origin.z;let p=t[u],g=t[u+3],w=t[u+1],M=t[u+3+1],b=t[u+2],z=t[u+3+2];return f>=0?(n=(p-m)*f,r=(g-m)*f):(n=(g-m)*f,r=(p-m)*f),l>=0?(a=(w-y)*l,o=(M-y)*l):(a=(M-y)*l,o=(w-y)*l),n>o||a>r||((a>n||isNaN(n))&&(n=a),(o=0?(h=(b-x)*d,c=(z-x)*d):(h=(z-x)*d,c=(b-x)*d),n>c||h>r)?!1:((h>n||n!==n)&&(n=h),(c=s)}function en(u,t,i,s,e,n,r,a){const{geometry:o,_indirectBuffer:h}=u;for(let c=s,f=s+e;c=0;let y,x;m?(y=Q(u),x=K(u,o)):(y=K(u,o),x=Q(u));const g=zt(y,r,s,e,n)?ys(y,t,i,s,e,n):null;if(g){const b=g.point[l];if(m?b<=r[x+f]:b>=r[x+f+3])return g}const M=zt(x,r,s,e,n)?ys(x,t,i,s,e,n):null;return g&&M?g.distance<=M.distance?g:M:g||M||null}}const Ui=new W,Zt=new rt,$t=new rt,ci=new q,ie=new X,Ri=new X;function hn(u,t,i,s){k.setBuffer(u._roots[t]);const e=xs(0,u,i,s);return k.clearBuffer(),e}function xs(u,t,i,s,e=null){const{float32Array:n,uint16Array:r,uint32Array:a}=k;let o=u*2;if(e===null&&(i.boundingBox||i.computeBoundingBox(),ie.set(i.boundingBox.min,i.boundingBox.max,s),e=ie),Y(o,r)){const c=t.geometry,f=c.index,l=c.attributes.position,d=i.index,m=i.attributes.position,y=H(u,a),x=J(o,r);if(ci.copy(s).invert(),i.boundsTree)return L(u,n,Ri),Ri.matrix.copy(ci),Ri.needsUpdate=!0,i.boundsTree.shapecast({intersectsBounds:g=>Ri.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(s),g.b.applyMatrix4(s),g.c.applyMatrix4(s),g.needsUpdate=!0;for(let w=y*3,M=(x+y)*3;wgs.distanceToBox(b),intersectsBounds:(b,z,_)=>_{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:S=>hi.distanceToBox(S),intersectsBounds:(S,B,T)=>T{for(let T=S,C=S+B;Tz&&(z=F),U_&&(_=U),RS&&(S=R)}}return o[l+0]!==w||o[l+1]!==M||o[l+2]!==b||o[l+3]!==z||o[l+4]!==_||o[l+5]!==S?(o[l+0]=w,o[l+1]=M,o[l+2]=b,o[l+3]=z,o[l+4]=_,o[l+5]=S,!0):!1}else{const p=l+8,g=r[l+6],w=p+d,M=g+d;let b=m,z=!1,_=!1;t?b||(z=t.has(w),_=t.has(M),b=!z&&!_):(z=!0,_=!0);const S=b||z,B=b||_;let T=!1;S&&(T=f(p,d,b));let C=!1;B&&(C=f(g,d,b));const P=T||C;if(P)for(let E=0;E<3;E++){const F=p+E,U=g+E,R=o[F],j=o[F+3],ht=o[U],lt=o[U+3];o[l+E]=Rlt?j:lt}return P}}}function yn(u,t,i,s,e,n,r){k.setBuffer(u._roots[t]),bs(0,u,i,s,e,n,r),k.clearBuffer()}function bs(u,t,i,s,e,n,r){const{float32Array:a,uint16Array:o,uint32Array:h}=k,c=u*2;if(Y(c,o)){const l=H(u,h),d=J(c,o);en(t,i,s,l,d,e,n,r)}else{const l=Q(u);zt(l,a,s,n,r)&&bs(l,t,i,s,e,n,r);const d=K(u,h);zt(d,a,s,n,r)&&bs(d,t,i,s,e,n,r)}}const xn=["x","y","z"];function gn(u,t,i,s,e,n){k.setBuffer(u._roots[t]);const r=ws(0,u,i,s,e,n);return k.clearBuffer(),r}function ws(u,t,i,s,e,n){const{float32Array:r,uint16Array:a,uint32Array:o}=k;let h=u*2;if(Y(h,a)){const f=H(u,o),l=J(h,a);return nn(t,i,s,f,l,e,n)}else{const f=js(u,o),l=xn[f],m=s.direction[l]>=0;let y,x;m?(y=Q(u),x=K(u,o)):(y=K(u,o),x=Q(u));const g=zt(y,r,s,e,n)?ws(y,t,i,s,e,n):null;if(g){const b=g.point[l];if(m?b<=r[x+f]:b>=r[x+f+3])return g}const M=zt(x,r,s,e,n)?ws(x,t,i,s,e,n):null;return g&&M?g.distance<=M.distance?g:M:g||M||null}}const Li=new W,Ht=new rt,jt=new rt,li=new q,se=new X,Ii=new X;function bn(u,t,i,s){k.setBuffer(u._roots[t]);const e=_s(0,u,i,s);return k.clearBuffer(),e}function _s(u,t,i,s,e=null){const{float32Array:n,uint16Array:r,uint32Array:a}=k;let o=u*2;if(e===null&&(i.boundingBox||i.computeBoundingBox(),se.set(i.boundingBox.min,i.boundingBox.max,s),e=se),Y(o,r)){const c=t.geometry,f=c.index,l=c.attributes.position,d=i.index,m=i.attributes.position,y=H(u,a),x=J(o,r);if(li.copy(s).invert(),i.boundsTree)return L(u,n,Ii),Ii.matrix.copy(li),Ii.needsUpdate=!0,i.boundsTree.shapecast({intersectsBounds:g=>Ii.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(s),g.b.applyMatrix4(s),g.c.applyMatrix4(s),g.needsUpdate=!0;for(let w=y,M=x+y;wMs.distanceToBox(b),intersectsBounds:(b,z,_)=>_{if(t.boundsTree){const _=t.boundsTree;return _.shapecast({boundsTraverseOrder:S=>ui.distanceToBox(S),intersectsBounds:(S,B,T)=>T{for(let T=S,C=S+B;Tnew W),Gt=new W,Jt=new W,As=new W,zs=new W;let Ss=!1;function Bn(u,t,i,s){if(Ss)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Ss=!0;const e=u._roots,n=t._roots;let r,a=0,o=0;const h=new q().copy(i).invert();for(let c=0,f=e.length;co.slice()),index:r?r.array.slice():null,indirectBuffer:n?n.slice():null}:a={roots:e,index:r?r.array:null,indirectBuffer:n},a}static deserialize(t,i,s={}){s={setIndex:!0,indirect:!!t.indirectBuffer,...s};const{index:e,roots:n,indirectBuffer:r}=t,a=new Di(i,{...s,[rs]:!0});if(a._roots=n,a._indirectBuffer=r||null,s.setIndex){const o=i.getIndex();if(o===null){const h=new ct(t.index,1,!1);i.setIndex(h)}else o.array!==e&&(o.array.set(e),o.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,i={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(i=Object.assign({...Tn,[rs]:!1},i),i.useSharedArrayBuffer&&!Sn())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,i[rs]||(We(this,i),!t.boundingBox&&i.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new W))),this.resolveTriangleIndex=i.indirect?s=>this._indirectBuffer[s]:s=>s}refit(t=null){return(this.indirect?pn:sn)(this,t)}traverse(t,i=0){const s=this._roots[i],e=new Uint32Array(s),n=new Uint16Array(s);r(0);function r(a,o=0){const h=a*2,c=n[h+15]===Mi;if(c){const f=e[a+6],l=n[h+14];t(o,c,new Float32Array(s,a*4,6),f,l)}else{const f=a+ni/4,l=e[a+6],d=e[a+7];t(o,c,new Float32Array(s,a*4,6),d)||(r(f,o+1),r(l,o+1))}}}raycast(t,i=0,s=0,e=1/0){const n=this._roots,r=this.geometry,a=[],o=i.isMaterial,h=Array.isArray(i),c=r.groups,f=o?i.side:i,l=this.indirect?yn:on;for(let d=0,m=n.length;df(l,d,m,y,x)?!0:s(l,d,this,a,m,y,i)}else r||(a?r=(f,l,d,m)=>s(f,l,this,a,d,m,i):r=(f,l,d)=>d);let o=!1,h=0;const c=this._roots;for(let f=0,l=c.length;f{const y=this.resolveTriangleIndex(m);V(r,y*3,a,o)}:m=>{V(r,m*3,a,o)},c=tt.getPrimitive(),f=t.geometry.index,l=t.geometry.attributes.position,d=t.indirect?m=>{const y=t.resolveTriangleIndex(m);V(c,y*3,f,l)}:m=>{V(c,m*3,f,l)};if(n){const m=(y,x,p,g,w,M,b,z)=>{for(let _=p,S=p+g;_qi.intersectsBox(s),intersectsTriangle:s=>qi.intersectsTriangle(s)})}intersectsSphere(t){return this.shapecast({intersectsBounds:i=>t.intersectsBox(i),intersectsTriangle:i=>i.intersectsSphere(t)})}closestPointToGeometry(t,i,s={},e={},n=0,r=1/0){return(this.indirect?zn:mn)(this,t,i,s,e,n,r)}closestPointToPoint(t,i={},s=0,e=1/0){return je(this,t,i,s,e)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(s=>{L(0,new Float32Array(s),ee),t.union(ee)}),t}}onmessage=({data:u})=>{let t=performance.now();function i(r){r=Math.min(r,1);const a=performance.now();a-t>=10&&r!==1&&(postMessage({error:null,serialized:null,position:null,progress:r}),t=a)}const{index:s,position:e,options:n}=u;try{const r=new ss;if(r.setAttribute("position",new ct(e,3,!1)),s&&r.setIndex(new ct(s,1,!1)),n.includedProgressCallback&&(n.onProgress=i),n.groups){const c=n.groups;for(const f in c){const l=c[f];r.addGroup(l.start,l.count,l.materialIndex)}}const a=new Di(r,n),o=Di.serialize(a,{copyIndexBuffer:!1});let h=[e.buffer,...o.roots];o.index&&h.push(o.index.buffer),h=h.filter(c=>typeof SharedArrayBuffer>"u"||!(c instanceof SharedArrayBuffer)),a._indirectBuffer&&h.push(o.indirectBuffer.buffer),postMessage({error:null,serialized:o,position:e,progress:1},h)}catch(r){postMessage({error:r,serialized:null,position:null,progress:1})}}})(); diff --git a/example/bundle/assets/gpuPathTracing-Dre1TxEd.js b/example/bundle/assets/gpuPathTracing-Dre1TxEd.js new file mode 100644 index 00000000..346894d3 --- /dev/null +++ b/example/bundle/assets/gpuPathTracing-Dre1TxEd.js @@ -0,0 +1,108 @@ +import{W as F,S as R,D as O,A as E,P as I,a4 as W,j as x,m as _,M as A,d as D,a8 as L,Q as T,U,Y as j,c as z}from"./ExtendedTriangle-Chm2bbkR.js";import{F as b}from"./Pass-DgEPdZ3p.js";import{G as B}from"./GLTFLoader-Dl6abS6P.js";import{O as H}from"./OrbitControls-lzJCl7xY.js";import{m as G}from"./BufferGeometryUtils-Cscy-pCt.js";import{S as V}from"./stats.min-GTpOrGrX.js";import{g as N}from"./lil-gui.module.min-Bc0DeA9g.js";import{M as k,F as Q,c as $,b as Y,a as X}from"./bvh_struct_definitions.glsl-Drzlg63W.js";import{M as q,S as J}from"./MeshBVH-CPVAl5W3.js";import"./_commonjsHelpers-Cpj98o6Y.js";const o={enableRaytracing:!0,smoothImageScaling:!0,resolutionScale:.5/window.devicePixelRatio,bounces:3,accumulate:!0};let e,t,l,i,p,s,P,m,c,d=0,M;K();S();function K(){e=new F({antialias:!1}),e.setPixelRatio(window.devicePixelRatio),e.setClearColor(594970),e.setSize(window.innerWidth,window.innerHeight),e.outputEncoding=void 0,document.body.appendChild(e.domElement),M=document.getElementById("output"),l=new R;const r=new O(16777215,1);r.position.set(1,1,1),l.add(r),l.add(new E(11583173,.5)),t=new I(75,window.innerWidth/window.innerHeight,.1,50),t.position.set(-2,2,3),t.far=100,t.updateProjectionMatrix(),p=new V,document.body.appendChild(p.dom);const a=new W({defines:{BOUNCES:5},uniforms:{bvh:{value:new k},normalAttribute:{value:new Q},cameraWorldMatrix:{value:new x},invProjectionMatrix:{value:new x},seed:{value:0},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + void main() { + + vec4 mvPosition = vec4( position, 1.0 ); + mvPosition = modelViewMatrix * mvPosition; + gl_Position = projectionMatrix * mvPosition; + + vUv = uv; + + } + + `,fragmentShader:` + #define RAY_OFFSET 1e-5 + + precision highp isampler2D; + precision highp usampler2D; + ${$} + ${Y} + ${X} + #include + + uniform mat4 cameraWorldMatrix; + uniform mat4 invProjectionMatrix; + uniform sampler2D normalAttribute; + uniform BVH bvh; + uniform float seed; + uniform float opacity; + varying vec2 vUv; + + void main() { + + // get [-1, 1] normalized device coordinates + vec2 ndc = 2.0 * vUv - vec2( 1.0 ); + vec3 rayOrigin, rayDirection; + ndcToCameraRay( ndc, cameraWorldMatrix, invProjectionMatrix, rayOrigin, rayDirection ); + + // Lambertian render + gl_FragColor = vec4( 0.0 ); + + vec3 throughputColor = vec3( 1.0 ); + vec3 randomPoint = vec3( .0 ); + + // hit results + uvec4 faceIndices = uvec4( 0u ); + vec3 faceNormal = vec3( 0.0, 0.0, 1.0 ); + vec3 barycoord = vec3( 0.0 ); + float side = 1.0; + float dist = 0.0; + + for ( int i = 0; i < BOUNCES; i ++ ) { + + if ( ! bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ) ) { + + float value = ( rayDirection.y + 0.5 ) / 1.5; + vec3 skyColor = mix( vec3( 1.0 ), vec3( 0.75, 0.85, 1.0 ), value ); + + gl_FragColor = vec4( skyColor * throughputColor * 2.0, 1.0 ); + + break; + + } + + // 1 / PI attenuation for physically correct lambert model + // https://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/ + throughputColor *= 1.0 / PI; + + randomPoint = vec3( + rand( vUv + float( i + 1 ) + vec2( seed, seed ) ), + rand( - vUv * seed + float( i ) - seed ), + rand( - vUv * float( i + 1 ) - vec2( seed, - seed ) ) + ); + randomPoint -= 0.5; + randomPoint *= 2.0; + + // ensure the random vector is not 0,0,0 and that it won't exactly negate + // the surface normal + + float pointLength = max( length( randomPoint ), 1e-4 ); + randomPoint /= pointLength; + randomPoint *= 0.999; + + // fetch the interpolated smooth normal + vec3 normal = + side * + textureSampleBarycoord( + normalAttribute, + barycoord, + faceIndices.xyz + ).xyz; + + // adjust the hit point by the surface normal by a factor of some offset and the + // maximum component-wise value of the current point to accommodate floating point + // error as values increase. + vec3 point = rayOrigin + rayDirection * dist; + vec3 absPoint = abs( point ); + float maxPoint = max( absPoint.x, max( absPoint.y, absPoint.z ) ); + rayOrigin = point + faceNormal * ( maxPoint + 1.0 ) * RAY_OFFSET; + rayDirection = normalize( normal + randomPoint ); + + } + + gl_FragColor.a = opacity; + + } + + `});s=new b(a),a.transparent=!0,a.depthWrite=!1,new B().load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/dragon-attenuation/DragonAttenuation.glb",f=>{let g;f.scene.traverse(v=>{v.isMesh&&v.name==="Dragon"&&(g=v,v.geometry.scale(.25,.25,.25).rotateX(Math.PI/2))});const w=new _(5,5,1,1);w.rotateX(-Math.PI/2);const y=G([w,g.geometry],!1);y.translate(0,-.5,0),c=new A(y,new D),l.add(c);const C=new q(c.geometry,{maxLeafTris:1,strategy:J});a.uniforms.bvh.value.updateFrom(C),a.uniforms.normalAttribute.value.updateFrom(c.geometry.attributes.normal)});const n=e.extensions.get("OES_texture_float_linear");m=new L(1,1,{format:T,type:n?U:j}),P=new b(new z({map:m.texture})),new H(t,e.domElement).addEventListener("change",()=>{u()}),i=new N,i.add(o,"enableRaytracing").name("enable"),i.add(o,"accumulate"),i.add(o,"smoothImageScaling"),i.add(o,"resolutionScale",.1,1,.01).onChange(h),i.add(o,"bounces",1,10,1).onChange(f=>{a.defines.BOUNCES=parseInt(f),a.needsUpdate=!0,u()}),i.open(),window.addEventListener("resize",h,!1),h()}function u(){d=0}function h(){t.aspect=window.innerWidth/window.innerHeight,t.updateProjectionMatrix();const r=window.innerWidth,a=window.innerHeight,n=window.devicePixelRatio*o.resolutionScale;e.setSize(r,a),e.setPixelRatio(n),m.setSize(r*n,a*n),u()}function S(){if(p.update(),requestAnimationFrame(S),e.domElement.style.imageRendering=o.smoothImageScaling?"auto":"pixelated",c&&o.enableRaytracing){if(o.accumulate)if(d===0)t.clearViewOffset();else{const a=m.width,n=m.height;t.setViewOffset(a,n,Math.random()-.5,Math.random()-.5,a,n)}else u();t.updateMatrixWorld();const r=(s.material.uniforms.seed.value+.11111)%2;s.material.uniforms.seed.value=r,s.material.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld),s.material.uniforms.invProjectionMatrix.value.copy(t.projectionMatrixInverse),s.material.uniforms.opacity.value=1/(d+1),e.autoClear=d===0,e.setRenderTarget(m),s.render(e),e.setRenderTarget(null),P.render(e),e.autoClear=!0,d++}else u(),t.clearViewOffset(),e.render(l,t);M.innerText=`samples: ${d}`} diff --git a/example/bundle/assets/gpuPathTracingSimple-BE4tTR20.js b/example/bundle/assets/gpuPathTracingSimple-BE4tTR20.js new file mode 100644 index 00000000..a15cc71f --- /dev/null +++ b/example/bundle/assets/gpuPathTracingSimple-BE4tTR20.js @@ -0,0 +1,67 @@ +import{W as h,S as M,D as x,A as b,P as g,T as y,M as S,d as P,a4 as H,j as m,e as O}from"./ExtendedTriangle-Chm2bbkR.js";import{O as W}from"./OrbitControls-lzJCl7xY.js";import{F as R}from"./Pass-DgEPdZ3p.js";import{S as A}from"./stats.min-GTpOrGrX.js";import{g as C}from"./lil-gui.module.min-Bc0DeA9g.js";import{M as _,S as j}from"./MeshBVH-CPVAl5W3.js";import{M as D,F,c as L,b as N,a as T}from"./bvh_struct_definitions.glsl-Drzlg63W.js";import"./_commonjsHelpers-Cpj98o6Y.js";const a={enableRaytracing:!0,animate:!0,resolutionScale:1/window.devicePixelRatio,smoothNormals:!0};let e,i,o,n,u,d,s,f;z();w();function z(){e=new h({antialias:!1}),e.setPixelRatio(window.devicePixelRatio),e.setClearColor(594970),e.setSize(window.innerWidth,window.innerHeight),e.outputEncoding=void 0,document.body.appendChild(e.domElement),o=new M;const r=new x(16777215,1);r.position.set(1,1,1),o.add(r),o.add(new b(11583173,.5)),i=new g(75,window.innerWidth/window.innerHeight,.1,50),i.position.set(0,0,4),i.far=100,i.updateProjectionMatrix(),u=new A,document.body.appendChild(u.dom);const t=new y(1,.3,300,50),c=new _(t,{maxLeafTris:1,strategy:j});s=new S(t,new P),o.add(s),f=new O;const l=new H({defines:{SMOOTH_NORMALS:1},uniforms:{bvh:{value:new D},normalAttribute:{value:new F},cameraWorldMatrix:{value:new m},invProjectionMatrix:{value:new m},invModelMatrix:{value:new m}},vertexShader:` + + varying vec2 vUv; + void main() { + + vec4 mvPosition = vec4( position, 1.0 ); + mvPosition = modelViewMatrix * mvPosition; + gl_Position = projectionMatrix * mvPosition; + + vUv = uv; + + } + + `,fragmentShader:` + precision highp isampler2D; + precision highp usampler2D; + + ${L} + ${N} + ${T} + + uniform mat4 cameraWorldMatrix; + uniform mat4 invProjectionMatrix; + uniform mat4 invModelMatrix; + uniform sampler2D normalAttribute; + uniform BVH bvh; + varying vec2 vUv; + + void main() { + + // get [-1, 1] normalized device coordinates + vec2 ndc = 2.0 * vUv - vec2( 1.0 ); + vec3 rayOrigin, rayDirection; + ndcToCameraRay( + ndc, invModelMatrix * cameraWorldMatrix, invProjectionMatrix, + rayOrigin, rayDirection + ); + + // hit results + uvec4 faceIndices = uvec4( 0u ); + vec3 faceNormal = vec3( 0.0, 0.0, 1.0 ); + vec3 barycoord = vec3( 0.0 ); + float side = 1.0; + float dist = 0.0; + + // get intersection + bool didHit = bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist ); + + #if SMOOTH_NORMALS + + vec3 normal = textureSampleBarycoord( + normalAttribute, + barycoord, + faceIndices.xyz + ).xyz; + + #else + + vec3 normal = face.normal; + + #endif + + // set the color + gl_FragColor = ! didHit ? vec4( 0.0366, 0.0813, 0.1057, 1.0 ) : vec4( normal, 1.0 ); + + } + `});d=new R(l),l.uniforms.bvh.value.updateFrom(c),l.uniforms.normalAttribute.value.updateFrom(t.attributes.normal),new W(i,e.domElement),n=new C,n.add(a,"enableRaytracing"),n.add(a,"animate"),n.add(a,"smoothNormals").onChange(p=>{d.material.defines.SMOOTH_NORMALS=Number(p),d.material.needsUpdate=!0}),n.add(a,"resolutionScale",.1,1,.01).onChange(v),n.open(),window.addEventListener("resize",v,!1),v()}function v(){i.aspect=window.innerWidth/window.innerHeight,i.updateProjectionMatrix();const r=window.innerWidth,t=window.innerHeight,c=window.devicePixelRatio*a.resolutionScale;e.setSize(r,t),e.setPixelRatio(c)}function w(){u.update(),requestAnimationFrame(w);const r=f.getDelta();if(a.animate&&(s.rotation.y+=r),a.enableRaytracing){i.updateMatrixWorld(),s.updateMatrixWorld();const t=d.material.uniforms;t.cameraWorldMatrix.value.copy(i.matrixWorld),t.invProjectionMatrix.value.copy(i.projectionMatrixInverse),t.invModelMatrix.value.copy(s.matrixWorld).invert(),d.render(e)}else e.render(o,i)} diff --git a/example/bundle/assets/inspector-D_7qX9FB.js b/example/bundle/assets/inspector-D_7qX9FB.js new file mode 100644 index 00000000..9dfed979 --- /dev/null +++ b/example/bundle/assets/inspector-D_7qX9FB.js @@ -0,0 +1,68 @@ +import{M as $,f as R,u as z,C as x,W as _,a8 as U,a9 as I,U as j,S as G,P as N,c as Q,a6 as q,aa as X,p as Y,R as J,V as K,a4 as Z}from"./ExtendedTriangle-Chm2bbkR.js";import{O as ee}from"./OrbitControls-lzJCl7xY.js";import{G as te}from"./GLTFLoader-Dl6abS6P.js";import{F as oe}from"./Pass-DgEPdZ3p.js";import{g as ae}from"./lil-gui.module.min-Bc0DeA9g.js";import{M as re}from"./MeshBVHHelper-jLfel8l5.js";import{C as ne,A as ie,S as O}from"./MeshBVH-CPVAl5W3.js";import{g as se,e as B}from"./Debug-Bq6kbTOM.js";import{a as le,c as de,d as me}from"./ExtensionUtilities-0qN33-Z7.js";import"./BufferGeometryUtils-Cscy-pCt.js";$.prototype.raycast=le;R.prototype.computeBoundsTree=de;R.prototype.disposeBoundsTree=me;let w,c,o,u,a,S,L,l,h,s,M=new z;const P=new Float32Array(1),ce="https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/dragon-attenuation/DragonAttenuation.glb",e={options:{strategy:O,maxLeafTris:10,maxDepth:40,rebuild:function(){D()}},visualization:{displayMesh:!0,simpleColors:!1,outline:!0,traversalThreshold:50},benchmark:{displayRays:!1,firstHitOnly:!0,rotations:10,castCount:1e3}},ue=new x(16770670).convertLinearToSRGB().getHex(),fe=25453,he=16081063;class pe extends Z{constructor(n){super({uniforms:{map:{value:null},threshold:{value:35},boundsColor:{value:new x(16777215)},backgroundColor:{value:new x(0)},thresholdColor:{value:new x(16711680)},resolution:{value:new z},outlineAlpha:{value:.5}},vertexShader:` + varying vec2 vUv; + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + } + `,fragmentShader:` + uniform sampler2D map; + uniform float threshold; + + uniform vec3 thresholdColor; + uniform vec3 boundsColor; + uniform vec3 backgroundColor; + uniform vec2 resolution; + uniform float outlineAlpha; + + varying vec2 vUv; + void main() { + + float count = texture2D( map, vUv ).r; + + if ( count == 0.0 ) { + + vec2 offset = 1.0 / resolution; + float c1 = texture2D( map, vUv + offset * vec2( 1.0, 0.0 ) ).r; + float c2 = texture2D( map, vUv + offset * vec2( - 1.0, 0.0 ) ).r; + float c3 = texture2D( map, vUv + offset * vec2( 0.0, 1.0 ) ).r; + float c4 = texture2D( map, vUv + offset * vec2( 0.0, - 1.0 ) ).r; + + float maxC = max( c1, max( c2, max( c3, c4 ) ) ); + if ( maxC != 0.0 ) { + + gl_FragColor.rgb = mix( backgroundColor, mix( boundsColor, vec3( 1.0 ), 0.5 ), outlineAlpha ); + gl_FragColor.a = 1.0; + return; + + } + + } + + if ( count > threshold ) { + + gl_FragColor.rgb = thresholdColor.rgb; + gl_FragColor.a = 1.0; + + } else { + + float alpha = count / threshold; + vec3 color = mix( boundsColor, vec3( 1.0 ), pow( alpha, 1.75 ) ); + + gl_FragColor.rgb = mix( backgroundColor, color, alpha ).rgb ; + gl_FragColor.a = 1.0; + + } + + } + `});const t=this.uniforms;for(const r in t)Object.defineProperty(this,r,{get(){return this.uniforms[r].value},set(i){this.uniforms[r].value=i}});this.setValues(n)}}function ge(){S=document.getElementById("output"),L=document.getElementById("benchmark"),o=new _({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(0,1),document.body.appendChild(o.domElement),h=new U(1,1,{format:I,type:j}),s=new oe(new pe({map:h.texture,depthWrite:!1})),w=new G,c=new N(75,window.innerWidth/window.innerHeight,.1,50),c.position.set(-2.5,1.5,2.5),c.far=100,c.updateProjectionMatrix(),new ee(c,o.domElement),window.addEventListener("resize",H,!1),H(),new te().load(ce,m=>{m.scene.traverse(f=>{f.isMesh&&f.name==="Dragon"&&(a=f)}),a.material=new Q({colorWrite:!1}),a.geometry.center(),a.position.set(0,0,0),w.add(a),u=new re(a,40),u.displayEdges=!1,u.displayParents=!0,u.color.set(16777215),u.opacity=1,u.depth=40;const g=u.meshMaterial;g.blending=q,g.blendDst=X,w.add(u),D(),y(!0)}),l=new Y,l.material.opacity=.1,l.material.transparent=!0,l.material.depthWrite=!1,l.frustumCulled=!1,w.add(l);const n=new ae,t=n.addFolder("BVH");t.add(e.options,"strategy",{CENTER:ne,AVERAGE:ie,SAH:O}),t.add(e.options,"maxLeafTris",1,30,1),t.add(e.options,"maxDepth",1,40,1),t.add(e.options,"rebuild"),t.open();const r=n.addFolder("Visualization");r.add(e.visualization,"displayMesh"),r.add(e.visualization,"simpleColors"),r.add(e.visualization,"outline"),r.add(e.visualization,"traversalThreshold",1,300,1),r.open();const i=n.addFolder("Benchmark");i.add(e.benchmark,"displayRays"),i.add(e.benchmark,"firstHitOnly").onChange(T),i.add(e.benchmark,"castCount",100,5e3,1).onChange(()=>{T(),y(!0)}),i.add(e.benchmark,"rotations",1,20,1).onChange(()=>{T(),y(!0)}),i.open(),window.addEventListener("pointermove",m=>{M.set(m.clientX,window.innerHeight-m.clientY)})}function H(){c.aspect=window.innerWidth/window.innerHeight,c.updateProjectionMatrix(),o.setSize(window.innerWidth,window.innerHeight),o.setPixelRatio(window.devicePixelRatio),h.setSize(window.innerWidth*window.devicePixelRatio,window.innerHeight*window.devicePixelRatio)}function D(){const d=performance.now();a.geometry.computeBoundsTree({strategy:parseInt(e.options.strategy),maxLeafTris:e.options.maxLeafTris,maxDepth:e.options.maxDepth});const n=performance.now()-d;u.update(),T();const t=se(a.geometry.boundsTree)[0];S.innerText=`construction time : ${n.toFixed(2)}ms +surface area score : ${t.surfaceAreaScore.toFixed(2)} +total nodes : ${t.nodeCount} +total leaf nodes : ${t.leafNodeCount} +min / max tris per leaf : ${t.tris.min} / ${t.tris.max} +min / max depth : ${t.depth.min} / ${t.depth.max} +memory (incl. geometry) : ${(B(a.geometry.boundsTree)*1e-6).toFixed(3)} mb +memory (excl. geometry) : ${(B(a.geometry.boundsTree._roots)*1e-6).toFixed(3)} mb`}function y(d=!1){let n=null,t=null;d&&(a.updateMatrixWorld(),t=new R,l.geometry.dispose(),n=[]);const r=new J;r.firstHitOnly=e.benchmark.firstHitOnly;const i=e.benchmark.castCount,m=e.benchmark.rotations,{ray:g}=r,{origin:f,direction:A}=g,V=performance.now();for(let v=0;v{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function w(l){let t,i;return(t=l.match(/(#|0x)?([a-f0-9]{6})/i))?i=t[2]:(t=l.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?i=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=l.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(i=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),!!i&&"#"+i}const k={isPrimitive:!0,match:l=>typeof l=="string",fromHexString:w,toHexString:w},m={isPrimitive:!0,match:l=>typeof l=="number",fromHexString:l=>parseInt(l.substring(1),16),toHexString:l=>"#"+l.toString(16).padStart(6,0)},L={isPrimitive:!1,match:Array.isArray,fromHexString(l,t,i=1){const e=m.fromHexString(l);t[0]=(e>>16&255)/255*i,t[1]=(e>>8&255)/255*i,t[2]=(255&e)/255*i},toHexString:([l,t,i],e=1)=>m.toHexString(l*(e=255/e)<<16^t*e<<8^i*e<<0)},S={isPrimitive:!1,match:l=>Object(l)===l,fromHexString(l,t,i=1){const e=m.fromHexString(l);t.r=(e>>16&255)/255*i,t.g=(e>>8&255)/255*i,t.b=(255&e)/255*i},toHexString:({r:l,g:t,b:i},e=1)=>m.toHexString(l*(e=255/e)<<16^t*e<<8^i*e<<0)},D=[k,m,L,S];class F extends u{constructor(t,i,e,n){var a;super(t,i,e,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(a=this.initialValue,D.find(r=>r.match(a))),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const r=w(this.$text.value);r&&this._setValueFromHexString(r)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){const i=this._format.fromHexString(t);this.setValue(i)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class f extends u{constructor(t,i,e){super(t,i,e,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",n=>{n.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class V extends u{constructor(t,i,e,n,a,r){super(t,i,e,"number"),this._initInput(),this.min(n),this.max(a);const d=r!==void 0;this.step(d?r:this._getImplicitStep(),d),this.updateDisplay()}decimals(t){return this._decimals=t,this.updateDisplay(),this}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,i=!0){return this._step=t,this._stepExplicit=i,this}updateDisplay(){const t=this.getValue();if(this._hasSlider){let i=(t-this._min)/(this._max-this._min);i=Math.max(0,Math.min(i,1)),this.$fill.style.width=100*i+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?t:t.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=s=>{const p=parseFloat(this.$input.value);isNaN(p)||(this._snapClampSetValue(p+s),this.$input.value=this.getValue())};let i,e,n,a,r,d=!1;const h=s=>{if(d){const p=s.clientX-i,o=s.clientY-e;Math.abs(o)>5?(s.preventDefault(),this.$input.blur(),d=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(p)>5&&c()}if(!d){const p=s.clientY-n;r-=p*this._step*this._arrowKeyMultiplier(s),a+r>this._max?r=this._max-a:a+r{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",c)};this.$input.addEventListener("input",()=>{let s=parseFloat(this.$input.value);isNaN(s)||(this._stepExplicit&&(s=this._snap(s)),this.setValue(this._clamp(s)))}),this.$input.addEventListener("keydown",s=>{s.code==="Enter"&&this.$input.blur(),s.code==="ArrowUp"&&(s.preventDefault(),t(this._step*this._arrowKeyMultiplier(s))),s.code==="ArrowDown"&&(s.preventDefault(),t(this._step*this._arrowKeyMultiplier(s)*-1))}),this.$input.addEventListener("wheel",s=>{this._inputFocused&&(s.preventDefault(),t(this._step*this._normalizeMouseWheel(s)))},{passive:!1}),this.$input.addEventListener("mousedown",s=>{i=s.clientX,e=n=s.clientY,d=!0,a=this.getValue(),r=0,window.addEventListener("mousemove",h),window.addEventListener("mouseup",c)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const t=o=>{const g=this.$slider.getBoundingClientRect();let b=(x=o,v=g.left,y=g.right,A=this._min,_=this._max,(x-v)/(y-v)*(_-A)+A);var x,v,y,A,_;this._snapClampSetValue(b)},i=o=>{t(o.clientX)},e=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",e)};let n,a,r=!1;const d=o=>{o.preventDefault(),this._setDraggingStyle(!0),t(o.touches[0].clientX),r=!1},h=o=>{if(r){const g=o.touches[0].clientX-n,b=o.touches[0].clientY-a;Math.abs(g)>Math.abs(b)?d(o):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",c))}else o.preventDefault(),t(o.touches[0].clientX)},c=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",c)},s=this._callOnFinishChange.bind(this);let p;this.$slider.addEventListener("mousedown",o=>{this._setDraggingStyle(!0),t(o.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",e)}),this.$slider.addEventListener("touchstart",o=>{o.touches.length>1||(this._hasScrollBar?(n=o.touches[0].clientX,a=o.touches[0].clientY,r=!0):d(o),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",c))},{passive:!1}),this.$slider.addEventListener("wheel",o=>{if(Math.abs(o.deltaX)this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){const t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class M extends u{constructor(t,i,e,n){super(t,i,e,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(n)?n:Object.values(n),this._names=Array.isArray(n)?n:Object.keys(n),this._names.forEach(a=>{const r=document.createElement("option");r.innerHTML=a,this.$select.appendChild(r)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const t=this.getValue(),i=this._values.indexOf(t);return this.$select.selectedIndex=i,this.$display.innerHTML=i===-1?t:this._names[i],this}}class H extends u{constructor(t,i,e){super(t,i,e,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",n=>{n.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let $=!1;class E{constructor({parent:t,autoPlace:i=t===void 0,container:e,width:n,title:a="Controls",injectStyles:r=!0,touchStyles:d=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",h=>{h.code!=="Enter"&&h.code!=="Space"||(h.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),d&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!$&&r&&(function(h){const c=document.createElement("style");c.innerHTML=h;const s=document.querySelector("head link[rel=stylesheet], head style");s?document.head.insertBefore(c,s):document.head.appendChild(c)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),$=!0),e?e.appendChild(this.domElement):i&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),n&&this.domElement.style.setProperty("--width",n+"px"),this.domElement.addEventListener("keydown",h=>h.stopPropagation()),this.domElement.addEventListener("keyup",h=>h.stopPropagation())}add(t,i,e,n,a){if(Object(e)===e)return new M(this,t,i,e);const r=t[i];switch(typeof r){case"number":return new V(this,t,i,e,n,a);case"boolean":return new C(this,t,i);case"string":return new H(this,t,i);case"function":return new f(this,t,i)}console.error(`gui.add failed + property:`,i,` + object:`,t,` + value:`,r)}addColor(t,i,e=1){return new F(this,t,i,e)}addFolder(t){return new E({parent:this,title:t})}load(t,i=!0){return t.controllers&&this.controllers.forEach(e=>{e instanceof f||e._name in t.controllers&&e.load(t.controllers[e._name])}),i&&t.folders&&this.folders.forEach(e=>{e._title in t.folders&&e.load(t.folders[e._title])}),this}save(t=!0){const i={controllers:{},folders:{}};return this.controllers.forEach(e=>{if(!(e instanceof f)){if(e._name in i.controllers)throw new Error(`Cannot save GUI with duplicate property "${e._name}"`);i.controllers[e._name]=e.save()}}),t&&this.folders.forEach(e=>{if(e._title in i.folders)throw new Error(`Cannot save GUI with duplicate folder "${e._title}"`);i.folders[e._title]=e.save()}),i}open(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const i=this.$children.clientHeight;this.$children.style.height=i+"px",this.domElement.classList.add("transition");const e=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",e))};this.$children.addEventListener("transitionend",e);const n=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=n+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(i=>i.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),this._onChange!==void 0&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(i=>{t=t.concat(i.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(i=>{t=t.concat(i.foldersRecursive())}),t}}export{E as g}; diff --git a/example/bundle/assets/meshopt_decoder.module-Cf1-17OU.js b/example/bundle/assets/meshopt_decoder.module-Cf1-17OU.js new file mode 100644 index 00000000..91507462 --- /dev/null +++ b/example/bundle/assets/meshopt_decoder.module-Cf1-17OU.js @@ -0,0 +1 @@ +var P=function(){var v="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",F="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",G=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),w=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var t=WebAssembly.validate(G)?F:v,d,n=WebAssembly.instantiate(x(t),{}).then(function(e){d=e.instance,d.exports.__wasm_call_ctors()});function x(e){for(var b=new Uint8Array(e.length),a=0;a96?c-97:c>64?c-39:c+4}for(var i=0,a=0;a0?O(e,b,a,m[c],s[i]):n.then(function(){var p=new Uint8Array(e*b);return g(d.exports[m[c]],p,e,b,a,d.exports[s[i]]),p})}}}();export{P as M}; diff --git a/example/bundle/assets/parallelMeshBVH.worker-3aq7SIs7.js b/example/bundle/assets/parallelMeshBVH.worker-3aq7SIs7.js new file mode 100644 index 00000000..3b8b9d02 --- /dev/null +++ b/example/bundle/assets/parallelMeshBVH.worker-3aq7SIs7.js @@ -0,0 +1,5 @@ +(function(){"use strict";/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const ae="166",Ue="";class qt{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const s=i.slice(0);for(let n=0,r=s.length;n>8&255]+I[l>>16&255]+I[l>>24&255]+"-"+I[t&255]+I[t>>8&255]+"-"+I[t>>16&15|64]+I[t>>24&255]+"-"+I[e&63|128]+I[e>>8&255]+"-"+I[e>>16&255]+I[e>>24&255]+I[i&255]+I[i>>8&255]+I[i>>16&255]+I[i>>24&255]).toLowerCase()}function V(l,t,e){return Math.max(t,Math.min(e,l))}function le(l,t){return(l%t+t)%t}function Pe(l,t,e,i,s){return i+(l-t)*(s-i)/(e-t)}function De(l,t,e){return l!==t?(e-l)/(t-l):0}function ce(l,t,e){return(1-e)*l+e*t}function Le(l,t,e,i){return ce(l,t,1-Math.exp(-e*i))}function Oe(l,t=1){return t-Math.abs(le(l,t*2)-t)}function Ne(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*(3-2*l))}function We(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*l*(l*(l*6-15)+10))}function qe(l,t){return l+Math.floor(Math.random()*(t-l+1))}function Xe(l,t){return l+Math.random()*(t-l)}function Ve(l){return l*(.5-Math.random())}function Ye(l){l!==void 0&&(oe=l);let t=oe+=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 Ze(l){return l*he}function ve(l){return l*ue}function Ge(l){return(l&l-1)===0&&l!==0}function He(l){return Math.pow(2,Math.ceil(Math.log(l)/Math.LN2))}function je(l){return Math.pow(2,Math.floor(Math.log(l)/Math.LN2))}function $e(l,t,e,i,s){const n=Math.cos,r=Math.sin,a=n(e/2),o=r(e/2),h=n((t+i)/2),u=r((t+i)/2),c=n((t-i)/2),m=r((t-i)/2),d=n((i-t)/2),f=r((i-t)/2);switch(s){case"XYX":l.set(a*u,o*c,o*m,a*h);break;case"YZY":l.set(o*m,a*u,o*c,a*h);break;case"ZXZ":l.set(o*c,o*m,a*u,a*h);break;case"XZX":l.set(a*u,o*f,o*d,a*h);break;case"YXY":l.set(o*d,a*u,o*f,a*h);break;case"ZYZ":l.set(o*f,o*d,a*u,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function at(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return l/4294967295;case Uint16Array:return l/65535;case Uint8Array:return l/255;case Int32Array:return Math.max(l/2147483647,-1);case Int16Array:return Math.max(l/32767,-1);case Int8Array:return Math.max(l/127,-1);default:throw new Error("Invalid component type.")}}function P(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return Math.round(l*4294967295);case Uint16Array:return Math.round(l*65535);case Uint8Array:return Math.round(l*255);case Int32Array:return Math.round(l*2147483647);case Int16Array:return Math.round(l*32767);case Int8Array:return Math.round(l*127);default:throw new Error("Invalid component type.")}}const Je={DEG2RAD:he,RAD2DEG:ue,generateUUID:pt,clamp:V,euclideanModulo:le,mapLinear:Pe,inverseLerp:De,lerp:ce,damp:Le,pingpong:Oe,smoothstep:Ne,smootherstep:We,randInt:qe,randFloat:Xe,randFloatSpread:Ve,seededRandom:Ye,degToRad:Ze,radToDeg:ve,isPowerOfTwo:Ge,ceilPowerOfTwo:He,floorPowerOfTwo:je,setQuaternionFromProperEuler:$e,normalize:P,denormalize:at};class Z{constructor(t=0,e=0){Z.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(V(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),s=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*i-r*s+t.x,this.y=n*s+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ot{constructor(t,e,i,s,n,r,a,o,h){ot.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,o,h)}set(t,e,i,s,n,r,a,o,h){const u=this.elements;return u[0]=t,u[1]=s,u[2]=a,u[3]=e,u[4]=n,u[5]=o,u[6]=i,u[7]=r,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[3],o=i[6],h=i[1],u=i[4],c=i[7],m=i[2],d=i[5],f=i[8],y=s[0],x=s[3],p=s[6],A=s[1],M=s[4],b=s[7],g=s[2],w=s[5],_=s[8];return n[0]=r*y+a*A+o*g,n[3]=r*x+a*M+o*w,n[6]=r*p+a*b+o*_,n[1]=h*y+u*A+c*g,n[4]=h*x+u*M+c*w,n[7]=h*p+u*b+c*_,n[2]=m*y+d*A+f*g,n[5]=m*x+d*M+f*w,n[8]=m*p+d*b+f*_,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],u=t[8];return e*r*u-e*a*h-i*n*u+i*a*o+s*n*h-s*r*o}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],u=t[8],c=u*r-a*h,m=a*o-u*n,d=h*n-r*o,f=e*c+i*m+s*d;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/f;return t[0]=c*y,t[1]=(s*h-u*i)*y,t[2]=(a*i-s*r)*y,t[3]=m*y,t[4]=(u*e-s*o)*y,t[5]=(s*n-a*e)*y,t[6]=d*y,t[7]=(i*o-h*e)*y,t[8]=(r*e-i*n)*y,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,n,r,a){const o=Math.cos(n),h=Math.sin(n);return this.set(i*o,i*h,-i*(o*r+h*a)+r+t,-s*h,s*o,-s*(-h*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Xt.makeScale(t,e)),this}rotate(t){return this.premultiply(Xt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Xt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<9;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Xt=new ot;function Qe(l){for(let t=l.length-1;t>=0;--t)if(l[t]>=65535)return!0;return!1}function de(l){return document.createElementNS("http://www.w3.org/1999/xhtml",l)}const me={};function Ke(l){l in me||(me[l]=!0,console.warn(l))}function Vt(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}let ht;class ti{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ht===void 0&&(ht=de("canvas")),ht.width=t.width,ht.height=t.height;const i=ht.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=ht}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=de("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),n=s.data;for(let r=0;r0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}it.DEFAULT_IMAGE=null,it.DEFAULT_MAPPING=300,it.DEFAULT_ANISOTROPY=1;class xt{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,n,r,a){let o=i[s+0],h=i[s+1],u=i[s+2],c=i[s+3];const m=n[r+0],d=n[r+1],f=n[r+2],y=n[r+3];if(a===0){t[e+0]=o,t[e+1]=h,t[e+2]=u,t[e+3]=c;return}if(a===1){t[e+0]=m,t[e+1]=d,t[e+2]=f,t[e+3]=y;return}if(c!==y||o!==m||h!==d||u!==f){let x=1-a;const p=o*m+h*d+u*f+c*y,A=p>=0?1:-1,M=1-p*p;if(M>Number.EPSILON){const g=Math.sqrt(M),w=Math.atan2(g,p*A);x=Math.sin(x*w)/g,a=Math.sin(a*w)/g}const b=a*A;if(o=o*x+m*b,h=h*x+d*b,u=u*x+f*b,c=c*x+y*b,x===1-a){const g=1/Math.sqrt(o*o+h*h+u*u+c*c);o*=g,h*=g,u*=g,c*=g}}t[e]=o,t[e+1]=h,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,s,n,r){const a=i[s],o=i[s+1],h=i[s+2],u=i[s+3],c=n[r],m=n[r+1],d=n[r+2],f=n[r+3];return t[e]=a*f+u*c+o*d-h*m,t[e+1]=o*f+u*m+h*c-a*d,t[e+2]=h*f+u*d+a*m-o*c,t[e+3]=u*f-a*c-o*m-h*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,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,n=t._z,r=t._order,a=Math.cos,o=Math.sin,h=a(i/2),u=a(s/2),c=a(n/2),m=o(i/2),d=o(s/2),f=o(n/2);switch(r){case"XYZ":this._x=m*u*c+h*d*f,this._y=h*d*c-m*u*f,this._z=h*u*f+m*d*c,this._w=h*u*c-m*d*f;break;case"YXZ":this._x=m*u*c+h*d*f,this._y=h*d*c-m*u*f,this._z=h*u*f-m*d*c,this._w=h*u*c+m*d*f;break;case"ZXY":this._x=m*u*c-h*d*f,this._y=h*d*c+m*u*f,this._z=h*u*f+m*d*c,this._w=h*u*c-m*d*f;break;case"ZYX":this._x=m*u*c-h*d*f,this._y=h*d*c+m*u*f,this._z=h*u*f-m*d*c,this._w=h*u*c+m*d*f;break;case"YZX":this._x=m*u*c+h*d*f,this._y=h*d*c+m*u*f,this._z=h*u*f-m*d*c,this._w=h*u*c-m*d*f;break;case"XZY":this._x=m*u*c-h*d*f,this._y=h*d*c-m*u*f,this._z=h*u*f+m*d*c,this._w=h*u*c+m*d*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],n=e[8],r=e[1],a=e[5],o=e[9],h=e[2],u=e[6],c=e[10],m=i+a+c;if(m>0){const d=.5/Math.sqrt(m+1);this._w=.25/d,this._x=(u-o)*d,this._y=(n-h)*d,this._z=(r-s)*d}else if(i>a&&i>c){const d=2*Math.sqrt(1+i-a-c);this._w=(u-o)/d,this._x=.25*d,this._y=(s+r)/d,this._z=(n+h)/d}else if(a>c){const d=2*Math.sqrt(1+a-i-c);this._w=(n-h)/d,this._x=(s+r)/d,this._y=.25*d,this._z=(o+u)/d}else{const d=2*Math.sqrt(1+c-i-a);this._w=(r-s)/d,this._x=(n+h)/d,this._y=(o+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(V(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,n=t._z,r=t._w,a=e._x,o=e._y,h=e._z,u=e._w;return this._x=i*u+r*a+s*h-n*o,this._y=s*u+r*o+n*a-i*h,this._z=n*u+r*h+i*o-s*a,this._w=r*u-i*a-s*o-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,n=this._z,r=this._w;let a=r*t._w+i*t._x+s*t._y+n*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=r,this._x=i,this._y=s,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const d=1-e;return this._w=d*r+e*this._w,this._x=d*i+e*this._x,this._y=d*s+e*this._y,this._z=d*n+e*this._z,this.normalize(),this}const h=Math.sqrt(o),u=Math.atan2(h,a),c=Math.sin((1-e)*u)/h,m=Math.sin(e*u)/h;return this._w=r*c+this._w*m,this._x=i*c+this._x*m,this._y=s*c+this._y*m,this._z=n*c+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),n*Math.sin(e),n*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 z{constructor(t=0,e=0,i=0){z.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(fe.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(fe.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=t.elements,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,a=t.z,o=t.w,h=2*(r*s-a*i),u=2*(a*e-n*s),c=2*(n*i-r*e);return this.x=e+o*h+r*c-a*u,this.y=i+o*u+a*h-n*c,this.z=s+o*c+n*u-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s,this.y=n[1]*e+n[5]*i+n[9]*s,this.z=n[2]*e+n[6]*i+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,n=t.z,r=e.x,a=e.y,o=e.z;return this.x=s*o-n*a,this.y=n*r-i*o,this.z=i*a-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Zt.copy(this).projectOnVector(t),this.sub(Zt)}reflect(t){return this.sub(Zt.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 i=this.dot(t)/e;return Math.acos(V(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,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,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Zt=new z,fe=new xt;class gt{constructor(t=new z(1/0,1/0,1/0),e=new z(-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,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,W),W.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(_t),Et.subVectors(this.max,_t),ut.subVectors(t.a,_t),lt.subVectors(t.b,_t),ct.subVectors(t.c,_t),$.subVectors(lt,ut),J.subVectors(ct,lt),st.subVectors(ut,ct);let e=[0,-$.z,$.y,0,-J.z,J.y,0,-st.z,st.y,$.z,0,-$.x,J.z,0,-J.x,st.z,0,-st.x,-$.y,$.x,0,-J.y,J.x,0,-st.y,st.x,0];return!vt(e,ut,lt,ct,Et)||(e=[1,0,0,0,1,0,0,0,1],!vt(e,ut,lt,ct,Et))?!1:(Tt.crossVectors($,J),e=[Tt.x,Tt.y,Tt.z],vt(e,ut,lt,ct,Et))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,W).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(W).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:(v[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),v[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),v[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),v[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),v[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),v[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),v[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),v[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(v),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 v=[new z,new z,new z,new z,new z,new z,new z,new z],W=new z,Ct=new gt,ut=new z,lt=new z,ct=new z,$=new z,J=new z,st=new z,_t=new z,Et=new z,Tt=new z,nt=new z;function vt(l,t,e,i,s){for(let n=0,r=l.length-3;n<=r;n+=3){nt.fromArray(l,n);const a=s.x*Math.abs(nt.x)+s.y*Math.abs(nt.y)+s.z*Math.abs(nt.z),o=t.dot(nt),h=e.dot(nt),u=i.dot(nt);if(Math.max(-Math.max(o,h,u),Math.min(o,h,u))>a)return!1}return!0}const ni=new gt,Mt=new z,Gt=new z;class ri{constructor(t=new z,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 i=this.center;e!==void 0?i.copy(e):ni.setFromPoints(t).getCenter(i);let s=0;for(let n=0,r=t.length;nthis.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;Mt.subVectors(t,this.center);const e=Mt.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(Mt,s/i),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Gt.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Mt.copy(t.center).add(Gt)),this.expandByPoint(Mt.copy(t.center).sub(Gt))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}class Y{constructor(t,e,i,s,n,r,a,o,h,u,c,m,d,f,y,x){Y.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,i,s,n,r,a,o,h,u,c,m,d,f,y,x)}set(t,e,i,s,n,r,a,o,h,u,c,m,d,f,y,x){const p=this.elements;return p[0]=t,p[4]=e,p[8]=i,p[12]=s,p[1]=n,p[5]=r,p[9]=a,p[13]=o,p[2]=h,p[6]=u,p[10]=c,p[14]=m,p[3]=d,p[7]=f,p[11]=y,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Y().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/dt.setFromMatrixColumn(t,0).length(),n=1/dt.setFromMatrixColumn(t,1).length(),r=1/dt.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,n=t.z,r=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),u=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){const m=r*u,d=r*c,f=a*u,y=a*c;e[0]=o*u,e[4]=-o*c,e[8]=h,e[1]=d+f*h,e[5]=m-y*h,e[9]=-a*o,e[2]=y-m*h,e[6]=f+d*h,e[10]=r*o}else if(t.order==="YXZ"){const m=o*u,d=o*c,f=h*u,y=h*c;e[0]=m+y*a,e[4]=f*a-d,e[8]=r*h,e[1]=r*c,e[5]=r*u,e[9]=-a,e[2]=d*a-f,e[6]=y+m*a,e[10]=r*o}else if(t.order==="ZXY"){const m=o*u,d=o*c,f=h*u,y=h*c;e[0]=m-y*a,e[4]=-r*c,e[8]=f+d*a,e[1]=d+f*a,e[5]=r*u,e[9]=y-m*a,e[2]=-r*h,e[6]=a,e[10]=r*o}else if(t.order==="ZYX"){const m=r*u,d=r*c,f=a*u,y=a*c;e[0]=o*u,e[4]=f*h-d,e[8]=m*h+y,e[1]=o*c,e[5]=y*h+m,e[9]=d*h-f,e[2]=-h,e[6]=a*o,e[10]=r*o}else if(t.order==="YZX"){const m=r*o,d=r*h,f=a*o,y=a*h;e[0]=o*u,e[4]=y-m*c,e[8]=f*c+d,e[1]=c,e[5]=r*u,e[9]=-a*u,e[2]=-h*u,e[6]=d*c+f,e[10]=m-y*c}else if(t.order==="XZY"){const m=r*o,d=r*h,f=a*o,y=a*h;e[0]=o*u,e[4]=-c,e[8]=h*u,e[1]=m*c+y,e[5]=r*u,e[9]=d*c-f,e[2]=f*c-d,e[6]=a*u,e[10]=y*c+m}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(ai,t,oi)}lookAt(t,e,i){const s=this.elements;return D.subVectors(t,e),D.lengthSq()===0&&(D.z=1),D.normalize(),Q.crossVectors(i,D),Q.lengthSq()===0&&(Math.abs(i.z)===1?D.x+=1e-4:D.z+=1e-4,D.normalize(),Q.crossVectors(i,D)),Q.normalize(),kt.crossVectors(D,Q),s[0]=Q.x,s[4]=kt.x,s[8]=D.x,s[1]=Q.y,s[5]=kt.y,s[9]=D.y,s[2]=Q.z,s[6]=kt.z,s[10]=D.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[4],o=i[8],h=i[12],u=i[1],c=i[5],m=i[9],d=i[13],f=i[2],y=i[6],x=i[10],p=i[14],A=i[3],M=i[7],b=i[11],g=i[15],w=s[0],_=s[4],S=s[8],B=s[12],E=s[1],C=s[5],k=s[9],T=s[13],U=s[2],N=s[6],j=s[10],X=s[14],rt=s[3],Ot=s[7],Nt=s[11],Wt=s[15];return n[0]=r*w+a*E+o*U+h*rt,n[4]=r*_+a*C+o*N+h*Ot,n[8]=r*S+a*k+o*j+h*Nt,n[12]=r*B+a*T+o*X+h*Wt,n[1]=u*w+c*E+m*U+d*rt,n[5]=u*_+c*C+m*N+d*Ot,n[9]=u*S+c*k+m*j+d*Nt,n[13]=u*B+c*T+m*X+d*Wt,n[2]=f*w+y*E+x*U+p*rt,n[6]=f*_+y*C+x*N+p*Ot,n[10]=f*S+y*k+x*j+p*Nt,n[14]=f*B+y*T+x*X+p*Wt,n[3]=A*w+M*E+b*U+g*rt,n[7]=A*_+M*C+b*N+g*Ot,n[11]=A*S+M*k+b*j+g*Nt,n[15]=A*B+M*T+b*X+g*Wt,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],i=t[4],s=t[8],n=t[12],r=t[1],a=t[5],o=t[9],h=t[13],u=t[2],c=t[6],m=t[10],d=t[14],f=t[3],y=t[7],x=t[11],p=t[15];return f*(+n*o*c-s*h*c-n*a*m+i*h*m+s*a*d-i*o*d)+y*(+e*o*d-e*h*m+n*r*m-s*r*d+s*h*u-n*o*u)+x*(+e*h*c-e*a*d-n*r*c+i*r*d+n*a*u-i*h*u)+p*(-s*a*u-e*o*c+e*a*m+s*r*c-i*r*m+i*o*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,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],u=t[8],c=t[9],m=t[10],d=t[11],f=t[12],y=t[13],x=t[14],p=t[15],A=c*x*h-y*m*h+y*o*d-a*x*d-c*o*p+a*m*p,M=f*m*h-u*x*h-f*o*d+r*x*d+u*o*p-r*m*p,b=u*y*h-f*c*h+f*a*d-r*y*d-u*a*p+r*c*p,g=f*c*o-u*y*o-f*a*m+r*y*m+u*a*x-r*c*x,w=e*A+i*M+s*b+n*g;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/w;return t[0]=A*_,t[1]=(y*m*n-c*x*n-y*s*d+i*x*d+c*s*p-i*m*p)*_,t[2]=(a*x*n-y*o*n+y*s*h-i*x*h-a*s*p+i*o*p)*_,t[3]=(c*o*n-a*m*n-c*s*h+i*m*h+a*s*d-i*o*d)*_,t[4]=M*_,t[5]=(u*x*n-f*m*n+f*s*d-e*x*d-u*s*p+e*m*p)*_,t[6]=(f*o*n-r*x*n-f*s*h+e*x*h+r*s*p-e*o*p)*_,t[7]=(r*m*n-u*o*n+u*s*h-e*m*h-r*s*d+e*o*d)*_,t[8]=b*_,t[9]=(f*c*n-u*y*n-f*i*d+e*y*d+u*i*p-e*c*p)*_,t[10]=(r*y*n-f*a*n+f*i*h-e*y*h-r*i*p+e*a*p)*_,t[11]=(u*a*n-r*c*n-u*i*h+e*c*h+r*i*d-e*a*d)*_,t[12]=g*_,t[13]=(u*y*s-f*c*s+f*i*m-e*y*m-u*i*x+e*c*x)*_,t[14]=(f*a*s-r*y*s-f*i*o+e*y*o+r*i*x-e*a*x)*_,t[15]=(r*c*s-u*a*s+u*i*o-e*c*o-r*i*m+e*a*m)*_,this}scale(t){const e=this.elements,i=t.x,s=t.y,n=t.z;return e[0]*=i,e[4]*=s,e[8]*=n,e[1]*=i,e[5]*=s,e[9]*=n,e[2]*=i,e[6]*=s,e[10]*=n,e[3]*=i,e[7]*=s,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,a=t.y,o=t.z,h=n*r,u=n*a;return this.set(h*r+i,h*a-s*o,h*o+s*a,0,h*a+s*o,u*a+i,u*o-s*r,0,h*o-s*a,u*o+s*r,n*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,n,r){return this.set(1,i,n,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,n=e._x,r=e._y,a=e._z,o=e._w,h=n+n,u=r+r,c=a+a,m=n*h,d=n*u,f=n*c,y=r*u,x=r*c,p=a*c,A=o*h,M=o*u,b=o*c,g=i.x,w=i.y,_=i.z;return s[0]=(1-(y+p))*g,s[1]=(d+b)*g,s[2]=(f-M)*g,s[3]=0,s[4]=(d-b)*w,s[5]=(1-(m+p))*w,s[6]=(x+A)*w,s[7]=0,s[8]=(f+M)*_,s[9]=(x-A)*_,s[10]=(1-(m+y))*_,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let n=dt.set(s[0],s[1],s[2]).length();const r=dt.set(s[4],s[5],s[6]).length(),a=dt.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),t.x=s[12],t.y=s[13],t.z=s[14],q.copy(this);const h=1/n,u=1/r,c=1/a;return q.elements[0]*=h,q.elements[1]*=h,q.elements[2]*=h,q.elements[4]*=u,q.elements[5]*=u,q.elements[6]*=u,q.elements[8]*=c,q.elements[9]*=c,q.elements[10]*=c,e.setFromRotationMatrix(q),i.x=n,i.y=r,i.z=a,this}makePerspective(t,e,i,s,n,r,a=2e3){const o=this.elements,h=2*n/(e-t),u=2*n/(i-s),c=(e+t)/(e-t),m=(i+s)/(i-s);let d,f;if(a===2e3)d=-(r+n)/(r-n),f=-2*r*n/(r-n);else if(a===2001)d=-r/(r-n),f=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return o[0]=h,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=u,o[9]=m,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=f,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,s,n,r,a=2e3){const o=this.elements,h=1/(e-t),u=1/(i-s),c=1/(r-n),m=(e+t)*h,d=(i+s)*u;let f,y;if(a===2e3)f=(r+n)*c,y=-2*c;else if(a===2001)f=n*c,y=-1*c;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-m,o[1]=0,o[5]=2*u,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=y,o[14]=-f,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<16;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const dt=new z,q=new Y,ai=new z(0,0,0),oi=new z(1,1,1),Q=new z,kt=new z,D=new z,ye=new Y,pe=new xt;class Rt{constructor(t=0,e=0,i=0,s=Rt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,n=s[0],r=s[4],a=s[8],o=s[1],h=s[5],u=s[9],c=s[2],m=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(V(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-V(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(V(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-V(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(m,d),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(V(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-V(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(a,n)):(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,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return ye.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ye,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return pe.setFromEuler(this),this.setFromQuaternion(pe,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}}Rt.DEFAULT_ORDER="XYZ";class hi{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let i=0;i0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.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()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(a,o){return a[o.uuid]===void 0&&(a[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const o=a.shapes;if(Array.isArray(o))for(let h=0,u=o.length;h0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(i.geometries=a),o.length>0&&(i.materials=o),h.length>0&&(i.textures=h),u.length>0&&(i.images=u),c.length>0&&(i.shapes=c),m.length>0&&(i.skeletons=m),d.length>0&&(i.animations=d),f.length>0&&(i.nodes=f)}return i.object=s,i;function r(a){const o=[];for(const h in a){const u=a[h];delete u.metadata,o.push(u)}return o}}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 i=0;i0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const h in o)o[h]!==void 0&&(t[h]=o[h]);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 i=this.attributes;for(const o in i){const h=i[o];t.data.attributes[o]=h.toJSON(t.data)}const s={};let n=!1;for(const o in this.morphAttributes){const h=this.morphAttributes[o],u=[];for(let c=0,m=h.length;c0&&(s[o]=u,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const 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 i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const h in s){const u=s[h];this.setAttribute(h,u.clone(e))}const n=t.morphAttributes;for(const h in n){const u=[],c=n[h];for(let m=0,d=c.length;mt;)e.pop().terminate()}runSubTask(t,e,i){return new Promise((s,n)=>{const r=this.workers[t];if(r.isRunning)throw new Error(`${this.name}: Worker ${t} is already running.`);r.isRunning=!0,r.postMessage(e),r.onerror=a=>{r.isRunning=!1,n(a)},r.onmessage=a=>{a.data.type==="progress"?i&&i(a.data.progress):(i&&i(1),r.isRunning=!1,s(a.data))}})}}const we=0,gi=1,_i=2,Jt=1.25,ze=1,zt=6*4+4+4,Mi=65535,bi=Math.pow(2,-24);function wi(l){return l.index?l.index.count:l.attributes.position.count}function Ut(l){return wi(l)/3}function Ae(l,t){const e=Ut(l),i=t||l.drawRange,s=i.start/3,n=(i.start+i.count)/3,r=Math.max(0,s),a=Math.min(e,n)-r;return[{offset:Math.floor(r),count:Math.floor(a)}]}function zi(l,t){if(!l.groups||!l.groups.length)return Ae(l,t);const e=[],i=new Set,s=t||l.drawRange,n=s.start/3,r=(s.start+s.count)/3;for(const o of l.groups){const h=o.start/3,u=(o.start+o.count)/3;i.add(Math.max(n,h)),i.add(Math.min(r,u))}const a=Array.from(i.values()).sort((o,h)=>o-h);for(let o=0;oo&&(o=w),Mf&&(f=M);const _=l[p+2],S=l[p+3],B=_-S,E=_+S;Bh&&(h=E),_y&&(y=_);const C=l[p+4],k=l[p+5],T=C-k,U=C+k;Tu&&(u=U),Cx&&(x=C)}i[0]=n,i[1]=r,i[2]=a,i[3]=o,i[4]=h,i[5]=u,s[0]=c,s[1]=m,s[2]=d,s[3]=f,s[4]=y,s[5]=x}function Ai(l,t=null,e=null,i=null){const s=l.attributes.position,n=l.index?l.index.array:null,r=Ut(l),a=s.normalized;let o;t===null?(o=new Float32Array(r*6*4),e=0,i=r):(o=t,e=e||0,i=i||r);const h=s.array,u=s.offset||0;let c=3;s.isInterleavedBufferAttribute&&(c=s.data.stride);const m=["getX","getY","getZ"];for(let d=e;dS&&(S=g),w>S&&(S=w);const B=(S-_)/2,E=M*2;o[y+E+0]=_+B,o[y+E+1]=B+(Math.abs(_)+B)*bi}}return o}function Se(l){let t=-1,e=-1/0;for(let i=0;i<3;i++){const s=l[i+3]-l[i];s>e&&(e=s,t=i)}return t}function Be(l,t){t.set(l)}function Ce(l,t,e){let i,s;for(let n=0;n<3;n++){const r=n+3;i=l[n],s=t[n],e[n]=is?i:s}}function Pt(l,t,e){for(let i=0;i<3;i++){const s=t[l+2*i],n=t[l+2*i+1],r=s-n,a=s+n;re[i+3]&&(e[i+3]=a)}}function At(l){const t=l[3]-l[0],e=l[4]-l[1],i=l[5]-l[2];return 2*(t*e+e*i+i*t)}const H=32,Si=(l,t)=>l.candidate-t.candidate,et=new Array(H).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Dt=new Float32Array(6);function Bi(l,t,e,i,s,n){let r=-1,a=0;if(n===we)r=Se(t),r!==-1&&(a=(t[r]+t[r+3])/2);else if(n===gi)r=Se(l),r!==-1&&(a=Ci(e,i,s,r));else if(n===_i){const o=At(l);let h=Jt*s;const u=i*6,c=(i+s)*6;for(let m=0;m<3;m++){const d=t[m],x=(t[m+3]-d)/H;if(s=_.candidate?Pt(b,e,_.rightCacheBounds):(Pt(b,e,_.leftCacheBounds),_.count++)}}for(let b=0;b=H&&(w=H-1);const _=et[w];_.count++,Pt(M,e,_.bounds)}const p=et[H-1];Be(p.bounds,p.rightCacheBounds);for(let M=H-2;M>=0;M--){const b=et[M],g=et[M+1];Ce(b.bounds,g.rightCacheBounds,b.rightCacheBounds)}let A=0;for(let M=0;M=o;)a--;if(r=o;)a--;if(rRi)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return St[e+6]=h/4,h=ee(h,a),St[e+7]=o,h}}function Fi(l,t){const e=(l.index?l.index.count:l.attributes.position.count)/3,i=e>2**16,s=i?4:2,n=new SharedArrayBuffer(e*s),r=i?new Uint32Array(n):new Uint16Array(n);for(let a=0,o=r.length;a=n&&(p=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(m))),_<=a||B>=n)return M(w+_),g.offset=w,g.count=_,g;const E=Bi(g.boundingData,S,t,w,_,o);if(E.axis===-1)return M(w+_),g.offset=w,g.count=_,g;const C=f(c,d,t,w,_,E);if(C===w||C===w+_)M(w+_),g.offset=w,g.count=_;else{g.splitAxis=E.axis;const k=new Kt,T=w,U=C-w;g.left=k,Qt(t,T,U,k.boundingData,x),b(k,T,U,x,B+1);const N=new Kt,j=C,X=_-U;g.right=N,Qt(t,j,X,N.boundingData,x),b(N,j,X,x,B+1)}return g}}const ie={strategy:we,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};let se=!1,Fe=0;const Bt=new xi(()=>new Worker(self.location.href,{type:"module"}));onmessage=async({data:l})=>{if(se)throw new Error("Worker is already running a task.");const{operation:t}=l;if(t==="BUILD_BVH"){se=!0;const{maxWorkerCount:e,index:i,position:s,options:n}=l;Bt.setWorkerCount(Je.floorPowerOfTwo(e));const r=re(i,s),a=n.indirect?Ae(r,n.range):zi(r,n.range),o=n.indirect?Fi(r):null,h=Ut(r),u=new Float32Array(new SharedArrayBuffer(h*6*4)),c=[];for(let x=0,p=Bt.workerCount;x{d+=.1*x,ne(d)}):null},y=[];for(let x=0,p=a.length;x{d+=.9*X/S,ne(d)})).then(X=>{const rt=X.buffer;T.buffer=rt,w+=rt.byteLength});A.push(j)}else _++}await Promise.all(A);const B=n.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,E=new B(w+_*zt);ke(0,b,E),y.push(E)}postMessage({error:null,serialized:{roots:y,index:i,indirectBuffer:o},position:s,progress:1}),se=!1}else if(t==="BUILD_SUBTREE"){const{offset:e,count:i,indirectBuffer:s,index:n,position:r,triangleBounds:a,options:o}=l,h={_indirectBuffer:s,geometry:re(n,r)},u={...ie,...o,onProgress:o.includedProgressCallback?ne:null},c=Re(h,a,e,i,u),m=te(c),d=new ArrayBuffer(zt*m);ke(0,c,d),postMessage({type:"result",buffer:d,progress:1},[d])}else if(t==="BUILD_TRIANGLE_BOUNDS"){const{index:e,position:i,triangleBounds:s,offset:n,count:r}=l,a=re(e,i);Ai(a,s,n,r),postMessage({type:"result"})}};function Ie(l){let t=0;return function(i){l(i-t),t=i}}function ne(l){l=Math.min(l,1);const t=performance.now();t-Fe>=10&&l!==1&&(postMessage({error:null,progress:l,type:"progress"}),Fe=t)}function re(l,t){const e=new $t;return l&&(e.index=new tt(l,1,!1)),e.setAttribute("position",new tt(t,3)),e}function Ii(l){const t=[];return e(l),t;function e(i,s=0){i.depth=s,t.push(i),!!i.count||(e(i.left,s+1),e(i.right,s+1))}}})(); diff --git a/example/bundle/assets/physics-CoIq-Rhb.js b/example/bundle/assets/physics-CoIq-Rhb.js new file mode 100644 index 00000000..150748f7 --- /dev/null +++ b/example/bundle/assets/physics-CoIq-Rhb.js @@ -0,0 +1 @@ +import{v as X,V as P,W as K,k as N,S as Q,F as Z,D as _,H as $,P as ee,R as te,u as ae,ab as k,M as W,C as I,b as oe,d as ie,e as ne,ac as se,c as re}from"./ExtendedTriangle-Chm2bbkR.js";import{G as de}from"./GLTFLoader-Dl6abS6P.js";import{O as ce}from"./OrbitControls-lzJCl7xY.js";import{S as le}from"./stats.min-GTpOrGrX.js";import{g as pe}from"./lil-gui.module.min-Bc0DeA9g.js";import{M as he}from"./MeshBVH-CPVAl5W3.js";import{M as me}from"./MeshBVHHelper-jLfel8l5.js";import{S as ue}from"./StaticGeometryGenerator-8L97b6eW.js";import"./BufferGeometryUtils-Cscy-pCt.js";import"./_commonjsHelpers-Cpj98o6Y.js";const r={displayCollider:!1,displayBVH:!1,displayParents:!1,visualizeDepth:10,gravity:-9.8,physicsSteps:5,simulationSpeed:1,sphereSize:1,pause:!1,step:()=>{const a=r.physicsSteps;for(let i=0;i{x.displayParents=c,x.update()}),o.add(r,"visualizeDepth",1,20,1).onChange(c=>{x.depth=c,x.update()}),o.open();const t=C.addFolder("Physics");t.add(r,"physicsSteps",0,30,1),t.add(r,"gravity",-100,100,.01).onChange(c=>{r.gravity=parseFloat(c)}),t.add(r,"simulationSpeed",0,5,.01),t.add(r,"sphereSize",.2,5,.1),t.add(r,"pause"),t.add(r,"step"),t.open(),C.add(r,"explode"),C.add(r,"reset"),C.open();const n=new te,m=new ae;let s=0,w=0;p.domElement.addEventListener("pointerdown",c=>{s=c.clientX,w=c.clientY}),p.domElement.addEventListener("pointerup",c=>{if(Math.abs(c.clientX-s)+Math.abs(c.clientY-w)>2)return;m.x=c.clientX/window.innerWidth*2-1,m.y=-(c.clientY/window.innerHeight)*2+1,n.setFromCamera(m,u);const H=O();H.position.copy(u.position).addScaledVector(n.ray.direction,3),H.velocity.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).addScaledVector(n.ray.direction,10*Math.random()+15).multiplyScalar(.5)}),window.addEventListener("resize",function(){u.aspect=window.innerWidth/window.innerHeight,u.updateProjectionMatrix(),p.setSize(window.innerWidth,window.innerHeight)},!1),window.createSphere=O}function ye(){new de().load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/low-poly-jungle-scene/scene.gltf",a=>{S=a.scene,S.scale.setScalar(.05);const i=new k(65535,9);i.distance=7,i.position.set(-100,-40,100),S.add(i);const e=new k(16768358,9);e.distance=15,e.intensity=5,e.position.set(80,80,135),e.shadow.normalBias=.01,e.shadow.bias=-.001,e.shadow.mapSize.setScalar(1024),e.castShadow=!0,S.add(e),S.updateMatrixWorld(!0);const o=new ue(S);o.attributes=["position"];const t=o.generate();t.boundsTree=new he(t),f=new W(t),f.material.wireframe=!0,f.material.opacity=.5,f.material.transparent=!0,x=new me(f,r.visualizeDepth),h.add(x),h.add(f),h.add(S),S.traverse(n=>{n.material&&(n.castShadow=!0,n.receiveShadow=!0,n.material.shadowSide=2)})})}function j(a,i,e,o,t,n=0){if(ts.intersectsSphere(l),intersectsTriangle:s=>{s.closestPointToPoint(l.center,d),d.sub(l.center);const w=d.length();if(ws.distanceToPoint(l.center)-l.radius}),m){d.subVectors(l.center,n.center).normalize(),t.velocity.reflect(d);const s=t.velocity.dot(d);t.velocity.addScaledVector(d,-s*.5),t.velocity.multiplyScalar(Math.max(1-a,0)),n.center.copy(l.center),D.copy(l.center).addScaledVector(d,-l.radius),j(t,null,D,d,s,.05)}}for(let e=0,o=y.length;eg.dot(s.velocity)?(L=F*v*(M-V)/(M+V),E=F*v*2*M/(M+V),L-=v):(L=F*v*2*V/(M+V),E=F*v*(V-M)/(M+V),E-=v),g.normalize(),t.velocity.addScaledVector(g,L),s.velocity.addScaledVector(g,E),D.copy(n.center).addScaledVector(d,-n.radius),j(t,s,D,d,v,0)}}t.position.copy(n.center)}}function ge(){y.forEach(a=>{a.material.dispose(),a.geometry.dispose(),h.remove(a)}),y.length=0,b.forEach(a=>{a.material.dispose(),a.geometry.dispose(),h.remove(a)}),b.length=0}function ve(){const a=new P;y.forEach(i=>{a.copy(i.position),a.y+=10,a.normalize(),i.velocity.addScaledVector(a,120)})}function q(a){if(f){const i=r.physicsSteps;for(let e=0;e=1&&(b.splice(i,1),o.parent.remove(o),o.geometry.dispose(),o.material.dispose(),i--,e--)}}function A(){G.update(),requestAnimationFrame(A);const a=Math.min(Y.getDelta(),.1);f&&(f.visible=r.displayCollider,x.visible=r.displayBVH,r.pause||q(r.simulationSpeed*a)),p.render(h,u)} diff --git a/example/bundle/assets/pointCloudIntersection-93xKCvxP.js b/example/bundle/assets/pointCloudIntersection-93xKCvxP.js new file mode 100644 index 00000000..5f1424cb --- /dev/null +++ b/example/bundle/assets/pointCloudIntersection-93xKCvxP.js @@ -0,0 +1,2 @@ +import{C as $,ad as J,ae as K,f as k,af as A,M as W,u as Q,R as E,W as ee,S as te,P as ne,ag as se,ah as re,c as O,b as oe,j as ae}from"./ExtendedTriangle-Chm2bbkR.js";import{S as ie}from"./Stats-9dH8FB2H.js";import{O as ce}from"./OrbitControls-lzJCl7xY.js";import{g as le}from"./lil-gui.module.min-Bc0DeA9g.js";import{M as ue}from"./MeshBVHHelper-jLfel8l5.js";import{C as Y,A as de,S as pe,N as q,I as me}from"./MeshBVH-CPVAl5W3.js";import{a as he,c as fe,d as ge}from"./ExtensionUtilities-0qN33-Z7.js";const g=new $;class ye extends J{constructor(l){super(l),this.propertyNameMapping={},this.customPropertyMapping={}}load(l,P,T,x){const h=this,p=new K(this.manager);p.setPath(this.path),p.setResponseType("arraybuffer"),p.setRequestHeader(this.requestHeader),p.setWithCredentials(this.withCredentials),p.load(l,function(u){try{P(h.parse(u))}catch(v){x?x(v):console.error(v),h.manager.itemError(l)}},T,x)}setPropertyNameMapping(l){this.propertyNameMapping=l}setCustomPropertyNameMapping(l){this.customPropertyMapping=l}parse(l){function P(e,r=0){const n=/^ply([\s\S]*)end_header(\r\n|\r|\n)/;let t="";const s=n.exec(e);s!==null&&(t=s[1]);const o={comments:[],elements:[],headerLength:r,objInfo:""},i=t.split(/\r\n|\r|\n/);let a;function w(d,m){const c={type:d[0]};return c.type==="list"?(c.name=d[3],c.countType=d[1],c.itemType=d[2]):c.name=d[1],c.name in m&&(c.name=m[c.name]),c}for(let d=0;dt.name);function n(t){for(let s=0,o=t.length;s0&&r.setIndex(e.indices),r.setAttribute("position",new A(e.vertices,3)),e.normals.length>0&&r.setAttribute("normal",new A(e.normals,3)),e.uvs.length>0&&r.setAttribute("uv",new A(e.uvs,2)),e.colors.length>0&&r.setAttribute("color",new A(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(r=r.toNonIndexed(),e.faceVertexUvs.length>0&&r.setAttribute("uv",new A(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&r.setAttribute("color",new A(e.faceVertexColors,3)));for(const n of Object.keys(H.customPropertyMapping))e[n].length>0&&r.setAttribute(n,new A(e[n],H.customPropertyMapping[n].length));return r.computeBoundingSphere(),r}function f(e,r,n,t){if(r==="vertex"){e.vertices.push(n[t.attrX],n[t.attrY],n[t.attrZ]),t.attrNX!==null&&t.attrNY!==null&&t.attrNZ!==null&&e.normals.push(n[t.attrNX],n[t.attrNY],n[t.attrNZ]),t.attrS!==null&&t.attrT!==null&&e.uvs.push(n[t.attrS],n[t.attrT]),t.attrR!==null&&t.attrG!==null&&t.attrB!==null&&(g.setRGB(n[t.attrR]/255,n[t.attrG]/255,n[t.attrB]/255).convertSRGBToLinear(),e.colors.push(g.r,g.g,g.b));for(const s of Object.keys(H.customPropertyMapping))for(const o of H.customPropertyMapping[s])e[s].push(n[o])}else if(r==="face"){const s=n.vertex_indices||n.vertex_index,o=n.texcoord;s.length===3?(e.indices.push(s[0],s[1],s[2]),o&&o.length===6&&(e.faceVertexUvs.push(o[0],o[1]),e.faceVertexUvs.push(o[2],o[3]),e.faceVertexUvs.push(o[4],o[5]))):s.length===4&&(e.indices.push(s[0],s[1],s[3]),e.indices.push(s[1],s[2],s[3])),t.attrR!==null&&t.attrG!==null&&t.attrB!==null&&(g.setRGB(n[t.attrR]/255,n[t.attrG]/255,n[t.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(g.r,g.g,g.b),e.faceVertexColors.push(g.r,g.g,g.b),e.faceVertexColors.push(g.r,g.g,g.b))}}function z(e,r){const n={};let t=0;for(let s=0;ss.getInt8(a),size:1};case"uint8":case"uchar":return{read:a=>s.getUint8(a),size:1};case"int16":case"short":return{read:a=>s.getInt16(a,i),size:2};case"uint16":case"ushort":return{read:a=>s.getUint16(a,i),size:2};case"int32":case"int":return{read:a=>s.getInt32(a,i),size:4};case"uint32":case"uint":return{read:a=>s.getUint32(a,i),size:4};case"float32":case"float":return{read:a=>s.getFloat32(a,i),size:4};case"float64":case"double":return{read:a=>s.getFloat64(a,i),size:8}}}for(let s=0,o=e.length;s=this.arr.length}next(){return this.arr[this.i++]}}W.prototype.raycast=he;k.prototype.computeBoundsTree=fe;k.prototype.disposeBoundsTree=ge;let F,_,B,b,C,M,L,X,D=new Q,S;const we="https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/point-cloud-porsche/scene.ply",V=new E,y={displayHelper:!1,helperDepth:10,displayParents:!1,strategy:Y,pointSize:.005,raycastThreshold:.005,useBVH:!0};function Te(){X=document.getElementById("output"),b=new ee({antialias:!0}),b.setPixelRatio(window.devicePixelRatio),b.setSize(window.innerWidth,window.innerHeight),b.setClearColor(1251612,1),document.body.appendChild(b.domElement),_=new te,B=new ne(75,window.innerWidth/window.innerHeight,.1,50),B.position.set(3,3,3),B.far=100,B.updateProjectionMatrix(),new ce(B,b.domElement),F=new ie,document.body.appendChild(F.dom),window.addEventListener("resize",function(){B.aspect=window.innerWidth/window.innerHeight,B.updateProjectionMatrix(),b.setSize(window.innerWidth,window.innerHeight)},!1),new ye().load(we,u=>{u.center();const v=new se({size:y.pointSize,vertexColors:!0});L=new re(u,v),L.matrixAutoUpdate=!1,_.add(L);const f=[],z=u.clone();let R=z.attributes.position.count;for(let I=0,N=R;I{M.displayParents=u,M.update()}),h.add(y,"helperDepth",1,20,1).name("depth").onChange(u=>{M.depth=parseInt(u),M.update()}),h.open();const p=x.addFolder("points");p.add(y,"useBVH"),p.add(y,"strategy",{CENTER:Y,AVERAGE:de,SAH:pe}).onChange(u=>{console.time("computeBoundsTree"),C.geometry.computeBoundsTree({strategy:parseInt(u)}),console.timeEnd("computeBoundsTree"),M.update()}),p.add(y,"pointSize",.001,.01,.001),p.add(y,"raycastThreshold",.001,.01,.001),p.open()}window.addEventListener("pointermove",j=>{if(!C)return;D.x=j.clientX/window.innerWidth*2-1,D.y=-(j.clientY/window.innerHeight)*2+1,V.setFromCamera(D,B);const l=window.performance.now();if(y.useBVH){S.visible=!1;const T=new ae;T.copy(C.matrixWorld).invert(),V.ray.applyMatrix4(T);const h=V.params.Points.threshold/((C.scale.x+C.scale.y+C.scale.z)/3),p=h*h,{ray:u}=V;let v=1/0;C.geometry.boundsTree.shapecast({boundsTraverseOrder:f=>f.distanceToPoint(u.origin),intersectsBounds:(f,z,R)=>R>v?q:(f.expandByScalar(h),u.intersectsBox(f)?me:q),intersectsTriangle:f=>{if(u.distanceSqToPoint(f.a)c()),a.add(e.raycasters,"speed").min(0).max(20),a.add(e.raycasters,"near").min(0).max(f).onChange(()=>c()),a.add(e.raycasters,"far").min(0).max(f).onChange(()=>c()),a.open();const n=u.addFolder("Mesh");n.add(e.mesh,"useBoundsTree").onChange(()=>c()),n.add(e.mesh,"splitStrategy",{CENTER:F,SAH:Y,AVERAGE:Z}).onChange(()=>c()),n.add(e.mesh,"count").min(1).max(300).step(1).onChange(()=>c()),n.add(e.mesh,"speed").min(0).max(20),n.add(e.mesh,"visualizeBounds").onChange(()=>c()),n.add(e.mesh,"displayParents").onChange(()=>c()),n.add(e.mesh,"visualBoundsDepth").min(1).max(20).step(1).onChange(()=>c()),n.open(),window.addEventListener("resize",function(){x.aspect=window.innerWidth/window.innerHeight,x.updateProjectionMatrix(),g.setSize(window.innerWidth,window.innerHeight)},!1)}function oe(){const t=new M(i,H);t.rotation.x=Math.random()*10,t.rotation.y=Math.random()*10,l.push(t),s.add(t)}function re(){const t=new D,o=new P({color:16777215}),d=new M(z,o),p=new M(z,o);p.scale.multiplyScalar(.25),d.scale.multiplyScalar(.5);const h=new M(ae,new P({color:16777215,transparent:!0,opacity:.25}));t.add(h),t.add(d),t.add(p),y.add(t),d.position.set(f,0,0),t.rotation.x=Math.random()*10,t.rotation.y=Math.random()*10,t.rotation.z=Math.random()*10;const u=new S,a=new S,n=Math.random()-.5,C=Math.random()-.5,V=Math.random()-.5;T.push({update:()=>{t.rotation.x+=n*1e-4*e.raycasters.speed*w,t.rotation.y+=C*1e-4*e.raycasters.speed*w,t.rotation.z+=V*1e-4*e.raycasters.speed*w,d.updateMatrixWorld(),u.setFromMatrixPosition(d.matrixWorld),a.copy(u).multiplyScalar(-1).normalize(),m.set(u,a),m.firstHitOnly=!0;const E=m.intersectObject(s,!0),v=E.length?E[0].distance:f;p.position.set(f-v,0,0);const A=E.length?v-m.near:v-m.near-(f-m.far);h.position.set(f-m.near-A/2,0,0),h.scale.set(1,A,1),h.rotation.z=Math.PI/2},remove:()=>{y.remove(t)}})}function c(){for(m.near=e.raycasters.near,m.far=e.raycasters.far;T.length>e.raycasters.count;)T.pop().remove();for(;T.lengthe.mesh.count;)s.remove(l.pop());for(;l.lengtha+(n-a)*C,p=(l.length-1)/299,h=d(0,2,p),u=d(1,.2,p);l.forEach(a=>{a.scale.set(1,1,1).multiplyScalar(u);const n=new S(0,1,0);n.applyAxisAngle(new S(1,0,0),Math.PI*Math.random()),n.applyAxisAngle(new S(0,1,0),2*Math.PI*Math.random()),n.multiplyScalar(h),a.position.set(n.x,n.y,n.z)})}const o=e.mesh.visualizeBounds&&i.boundsTree;r&&!o&&(s.remove(r),r=null),!r&&o&&(r=new _(l[0]),s.add(r)),r&&(r.depth=e.mesh.visualBoundsDepth,r.displayParents=e.mesh.displayParents,r.update())}function W(){B.begin();const t=window.performance.now();b=b||t,w=t-b,s.rotation.x+=1e-4*e.mesh.speed*w,s.rotation.y+=1e-4*e.mesh.speed*w,s.children.forEach(o=>{o.rotation.x+=1e-4*e.mesh.speed*w,o.rotation.y+=1e-4*e.mesh.speed*w}),s.updateMatrixWorld(),T.forEach(o=>o.update()),g.render(y,x),b=t,B.end(),requestAnimationFrame(W)} diff --git a/example/bundle/assets/sculpt-5vTjmlgn.js b/example/bundle/assets/sculpt-5vTjmlgn.js new file mode 100644 index 00000000..5591dc8e --- /dev/null +++ b/example/bundle/assets/sculpt-5vTjmlgn.js @@ -0,0 +1 @@ +import{M as ne,f as ae,V as b,u as se,W as de,S as ce,F as le,D as pe,A as me,p as fe,P as ue,ak as Y,al as we,R as ie,am as he,o as Q,j as ye,v as ge,l as xe,x as be}from"./ExtendedTriangle-Chm2bbkR.js";import{S as ve}from"./Stats-9dH8FB2H.js";import{g as Se}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as Be}from"./OrbitControls-lzJCl7xY.js";import{a as Ce}from"./BufferGeometryUtils-Cscy-pCt.js";import{M as Me}from"./MeshBVHHelper-jLfel8l5.js";import{I as $,a as Ee,N as ze}from"./MeshBVH-CPVAl5W3.js";import{a as Ae,c as Te,d as Pe}from"./ExtensionUtilities-0qN33-Z7.js";ne.prototype.raycast=Ae;ae.prototype.computeBoundsTree=Te;ae.prototype.disposeBoundsTree=Pe;let U,x,M,C,I,o,h,S,y,He=new b(0,0,1),O=!1,B=new se,W=new se,Z=!1,ee=!1,v=new b,q,oe=!1;const t={matcap:"Clay",size:.1,brush:"clay",intensity:50,maxSteps:10,invert:!1,symmetrical:!0,flatShading:!1,depth:10,displayHelper:!1},H={};Ie();re();function te(){o&&(o.geometry.dispose(),o.material.dispose(),x.remove(o));let p=new he(1,100);p.deleteAttribute("uv"),p=Ce(p),p.attributes.position.setUsage(Q),p.attributes.normal.setUsage(Q),p.computeBoundsTree({setBoundingBox:!1}),o=new ne(p,q),o.frustumCulled=!1,x.add(o),y||(y=new Me(o,t.depth),t.displayHelper&&x.add(y)),y.mesh=o,y.update()}function Ie(){C=new de({antialias:!0}),C.setPixelRatio(window.devicePixelRatio),C.setSize(window.innerWidth,window.innerHeight),C.setClearColor(394761,1),C.outputEncoding=void 0,document.body.appendChild(C.domElement),C.domElement.style.touchAction="none",x=new ce,x.fog=new le(2503224/2,20,60);const a=new pe(16777215,.5);a.position.set(1,1,1),x.add(a),x.add(new me(16777215,.4));const n=[new b,new b(0,0,1)];for(let e=0;e<50;e++){const s=e+1,r=Math.sin(2*Math.PI*e/50),d=Math.cos(2*Math.PI*e/50),i=Math.sin(2*Math.PI*s/50),f=Math.cos(2*Math.PI*s/50);n.push(new b(r,d,0),new b(i,f,0))}h=new fe,h.geometry.setFromPoints(n),h.material.color.set(16485376),x.add(h),S=h.clone(),x.add(S),M=new ue(75,window.innerWidth/window.innerHeight,.1,50),M.position.set(0,0,3),M.far=100,M.updateProjectionMatrix(),U=new ve,document.body.appendChild(U.dom),H.Clay=new Y().load("../textures/B67F6B_4B2E2A_6C3A34_F3DBC6-256px.png"),H["Red Wax"]=new Y().load("../textures/763C39_431510_210504_55241C-256px.png"),H["Shiny Green"]=new Y().load("../textures/3B6E10_E3F2C3_88AC2E_99CE51-256px.png"),H.Normal=new Y().load("../textures/7877EE_D87FC5_75D9C7_1C78C0-256px.png"),q=new we({flatShading:t.flatShading});for(const e in H)H[e].encoding=void 0;te();const m=new Se;m.add(t,"matcap",Object.keys(H));const c=m.addFolder("Sculpting");c.add(t,"brush",["normal","clay","flatten"]),c.add(t,"size").min(.025).max(.25).step(.005),c.add(t,"intensity").min(1).max(100).step(1),c.add(t,"maxSteps").min(1).max(25).step(1),c.add(t,"symmetrical"),c.add(t,"invert"),c.add(t,"flatShading").onChange(e=>{o.material.flatShading=e,o.material.needsUpdate=!0}),c.open();const l=m.addFolder("BVH Helper");l.add(t,"depth").min(1).max(20).step(1).onChange(e=>{y.depth=parseFloat(e),y.update()}),l.add(t,"displayHelper").onChange(e=>{e?(x.add(y),y.update()):x.remove(y)}),l.open(),m.add({reset:te},"reset"),m.add({rebuildBVH:()=>{o.geometry.computeBoundsTree({setBoundingBox:!1}),y.update()}},"rebuildBVH"),m.open(),window.addEventListener("resize",function(){M.aspect=window.innerWidth/window.innerHeight,M.updateProjectionMatrix(),C.setSize(window.innerWidth,window.innerHeight)},!1),window.addEventListener("pointermove",function(e){B.x=e.clientX/window.innerWidth*2-1,B.y=-(e.clientY/window.innerHeight)*2+1,O=!0}),window.addEventListener("pointerdown",e=>{B.x=e.clientX/window.innerWidth*2-1,B.y=-(e.clientY/window.innerHeight)*2+1,Z=!!(e.buttons&3),oe=!!(e.buttons&2),O=!0;const s=new ie;s.setFromCamera(B,M),s.firstHitOnly=!0;const r=s.intersectObject(o);I.enabled=r.length===0},!0),window.addEventListener("pointerup",e=>{Z=!!(e.buttons&3),e.pointerType==="touch"&&(O=!1)}),window.addEventListener("contextmenu",function(e){e.preventDefault()}),window.addEventListener("wheel",function(e){let s=e.deltaY;e.deltaMode===1&&(s*=40),e.deltaMode===2&&(s*=40),t.size+=s*1e-4,t.size=Math.max(Math.min(t.size,.25),.025),m.controllersRecursive().forEach(r=>r.updateDisplay())}),I=new Be(M,C.domElement),I.minDistance=1.5,I.addEventListener("start",function(){this.active=!0}),I.addEventListener("end",function(){this.active=!1})}function X(p,a,n=!1,m={}){const{accumulatedTriangles:c=new Set,accumulatedIndices:l=new Set,accumulatedTraversedNodeIndices:e=new Set}=m,s=new ye;s.copy(o.matrixWorld).invert();const r=new ge;r.center.copy(p).applyMatrix4(s),r.radius=t.size;const d=new Set,i=new b,f=new b,z=o.geometry.index,g=o.geometry.attributes.position,F=o.geometry.attributes.normal,V=new Set;o.geometry.boundsTree.shapecast({intersectsBounds:(u,N,L,w,E)=>{e.add(E);const D=r.intersectsBox(u),{min:_,max:R}=u;if(D){for(let A=0;A<=1;A++)for(let T=0;T<=1;T++)for(let P=0;P<=1;P++)if(i.set(A===0?_.x:R.x,T===0?_.y:R.y,P===0?_.z:R.z),!r.containsPoint(i))return $;return Ee}return D?$:ze},intersectsTriangle:(u,N,L)=>{const w=N;V.add(w),c.add(w);const E=3*N,D=E+0,_=E+1,R=E+2,A=z.getX(D),T=z.getX(_),P=z.getX(R);return L?(d.add(A),d.add(T),d.add(P),l.add(A),l.add(T),l.add(P)):(r.containsPoint(u.a)&&(d.add(A),l.add(A)),r.containsPoint(u.b)&&(d.add(T),l.add(T)),r.containsPoint(u.c)&&(d.add(P),l.add(P))),!1}});const J=new b;J.copy(p).applyMatrix4(s);const j=new b;let k=0;if(d.forEach(u=>{i.fromBufferAttribute(F,u),f.add(i),n||(k++,i.fromBufferAttribute(g,u),j.add(i))}),f.normalize(),a.quaternion.setFromUnitVectors(He,f),k&&j.multiplyScalar(1/k),n)return;const K=t.intensity*1e-4,G=new xe;G.setFromNormalAndCoplanarPoint(f,j),d.forEach(u=>{i.fromBufferAttribute(g,u);const N=i.distanceTo(J),L=t.invert!==oe?-1:1;let w=1-N/t.size;if(t.brush==="clay"){w=Math.pow(w,3);const E=G.distanceToPoint(i),D=L*Math.min(w*4,1);i.addScaledVector(f,D*K-L*E*D*.3)}else if(t.brush==="normal")w=Math.pow(w,2),i.addScaledVector(f,L*w*K);else if(t.brush==="flatten"){w=Math.pow(w,2);const E=G.distanceToPoint(i);i.addScaledVector(f,-E*w*t.intensity*.01*.5)}g.setXYZ(u,i.x,i.y,i.z),F.setXYZ(u,0,0,0)}),d.size&&(g.needsUpdate=!0)}function Fe(p,a){const n=new b,m=new b,c=o.geometry.index,l=o.geometry.attributes.position,e=o.geometry.attributes.normal,s=new be;p.forEach(r=>{const d=r*3,i=d+0,f=d+1,z=d+2,g=c.getX(i),F=c.getX(f),V=c.getX(z);s.a.fromBufferAttribute(l,g),s.b.fromBufferAttribute(l,F),s.c.fromBufferAttribute(l,V),s.getNormal(m),a.has(g)&&(n.fromBufferAttribute(e,g),n.add(m),e.setXYZ(g,n.x,n.y,n.z)),a.has(F)&&(n.fromBufferAttribute(e,F),n.add(m),e.setXYZ(F,n.x,n.y,n.z)),a.has(V)&&(n.fromBufferAttribute(e,V),n.add(m),e.setXYZ(V,n.x,n.y,n.z))}),a.forEach(r=>{n.fromBufferAttribute(e,r),n.normalize(),e.setXYZ(r,n.x,n.y,n.z)}),e.needsUpdate=!0}function re(){if(requestAnimationFrame(re),U.begin(),q.matcap=H[t.matcap],I.active||!O)h.visible=!1,S.visible=!1,v.setScalar(1/0);else{const p=new ie;p.setFromCamera(B,M),p.firstHitOnly=!0;const a=p.intersectObject(o,!0)[0];if(a)if(h.visible=!0,h.scale.set(t.size,t.size,.1),h.position.copy(a.point),S.visible=t.symmetrical,S.scale.set(t.size,t.size,.1),S.position.copy(a.point),S.position.x*=-1,I.enabled=!1,v.x===1/0&&v.copy(a.point),!(Z||ee))X(a.point,h,!0),t.symmetrical&&(a.point.x*=-1,X(a.point,S,!0),a.point.x*=-1),W.copy(B),v.copy(a.point);else{const n=(B.x-W.x)*window.innerWidth*window.devicePixelRatio,m=(B.y-W.y)*window.innerHeight*window.devicePixelRatio;let c=Math.sqrt(n*n+m*m),l=a.point.distanceTo(v);const e=t.size*.15,s=Math.max(e/l,1/t.maxSteps),r=c*s;let d=0;const i=new Set,f=new Set,z=new Set,g={accumulatedTriangles:i,accumulatedIndices:f,accumulatedTraversedNodeIndices:z};for(;l>e&&c>t.size*200/a.distance&&(W.lerp(B,s),v.lerp(a.point,s),l-=e,c-=r,X(v,h,!1,g),t.symmetrical&&(v.x*=-1,X(v,S,!1,g),v.x*=-1),d++,!(d>t.maxSteps)););d>0?(Fe(i,f),o.geometry.boundsTree.refit(z),y.parent!==null&&y.update()):(X(a.point,h,!0),t.symmetrical&&(a.point.x*=-1,X(a.point,S,!0),a.point.x*=-1))}else I.enabled=!0,h.visible=!1,S.visible=!1,W.copy(B),v.setScalar(1/0)}ee=Z,C.render(x,M),U.end()} diff --git a/example/bundle/assets/sdfGeneration-Cn_uPCwa.js b/example/bundle/assets/sdfGeneration-Cn_uPCwa.js new file mode 100644 index 00000000..1204316d --- /dev/null +++ b/example/bundle/assets/sdfGeneration-Cn_uPCwa.js @@ -0,0 +1,400 @@ +import{a4 as C,j as h,V as u,W as J,S as Z,D as ee,A as te,P as oe,an as ne,a as ie,M as re,d as ae,ao as se,a9 as G,U as L,Y as ce,a0 as T,ap as de,x as le,aq as ue}from"./ExtendedTriangle-Chm2bbkR.js";import{G as ve}from"./GLTFLoader-Dl6abS6P.js";import{F as M}from"./Pass-DgEPdZ3p.js";import{O as fe}from"./OrbitControls-lzJCl7xY.js";import{g as me}from"./lil-gui.module.min-Bc0DeA9g.js";import{S as pe}from"./stats.min-GTpOrGrX.js";import{G as xe}from"./GenerateMeshBVHWorker-B43A4fin.js";import{M as he,c as ge,b as be,a as ye}from"./bvh_struct_definitions.glsl-Drzlg63W.js";import{M as we}from"./meshopt_decoder.module-Cf1-17OU.js";import{S as Te}from"./StaticGeometryGenerator-8L97b6eW.js";import"./BufferGeometryUtils-Cscy-pCt.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./MeshBVH-CPVAl5W3.js";const De=` + +float dot2( vec3 v ) { + + return dot( v, v ); + +} + +// https://www.shadertoy.com/view/ttfGWl +vec3 closestPointToTriangle( vec3 p, vec3 v0, vec3 v1, vec3 v2, out vec3 barycoord ) { + + vec3 v10 = v1 - v0; + vec3 v21 = v2 - v1; + vec3 v02 = v0 - v2; + + vec3 p0 = p - v0; + vec3 p1 = p - v1; + vec3 p2 = p - v2; + + vec3 nor = cross( v10, v02 ); + + // method 2, in barycentric space + vec3 q = cross( nor, p0 ); + float d = 1.0 / dot2( nor ); + float u = d * dot( q, v02 ); + float v = d * dot( q, v10 ); + float w = 1.0 - u - v; + + if( u < 0.0 ) { + + w = clamp( dot( p2, v02 ) / dot2( v02 ), 0.0, 1.0 ); + u = 0.0; + v = 1.0 - w; + + } else if( v < 0.0 ) { + + u = clamp( dot( p0, v10 ) / dot2( v10 ), 0.0, 1.0 ); + v = 0.0; + w = 1.0 - u; + + } else if( w < 0.0 ) { + + v = clamp( dot( p1, v21 ) / dot2( v21 ), 0.0, 1.0 ); + w = 0.0; + u = 1.0-v; + + } + + barycoord = vec3( u, v, w ); + return u * v1 + v * v2 + w * v0; + +} + +float distanceToTriangles( + // geometry info and triangle range + sampler2D positionAttr, usampler2D indexAttr, uint offset, uint count, + + // point and cut off range + vec3 point, float closestDistanceSquared, + + // outputs + inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord, inout float side, inout vec3 outPoint +) { + + bool found = false; + vec3 localBarycoord; + for ( uint i = offset, l = offset + count; i < l; i ++ ) { + + uvec3 indices = uTexelFetch1D( indexAttr, i ).xyz; + vec3 a = texelFetch1D( positionAttr, indices.x ).rgb; + vec3 b = texelFetch1D( positionAttr, indices.y ).rgb; + vec3 c = texelFetch1D( positionAttr, indices.z ).rgb; + + // get the closest point and barycoord + vec3 closestPoint = closestPointToTriangle( point, a, b, c, localBarycoord ); + vec3 delta = point - closestPoint; + float sqDist = dot2( delta ); + if ( sqDist < closestDistanceSquared ) { + + // set the output results + closestDistanceSquared = sqDist; + faceIndices = uvec4( indices.xyz, i ); + faceNormal = normalize( cross( a - b, b - c ) ); + barycoord = localBarycoord; + outPoint = closestPoint; + side = sign( dot( faceNormal, delta ) ); + + } + + } + + return closestDistanceSquared; + +} + +float distanceSqToBounds( vec3 point, vec3 boundsMin, vec3 boundsMax ) { + + vec3 clampedPoint = clamp( point, boundsMin, boundsMax ); + vec3 delta = point - clampedPoint; + return dot( delta, delta ); + +} + +float distanceSqToBVHNodeBoundsPoint( vec3 point, sampler2D bvhBounds, uint currNodeIndex ) { + + uint cni2 = currNodeIndex * 2u; + vec3 boundsMin = texelFetch1D( bvhBounds, cni2 ).xyz; + vec3 boundsMax = texelFetch1D( bvhBounds, cni2 + 1u ).xyz; + return distanceSqToBounds( point, boundsMin, boundsMax ); + +} + +// use a macro to hide the fact that we need to expand the struct into separate fields +#define bvhClosestPointToPoint( bvh, point, faceIndices, faceNormal, barycoord, side, outPoint ) _bvhClosestPointToPoint( bvh.position, bvh.index, bvh.bvhBounds, bvh.bvhContents, point, faceIndices, faceNormal, barycoord, side, outPoint ) + +float _bvhClosestPointToPoint( + // bvh info + sampler2D bvh_position, usampler2D bvh_index, sampler2D bvh_bvhBounds, usampler2D bvh_bvhContents, + + // point to check + vec3 point, + + // output variables + inout uvec4 faceIndices, inout vec3 faceNormal, inout vec3 barycoord, + inout float side, inout vec3 outPoint + ) { + + // stack needs to be twice as long as the deepest tree we expect because + // we push both the left and right child onto the stack every traversal + int ptr = 0; + uint stack[ BVH_STACK_DEPTH ]; + stack[ 0 ] = 0u; + + float closestDistanceSquared = pow( 100000.0, 2.0 ); + bool found = false; + while ( ptr > - 1 && ptr < BVH_STACK_DEPTH ) { + + uint currNodeIndex = stack[ ptr ]; + ptr --; + + // check if we intersect the current bounds + float boundsHitDistance = distanceSqToBVHNodeBoundsPoint( point, bvh_bvhBounds, currNodeIndex ); + if ( boundsHitDistance > closestDistanceSquared ) { + + continue; + + } + + uvec2 boundsInfo = uTexelFetch1D( bvh_bvhContents, currNodeIndex ).xy; + bool isLeaf = bool( boundsInfo.x & 0xffff0000u ); + if ( isLeaf ) { + + uint count = boundsInfo.x & 0x0000ffffu; + uint offset = boundsInfo.y; + closestDistanceSquared = distanceToTriangles( + bvh_position, bvh_index, offset, count, point, closestDistanceSquared, + + // outputs + faceIndices, faceNormal, barycoord, side, outPoint + ); + + } else { + + uint leftIndex = currNodeIndex + 1u; + uint splitAxis = boundsInfo.x & 0x0000ffffu; + uint rightIndex = boundsInfo.y; + bool leftToRight = distanceSqToBVHNodeBoundsPoint( point, bvh_bvhBounds, leftIndex ) < distanceSqToBVHNodeBoundsPoint( point, bvh_bvhBounds, rightIndex );//rayDirection[ splitAxis ] >= 0.0; + uint c1 = leftToRight ? leftIndex : rightIndex; + uint c2 = leftToRight ? rightIndex : leftIndex; + + // set c2 in the stack so we traverse it later. We need to keep track of a pointer in + // the stack while we traverse. The second pointer added is the one that will be + // traversed first + ptr ++; + stack[ ptr ] = c2; + ptr ++; + stack[ ptr ] = c1; + + } + + } + + return sqrt( closestDistanceSquared ); + +} +`;class Se extends C{constructor(o){super({uniforms:{matrix:{value:new h},zValue:{value:0},bvh:{value:new he}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + } + + `,fragmentShader:` + + precision highp isampler2D; + precision highp usampler2D; + + ${ge} + ${be} + ${ye} + ${De} + + varying vec2 vUv; + + uniform BVH bvh; + uniform float zValue; + uniform mat4 matrix; + + void main() { + + // compute the point in space to check + vec3 point = vec3( vUv, zValue ); + point -= vec3( 0.5 ); + point = ( matrix * vec4( point, 1.0 ) ).xyz; + + // retrieve the distance and other values + uvec4 faceIndices; + vec3 faceNormal; + vec3 barycoord; + float side; + vec3 outPoint; + float dist = bvhClosestPointToPoint( bvh, point.xyz, faceIndices, faceNormal, barycoord, side, outPoint ); + + // if the triangle side is the back then it must be on the inside and the value negative + gl_FragColor = vec4( side * dist, 0, 0, 0 ); + + } + + `}),this.setValues(o)}}class Ie extends C{constructor(o){super({defines:{DISPLAY_GRID:0},uniforms:{sdfTex:{value:null},layer:{value:0},layers:{value:0}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + } + + `,fragmentShader:` + precision highp sampler3D; + + varying vec2 vUv; + uniform sampler3D sdfTex; + uniform float layer; + uniform float layers; + + void main() { + + #if DISPLAY_GRID + + float dim = ceil( sqrt( layers ) ); + vec2 cell = floor( vUv * dim ); + vec2 frac = vUv * dim - cell; + float zLayer = ( cell.y * dim + cell.x ) / ( dim * dim ); + + float dist = texture( sdfTex, vec3( frac, zLayer ) ).r; + gl_FragColor.rgb = dist > 0.0 ? vec3( 0, dist, 0 ) : vec3( - dist, 0, 0 ); + gl_FragColor.a = 1.0; + + #else + + float dist = texture( sdfTex, vec3( vUv, layer ) ).r; + gl_FragColor.rgb = dist > 0.0 ? vec3( 0, dist, 0 ) : vec3( - dist, 0, 0 ); + gl_FragColor.a = 1.0; + + #endif + + #include + + } + `}),this.setValues(o)}}class Pe extends C{constructor(o){super({defines:{MAX_STEPS:500,SURFACE_EPSILON:.001},uniforms:{surface:{value:0},sdfTex:{value:null},normalStep:{value:new u},projectionInverse:{value:new h},sdfTransformInverse:{value:new h}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + } + + `,fragmentShader:` + precision highp sampler3D; + + varying vec2 vUv; + + uniform float surface; + uniform sampler3D sdfTex; + uniform vec3 normalStep; + uniform mat4 projectionInverse; + uniform mat4 sdfTransformInverse; + + #include + + // distance to box bounds + vec2 rayBoxDist( vec3 boundsMin, vec3 boundsMax, vec3 rayOrigin, vec3 rayDir ) { + + vec3 t0 = ( boundsMin - rayOrigin ) / rayDir; + vec3 t1 = ( boundsMax - rayOrigin ) / rayDir; + vec3 tmin = min( t0, t1 ); + vec3 tmax = max( t0, t1 ); + + float distA = max( max( tmin.x, tmin.y ), tmin.z ); + float distB = min( tmax.x, min( tmax.y, tmax.z ) ); + + float distToBox = max( 0.0, distA ); + float distInsideBox = max( 0.0, distB - distToBox ); + return vec2( distToBox, distInsideBox ); + + } + + void main() { + + // get the inverse of the sdf box transform + mat4 sdfTransform = inverse( sdfTransformInverse ); + + // convert the uv to clip space for ray transformation + vec2 clipSpace = 2.0 * vUv - vec2( 1.0 ); + + // get world ray direction + vec3 rayOrigin = vec3( 0.0 ); + vec4 homogenousDirection = projectionInverse * vec4( clipSpace, - 1.0, 1.0 ); + vec3 rayDirection = normalize( homogenousDirection.xyz / homogenousDirection.w ); + + // transform ray into local coordinates of sdf bounds + vec3 sdfRayOrigin = ( sdfTransformInverse * vec4( rayOrigin, 1.0 ) ).xyz; + vec3 sdfRayDirection = normalize( ( sdfTransformInverse * vec4( rayDirection, 0.0 ) ).xyz ); + + // find whether our ray hits the box bounds in the local box space + vec2 boxIntersectionInfo = rayBoxDist( vec3( - 0.5 ), vec3( 0.5 ), sdfRayOrigin, sdfRayDirection ); + float distToBox = boxIntersectionInfo.x; + float distInsideBox = boxIntersectionInfo.y; + bool intersectsBox = distInsideBox > 0.0; + + gl_FragColor = vec4( 0.0 ); + if ( intersectsBox ) { + + // find the surface point in world space + bool intersectsSurface = false; + vec4 localPoint = vec4( sdfRayOrigin + sdfRayDirection * ( distToBox + 1e-5 ), 1.0 ); + vec4 point = sdfTransform * localPoint; + + // ray march + for ( int i = 0; i < MAX_STEPS; i ++ ) { + + // sdf box extends from - 0.5 to 0.5 + // transform into the local bounds space [ 0, 1 ] and check if we're inside the bounds + vec3 uv = ( sdfTransformInverse * point ).xyz + vec3( 0.5 ); + if ( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 || uv.z < 0.0 || uv.z > 1.0 ) { + + break; + + } + + // get the distance to surface and exit the loop if we're close to the surface + float distanceToSurface = texture2D( sdfTex, uv ).r - surface; + if ( distanceToSurface < SURFACE_EPSILON ) { + + intersectsSurface = true; + break; + + } + + // step the ray + point.xyz += rayDirection * abs( distanceToSurface ); + + } + + // find the surface normal + if ( intersectsSurface ) { + + // compute the surface normal + vec3 uv = ( sdfTransformInverse * point ).xyz + vec3( 0.5 ); + float dx = texture( sdfTex, uv + vec3( normalStep.x, 0.0, 0.0 ) ).r - texture( sdfTex, uv - vec3( normalStep.x, 0.0, 0.0 ) ).r; + float dy = texture( sdfTex, uv + vec3( 0.0, normalStep.y, 0.0 ) ).r - texture( sdfTex, uv - vec3( 0.0, normalStep.y, 0.0 ) ).r; + float dz = texture( sdfTex, uv + vec3( 0.0, 0.0, normalStep.z ) ).r - texture( sdfTex, uv - vec3( 0.0, 0.0, normalStep.z ) ).r; + vec3 normal = normalize( vec3( dx, dy, dz ) ); + + // compute some basic lighting effects + vec3 lightDirection = normalize( vec3( 1.0 ) ); + float lightIntensity = + saturate( dot( normal, lightDirection ) ) + + saturate( dot( normal, - lightDirection ) ) * 0.05 + + 0.1; + gl_FragColor.rgb = vec3( lightIntensity ); + gl_FragColor.a = 1.0; + + } + + } + + #include + + } + `}),this.setValues(o)}}const t={gpuGeneration:!0,resolution:75,margin:.2,regenerate:()=>E(),mode:"raymarching",layer:0,surface:.1};let i,a,v,p,F,s,H,z,c,n,D,x,A,l,U;const W=new h;Be();O();function Be(){H=document.getElementById("output"),i=new J({antialias:!0}),i.setPixelRatio(window.devicePixelRatio),i.setSize(window.innerWidth,window.innerHeight),i.setClearColor(0,0),document.body.appendChild(i.domElement),v=new Z;const e=new ee(16777215,1);e.position.set(1,1,1),v.add(e),v.add(new te(16777215,.2)),a=new oe(75,window.innerWidth/window.innerHeight,.1,50),a.position.set(1,1,2),a.far=100,a.updateProjectionMatrix(),s=new ne(new ie),v.add(s),new fe(a,i.domElement),F=new pe,document.body.appendChild(F.dom),x=new M(new Se),A=new M(new Ie),l=new M(new Pe),U=new xe,new ve().setMeshoptDecoder(we).loadAsync("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/stanford-bunny/bunny.glb").then(o=>{o.scene.updateMatrixWorld(!0);const r=new Te(o.scene);return r.attributes=["position","normal"],r.useGroups=!1,c=r.generate().center(),U.generate(c,{maxLeafTris:1})}).then(o=>{z=o,D=new re(c,new ae),v.add(D),E()}),q(),window.addEventListener("resize",function(){a.aspect=window.innerWidth/window.innerHeight,a.updateProjectionMatrix(),i.setSize(window.innerWidth,window.innerHeight)},!1)}function q(){p&&p.destroy(),t.layer=Math.min(t.resolution,t.layer),p=new me;const e=p.addFolder("generation");e.add(t,"gpuGeneration"),e.add(t,"resolution",10,200,1),e.add(t,"margin",0,1),e.add(t,"regenerate");const o=p.addFolder("display");o.add(t,"mode",["geometry","raymarching","layer","grid layers"]).onChange(()=>{q()}),t.mode==="layer"&&o.add(t,"layer",0,t.resolution,1),t.mode==="raymarching"&&o.add(t,"surface",-.2,.5)}function E(){const e=t.resolution,o=new h,r=new u,S=new ue,f=new u;c.boundingBox.getCenter(r),f.subVectors(c.boundingBox.max,c.boundingBox.min),f.x+=2*t.margin,f.y+=2*t.margin,f.z+=2*t.margin,o.compose(r,S,f),W.copy(o).invert(),s.box.copy(c.boundingBox),s.box.min.x-=t.margin,s.box.min.y-=t.margin,s.box.min.z-=t.margin,s.box.max.x+=t.margin,s.box.max.y+=t.margin,s.box.max.z+=t.margin,n&&n.dispose();const m=1/e,g=.5*m,j=window.performance.now();if(t.gpuGeneration){const I=i.extensions.get("OES_texture_float_linear");n=new se(e,e,e),n.texture.format=G,n.texture.type=I?L:ce,n.texture.minFilter=T,n.texture.magFilter=T,x.material.uniforms.bvh.value.updateFrom(z),x.material.uniforms.matrix.value.copy(o);for(let d=0;d0?-k:k}}const X=window.performance.now()-j;H.innerText=`${X.toFixed(2)}ms`,q()}function O(){if(F.update(),requestAnimationFrame(O),n){if(t.mode==="geometry")i.render(v,a);else if(t.mode==="layer"||t.mode==="grid layers"){let e;const o=A.material;n.isData3DTexture?(o.uniforms.layer.value=t.layer/n.image.width,o.uniforms.sdfTex.value=n,e=n):(o.uniforms.layer.value=t.layer/n.width,o.uniforms.sdfTex.value=n.texture,e=n.texture),o.uniforms.layers.value=e.image.width;const r=t.mode==="layer"?0:1;r!==o.defines.DISPLAY_GRID&&(o.defines.DISPLAY_GRID=r,o.needsUpdate=!0),A.render(i)}else if(t.mode==="raymarching"){a.updateMatrixWorld(),D.updateMatrixWorld();let e;n.isData3DTexture?e=n:e=n.texture;const{width:o,depth:r,height:S}=e.image;l.material.uniforms.sdfTex.value=e,l.material.uniforms.normalStep.value.set(1/o,1/S,1/r),l.material.uniforms.surface.value=t.surface,l.material.uniforms.projectionInverse.value.copy(a.projectionMatrixInverse),l.material.uniforms.sdfTransformInverse.value.copy(D.matrixWorld).invert().premultiply(W).multiply(a.matrixWorld),l.render(i)}}else return} diff --git a/example/bundle/assets/selection-soi6DL02.js b/example/bundle/assets/selection-soi6DL02.js new file mode 100644 index 00000000..a1a6cfa5 --- /dev/null +++ b/example/bundle/assets/selection-soi6DL02.js @@ -0,0 +1 @@ +import{C as Me,W as be,S as ve,D as Se,A as Te,P as Ce,aj as Ee,G as Ie,M as F,T as Ae,d as He,aD as Le,c as ee,aE as We,m as Re,aF as Be,aG as te,aH as ne,u as $,af as oe,w as Oe,j as fe,V as z,z as Pe,L as ue,n as De}from"./ExtendedTriangle-Chm2bbkR.js";import{S as Ne}from"./stats.min-GTpOrGrX.js";import{g as ze}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as Ue}from"./OrbitControls-lzJCl7xY.js";import{M as Fe,I as X,N as se,a as Xe}from"./MeshBVH-CPVAl5W3.js";import{M as Ve}from"./MeshBVHHelper-jLfel8l5.js";import"./_commonjsHelpers-Cpj98o6Y.js";const d={toolMode:"lasso",selectionMode:"intersection",liveUpdate:!1,selectModel:!1,wireframe:!1,useBoundsTree:!0,displayHelper:!1,helperDepth:10,rotate:!0};let A,C,W,V,Q,R,T,b,N,H,O,pe,B;const n=[];let Z=!1,_=!1,D=!1;Ge();ye();function Ge(){pe=document.getElementById("output");const s=new Me(2503224);A=new be({antialias:!0}),A.setPixelRatio(window.devicePixelRatio),A.setSize(window.innerWidth,window.innerHeight),A.setClearColor(s,1),A.shadowMap.enabled=!0,document.body.appendChild(A.domElement),W=new ve;const l=new Se(16777215,3);l.castShadow=!0,l.shadow.mapSize.set(2048,2048),l.position.set(10,10,10),W.add(l),W.add(new Te(11583173,2.5)),C=new Ce(75,window.innerWidth/window.innerHeight,.1,50),C.position.set(2,4,6),C.far=100,C.updateProjectionMatrix(),W.add(C),T=new Ee,T.material.color.set(16750592),T.renderOrder=1,T.position.z=-.2,T.depthTest=!1,T.scale.setScalar(1),C.add(T),B=new Ie,W.add(B),b=new F(new Ae(1.5,.5,500,60).toNonIndexed(),new He({polygonOffset:!0,polygonOffsetFactor:1})),b.geometry.boundsTree=new Fe(b.geometry),b.geometry.setAttribute("color",new Le(new Array(b.geometry.index.count*3).fill(255),3,!0)),b.castShadow=!0,b.receiveShadow=!0,B.add(b),N=new Ve(b,10),B.add(N),H=new F,H.geometry=b.geometry.clone(),H.geometry.drawRange.count=0,H.material=new ee({opacity:.05,transparent:!0,depthWrite:!1}),H.material.color.set(16750592),H.renderOrder=1,B.add(H),O=new F,O.geometry=H.geometry,O.material=new ee({opacity:.25,transparent:!0,wireframe:!0,depthWrite:!1}),O.material.color.copy(H.material.color),O.renderOrder=2,B.add(O);const g=new We(10,10,16777215,16777215);g.material.opacity=.2,g.material.transparent=!0,g.position.y=-2.75,W.add(g);const h=new F(new Re,new Be({color:0,opacity:.2,depthWrite:!1}));h.position.y=-2.74,h.rotation.x=-Math.PI/2,h.scale.setScalar(20),h.renderOrder=2,h.receiveShadow=!0,W.add(h),Q=new Ne,document.body.appendChild(Q.dom),R=new Ue(C,A.domElement),R.minDistance=3,R.touches.ONE=te.PAN,R.mouseButtons.LEFT=ne.PAN,R.touches.TWO=te.ROTATE,R.mouseButtons.RIGHT=ne.ROTATE,R.enablePan=!1,V=new ze;const u=V.addFolder("selection");u.add(d,"toolMode",["lasso","box"]),u.add(d,"selectionMode",["centroid","centroid-visible","intersection"]),u.add(d,"selectModel"),u.add(d,"liveUpdate"),u.add(d,"useBoundsTree"),u.open();const e=V.addFolder("display");e.add(d,"wireframe"),e.add(d,"rotate"),e.add(d,"displayHelper"),e.add(d,"helperDepth",1,30,1).onChange(f=>{N.depth=f,N.update()}),e.open(),V.open();let r=-1/0,o=-1/0,i=-1/0,c=-1/0;const t=new $,a=new $,p=new $;A.domElement.addEventListener("pointerdown",f=>{i=f.clientX,c=f.clientY,r=f.clientX/window.innerWidth*2-1,o=-(f.clientY/window.innerHeight*2-1),n.length=0,Z=!0}),A.domElement.addEventListener("pointerup",()=>{T.visible=!1,Z=!1,n.length&&(D=!0)}),A.domElement.addEventListener("pointermove",f=>{if(!(1&f.buttons))return;const v=f.clientX,M=f.clientY,y=f.clientX/window.innerWidth*2-1,x=-(f.clientY/window.innerHeight*2-1);if(d.toolMode==="box")n.length=3*5,n[0]=r,n[1]=o,n[2]=0,n[3]=y,n[4]=o,n[5]=0,n[6]=y,n[7]=x,n[8]=0,n[9]=r,n[10]=x,n[11]=0,n[12]=r,n[13]=o,n[14]=0,(v!==i||M!==c)&&(_=!0),i=v,c=M,T.visible=!0,d.liveUpdate&&(D=!0);else if(Math.abs(v-i)>=3||Math.abs(M-c)>=3){const E=(n.length/3-1)*3;let w=!1;n.length>3&&(t.set(n[E-3],n[E-3+1]),a.set(n[E],n[E+1]),a.sub(t).normalize(),t.set(n[E],n[E+1]),p.set(y,x),p.sub(t).normalize(),w=a.dot(p)>.99),w?(n[E]=y,n[E+1]=x):n.push(y,x,0),_=!0,T.visible=!0,i=v,c=M,d.liveUpdate&&(D=!0)}}),window.addEventListener("resize",function(){C.aspect=window.innerWidth/window.innerHeight,C.updateProjectionMatrix(),A.setSize(window.innerWidth,window.innerHeight)},!1)}function ye(){if(Q.update(),requestAnimationFrame(ye),b.material.wireframe=d.wireframe,N.visible=d.displayHelper,_){if(d.toolMode==="lasso"){const l=n.length;n.push(n[0],n[1],n[2]),T.geometry.setAttribute("position",new oe(n,3,!1)),n.length=l}else T.geometry.setAttribute("position",new oe(n,3,!1));T.frustumCulled=!1,_=!1}D&&(D=!1,n.length>0&&Ye());const s=Math.tan(Oe.DEG2RAD*C.fov/2)*T.position.z;T.scale.set(-s*C.aspect,-s,1),A.render(W,C),d.rotate&&(B.rotation.y+=.01,d.liveUpdate&&Z&&(D=!0))}const re=new fe,ie=new z,J=new Pe,G=new z,ae=new z,le=new z,Y=new fe,ce=new Array(8).fill().map(()=>new z),j=new Array(12).fill().map(()=>new ue),P=[],k=[];function Ye(){for(Y.copy(b.matrixWorld).premultiply(C.matrixWorldInverse).premultiply(C.projectionMatrix);P.length{if(!d.useBoundsTree)return X;const{min:c,max:t}=e;let a=0,p=1/0,f=-1/0,v=1/0;for(let w=0;w<=1;w++)for(let I=0;I<=1;I++)for(let S=0;S<=1;S++){const m=ce[a];m.x=w===0?c.x:t.x,m.y=I===0?c.y:t.y,m.z=S===0?c.z:t.z,m.w=1,m.applyMatrix4(Y),a++,m.yf&&(f=m.y),m.xf,we=q>f;if(he&&we)continue;const ge=U{const S=x[(I+1)%x.length],m=j[I];return m.start.copy(w),m.end.copy(S),m});if(K(y[0].start,L)%2===1)return X;let E=0;for(let w=0,I=x.length;w{const c=r*3,t=c+0,a=c+1,p=c+2,f=d.useBoundsTree?k[i]:P;if(d.selectionMode==="centroid"||d.selectionMode==="centroid-visible"){if(G.copy(e.a).add(e.b).add(e.c).multiplyScalar(1/3),ae.copy(G).applyMatrix4(Y),o||K(ae,f)%2===1)return d.selectionMode==="centroid-visible"&&(e.getNormal(le),J.origin.copy(G).addScaledVector(le,1e-6),J.direction.subVectors(ie,G),b.geometry.boundsTree.raycastFirst(J,De))?!1:(l.push(t,a,p),d.selectModel)}else if(d.selectionMode==="intersection"){if(o)return l.push(t,a,p),d.selectModel;const v=[e.a,e.b,e.c];for(let y=0;y<3;y++){const x=v[y];if(x.applyMatrix4(Y),K(x,f)%2===1)return l.push(t,a,p),d.selectModel}const M=[j[0],j[1],j[2]];M[0].start.copy(e.a),M[0].end.copy(e.b),M[1].start.copy(e.b),M[1].end.copy(e.c),M[2].start.copy(e.c),M[2].end.copy(e.a);for(let y=0;y<3;y++){const x=M[y];for(let L=0,E=f.length;L0?1:2}function g(t,a){return(t.x-a.x)*(t.x-a.x)+(t.y-a.y)*(t.y-a.y)}function h(t,a){const p=l(r,t,a);return p==0?g(r,a)>=g(r,t)?-1:1:p==2?-1:1}let u=1/0,e=-1;for(let t=0,a=s.length;ti&&o>c||ot&&r>a)return!1;if(rh.end.y;for(let e=0,r=l.length;eo.end.y;ke(s,o,u,i)&&g++,u=i}return g}function de(s,l){function g(o,i,c){return(c.y-o.y)*(i.x-o.x)>(i.y-o.y)*(c.x-o.x)}const h=s.start,u=s.end,e=l.start,r=l.end;return g(h,e,r)!==g(u,e,r)&&g(h,u,e)!==g(h,u,r)} diff --git a/example/bundle/assets/shapecast-CpVgVtwV.js b/example/bundle/assets/shapecast-CpVgVtwV.js new file mode 100644 index 00000000..d9081570 --- /dev/null +++ b/example/bundle/assets/shapecast-CpVgVtwV.js @@ -0,0 +1 @@ +import{M as w,f as T,V as M,a5 as D,W,S as F,F as G,D as H,A as I,T as B,i as R,n as k,P as j,d as A,b as V,y as O,j as q,v as K,a as U}from"./ExtendedTriangle-Chm2bbkR.js";import{S as J}from"./stats.min-GTpOrGrX.js";import{g as N}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as Q}from"./OrbitControls-lzJCl7xY.js";import{T as X}from"./TransformControls-CXlfLtXQ.js";import{M as Y}from"./MeshBVHHelper-jLfel8l5.js";import{a as Z,c as _,d as $}from"./ExtensionUtilities-0qN33-Z7.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./MeshBVH-CPVAl5W3.js";w.prototype.raycast=Z;T.prototype.computeBoundsTree=_;T.prototype.disposeBoundsTree=$;const e={speed:1,visualizeBounds:!1,visualBoundsDepth:10,shape:"sphere",position:new M,rotation:new D,scale:new M(1,1,1)};let x,s,p,m,f,r,a,d,n={};function ee(){m=new W({antialias:!0}),m.setPixelRatio(window.devicePixelRatio),m.setSize(window.innerWidth,window.innerHeight),m.setClearColor(1251612,1),document.body.appendChild(m.domElement),s=new F,s.fog=new G(2503224/2,20,60);const l=new H(16777215,1.5);l.position.set(1,1,1),s.add(l),s.add(new I(16777215,1.2));const t=1,u=.4,o=400,c=100,P=new B(t,u,o,c),z=new R({color:16777215,side:k});d=new w(P,z),d.geometry.computeBoundsTree(),s.add(d),p=new j(75,window.innerWidth/window.innerHeight,.1,50),p.position.set(3,3,3),p.far=100,p.updateProjectionMatrix(),a=new X(p,m.domElement),s.add(a),f=new Q(p,m.domElement),x=new J,document.body.appendChild(x.dom);const g=new A({metalness:.1,transparent:!0,opacity:.75,premultipliedAlpha:!0});n.sphere=new w(new V(1,50,50),g),s.add(n.sphere),n.box=new w(new O(1,1,1),g),s.add(n.box),n.geometry=new w(new B(.5,.2,200,50),g),n.geometry.geometry.computeBoundsTree(),s.add(n.geometry);const i=new N;i.add(e,"speed").min(0).max(10),i.add(e,"visualizeBounds").onChange(()=>v()),i.add(e,"visualBoundsDepth").min(1).max(40).step(1).onChange(()=>v()),i.add(e,"shape",["sphere","box","geometry"]),i.add(a,"mode",["translate","rotate"]);const h=i.addFolder("position");h.add(e.position,"x").min(-5).max(5).step(.001),h.add(e.position,"y").min(-5).max(5).step(.001),h.add(e.position,"z").min(-5).max(5).step(.001),h.open();const y=i.addFolder("rotation");y.add(e.rotation,"x").min(-Math.PI).max(Math.PI).step(.001),y.add(e.rotation,"y").min(-Math.PI).max(Math.PI).step(.001),y.add(e.rotation,"z").min(-Math.PI).max(Math.PI).step(.001),y.open(),i.open(),a.addEventListener("change",function(){e.position.copy(n[e.shape].position),e.rotation.copy(n[e.shape].rotation),e.scale.copy(n[e.shape].scale),i.controllersRecursive().forEach(b=>b.updateDisplay())}),a.addEventListener("mouseDown",function(){f.enabled=!1}),a.addEventListener("mouseUp",function(){f.enabled=!0}),f.addEventListener("start",function(){a.enabled=!1}),f.addEventListener("end",function(){a.enabled=!0}),window.addEventListener("resize",function(){p.aspect=window.innerWidth/window.innerHeight,p.updateProjectionMatrix(),m.setSize(window.innerWidth,window.innerHeight)},!1),window.addEventListener("keydown",function(b){switch(b.key){case"w":a.mode="translate";break;case"e":a.mode="rotate";break}i.controllersRecursive().forEach(L=>L.updateDisplay())})}function v(){r&&!e.visualizeBounds&&(s.remove(r),r=null),!r&&e.visualizeBounds&&(r=new Y(d),s.add(r)),r&&(r.depth=e.visualBoundsDepth)}let S=window.performance.now();function C(){const E=window.performance.now()-S;S=window.performance.now(),d.rotation.y+=e.speed*E*.001,d.updateMatrixWorld(),x.begin(),r&&r.update(),m.render(s,p),x.end();for(const o in n)n[o].visible=!1;const l=e.shape,t=n[l];t.visible=!0,t.position.copy(e.position),t.rotation.copy(e.rotation),t.scale.copy(e.scale);const u=new q().copy(d.matrixWorld).invert().multiply(t.matrixWorld);if(l==="sphere"){const o=new K(void 0,1);o.applyMatrix4(u);const c=d.geometry.boundsTree.intersectsSphere(o);t.material.color.set(c?15277667:6710886),t.material.emissive.set(15277667).multiplyScalar(c?.25:0)}else if(l==="box"){const o=new U;o.min.set(-.5,-.5,-.5),o.max.set(.5,.5,.5);const c=d.geometry.boundsTree.intersectsBox(o,u);t.material.color.set(c?15277667:6710886),t.material.emissive.set(15277667).multiplyScalar(c?.25:0)}else if(l==="geometry"){const o=d.geometry.boundsTree.intersectsGeometry(t.geometry,u);t.material.color.set(o?15277667:6710886),t.material.emissive.set(15277667).multiplyScalar(o?.25:0)}a.object!==t&&a.attach(t),requestAnimationFrame(C)}ee();v();C(); diff --git a/example/bundle/assets/skinnedMesh-DcIBeIKd.js b/example/bundle/assets/skinnedMesh-DcIBeIKd.js new file mode 100644 index 00000000..a874db68 --- /dev/null +++ b/example/bundle/assets/skinnedMesh-DcIBeIKd.js @@ -0,0 +1,3 @@ +import{f as G,W as E,k as R,S as z,D,A as U,P as I,aJ as $,aK as j,a as V,aL as q,c as J,M as B,m as K,aF as N,e as Q}from"./ExtendedTriangle-Chm2bbkR.js";import{G as X}from"./GLTFLoader-Dl6abS6P.js";import{S as Y}from"./stats.min-GTpOrGrX.js";import{g as Z}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as _}from"./OrbitControls-lzJCl7xY.js";import{M as ee}from"./MeshBVHHelper-jLfel8l5.js";import{g as te}from"./Debug-Bq6kbTOM.js";import{c as ae}from"./ExtensionUtilities-0qN33-Z7.js";import{S as re}from"./StaticGeometryGenerator-8L97b6eW.js";import"./BufferGeometryUtils-Cscy-pCt.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./MeshBVH-CPVAl5W3.js";G.prototype.computeBoundsTree=ae;const e={display:!0,displayOriginal:!0,material:"wireframe",updatePositionOnly:!1,skeletonHelper:!1,bvhHelper:!0,bvhHelperDepth:10,autoUpdate:!0,updateRate:2.5,pause:!1,regenerate:()=>{T()}};let r,o,s,W,b,P,L,H,v,M,d,f,y,t,S,x=0,C=null,F,A,k;oe();O();function oe(){L=document.getElementById("output"),r=new E({antialias:!0}),r.setPixelRatio(window.devicePixelRatio),r.setSize(window.innerWidth,window.innerHeight),r.setClearColor(1118481,1),r.shadowMap.enabled=!0,r.shadowMap.type=R,r.outputEncoding=void 0,document.body.appendChild(r.domElement),s=new z;const n=new D(16777215,3);n.position.set(5,5,2.5),n.shadow.mapSize.setScalar(1024),n.shadow.normalBias=.01,n.castShadow=!0;const i=n.shadow.camera;i.left=i.bottom=-7.5,i.right=i.top=7.5,i.updateProjectionMatrix(),s.add(n),s.add(new U(11583173,2.4)),o=new I(75,window.innerWidth/window.innerHeight,.1,50),o.position.set(10,0,0),o.far=100,o.updateProjectionMatrix(),H=new _(o,r.domElement),W=new Q,P=new Y,document.body.appendChild(P.dom),new X().load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/trex/scene.gltf",a=>{d=a.scene,d.traverse(w=>{w.isMesh&&(w.castShadow=!0,w.receiveShadow=!0,w.frustumCulled=!1)}),d.updateMatrixWorld(!0),s.add(d),y=new $(d),y.visible=!1,s.add(y);const h=a.animations;v=new j(d),M=v.clipAction(h[0]),M.play(),M.paused=e.pause;const g=new V;g.setFromObject(d),g.getCenter(H.target),g.getCenter(o.position),o.position.x=7.5,o.position.z=3.5,H.update(),S=new re(d),k=S.getMaterials(),A=k.map(w=>new q({normalMap:w.normalMap})),F=new J({wireframe:!0,transparent:!0,opacity:.05,depthWrite:!1}),t=new B(new G,F),t.receiveShadow=!0,s.add(t),f=new ee(t,10),s.add(f),T()});const l=new B(new K,new N({color:16777215,opacity:.025,transparent:!0}));l.rotation.x=-Math.PI/2,l.receiveShadow=!0,l.scale.setScalar(50),s.add(l),b=new Z;const p=b.addFolder("static mesh");p.add(e,"display"),p.add(e,"displayOriginal"),p.add(e,"material",["wireframe","normal","original"]).onChange(a=>{if(t)switch(a){case"wireframe":t.material=F,t.castShadow=!1;break;case"normal":t.material=A,t.castShadow=!0;break;case"original":t.material=k,t.castShadow=!0;break}}),p.add(e,"updatePositionOnly").onChange(a=>{S.attributes=a?["position"]:["position","normal","tangent","uv","uv2"];const h=t.geometry;h.dispose();for(const g in h.attributes)h.deleteAttribute(g)}),p.open();const m=b.addFolder("helpers");m.add(e,"skeletonHelper"),m.add(e,"bvhHelper"),m.add(e,"bvhHelperDepth",1,20,1).onChange(a=>{f.depth=parseInt(a),f.update()}),m.open();const c=b.addFolder("bvh animation");c.add(e,"autoUpdate"),c.add(e,"updateRate",0,5,.001),c.add(e,"pause").onChange(a=>{M&&(M.paused=a)}),c.add(e,"regenerate"),c.open(),b.open(),window.addEventListener("resize",function(){o.aspect=window.innerWidth/window.innerHeight,o.updateProjectionMatrix(),r.setSize(window.innerWidth,window.innerHeight)},!1)}function T(){if(t){let u,n,i;i=window.performance.now(),S.generate(t.geometry),u=window.performance.now()-i,i=window.performance.now(),t.geometry.boundsTree?(t.geometry.boundsTree.refit(),n=(window.performance.now()-i).toFixed(2)):(t.geometry.computeBoundsTree(),n="-"),f.update(),x=0;const l=te(t.geometry.boundsTree);C===null&&(C=l);let p=0,m=0;for(const a in l)p+=l[a].surfaceAreaScore,m+=C[a].surfaceAreaScore;const c=p/m-1;L.innerHTML=`mesh generation time: ${u.toFixed(2)} ms +refit time: ${n} ms +bvh degradation: ${(100*c).toFixed(2)}%`}}function O(){P.update(),requestAnimationFrame(O);const u=Math.min(W.getDelta(),30*.001);v&&(v.update(u),y.visible=e.skeletonHelper,t.visible=e.display,f.visible=e.bvhHelper,d.visible=e.displayOriginal),s.updateMatrixWorld(!0),e.autoUpdate&&!e.pause?(x>e.updateRate&&T(),x+=u):x=0,r.render(s,o)} diff --git a/example/bundle/assets/stats.min-GTpOrGrX.js b/example/bundle/assets/stats.min-GTpOrGrX.js new file mode 100644 index 00000000..a421bec3 --- /dev/null +++ b/example/bundle/assets/stats.min-GTpOrGrX.js @@ -0,0 +1 @@ +import{c as E,g as b}from"./_commonjsHelpers-Cpj98o6Y.js";var y={exports:{}};(function(S,R){(function(p,i){S.exports=i()})(E,function(){var p=function(){function i(n){return a.appendChild(n.dom),n}function f(n){for(var l=0;lo+1e3&&(x.update(1e3*e/(n-o),100),o=n,e=0,h)){var l=performance.memory;h.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){r=this.end()},domElement:a,setMode:f}};return p.Panel=function(i,f,c){var a=1/0,r=0,o=Math.round,e=o(window.devicePixelRatio||1),x=80*e,v=48*e,h=3*e,n=2*e,l=3*e,s=15*e,d=74*e,m=30*e,u=document.createElement("canvas");u.width=x,u.height=v,u.style.cssText="width:80px;height:48px";var t=u.getContext("2d");return t.font="bold "+9*e+"px Helvetica,Arial,sans-serif",t.textBaseline="top",t.fillStyle=c,t.fillRect(0,0,x,v),t.fillStyle=f,t.fillText(i,h,n),t.fillRect(l,s,d,m),t.fillStyle=c,t.globalAlpha=.9,t.fillRect(l,s,d,m),{dom:u,update:function(g,w){a=Math.min(a,g),r=Math.max(r,g),t.fillStyle=c,t.globalAlpha=1,t.fillRect(0,0,x,s),t.fillStyle=f,t.fillText(o(g)+" "+i+" ("+o(a)+"-"+o(r)+")",h,n),t.drawImage(u,l+e,s,d-e,m,l,s,d-e,m),t.fillRect(l+d-e,s,e,m),t.fillStyle=c,t.globalAlpha=.9,t.fillRect(l+d-e,s,e,o((1-g/w)*m))}}},p})})(y);var P=y.exports;const D=b(P);export{D as S}; diff --git a/example/bundle/assets/triangleIntersect-D-jq5AUA.js b/example/bundle/assets/triangleIntersect-D-jq5AUA.js new file mode 100644 index 00000000..48a04b7f --- /dev/null +++ b/example/bundle/assets/triangleIntersect-D-jq5AUA.js @@ -0,0 +1 @@ +import{aP as G,L as X,W as R,S as T,D as U,A as V,i as v,n as I,b as W,M as h,h as A,f as Y,B as Z,P as D,V as H,j as P,w as j}from"./ExtendedTriangle-Chm2bbkR.js";import{S as k}from"./stats.min-GTpOrGrX.js";import{g as B}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as F}from"./OrbitControls-lzJCl7xY.js";import"./_commonjsHelpers-Cpj98o6Y.js";const E={sphereSize:1},e=new G,t=new G;e.a.set(-1,0,0);e.b.set(2,0,-2);e.c.set(2,0,2);t.a.set(1,0,0);t.b.set(-2,-2,0);t.c.set(-2,2,0);e.needsUpdate=!0;t.needsUpdate=!0;let M,r,d,f,x,c=[],a=[],y,w=new X,S,z,g;function N(){f=new R({antialias:!0}),f.setPixelRatio(window.devicePixelRatio),f.setSize(window.innerWidth,window.innerHeight),f.setClearColor(1251612,1),document.body.appendChild(f.domElement),r=new T;const n=new U(16777215,.3);n.position.set(10,10,10),r.add(n),r.add(new V(16777215,.8));const m=new v({color:16711680,side:I}),b=new v({color:255,side:I}),i=new v({color:65280,side:I}),s=new W(1);for(let l=0;l<2;l++){const p=new h(s,m);a.push(p),r.add(p)}for(let l=0;l<3;l++){const p=new h(s,b);c.push(p),r.add(p)}for(let l=0;l<3;l++){const p=new h(s,i);c.push(p),r.add(p)}const L=new A;y=new h(L,m),r.add(y);const C=new Y;C.setAttribute("position",new Z(new Float32Array([1,1,1,2,2,2,3,3,3]),3)),S=new h(C.clone(),b),r.add(S),z=new h(C.clone(),i),r.add(z),d=new D(75,window.innerWidth/window.innerHeight,.1,50),d.position.set(10,10,10),d.far=100,d.updateProjectionMatrix(),x=new F(d,f.domElement),x.target.add(e.a).add(e.b).add(e.c).add(t.a).add(t.b).add(t.c).multiplyScalar(1/6),d.position.add(x.target),x.update(),M=new k,document.body.appendChild(M.dom),x.addEventListener("change",function(){u()}),window.addEventListener("resize",function(){d.aspect=window.innerWidth/window.innerHeight,d.updateProjectionMatrix(),f.setSize(window.innerWidth,window.innerHeight),u()},!1)}function O(){g=new B,g.add(E,"sphereSize",0,5,.001).onChange(u);const o=["a1","b1","c1","a2","b2","c2"],n=[e.a,e.b,e.c,t.a,t.b,t.c];for(let i=0;i<6;i++){const s=g.addFolder(o[i]);s.add(n[i],"x").min(-10).max(10).step(.001).onChange(u),s.add(n[i],"y").min(-10).max(10).step(.001).onChange(u),s.add(n[i],"z").min(-10).max(10).step(.001).onChange(u),s.open()}const m=["Inter1","Inter2"],b=[w.start,w.end];for(let i=0;i<2;i++){const s=g.addFolder(m[i]);s.add(b[i],"x").step(.001),s.add(b[i],"y").step(.001),s.add(b[i],"z").step(.001),s.open()}g.open()}function q(o,n){o.geometry.dispose();const m=new H().subVectors(n.start,n.end);o.geometry=new A(1,1,m.length(),6,4,!0),o.geometry.applyMatrix4(new P().makeTranslation(0,m.length()/2,0)),o.geometry.applyMatrix4(new P().makeRotationX(j.degToRad(90))),o.geometry.computeVertexNormals(),o.position.copy(n.start),o.lookAt(n.end)}function J(){c[0].position.copy(e.a),c[1].position.copy(e.b),c[2].position.copy(e.c),c[3].position.copy(t.a),c[4].position.copy(t.b),c[5].position.copy(t.c),a[0].position.copy(w.start),a[1].position.copy(w.end)}function K(){const o=S.geometry.getAttribute("position");o.setXYZ(0,e.a.x,e.a.y,e.a.z),o.setXYZ(1,e.b.x,e.b.y,e.b.z),o.setXYZ(2,e.c.x,e.c.y,e.c.z),o.needsUpdate=!0,S.geometry.computeVertexNormals();const n=z.geometry.getAttribute("position");n.setXYZ(0,t.a.x,t.a.y,t.a.z),n.setXYZ(1,t.b.x,t.b.y,t.b.z),n.setXYZ(2,t.c.x,t.c.y,t.c.z),n.needsUpdate=!0,z.geometry.computeVertexNormals()}function u(){M.begin(),y.visible=!1,a[0].visible=!1,a[1].visible=!1,e.update(),t.update(),e.intersectsTriangle(t,w)?(q(y,w),y.visible=!0,a[0].visible=!0,a[1].visible=!0):(w.start.set(1/0,1/0,1/0),w.end.set(1/0,1/0,1/0)),J(),K(),[...c,...a].forEach(n=>{n.scale.setScalar(.005*E.sphereSize*n.position.distanceTo(d.position))}),a.forEach(n=>n.scale.multiplyScalar(1.5)),y.scale.setScalar(.5*Math.min(a[0].scale.x,a[1].scale.x)),y.scale.z=1,g.controllersRecursive().forEach(n=>n.updateDisplay()),f.render(r,d),M.end()}N();O();u(); diff --git a/example/bundle/assets/voxelize-DutdC9Hh.js b/example/bundle/assets/voxelize-DutdC9Hh.js new file mode 100644 index 00000000..89e6e1b2 --- /dev/null +++ b/example/bundle/assets/voxelize-DutdC9Hh.js @@ -0,0 +1 @@ +import{W as U,S as V,D as L,A as I,P as q,c as K,M as P,T as Q,y as J,aQ as N,C as R,aR as X,d as Y,V as T,j as k,a as Z,z as _,aq as $}from"./ExtendedTriangle-Chm2bbkR.js";import{G as z}from"./GLTFLoader-Dl6abS6P.js";import{M as O}from"./meshopt_decoder.module-Cf1-17OU.js";import{S as ee}from"./stats.min-GTpOrGrX.js";import{g as te}from"./lil-gui.module.min-Bc0DeA9g.js";import{O as oe}from"./OrbitControls-lzJCl7xY.js";import{R as ne}from"./RoundedBoxGeometry-BW68IL6j.js";import{G as D}from"./GenerateMeshBVHWorker-B43A4fin.js";import{M as ae}from"./MeshBVH-CPVAl5W3.js";import"./BufferGeometryUtils-Cscy-pCt.js";import"./_commonjsHelpers-Cpj98o6Y.js";let m,w,a,C,H,t,u,r=!1,v=null;const o={model:"Torus Knot",scale:.75,resolution:30,solid:!0,displayMesh:!0,displayBounds:!1,insideOnly:!1,rebuild:()=>r=!0},s={};re();E();function re(){document.getElementById("output"),m=new U({antialias:!0}),m.setPixelRatio(window.devicePixelRatio),m.setSize(window.innerWidth,window.innerHeight),m.setClearColor(1449501,1),m.outputEncoding=void 0,document.body.appendChild(m.domElement),a=new V;const d=new L(16777215,3);d.position.set(3,6,9),a.add(d);const l=new L(16777215,.3);l.position.set(-3,-6,-9),a.add(l);const c=new I(16777215,.75);a.add(c),w=new q(75,window.innerWidth/window.innerHeight,.1,50),w.position.set(1,.5,1),w.far=100,w.updateProjectionMatrix(),new oe(w,m.domElement),H=new ee,document.body.appendChild(H.dom);const h=new K({transparent:!0,wireframe:!0,depthWrite:!1,opacity:.02});new z().setMeshoptDecoder(O).load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/happy-buddha/buddha.glb",n=>{const e=n.scene.children[0];e.geometry.center(),e.material=h,e.scale.setScalar(1.5),e.rotation.y=-Math.PI/2,new D().generate(e.geometry).then(y=>{a.add(e),s.Buddha={model:e,bvh:y},o.model==="Buddha"&&(r=!0)})}),new z().setMeshoptDecoder(O).load("https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/stanford-bunny/bunny.glb",n=>{const e=n.scene.children[0];e.geometry.center(),e.material=h,e.rotation.y=Math.PI/2,e.scale.setScalar(.65),new D().generate(e.geometry).then(y=>{a.add(e),s.Bunny={model:e,bvh:y},o.model==="Bunny"&&(r=!0)})});{const n=new P(new Q(.3,.1,400,60),h),e=new ae(n.geometry);a.add(n),s["Torus Knot"]={bvh:e,model:n},r=!0}s.Buddha={model:null,bvh:null},s.Bunny={model:null,bvh:null};const B=new P(new J);u=new N(B,16777215),u.material.opacity=.35,u.material.transparent=!0,a.add(u),C=new te,C.add(o,"model",Object.keys(s)).onChange(()=>{r=!0});const f=C.addFolder("voxelize");f.add(o,"resolution",5,75,1).onChange(()=>{r=!0}),f.add(o,"scale",.1,4).onChange(()=>{r=!0}),f.add(o,"solid").onChange(()=>{r=!0}),f.add(o,"insideOnly").onChange(()=>{r=!0}),f.add(o,"rebuild");const x=C.addFolder("helpers");x.add(o,"displayMesh"),x.add(o,"displayBounds"),window.addEventListener("resize",function(){w.aspect=window.innerWidth/window.innerHeight,w.updateProjectionMatrix(),m.setSize(window.innerWidth,window.innerHeight)},!1)}function*se(){const i=o.resolution,d=i**3,l=o.scale,c=l/i,h=new R(16777215),B=new R(16761095).convertSRGBToLinear();t&&t.instanceMatrix.count!==d&&(t.material.dispose(),t.dispose(),t.parent.remove(t),t=null);const{model:f,bvh:x}=s[o.model];if(!f)return;t||(t=new X(new ne(1,1,1,4,.1),new Y,d),t.setColorAt(0,h),a.add(t));const n=-l/2+c*.5,e=new T,g=new $,y=new T().setScalar(c),b=new k,S=new Z,j=new k().copy(f.matrixWorld).invert(),M=new _;M.direction.set(0,0,1);let p=0;for(let W=0;W0&&(b.compose(e,g,y),t.setMatrixAt(p,b),t.setColorAt(p,B),t.instanceMatrix.needsUpdate=!0,t.instanceColor.needsUpdate=!0,p++)}t.count=p,yield}t.count=p}function E(){if(H.update(),requestAnimationFrame(E),a.updateMatrixWorld(!0),r&&(v=se(),r=!1),v){let d=window.performance.now();for(;window.performance.now()-d<16;)if(v.next().done){v=null;break}}u&&(u.object.scale.setScalar(o.scale),u.object.updateMatrixWorld(!0),u.update());for(const d in s){const l=s[d];l.model&&(l.model.visible=!1)}const{model:i}=s[o.model];i&&(i.visible=o.displayMesh,u.visible=o.displayBounds),m.render(a,w)} diff --git a/example/bundle/asyncGenerate.html b/example/bundle/asyncGenerate.html new file mode 100644 index 00000000..e6c630e4 --- /dev/null +++ b/example/bundle/asyncGenerate.html @@ -0,0 +1,68 @@ + + + + three-mesh-bvh - Async BVH Generation + + + + + + + + + + + + + + + +
+
+
100%
+
+
+ + diff --git a/example/bundle/batchedMesh.html b/example/bundle/batchedMesh.html new file mode 100644 index 00000000..019c8e58 --- /dev/null +++ b/example/bundle/batchedMesh.html @@ -0,0 +1,43 @@ + + + + three-mesh-bvh - Complex Geometry Raycasting + + + + + + + + + + + + +
+ BatchedMesh with 3 geometries. +
+ + diff --git a/example/bundle/characterMovement.html b/example/bundle/characterMovement.html new file mode 100644 index 00000000..6a36af37 --- /dev/null +++ b/example/bundle/characterMovement.html @@ -0,0 +1,56 @@ + + + + three-mesh-bvh - Character Movement + + + + + + + + + + + + + + + + + +
+ Basic character movement example. Click and drag to rotate the camera direction and use WASD to move. + +
+
+ + Model by Warkarma on Sketchfab. +
+ + diff --git a/example/bundle/clippedEdges.html b/example/bundle/clippedEdges.html new file mode 100644 index 00000000..f0dfe5b1 --- /dev/null +++ b/example/bundle/clippedEdges.html @@ -0,0 +1,68 @@ + + + + three-mesh-bvh - Clipped Edges + + + + + + + + + + + + + + + + +
+ + Using MeshBVH to quickly detect plane-clipped triangle edges on static, +
+ merged 2 million polygon model. Stencil buffer used for solid clip cap. +
+ + Model by T-FLEX CAD on Sketchfab. +
+
+ + diff --git a/example/bundle/coi-serviceworker.js b/example/bundle/coi-serviceworker.js new file mode 100644 index 00000000..921ff82a --- /dev/null +++ b/example/bundle/coi-serviceworker.js @@ -0,0 +1,121 @@ +/* eslint-disable */ +// copied from https://github.com/gzuidhof/coi-serviceworker + +/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */ +let coepCredentialless = false; +if (typeof window === 'undefined') { + self.addEventListener("install", () => self.skipWaiting()); + self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim())); + + self.addEventListener("message", (ev) => { + if (!ev.data) { + return; + } else if (ev.data.type === "deregister") { + self.registration + .unregister() + .then(() => { + return self.clients.matchAll(); + }) + .then(clients => { + clients.forEach((client) => client.navigate(client.url)); + }); + } else if (ev.data.type === "coepCredentialless") { + coepCredentialless = ev.data.value; + } + }); + + self.addEventListener("fetch", function (event) { + const r = event.request; + if (r.cache === "only-if-cached" && r.mode !== "same-origin") { + return; + } + + const request = (coepCredentialless && r.mode === "no-cors") + ? new Request(r, { + credentials: "omit", + }) + : r; + event.respondWith( + fetch(request) + .then((response) => { + if (response.status === 0) { + return response; + } + + const newHeaders = new Headers(response.headers); + newHeaders.set("Cross-Origin-Embedder-Policy", + coepCredentialless ? "credentialless" : "require-corp" + ); + if (!coepCredentialless) { + newHeaders.set("Cross-Origin-Resource-Policy", "cross-origin"); + } + newHeaders.set("Cross-Origin-Opener-Policy", "same-origin"); + + return new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: newHeaders, + }); + }) + .catch((e) => console.error(e)) + ); + }); + +} else { + (() => { + // You can customize the behavior of this script through a global `coi` variable. + const coi = { + shouldRegister: () => true, + shouldDeregister: () => false, + coepCredentialless: () => !(window.chrome || window.netscape), + doReload: () => window.location.reload(), + quiet: false, + ...window.coi + }; + + const n = navigator; + + if (n.serviceWorker && n.serviceWorker.controller) { + n.serviceWorker.controller.postMessage({ + type: "coepCredentialless", + value: coi.coepCredentialless(), + }); + + if (coi.shouldDeregister()) { + n.serviceWorker.controller.postMessage({ type: "deregister" }); + } + } + + // If we're already coi: do nothing. Perhaps it's due to this script doing its job, or COOP/COEP are + // already set from the origin server. Also if the browser has no notion of crossOriginIsolated, just give up here. + if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return; + + if (!window.isSecureContext) { + !coi.quiet && console.log("COOP/COEP Service Worker not registered, a secure context is required."); + return; + } + + // In some environments (e.g. Chrome incognito mode) this won't be available + if (n.serviceWorker) { + n.serviceWorker.register(window.document.currentScript.src).then( + (registration) => { + !coi.quiet && console.log("COOP/COEP Service Worker registered", registration.scope); + + registration.addEventListener("updatefound", () => { + !coi.quiet && console.log("Reloading page to make use of updated COOP/COEP Service Worker."); + coi.doReload(); + }); + + // If the registration is active, but it's not controlling the page + if (registration.active && !n.serviceWorker.controller) { + !coi.quiet && console.log("Reloading page to make use of COOP/COEP Service Worker."); + coi.doReload(); + } + }, + (err) => { + !coi.quiet && console.error("COOP/COEP Service Worker failed to register:", err); + } + ); + } + })(); +} diff --git a/example/bundle/collectTriangles.html b/example/bundle/collectTriangles.html new file mode 100644 index 00000000..47ee7c38 --- /dev/null +++ b/example/bundle/collectTriangles.html @@ -0,0 +1,29 @@ + + + + three-mesh-bvh - Geometry Collect Triangles + + + + + + + + + + + + + + diff --git a/example/bundle/cpuPathTracing.html b/example/bundle/cpuPathTracing.html new file mode 100644 index 00000000..2522c7c0 --- /dev/null +++ b/example/bundle/cpuPathTracing.html @@ -0,0 +1,68 @@ + + + + three-mesh-bvh - CPU Path Tracing + + + + + + + + + + + + + + + + +
+ CPU Path Tracer demo based on a smattering of online resources. Engine by T-FLEX CAD on Sketchfab. +

+ Checkout the Raytracing in One Weekend series and PBR Book for some great introductions to path tracing! +
+
+
+ + diff --git a/example/bundle/diamond.html b/example/bundle/diamond.html new file mode 100644 index 00000000..543e011f --- /dev/null +++ b/example/bundle/diamond.html @@ -0,0 +1,53 @@ + + + + + Total Internal Refraction + + + + + + + + + + + + + + +
+ Using shader ray tracing to model internal reflection for a diamond material. +
+ Model from Sketchfab. Full material implementation available here. +
+ + + diff --git a/example/bundle/distancecast.html b/example/bundle/distancecast.html new file mode 100644 index 00000000..29ba595b --- /dev/null +++ b/example/bundle/distancecast.html @@ -0,0 +1,42 @@ + + + + three-mesh-bvh - Geometry Closest Distance + + + + + + + + + + + + + + + +
+ + diff --git a/example/bundle/edgeIntersect.html b/example/bundle/edgeIntersect.html new file mode 100644 index 00000000..35416f97 --- /dev/null +++ b/example/bundle/edgeIntersect.html @@ -0,0 +1,30 @@ + + + + three-mesh-bvh - Geometry Edge Intersection + + + + + + + + + + + + + + + diff --git a/example/bundle/gpuPathTracing.html b/example/bundle/gpuPathTracing.html new file mode 100644 index 00000000..b372ac13 --- /dev/null +++ b/example/bundle/gpuPathTracing.html @@ -0,0 +1,60 @@ + + + + three-mesh-bvh - GPU Path Tracing + + + + + + + + + + + + + + + + +
+ Lambertian material Path Tracer implemented using BVH intersections on the GPU. +
+
+ + diff --git a/example/bundle/gpuPathTracingSimple.html b/example/bundle/gpuPathTracingSimple.html new file mode 100644 index 00000000..56e7c0d0 --- /dev/null +++ b/example/bundle/gpuPathTracingSimple.html @@ -0,0 +1,45 @@ + + + + three-mesh-bvh - GPU Path Tracing + + + + + + + + + + + + + + +
+ Simple example of running BVH intersections on an animated geometry on the GPU in a shader. +
+ + diff --git a/example/bundle/inspector.html b/example/bundle/inspector.html new file mode 100644 index 00000000..8dad5611 --- /dev/null +++ b/example/bundle/inspector.html @@ -0,0 +1,73 @@ + + + + three-mesh-bvh - BVH Inspector + + + + + + + + + + + + + + + + +
+ BVH inspector showing the number of traversals at a given pixel, various BVH construction stats, and basic raycast benchmark. +
+
+ Pixels with traversal counts above the "traversalTreshold" are highlighted in red. +
+
+
+
+
+ + diff --git a/example/bundle/physics.html b/example/bundle/physics.html new file mode 100644 index 00000000..cb1d44ad --- /dev/null +++ b/example/bundle/physics.html @@ -0,0 +1,55 @@ + + + + three-mesh-bvh - Rudimentary Sphere Physics + + + + + + + + + + + + + + + + +
+ Rudimentary sphere collision physics with an environment using MeshBVH. + +
+
+ + Model by Lowpolyprincipal on Sketchfab. +
+ + diff --git a/example/bundle/pointCloudIntersection.html b/example/bundle/pointCloudIntersection.html new file mode 100644 index 00000000..a284f0ce --- /dev/null +++ b/example/bundle/pointCloudIntersection.html @@ -0,0 +1,63 @@ + + + + three-mesh-bvh - Geometry point clouds + + + + + + + + + + + + + +
+ Point cloud intersection by modeling points as degenerate triangles with MeshBVH. + +
+
+ + Model by SiteScape on Sketchfab. +
+
+ + diff --git a/example/bundle/randomSampleDebug.html b/example/bundle/randomSampleDebug.html new file mode 100644 index 00000000..4094ff8d --- /dev/null +++ b/example/bundle/randomSampleDebug.html @@ -0,0 +1,38 @@ + + + + three-mesh-bvh - Random Sample Debug + + + + + + + + + + + +
+ + diff --git a/example/bundle/raycast.html b/example/bundle/raycast.html new file mode 100644 index 00000000..52c4b91f --- /dev/null +++ b/example/bundle/raycast.html @@ -0,0 +1,30 @@ + + + + three-mesh-bvh - Complex Geometry Raycasting + + + + + + + + + + + + + + + diff --git a/example/bundle/sculpt.html b/example/bundle/sculpt.html new file mode 100644 index 00000000..1d97123e --- /dev/null +++ b/example/bundle/sculpt.html @@ -0,0 +1,51 @@ + + + + three-mesh-bvh - Geometry Sculpting + + + + + + + + + + + + + + +
+ Inspired by SculptGL. +
+
+ Matcap textures from nidorx/matcaps repo. +
+ + diff --git a/example/bundle/sdfGeneration.html b/example/bundle/sdfGeneration.html new file mode 100644 index 00000000..eae1717f --- /dev/null +++ b/example/bundle/sdfGeneration.html @@ -0,0 +1,69 @@ + + + + three-mesh-bvh - Fast SDF Generation + + + + + + + + + + + + + + + + + + + +
+ 3D Texture Signed Distance Field generation on the gpu and raymarching. +
+ "Surface" sets the distance at which the surface is rendered. +
+ "Layers" show the raw signed distance values. + +
+
+ + diff --git a/example/bundle/selection.html b/example/bundle/selection.html new file mode 100644 index 00000000..81548efb --- /dev/null +++ b/example/bundle/selection.html @@ -0,0 +1,58 @@ + + + + three-mesh-bvh - Geometry Collect Triangles + + + + + + + + + + + + + +
+ Right click rotate, left click drag selection +
+ NOTE: Triangles and bounds clipped by the camera not supported +
+
+ + diff --git a/example/bundle/shapecast.html b/example/bundle/shapecast.html new file mode 100644 index 00000000..31a50da5 --- /dev/null +++ b/example/bundle/shapecast.html @@ -0,0 +1,32 @@ + + + + three-mesh-bvh - Geometry Lasso Selection + + + + + + + + + + + + + + + + + diff --git a/example/bundle/skinnedMesh.html b/example/bundle/skinnedMesh.html new file mode 100644 index 00000000..9656f90b --- /dev/null +++ b/example/bundle/skinnedMesh.html @@ -0,0 +1,68 @@ + + + + three-mesh-bvh - Skinned Mesh BVH + + + + + + + + + + + + + + + + + + +
+ SkinnedMesh and morph target BVH support by iteratively generating a static version of
+ the geometry and refitting the existing BVH. +
+
+
+
Model by DailyArt on Sketchfab
+
+ + diff --git a/example/bundle/triangleIntersect.html b/example/bundle/triangleIntersect.html new file mode 100644 index 00000000..992a427b --- /dev/null +++ b/example/bundle/triangleIntersect.html @@ -0,0 +1,28 @@ + + + + three-mesh-bvh - Triangle-Triangle Intersection + + + + + + + + + + + + + diff --git a/example/bundle/voxelize.html b/example/bundle/voxelize.html new file mode 100644 index 00000000..dc0e89eb --- /dev/null +++ b/example/bundle/voxelize.html @@ -0,0 +1,65 @@ + + + + three-mesh-bvh - Geometry Voxelization + + + + + + + + + + + + + + + + + +
+ Demonstration of voxelizing a mesh with the ability to detect the inside and outside of a model. +
+
+
+
+ +