var oA=Object.create;var Pl=Object.defineProperty,aA=Object.defineProperties,lA=Object.getOwnPropertyDescriptor,cA=Object.getOwnPropertyDescriptors,uA=Object.getOwnPropertyNames,Ag=Object.getOwnPropertySymbols,hA=Object.getPrototypeOf,_g=Object.prototype.hasOwnProperty,dA=Object.prototype.propertyIsEnumerable;var Tg=(r,e,t)=>e in r?Pl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ue=(r,e)=>{for(var t in e||(e={}))_g.call(e,t)&&Tg(r,t,e[t]);if(Ag)for(var t of Ag(e))dA.call(e,t)&&Tg(r,t,e[t]);return r},tt=(r,e)=>aA(r,cA(e)),Eg=r=>Pl(r,"__esModule",{value:!0});var Ng=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),fA=(r,e)=>{Eg(r);for(var t in e)Pl(r,t,{get:e[t],enumerable:!0})},pA=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of uA(e))!_g.call(r,n)&&n!=="default"&&Pl(r,n,{get:()=>e[n],enumerable:!(t=lA(e,n))||t.enumerable});return r},Cg=r=>pA(Eg(Pl(r!=null?oA(hA(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var Y0=Ng($h=>{"use strict";$h.byteLength=Z2;$h.toByteArray=eI;$h.fromByteArray=iI;var yr=[],Li=[],Q2=typeof Uint8Array!="undefined"?Uint8Array:Array,Om="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Po=0,X0=Om.length;Po0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Z2(r){var e=q0(r),t=e[0],n=e[1];return(t+n)*3/4-n}function $2(r,e,t){return(e+t)*3/4-t}function eI(r){var e,t=q0(r),n=t[0],i=t[1],s=new Q2($2(r,n,i)),o=0,a=i>0?n-4:n,l;for(l=0;l>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Li[r.charCodeAt(l)]<<2|Li[r.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=Li[r.charCodeAt(l)]<<10|Li[r.charCodeAt(l+1)]<<4|Li[r.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function tI(r){return yr[r>>18&63]+yr[r>>12&63]+yr[r>>6&63]+yr[r&63]}function nI(r,e,t){for(var n,i=[],s=e;sa?a:o+s));return n===1?(e=r[t-1],i.push(yr[e>>2]+yr[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(yr[e>>10]+yr[e>>4&63]+yr[e<<2&63]+"=")),i.join("")}});var tA=Ng((Xd,eA)=>{(function(r,e){typeof Xd=="object"&&typeof eA!="undefined"?e(Xd):typeof define=="function"&&define.amd?define(["exports"],e):e((r=typeof globalThis!="undefined"?globalThis:r||self).SVDJS={})})(Xd,function(r){"use strict";r.SVD=function(e,t,n,i,s){if(t=t===void 0||t,n=n===void 0||n,s=1e-64/(i=i||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var o,a,l,c,u,h,d,f,p,m,v,g,y=e[0].length,x=e.length;if(x>8&255]+Cn[r>>16&255]+Cn[r>>24&255]+"-"+Cn[e&255]+Cn[e>>8&255]+"-"+Cn[e>>16&15|64]+Cn[e>>24&255]+"-"+Cn[t&63|128]+Cn[t>>8&255]+"-"+Cn[t>>16&255]+Cn[t>>24&255]+Cn[n&255]+Cn[n>>8&255]+Cn[n>>16&255]+Cn[n>>24&255]).toUpperCase()}function Ln(r,e,t){return Math.max(e,Math.min(t,r))}function nf(r,e){return(r%e+e)%e}function k_(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function V_(r,e,t){return r!==e?(t-r)/(e-r):0}function Fl(r,e,t){return(1-t)*r+t*e}function H_(r,e,t,n){return Fl(r,e,1-Math.exp(-t*n))}function j_(r,e=1){return e-Math.abs(nf(r,e*2)-e)}function W_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function J_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function X_(r,e){return r+Math.floor(Math.random()*(e-r+1))}function q_(r,e){return r+Math.random()*(e-r)}function Y_(r){return r*(.5-Math.random())}function K_(r){return r!==void 0&&(Eu=r%2147483647),Eu=Eu*16807%2147483647,(Eu-1)/2147483646}function Q_(r){return r*Qo}function Z_(r){return r*Ol}function rf(r){return(r&r-1)==0&&r!==0}function $g(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function ey(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function $_(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),d=o((e-n)/2),f=s((n-e)/2),p=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*h,l*d,a*c);break;case"YZY":r.set(l*d,a*u,l*h,a*c);break;case"ZXZ":r.set(l*h,l*d,a*u,a*c);break;case"XZX":r.set(a*u,l*p,l*f,a*c);break;case"YXY":r.set(l*f,a*u,l*p,a*c);break;case"ZYZ":r.set(l*p,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}var Ee=Object.freeze({__proto__:null,DEG2RAD:Qo,RAD2DEG:Ol,generateUUID:fi,clamp:Ln,euclideanModulo:nf,mapLinear:k_,inverseLerp:V_,lerp:Fl,damp:H_,pingpong:j_,smoothstep:W_,smootherstep:J_,randInt:X_,randFloat:q_,randFloatSpread:Y_,seededRandom:K_,degToRad:Q_,radToDeg:Z_,isPowerOfTwo:rf,ceilPowerOfTwo:$g,floorPowerOfTwo:ey,setQuaternionFromProperEuler:$_}),O=class{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}};O.prototype.isVector2=!0;var Dt=class{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],p=n[8],m=i[0],v=i[3],g=i[6],y=i[1],x=i[4],b=i[7],w=i[2],_=i[5],S=i[8];return s[0]=o*m+a*y+l*w,s[3]=o*v+a*x+l*_,s[6]=o*g+a*b+l*S,s[1]=c*m+u*y+h*w,s[4]=c*v+u*x+h*_,s[7]=c*g+u*b+h*S,s[2]=d*m+f*y+p*w,s[5]=d*v+f*x+p*_,s[8]=d*g+f*b+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,d=a*l-u*s,f=c*s-o*l,p=t*h+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=h*m,e[1]=(i*c-u*n)*m,e[2]=(a*n-i*o)*m,e[3]=d*m,e[4]=(u*t-i*l)*m,e[5]=(i*s-a*t)*m,e[6]=f*m,e[7]=(n*l-c*t)*m,e[8]=(o*t-n*s)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],c=i[4],u=i[7];return i[0]=t*s+n*l,i[3]=t*o+n*c,i[6]=t*a+n*u,i[1]=-n*s+t*l,i[4]=-n*o+t*c,i[7]=-n*a+t*u,this}translate(e,t){let n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Dt.prototype.isMatrix3=!0;var Zo,Zs=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Zo===void 0&&(Zo=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Zo.width=e.width,Zo.height=e.height;let n=Zo.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Zo}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}},e1=0,xt=class extends cn{constructor(e=xt.DEFAULT_IMAGE,t=xt.DEFAULT_MAPPING,n=Zt,i=Zt,s=$e,o=Ai,a=zt,l=At,c=1,u=ln){super();Object.defineProperty(this,"id",{value:e1++}),this.uuid=fi(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new O(0,0),this.repeat=new O(1,1),this.center=new O(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Dt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){let i=this.image;if(i.uuid===void 0&&(i.uuid=fi()),!t&&e.images[i.uuid]===void 0){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o1)switch(this.wrapS){case di:e.x=e.x-Math.floor(e.x);break;case Zt:e.x=e.x<0?0:1;break;case qr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case di:e.y=e.y-Math.floor(e.y);break;case Zt:e.y=e.y<0?0:1;break;case qr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&this.version++}};xt.DEFAULT_IMAGE=void 0;xt.DEFAULT_MAPPING=Kd;xt.prototype.isTexture=!0;function sf(r){return typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap?Zs.getDataURL(r):r.data?{data:Array.prototype.slice.call(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Qe=class{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,o=.01,a=.1,l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],p=l[9],m=l[2],v=l[6],g=l[10];if(Math.abs(u-d)b&&x>w?xw?b=0?1:-1,x=1-g*g;if(x>Number.EPSILON){let w=Math.sqrt(x),_=Math.atan2(w,g*y);v=Math.sin(v*_)/w,a=Math.sin(a*_)/w}let b=a*y;if(l=l*v+d*b,c=c*v+f*b,u=u*v+p*b,h=h*v+m*b,v===1-a){let w=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=w,c*=w,u*=w,h*=w}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return e[t]=a*p+u*h+l*f-c*d,e[t+1]=l*p+u*d+c*h-a*f,e[t+2]=c*p+u*f+a*d-l*h,e[t+3]=u*p-a*h-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),h=a(s/2),d=l(n/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>h){let f=2*Math.sqrt(1+n-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>h){let f=2*Math.sqrt(1+a-n-h);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+h-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ln(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){this.copy(e).slerp(t,n)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};Tt.prototype.isQuaternion=!0;var M=class{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(ny.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ny.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*i-a*n,u=l*n+a*t-s*i,h=l*i+s*n-o*t,d=-s*t-o*n-a*i;return this.x=c*l+d*-s+u*-a-h*-o,this.y=u*l+d*-o+h*-s-c*-a,this.z=h*l+d*-a+c*-o-u*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return of.copy(this).projectOnVector(e),this.sub(of)}reflect(e){return this.sub(of.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ln(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}};M.prototype.isVector3=!0;var of=new M,ny=new Tt,tn=class{constructor(e=new M(1/0,1/0,1/0),t=new M(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.length;ls&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.count;ls&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,zl),zl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Gl),Nu.subVectors(this.max,Gl),$o.subVectors(e.a,Gl),ea.subVectors(e.b,Gl),ta.subVectors(e.c,Gl),$r.subVectors(ea,$o),es.subVectors(ta,ea),$s.subVectors($o,ta);let t=[0,-$r.z,$r.y,0,-es.z,es.y,0,-$s.z,$s.y,$r.z,0,-$r.x,es.z,0,-es.x,$s.z,0,-$s.x,-$r.y,$r.x,0,-es.y,es.x,0,-$s.y,$s.x,0];return!lf(t,$o,ea,ta,Nu)||(t=[1,0,0,0,1,0,0,0,1],!lf(t,$o,ea,ta,Nu))?!1:(Cu.crossVectors($r,es),t=[Cu.x,Cu.y,Cu.z],lf(t,$o,ea,ta,Nu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return zl.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(zl).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Nr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Nr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Nr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Nr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Nr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Nr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Nr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Nr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Nr),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};tn.prototype.isBox3=!0;var Nr=[new M,new M,new M,new M,new M,new M,new M,new M],zl=new M,af=new tn,$o=new M,ea=new M,ta=new M,$r=new M,es=new M,$s=new M,Gl=new M,Nu=new M,Cu=new M,eo=new M;function lf(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){eo.fromArray(r,s);let a=i.x*Math.abs(eo.x)+i.y*Math.abs(eo.y)+i.z*Math.abs(eo.z),l=e.dot(eo),c=t.dot(eo),u=n.dot(eo);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var t1=new tn,iy=new M,cf=new M,uf=new M,ti=class{constructor(e=new M,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):t1.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){uf.subVectors(e,this.center);let t=uf.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(uf.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return cf.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(iy.copy(e.center).add(cf)),this.expandByPoint(iy.copy(e.center).sub(cf)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Cr=new M,hf=new M,Lu=new M,ts=new M,df=new M,Iu=new M,ff=new M,or=class{constructor(e=new M,t=new M(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Cr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Cr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Cr.copy(this.direction).multiplyScalar(t).add(this.origin),Cr.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){hf.copy(e).add(t).multiplyScalar(.5),Lu.copy(t).sub(e).normalize(),ts.copy(this.origin).sub(hf);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Lu),a=ts.dot(this.direction),l=-ts.dot(Lu),c=ts.lengthSq(),u=Math.abs(1-o*o),h,d,f,p;if(u>0)if(h=o*l-a,d=o*a-l,p=s*u,h>=0)if(d>=-p)if(d<=p){let m=1/u;h*=m,d*=m,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d<=-p?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+c):d<=p?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+c);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(Lu).multiplyScalar(d).add(hf),f}intersectSphere(e,t){Cr.subVectors(e.center,this.origin);let n=Cr.dot(this.direction),i=Cr.dot(Cr)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(s=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||s>i||((s>n||n!==n)&&(n=s),(o=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Cr)!==null}intersectTriangle(e,t,n,i,s){df.subVectors(t,e),Iu.subVectors(n,e),ff.crossVectors(df,Iu);let o=this.direction.dot(ff),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ts.subVectors(this.origin,e);let l=a*this.direction.dot(Iu.crossVectors(ts,Iu));if(l<0)return null;let c=a*this.direction.dot(df.cross(ts));if(c<0||l+c>o)return null;let u=-a*ts.dot(ff);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},me=class{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,s,o,a,l,c,u,h,d,f,p,m,v){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=v,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 me().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/na.setFromMatrixColumn(e,0).length(),s=1/na.setFromMatrixColumn(e,1).length(),o=1/na.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=o*u,f=o*h,p=a*u,m=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+p*c,t[5]=d-m*c,t[9]=-a*l,t[2]=m-d*c,t[6]=p+f*c,t[10]=o*l}else if(e.order==="YXZ"){let d=l*u,f=l*h,p=c*u,m=c*h;t[0]=d+m*a,t[4]=p*a-f,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=f*a-p,t[6]=m+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*u,f=l*h,p=c*u,m=c*h;t[0]=d-m*a,t[4]=-o*h,t[8]=p+f*a,t[1]=f+p*a,t[5]=o*u,t[9]=m-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*u,f=o*h,p=a*u,m=a*h;t[0]=l*u,t[4]=p*c-f,t[8]=d*c+m,t[1]=l*h,t[5]=m*c+d,t[9]=f*c-p,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,f=o*c,p=a*l,m=a*c;t[0]=l*u,t[4]=m-d*h,t[8]=p*h+f,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=f*h+p,t[10]=d-m*h}else if(e.order==="XZY"){let d=o*l,f=o*c,p=a*l,m=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+m,t[5]=o*u,t[9]=f*h-p,t[2]=p*h-f,t[6]=a*u,t[10]=m*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(n1,e,i1)}lookAt(e,t,n){let i=this.elements;return pi.subVectors(e,t),pi.lengthSq()===0&&(pi.z=1),pi.normalize(),ns.crossVectors(n,pi),ns.lengthSq()===0&&(Math.abs(n.z)===1?pi.x+=1e-4:pi.z+=1e-4,pi.normalize(),ns.crossVectors(n,pi)),ns.normalize(),Pu.crossVectors(pi,ns),i[0]=ns.x,i[4]=Pu.x,i[8]=pi.x,i[1]=ns.y,i[5]=Pu.y,i[9]=pi.y,i[2]=ns.z,i[6]=Pu.z,i[10]=pi.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],p=n[2],m=n[6],v=n[10],g=n[14],y=n[3],x=n[7],b=n[11],w=n[15],_=i[0],S=i[4],A=i[8],T=i[12],L=i[1],C=i[5],U=i[9],P=i[13],R=i[2],G=i[6],B=i[10],j=i[14],ne=i[3],le=i[7],W=i[11],z=i[15];return s[0]=o*_+a*L+l*R+c*ne,s[4]=o*S+a*C+l*G+c*le,s[8]=o*A+a*U+l*B+c*W,s[12]=o*T+a*P+l*j+c*z,s[1]=u*_+h*L+d*R+f*ne,s[5]=u*S+h*C+d*G+f*le,s[9]=u*A+h*U+d*B+f*W,s[13]=u*T+h*P+d*j+f*z,s[2]=p*_+m*L+v*R+g*ne,s[6]=p*S+m*C+v*G+g*le,s[10]=p*A+m*U+v*B+g*W,s[14]=p*T+m*P+v*j+g*z,s[3]=y*_+x*L+b*R+w*ne,s[7]=y*S+x*C+b*G+w*le,s[11]=y*A+x*U+b*B+w*W,s[15]=y*T+x*P+b*j+w*z,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],p=e[3],m=e[7],v=e[11],g=e[15];return p*(+s*l*h-i*c*h-s*a*d+n*c*d+i*a*f-n*l*f)+m*(+t*l*f-t*c*d+s*o*d-i*o*f+i*c*u-s*l*u)+v*(+t*c*h-t*a*f-s*o*h+n*o*f+s*a*u-n*c*u)+g*(-i*a*u-t*l*h+t*a*d+i*o*h-n*o*d+n*l*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],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is(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,d=s*c,f=s*u,p=s*h,m=o*u,v=o*h,g=a*h,y=l*c,x=l*u,b=l*h,w=n.x,_=n.y,S=n.z;return i[0]=(1-(m+g))*w,i[1]=(f+b)*w,i[2]=(p-x)*w,i[3]=0,i[4]=(f-b)*_,i[5]=(1-(d+g))*_,i[6]=(v+y)*_,i[7]=0,i[8]=(p+x)*S,i[9]=(v-y)*S,i[10]=(1-(d+m))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=na.set(i[0],i[1],i[2]).length(),o=na.set(i[4],i[5],i[6]).length(),a=na.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],zi.copy(this);let c=1/s,u=1/o,h=1/a;return zi.elements[0]*=c,zi.elements[1]*=c,zi.elements[2]*=c,zi.elements[4]*=u,zi.elements[5]*=u,zi.elements[6]*=u,zi.elements[8]*=h,zi.elements[9]*=h,zi.elements[10]*=h,t.setFromRotationMatrix(zi),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,l=2*s/(t-e),c=2*s/(n-i),u=(t+e)/(t-e),h=(n+i)/(n-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,s,o){let a=this.elements,l=1/(t-e),c=1/(n-i),u=1/(o-s),h=(t+e)*l,d=(n+i)*c,f=(o+s)*u;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};me.prototype.isMatrix4=!0;var na=new M,zi=new me,n1=new M(0,0,0),i1=new M(1,1,1),ns=new M,Pu=new M,pi=new M,ry=new me,sy=new Tt,On=class{constructor(e=0,t=0,n=0,i=On.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(Ln(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ln(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ln(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Ln(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Ln(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Ln(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ry.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ry,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return sy.setFromEuler(this),this.setFromQuaternion(sy,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new M(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}};On.prototype.isEuler=!0;On.DefaultOrder="XYZ";On.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var pf=class{constructor(){this.mask=1|0}set(e){this.mask=1<1){for(let t=0;t1){for(let n=0;n0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f)}return n.object=i,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Gi.subVectors(i,t),Ir.subVectors(n,t),mf.subVectors(e,t);let o=Gi.dot(Gi),a=Gi.dot(Ir),l=Gi.dot(mf),c=Ir.dot(Ir),u=Ir.dot(mf),h=o*c-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(c*l-a*u)*d,p=(o*u-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Pr),Pr.x>=0&&Pr.y>=0&&Pr.x+Pr.y<=1}static getUV(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Pr),l.set(0,0),l.addScaledVector(s,Pr.x),l.addScaledVector(o,Pr.y),l.addScaledVector(a,Pr.z),l}static isFrontFacing(e,t,n,i){return Gi.subVectors(n,t),Ir.subVectors(e,t),Gi.cross(Ir).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Gi.subVectors(this.c,this.b),Ir.subVectors(this.a,this.b),Gi.cross(Ir).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return qt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return qt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return qt.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return qt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;ra.subVectors(i,n),sa.subVectors(s,n),gf.subVectors(e,n);let l=ra.dot(gf),c=sa.dot(gf);if(l<=0&&c<=0)return t.copy(n);yf.subVectors(e,i);let u=ra.dot(yf),h=sa.dot(yf);if(u>=0&&h<=u)return t.copy(i);let d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(ra,o);vf.subVectors(e,s);let f=ra.dot(vf),p=sa.dot(vf);if(p>=0&&f<=p)return t.copy(s);let m=f*c-l*p;if(m<=0&&c>=0&&p<=0)return a=c/(c-p),t.copy(n).addScaledVector(sa,a);let v=u*p-f*h;if(v<=0&&h-u>=0&&f-p>=0)return hy.subVectors(s,i),a=(h-u)/(h-u+(f-p)),t.copy(i).addScaledVector(hy,a);let g=1/(v+m+d);return o=m*g,a=d*g,t.copy(n).addScaledVector(ra,o).addScaledVector(sa,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},l1=0,nn=class extends cn{constructor(){super();Object.defineProperty(this,"id",{value:l1++}),this.uuid=fi(),this.name="",this.type="Material",this.fog=!0,this.blending=Vs,this.side=Oi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Gg,this.blendDst=Ug,this.blendEquation=Vo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Yd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=U_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=tf,this.stencilZFail=tf,this.stencilZPass=tf,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===Dg;continue}let i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,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&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.specularTint&&this.specularTint.isColor&&(n.specularTint=this.specularTint.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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(n.specularTintMap=this.specularTintMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),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(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationTint!==void 0&&(n.attenuationTint=this.attenuationTint.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!==Vs&&(n.blending=this.blending),this.side!==Oi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&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&&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.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),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=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};nn.prototype.isMaterial=!0;var dy={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},Ui={h:0,s:0,l:0},Ru={h:0,s:0,l:0};function xf(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function bf(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function wf(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var fe=class{constructor(e,t,n){return t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=nf(e,1),t=Ln(t,0,1),n=Ln(n,0,1),t===0)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,s=2*n-i;this.r=xf(s,i,e+1/3),this.g=xf(s,i,e),this.b=xf(s,i,e-1/3)}return this}setStyle(e){function t(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let i,s=n[1],o=n[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[4]),this;if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[4]),this;break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){let a=parseFloat(i[1])/360,l=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return t(i[4]),this.setHSL(a,l,c)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=n[1],s=i.length;if(s===3)return this.r=parseInt(i.charAt(0)+i.charAt(0),16)/255,this.g=parseInt(i.charAt(1)+i.charAt(1),16)/255,this.b=parseInt(i.charAt(2)+i.charAt(2),16)/255,this;if(s===6)return this.r=parseInt(i.charAt(0)+i.charAt(1),16)/255,this.g=parseInt(i.charAt(2)+i.charAt(3),16)/255,this.b=parseInt(i.charAt(4)+i.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){let t=dy[e.toLowerCase()];return t!==void 0?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){let n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=bf(e.r),this.g=bf(e.g),this.b=bf(e.b),this}copyLinearToSRGB(e){return this.r=wf(e.r),this.g=wf(e.g),this.b=wf(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){let t=this.r,n=this.g,i=this.b,s=Math.max(t,n,i),o=Math.min(t,n,i),a,l,c=(o+s)/2;if(o===s)a=0,l=0;else{let u=s-o;switch(l=c<=.5?u/(s+o):u/(2-s-o),s){case t:a=(n-i)/u+(ne&&(e=r[t]);return e}var c1={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function oa(r,e){return new c1[r](e)}var u1=0,_i=new me,Af=new Ke,aa=new M,mi=new tn,kl=new tn,Mn=new M,we=class extends cn{constructor(){super();Object.defineProperty(this,"id",{value:u1++}),this.uuid=fi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(py(e)>65535?is:Mf)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new Dt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return _i.makeRotationFromQuaternion(e),this.applyMatrix4(_i),this}rotateX(e){return _i.makeRotationX(e),this.applyMatrix4(_i),this}rotateY(e){return _i.makeRotationY(e),this.applyMatrix4(_i),this}rotateZ(e){return _i.makeRotationZ(e),this.applyMatrix4(_i),this}translate(e,t,n){return _i.makeTranslation(e,t,n),this.applyMatrix4(_i),this}scale(e,t,n){return _i.makeScale(e,t,n),this.applyMatrix4(_i),this}lookAt(e){return Af.lookAt(e),Af.updateMatrix(),this.applyMatrix4(Af.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(aa).negate(),this.translate(aa.x,aa.y,aa.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new we().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let c in i){let u=i[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let d=0,f=h.length;d0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),_f.copy(n.boundingSphere),_f.applyMatrix4(s),e.ray.intersectsSphere(_f)===!1)||(my.copy(s).invert(),la.copy(e.ray).applyMatrix4(my),n.boundingBox!==null&&la.intersectsBox(n.boundingBox)===!1))return;let o;if(n.isBufferGeometry){let a=n.index,l=n.attributes.position,c=n.morphAttributes.position,u=n.morphTargetsRelative,h=n.attributes.uv,d=n.attributes.uv2,f=n.groups,p=n.drawRange;if(a!==null)if(Array.isArray(i))for(let m=0,v=f.length;mt.far?null:{distance:c,point:Vu.clone(),object:r}}function Hu(r,e,t,n,i,s,o,a,l,c,u,h){rs.fromBufferAttribute(i,c),ss.fromBufferAttribute(i,u),os.fromBufferAttribute(i,h);let d=r.morphTargetInfluences;if(s&&d){Ou.set(0,0,0),Fu.set(0,0,0),zu.set(0,0,0);for(let p=0,m=s.length;p0?1:-1,u.push(le.x,le.y,le.z),h.push(D/S),h.push(1-W/A),j+=1}}for(let W=0;W0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}};_t.prototype.isShaderMaterial=!0;var Dr=class extends Ke{constructor(){super();this.type="Camera",this.matrixWorldInverse=new me,this.projectionMatrix=new me,this.projectionMatrixInverse=new me}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};Dr.prototype.isCamera=!0;var Vt=class extends Dr{constructor(e=50,t=1,n=.1,i=2e3){super();this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Ol*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Qo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ol*2*Math.atan(Math.tan(Qo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,o){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Qo*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};Vt.prototype.isPerspectiveCamera=!0;var ua=90,ha=1,ju=class extends Ke{constructor(e,t,n){super();if(this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;let i=new Vt(ua,ha,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new M(1,0,0)),this.add(i);let s=new Vt(ua,ha,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new M(-1,0,0)),this.add(s);let o=new Vt(ua,ha,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new M(0,1,0)),this.add(o);let a=new Vt(ua,ha,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new M(0,-1,0)),this.add(a);let l=new Vt(ua,ha,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new M(0,0,1)),this.add(l);let c=new Vt(ua,ha,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new M(0,0,-1)),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget,[i,s,o,a,l,c]=this.children,u=e.xr.enabled,h=e.getRenderTarget();e.xr.enabled=!1;let d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(h),e.xr.enabled=u}},as=class extends xt{constructor(e,t,n,i,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:js,a=a!==void 0?a:Nt;super(e,t,n,i,s,o,a,l,c,u);this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};as.prototype.isCubeTexture=!0;var Lf=class extends bt{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n);super(e,e,t);t=t||{},this.texture=new as(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:$e,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=zt,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let 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 jn(5,5,5),s=new _t({name:"CubemapFromEquirect",uniforms:ca(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:kt,blending:It});s.uniforms.tEquirect.value=t;let o=new gt(i,s),a=t.minFilter;return t.minFilter===Ai&&(t.minFilter=$e),new ju(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}};Lf.prototype.isWebGLCubeRenderTarget=!0;var If=new M,p1=new M,m1=new Dt,ni=class{constructor(e=new M(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=If.subVectors(n,t).cross(p1.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let n=e.delta(If),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||m1.getNormalMatrix(e),i=this.coplanarPoint(If).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};ni.prototype.isPlane=!0;var da=new ti,Wu=new M,Vl=class{constructor(e=new ni,t=new ni,n=new ni,i=new ni,s=new ni,o=new ni){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,i=n[0],s=n[1],o=n[2],a=n[3],l=n[4],c=n[5],u=n[6],h=n[7],d=n[8],f=n[9],p=n[10],m=n[11],v=n[12],g=n[13],y=n[14],x=n[15];return t[0].setComponents(a-i,h-l,m-d,x-v).normalize(),t[1].setComponents(a+i,h+l,m+d,x+v).normalize(),t[2].setComponents(a+s,h+c,m+f,x+g).normalize(),t[3].setComponents(a-s,h-c,m-f,x-g).normalize(),t[4].setComponents(a-o,h-u,m-p,x-y).normalize(),t[5].setComponents(a+o,h+u,m+p,x+y).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),da.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(da)}intersectsSprite(e){return da.center.set(0,0,0),da.radius=.7071067811865476,da.applyMatrix4(e.matrixWorld),this.intersectsSphere(da)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,Wu.y=i.normal.y>0?e.max.y:e.min.y,Wu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Wu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function gy(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function g1(r,e){let t=e.isWebGL2,n=new WeakMap;function i(c,u){let h=c.array,d=c.usage,f=r.createBuffer();r.bindBuffer(u,f),r.bufferData(u,h,d),c.onUploadCallback();let p=5126;return h instanceof Float32Array?p=5126:h instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):h instanceof Uint16Array?c.isFloat16BufferAttribute?t?p=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):p=5123:h instanceof Int16Array?p=5122:h instanceof Uint32Array?p=5125:h instanceof Int32Array?p=5124:h instanceof Int8Array?p=5120:(h instanceof Uint8Array||h instanceof Uint8ClampedArray)&&(p=5121),{buffer:f,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){let d=u.array,f=u.updateRange;r.bindBuffer(h,c),f.count===-1?r.bufferSubData(h,0,d):(t?r.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=n.get(c);u&&(r.deleteBuffer(u.buffer),n.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=n.get(c);(!d||d.version 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in vec3 f90, const in float dotVH ) { float fresnel = exp2( ( -5.55473 * dotVH - 6.98316 ) * dotVH ); return ( f90 - f0 ) * fresnel + f0; } vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) { float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV ); vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0; return Fr * fresnel + F0; } float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); return 1.0 / ( gl * gv ); } float G_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 ); } vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in vec3 f90, const in float roughness ) { float alpha = pow2( roughness ); vec3 halfDir = normalize( incidentLight.direction + viewDir ); float dotNL = saturate( dot( normal, incidentLight.direction ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotLH = saturate( dot( incidentLight.direction, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotLH ); float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( G * 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 ); } vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 brdf = integrateSpecularBRDF( dotNV, roughness ); return specularColor * brdf.x + brdf.y; } void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness ); vec2 brdf = integrateSpecularBRDF( dotNV, roughness ); vec3 FssEss = F * brdf.x + brdf.y; float Ess = brdf.x + brdf.y; float Ems = 1.0 - Ess; vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir ); float dotNH = saturate( dot( geometry.normal, halfDir ) ); float dotLH = saturate( dot( incidentLight.direction, halfDir ) ); vec3 F = F_Schlick( specularColor, vec3( 1.0 ), dotLH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) { return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 ); } float BlinnExponentToGGXRoughness( const in float blinnExponent ) { return sqrt( 2.0 / ( blinnExponent + 2.0 ) ); } #if defined( USE_SHEEN ) float D_Charlie(float roughness, float NoH) { float invAlpha = 1.0 / roughness; float cos2h = NoH * NoH; float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI); } float V_Neubelt(float NoV, float NoL) { return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV))); } vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) { vec3 N = geometry.normal; vec3 V = geometry.viewDir; vec3 H = normalize( V + L ); float dotNH = saturate( dot( N, H ) ); return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) ); } #endif`,_1=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,T1=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #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`,E1=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,N1=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,C1=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,L1=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,I1=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,P1=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,D1=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,R1=`#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; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } 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 max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); } 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; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef CLEARCOAT vec3 clearcoatNormal; #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 ); } vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) { float distance = dot( planeNormal, point - pointOnPlane ); return - distance * planeNormal + point; } float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) { return sign( dot( point - pointOnPlane, planeNormal ) ); } vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) { return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine; } 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 linearToRelativeLuminance( const in vec3 color ) { vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); return dot( weights, color.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 ); }`,B1=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_maxMipLevel 8.0 #define cubeUV_minMipLevel 4.0 #define cubeUV_maxTileSize 256.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 ); float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize ); vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ); vec2 f = fract( uv ); uv += 0.5 - f; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; if ( mipInt < cubeUV_maxMipLevel ) { uv.y += 2.0 * cubeUV_maxTileSize; } uv.y += filterInt * 2.0 * cubeUV_minTileSize; uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize ); uv *= texelSize; vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; uv.x += texelSize; vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; uv.y += texelSize; vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; uv.x -= texelSize; vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb; vec3 tm = mix( tl, tr, f.x ); vec3 bm = mix( bl, br, f.x ); return mix( tm, bm, f.y ); } #define r0 1.0 #define v0 0.339 #define m0 - 2.0 #define r1 0.8 #define v1 0.276 #define m1 - 1.0 #define r4 0.4 #define v4 0.046 #define m4 2.0 #define r5 0.305 #define v5 0.016 #define m5 3.0 #define r6 0.21 #define v6 0.0038 #define m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= r1 ) { mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0; } else if ( roughness >= r4 ) { mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1; } else if ( roughness >= r5 ) { mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4; } else if ( roughness >= r6 ) { mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel ); 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`,O1=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,F1=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,z1=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,G1=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; totalEmissiveRadiance *= emissiveColor.rgb; #endif`,U1=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,k1="gl_FragColor = linearToOutputTexel( gl_FragColor );",V1=` vec4 LinearToLinear( in vec4 value ) { return value; } vec4 GammaToLinear( in vec4 value, in float gammaFactor ) { return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a ); } vec4 LinearToGamma( in vec4 value, in float gammaFactor ) { return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a ); } vec4 sRGBToLinear( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 LinearTosRGB( 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 RGBEToLinear( in vec4 value ) { return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 ); } vec4 LinearToRGBE( in vec4 value ) { float maxComponent = max( max( value.r, value.g ), value.b ); float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 ); return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 ); } vec4 RGBMToLinear( in vec4 value, in float maxRange ) { return vec4( value.rgb * value.a * maxRange, 1.0 ); } vec4 LinearToRGBM( in vec4 value, in float maxRange ) { float maxRGB = max( value.r, max( value.g, value.b ) ); float M = clamp( maxRGB / maxRange, 0.0, 1.0 ); M = ceil( M * 255.0 ) / 255.0; return vec4( value.rgb / ( M * maxRange ), M ); } vec4 RGBDToLinear( in vec4 value, in float maxRange ) { return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 ); } vec4 LinearToRGBD( in vec4 value, in float maxRange ) { float maxRGB = max( value.r, max( value.g, value.b ) ); float D = max( maxRange / maxRGB, 1.0 ); D = clamp( floor( D ) / 255.0, 0.0, 1.0 ); return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D ); } const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 ); vec4 LinearToLogLuv( in vec4 value ) { vec3 Xp_Y_XYZp = cLogLuvM * value.rgb; Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) ); vec4 vResult; vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z; float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0; vResult.w = fract( Le ); vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0; return vResult; } const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 ); vec4 LogLuvToLinear( in vec4 value ) { float Le = value.z * 255.0 + value.w; vec3 Xp_Y_XYZp; Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 ); Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y; Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z; vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb; return vec4( max( vRGB, 0.0 ), 1.0 ); }`,H1=`#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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); #else vec4 envColor = vec4( 0.0 ); #endif #ifndef ENVMAP_TYPE_CUBE_UV envColor = envMapTexelToLinear( envColor ); #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`,j1=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform int maxMipLevel; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,W1=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,J1=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,X1=`#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`,q1=`#ifdef USE_FOG fogDepth = - mvPosition.z; #endif`,Y1=`#ifdef USE_FOG varying float fogDepth; #endif`,K1=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, fogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,Q1=`#ifdef USE_FOG uniform vec3 fogColor; varying float fogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,Z1=`#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 texture2D( gradientMap, coord ).rgb; #else return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); #endif }`,$1=`#ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #endif`,eT=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,tT=`vec3 diffuse = vec3( 1.0 ); GeometricContext geometry; geometry.position = mvPosition.xyz; geometry.normal = normalize( transformedNormal ); geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); GeometricContext backGeometry; backGeometry.position = geometry.position; backGeometry.normal = -geometry.normal; backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); #endif IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); vIndirectFront += getLightProbeIrradiance( lightProbe, geometry ); #ifdef DOUBLE_SIDED vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry ); #endif #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_HEMI_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); #ifdef DOUBLE_SIDED vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry ); #endif } #pragma unroll_loop_end #endif`,nT=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; 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 GeometricContext geometry ) { vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif return irradiance; } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) { directLight.color = directionalLight.color; directLight.direction = directionalLight.direction; directLight.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 getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) { vec3 lVector = pointLight.position - geometry.position; directLight.direction = normalize( lVector ); float lightDistance = length( lVector ); directLight.color = pointLight.color; directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay ); directLight.visible = ( directLight.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 getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) { vec3 lVector = spotLight.position - geometry.position; directLight.direction = normalize( lVector ); float lightDistance = length( lVector ); float angleCos = dot( directLight.direction, spotLight.direction ); if ( angleCos > spotLight.coneCos ) { float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos ); directLight.color = spotLight.color; directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay ); directLight.visible = true; } else { directLight.color = vec3( 0.0 ); directLight.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 GeometricContext geometry ) { float dotNL = dot( geometry.normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif return irradiance; } #endif`,iT=`#if defined( USE_ENVMAP ) #ifdef ENVMAP_MODE_REFRACTION uniform float refractionRatio; #endif vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) { vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix ); #ifdef ENVMAP_TYPE_CUBE vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) ); #else vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); #else vec4 envMapColor = vec4( 0.0 ); #endif return PI * envMapColor.rgb * envMapIntensity; } float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) { float maxMIPLevelScalar = float( maxMIPLevel ); float sigma = PI * roughness * roughness / ( 1.0 + roughness ); float desiredMIPLevel = maxMIPLevelScalar + log2( sigma ); return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar ); } vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) { #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( -viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); #else vec3 reflectVec = refract( -viewDir, normal, refractionRatio ); #endif reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel ); #ifdef ENVMAP_TYPE_CUBE vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz ); #ifdef TEXTURE_LOD_EXT vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel ); #else vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel ); #endif envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb; #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); #endif return envMapColor.rgb * envMapIntensity; } #endif`,rT=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,sT=`varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon #define Material_LightProbeLOD( material ) (0)`,oT=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,aT=`varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong #define Material_LightProbeLOD( material ) (0)`,lT=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness; material.specularRoughness = min( material.specularRoughness, 1.0 ); #ifdef REFLECTIVITY #ifdef SPECULAR vec3 specularIntensityFactor = vec3( specularIntensity ); vec3 specularTintFactor = specularTint; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARTINTMAP specularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, vUv ) ).rgb; #endif material.specularColorF90 = mix( specularIntensityFactor, vec3( 1.0 ), metalnessFactor ); #else vec3 specularIntensityFactor = vec3( 1.0 ); vec3 specularTintFactor = vec3( 1.0 ); material.specularColorF90 = vec3( 1.0 ); #endif material.specularColor = mix( min( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ) * specularTintFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor ); material.specularColorF90 = vec3( 1.0 ); #endif #ifdef CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_SHEEN material.sheenColor = sheen; #endif`,cT=`struct PhysicalMaterial { vec3 diffuseColor; float specularRoughness; vec3 specularColor; vec3 specularColorF90; #ifdef CLEARCOAT float clearcoat; float clearcoatRoughness; #endif #ifdef USE_SHEEN vec3 sheenColor; #endif }; #define MAXIMUM_SPECULAR_COEFFICIENT 0.16 #define DEFAULT_SPECULAR_COEFFICIENT 0.04 float clearcoatDHRApprox( const in float roughness, const in float dotNL ) { return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) ); } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.specularRoughness; 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif #ifdef CLEARCOAT float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = ccDotNL * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS ccIrradiance *= PI; #endif float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL ); reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), vec3( 1.0 ), material.clearcoatRoughness ); #else float clearcoatDHR = 0.0; #endif #ifdef USE_SHEEN reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen( material.specularRoughness, directLight.direction, geometry, material.sheenColor ); #else reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularColorF90, material.specularRoughness); #endif reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef CLEARCOAT float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness ); float ccDotNL = ccDotNV; float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL ); #else float clearcoatDHR = 0.0; #endif float clearcoatInv = 1.0 - clearcoatDHR; vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering ); vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); reflectedLight.indirectSpecular += clearcoatInv * 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 ); }`,uT=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #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 ]; getPointDirectLightIrradiance( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; #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 ]; getSpotDirectLightIrradiance( spotLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, 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 ]; getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, 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, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,hT=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel= texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #ifndef PHYSICALLY_CORRECT_LIGHTS lightMapIrradiance *= PI; #endif irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel ); #ifdef CLEARCOAT clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel ); #endif #endif`,dT=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,fT=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,pT=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,mT=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,gT=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,yT=`#ifdef USE_MAP vec4 texelColor = texture2D( map, vUv ); texelColor = mapTexelToLinear( texelColor ); diffuseColor *= texelColor; #endif`,vT=`#ifdef USE_MAP uniform sampler2D map; #endif`,xT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP vec4 mapTexel = texture2D( map, uv ); diffuseColor *= mapTexelToLinear( mapTexel ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,bT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,wT=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,ST=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,MT=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif`,AT=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif`,_T=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif`,TT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,ET=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,NT=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.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 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`,CT=`#ifdef CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,LT=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); #endif #endif`,IT=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,PT=`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 ); } 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 linearClipZ, const in float near, const in float far ) { return linearClipZ * ( 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 invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,DT=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,RT=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,BT=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,OT=`#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`,FT=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,zT=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,GT=`#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 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 ]; varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { 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 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 shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); bool inFrustum = all( inFrustumVec ); bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); bool frustumTest = all( frustumTestVec ); 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 shadow; } 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 shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( 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 return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,UT=`#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 shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { 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 shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,kT=`#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #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_SPOT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 ); vSpotShadowCoord[ i ] = spotShadowMatrix[ 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`,VT=`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.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.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ 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.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,HT=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,jT=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; #ifdef BONE_TEXTURE uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #else uniform mat4 boneMatrices[ MAX_BONES ]; mat4 getBoneMatrix( const in float i ) { mat4 bone = boneMatrices[ int(i) ]; return bone; } #endif #endif`,WT=`#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`,JT=`#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`,XT=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,qT=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,YT=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,KT=`#ifndef saturate #define saturate(a) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return 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 ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,QT=`#ifdef USE_TRANSMISSION float transmissionFactor = transmission; float thicknessFactor = thickness; #ifdef USE_TRANSMISSIONMAP transmissionFactor *= texture2D( transmissionMap, vUv ).r; #endif #ifdef USE_THICKNESSMAP thicknessFactor *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition.xyz / vWorldPosition.w; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); float ior = ( 1.0 + 0.4 * reflectivity ) / ( 1.0 - 0.4 * reflectivity ); vec3 transmission = transmissionFactor * getIBLVolumeRefraction( n, v, roughnessFactor, material.diffuseColor, material.specularColor, pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor, attenuationTint, attenuationDistance ); totalDiffuse = mix( totalDiffuse, transmission, transmissionFactor ); #endif`,ZT=`#ifdef USE_TRANSMISSION #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 vec4 vWorldPosition; vec3 getVolumeTransmissionRay(vec3 n, vec3 v, float thickness, float ior, 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(float roughness, float ior) { return roughness * clamp(ior * 2.0 - 2.0, 0.0, 1.0); } vec3 getTransmissionSample(vec2 fragCoord, float roughness, float ior) { float framebufferLod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness, ior); return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod).rgb; } vec3 applyVolumeAttenuation(vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance) { if (attenuationDistance == 0.0) { return radiance; } else { vec3 attenuationCoefficient = -log(attenuationColor) / attenuationDistance; vec3 transmittance = exp(-attenuationCoefficient * transmissionDistance); return transmittance * radiance; } } vec3 getIBLVolumeRefraction(vec3 n, vec3 v, float perceptualRoughness, vec3 baseColor, vec3 specularColor, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec3 attenuationColor, float attenuationDistance) { 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; vec3 transmittedLight = getTransmissionSample(refractionCoords, perceptualRoughness, ior); vec3 attenuatedColor = applyVolumeAttenuation(transmittedLight, length(transmissionRay), attenuationColor, attenuationDistance); return (1.0 - specularColor) * attenuatedColor * baseColor; } #endif`,$T=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,eE=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,tE=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,nE=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,iE=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,rE=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,sE=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,oE=`uniform sampler2D t2D; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,aE=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,lE=`#include uniform float opacity; varying vec3 vWorldDirection; #include void main() { vec3 vReflect = vWorldDirection; #include gl_FragColor = envColor; gl_FragColor.a *= opacity; #include #include }`,cE=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,uE=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #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 }`,hE=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,dE=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,fE=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,pE=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); vec4 texColor = texture2D( tEquirect, sampleUV ); gl_FragColor = mapTexelToLinear( texColor ); #include #include }`,mE=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,gE=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,yE=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include }`,vE=`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() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #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, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,xE=`#include #include #include #include #include #include #include #include #include #include void main() { #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 }`,bE=`uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 #ifdef DOUBLE_SIDED reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; #else reflectedLight.indirectDiffuse += vIndirectFront; #endif #include reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ); #ifdef DOUBLE_SIDED reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; #else reflectedLight.directDiffuse = vLightFront; #endif reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask(); #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,wE=`#define LAMBERT varying vec3 vLightFront; varying vec3 vIndirectFront; #ifdef DOUBLE_SIDED varying vec3 vLightBack; varying vec3 vIndirectBack; #endif #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 #include }`,SE=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #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 ); matcapColor = matcapTexelToLinear( matcapColor ); #else vec4 matcapColor = vec4( 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,ME=`#define MATCAP varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,AE=`#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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,_E=`#define TOON varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,TE=`#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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,EE=`#define PHONG varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,NE=`#define STANDARD #ifdef PHYSICAL #define REFLECTIVITY #define CLEARCOAT #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationTint; #endif #ifdef REFLECTIVITY uniform float reflectivity; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularTint; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARTINTMAP uniform sampler2D specularTintMap; #endif #endif #ifdef CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_SHEEN uniform vec3 sheen; #endif varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #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() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include #include }`,CE=`#define STANDARD varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #ifdef USE_TRANSMISSION varying vec4 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition; #endif }`,LE=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); }`,IE=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,PE=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include #include }`,DE=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #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 }`,RE=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,BE=`#include #include #include void main() { #include #include #include #include #include #include #include #include #include #include }`,OE=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; gl_FragColor = vec4( outgoingLight, diffuseColor.a ); #include #include #include }`,FE=`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 }`,at={alphamap_fragment:y1,alphamap_pars_fragment:v1,alphatest_fragment:x1,aomap_fragment:b1,aomap_pars_fragment:w1,begin_vertex:S1,beginnormal_vertex:M1,bsdfs:A1,bumpmap_pars_fragment:_1,clipping_planes_fragment:T1,clipping_planes_pars_fragment:E1,clipping_planes_pars_vertex:N1,clipping_planes_vertex:C1,color_fragment:L1,color_pars_fragment:I1,color_pars_vertex:P1,color_vertex:D1,common:R1,cube_uv_reflection_fragment:B1,defaultnormal_vertex:O1,displacementmap_pars_vertex:F1,displacementmap_vertex:z1,emissivemap_fragment:G1,emissivemap_pars_fragment:U1,encodings_fragment:k1,encodings_pars_fragment:V1,envmap_fragment:H1,envmap_common_pars_fragment:j1,envmap_pars_fragment:W1,envmap_pars_vertex:J1,envmap_physical_pars_fragment:iT,envmap_vertex:X1,fog_vertex:q1,fog_pars_vertex:Y1,fog_fragment:K1,fog_pars_fragment:Q1,gradientmap_pars_fragment:Z1,lightmap_fragment:$1,lightmap_pars_fragment:eT,lights_lambert_vertex:tT,lights_pars_begin:nT,lights_toon_fragment:rT,lights_toon_pars_fragment:sT,lights_phong_fragment:oT,lights_phong_pars_fragment:aT,lights_physical_fragment:lT,lights_physical_pars_fragment:cT,lights_fragment_begin:uT,lights_fragment_maps:hT,lights_fragment_end:dT,logdepthbuf_fragment:fT,logdepthbuf_pars_fragment:pT,logdepthbuf_pars_vertex:mT,logdepthbuf_vertex:gT,map_fragment:yT,map_pars_fragment:vT,map_particle_fragment:xT,map_particle_pars_fragment:bT,metalnessmap_fragment:wT,metalnessmap_pars_fragment:ST,morphnormal_vertex:MT,morphtarget_pars_vertex:AT,morphtarget_vertex:_T,normal_fragment_begin:TT,normal_fragment_maps:ET,normalmap_pars_fragment:NT,clearcoat_normal_fragment_begin:CT,clearcoat_normal_fragment_maps:LT,clearcoat_pars_fragment:IT,packing:PT,premultiplied_alpha_fragment:DT,project_vertex:RT,dithering_fragment:BT,dithering_pars_fragment:OT,roughnessmap_fragment:FT,roughnessmap_pars_fragment:zT,shadowmap_pars_fragment:GT,shadowmap_pars_vertex:UT,shadowmap_vertex:kT,shadowmask_pars_fragment:VT,skinbase_vertex:HT,skinning_pars_vertex:jT,skinning_vertex:WT,skinnormal_vertex:JT,specularmap_fragment:XT,specularmap_pars_fragment:qT,tonemapping_fragment:YT,tonemapping_pars_fragment:KT,transmission_fragment:QT,transmission_pars_fragment:ZT,uv_pars_fragment:$T,uv_pars_vertex:eE,uv_vertex:tE,uv2_pars_fragment:nE,uv2_pars_vertex:iE,uv2_vertex:rE,worldpos_vertex:sE,background_frag:oE,background_vert:aE,cube_frag:lE,cube_vert:cE,depth_frag:uE,depth_vert:hE,distanceRGBA_frag:dE,distanceRGBA_vert:fE,equirect_frag:pE,equirect_vert:mE,linedashed_frag:gE,linedashed_vert:yE,meshbasic_frag:vE,meshbasic_vert:xE,meshlambert_frag:bE,meshlambert_vert:wE,meshmatcap_frag:SE,meshmatcap_vert:ME,meshtoon_frag:AE,meshtoon_vert:_E,meshphong_frag:TE,meshphong_vert:EE,meshphysical_frag:NE,meshphysical_vert:CE,normal_frag:LE,normal_vert:IE,points_frag:PE,points_vert:DE,shadow_frag:RE,shadow_vert:BE,sprite_frag:OE,sprite_vert:FE},be={common:{diffuse:{value:new fe(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Dt},uv2Transform:{value:new Dt},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new O(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new fe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 fe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Dt}},sprite:{diffuse:{value:new fe(16777215)},opacity:{value:1},center:{value:new O(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Dt}}},ar={basic:{uniforms:Fn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:at.meshbasic_vert,fragmentShader:at.meshbasic_frag},lambert:{uniforms:Fn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.fog,be.lights,{emissive:{value:new fe(0)}}]),vertexShader:at.meshlambert_vert,fragmentShader:at.meshlambert_frag},phong:{uniforms:Fn([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new fe(0)},specular:{value:new fe(1118481)},shininess:{value:30}}]),vertexShader:at.meshphong_vert,fragmentShader:at.meshphong_frag},standard:{uniforms:Fn([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new fe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:at.meshphysical_vert,fragmentShader:at.meshphysical_frag},toon:{uniforms:Fn([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new fe(0)}}]),vertexShader:at.meshtoon_vert,fragmentShader:at.meshtoon_frag},matcap:{uniforms:Fn([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:at.meshmatcap_vert,fragmentShader:at.meshmatcap_frag},points:{uniforms:Fn([be.points,be.fog]),vertexShader:at.points_vert,fragmentShader:at.points_frag},dashed:{uniforms:Fn([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:at.linedashed_vert,fragmentShader:at.linedashed_frag},depth:{uniforms:Fn([be.common,be.displacementmap]),vertexShader:at.depth_vert,fragmentShader:at.depth_frag},normal:{uniforms:Fn([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:at.normal_vert,fragmentShader:at.normal_frag},sprite:{uniforms:Fn([be.sprite,be.fog]),vertexShader:at.sprite_vert,fragmentShader:at.sprite_frag},background:{uniforms:{uvTransform:{value:new Dt},t2D:{value:null}},vertexShader:at.background_vert,fragmentShader:at.background_frag},cube:{uniforms:Fn([be.envmap,{opacity:{value:1}}]),vertexShader:at.cube_vert,fragmentShader:at.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:at.equirect_vert,fragmentShader:at.equirect_frag},distanceRGBA:{uniforms:Fn([be.common,be.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:at.distanceRGBA_vert,fragmentShader:at.distanceRGBA_frag},shadow:{uniforms:Fn([be.lights,be.fog,{color:{value:new fe(0)},opacity:{value:1}}]),vertexShader:at.shadow_vert,fragmentShader:at.shadow_frag}};ar.physical={uniforms:Fn([ar.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new O(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new fe(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new O},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationTint:{value:new fe(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularTint:{value:new fe(1,1,1)},specularTintMap:{value:null}}]),vertexShader:at.meshphysical_vert,fragmentShader:at.meshphysical_frag};function zE(r,e,t,n,i){let s=new fe(0),o=0,a,l,c=null,u=0,h=null;function d(p,m){let v=!1,g=m.isScene===!0?m.background:null;g&&g.isTexture&&(g=e.get(g));let y=r.xr,x=y.getSession&&y.getSession();x&&x.environmentBlendMode==="additive"&&(g=null),g===null?f(s,o):g&&g.isColor&&(f(g,1),v=!0),(r.autoClear||v)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),g&&(g.isCubeTexture||g.mapping===Js)?(l===void 0&&(l=new gt(new jn(1,1,1),new _t({name:"BackgroundCubeMaterial",uniforms:ca(ar.cube.uniforms),vertexShader:ar.cube.vertexShader,fragmentShader:ar.cube.fragmentShader,side:kt,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,w,_){this.matrixWorld.copyPosition(_.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=g,l.material.uniforms.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,(c!==g||u!==g.version||h!==r.toneMapping)&&(l.material.needsUpdate=!0,c=g,u=g.version,h=r.toneMapping),p.unshift(l,l.geometry,l.material,0,0,null)):g&&g.isTexture&&(a===void 0&&(a=new gt(new ls(2,2),new _t({name:"BackgroundMaterial",uniforms:ca(ar.background.uniforms),vertexShader:ar.background.vertexShader,fragmentShader:ar.background.fragmentShader,side:Oi,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=g,g.matrixAutoUpdate===!0&&g.updateMatrix(),a.material.uniforms.uvTransform.value.copy(g.matrix),(c!==g||u!==g.version||h!==r.toneMapping)&&(a.material.needsUpdate=!0,c=g,u=g.version,h=r.toneMapping),p.unshift(a,a.geometry,a.material,0,0,null))}function f(p,m){t.buffers.color.setClear(p.r,p.g,p.b,m,i)}return{getClearColor:function(){return s},setClearColor:function(p,m=1){s.set(p),o=m,f(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(p){o=p,f(s,o)},render:d}}function GE(r,e,t,n){let i=r.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=m(null),c=l;function u(P,R,G,B,j){let ne=!1;if(o){let le=p(B,G,R);c!==le&&(c=le,d(c.object)),ne=v(B,j),ne&&g(B,j)}else{let le=R.wireframe===!0;(c.geometry!==B.id||c.program!==G.id||c.wireframe!==le)&&(c.geometry=B.id,c.program=G.id,c.wireframe=le,ne=!0)}P.isInstancedMesh===!0&&(ne=!0),j!==null&&t.update(j,34963),ne&&(S(P,R,G,B),j!==null&&r.bindBuffer(34963,t.get(j).buffer))}function h(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(P){return n.isWebGL2?r.bindVertexArray(P):s.bindVertexArrayOES(P)}function f(P){return n.isWebGL2?r.deleteVertexArray(P):s.deleteVertexArrayOES(P)}function p(P,R,G){let B=G.wireframe===!0,j=a[P.id];j===void 0&&(j={},a[P.id]=j);let ne=j[R.id];ne===void 0&&(ne={},j[R.id]=ne);let le=ne[B];return le===void 0&&(le=m(h()),ne[B]=le),le}function m(P){let R=[],G=[],B=[];for(let j=0;j=0){let D=j[W];if(D!==void 0){let K=D.normalized,q=D.itemSize,ee=t.get(D);if(ee===void 0)continue;let V=ee.buffer,de=ee.type,ae=ee.bytesPerElement;if(D.isInterleavedBufferAttribute){let te=D.data,X=te.stride,se=D.offset;te&&te.isInstancedInterleavedBuffer?(b(z,te.meshPerAttribute),B._maxInstanceCount===void 0&&(B._maxInstanceCount=te.meshPerAttribute*te.count)):x(z),r.bindBuffer(34962,V),_(z,q,de,K,X*ae,se*ae)}else D.isInstancedBufferAttribute?(b(z,D.meshPerAttribute),B._maxInstanceCount===void 0&&(B._maxInstanceCount=D.meshPerAttribute*D.count)):x(z),r.bindBuffer(34962,V),_(z,q,de,K,0,0)}else if(W==="instanceMatrix"){let K=t.get(P.instanceMatrix);if(K===void 0)continue;let q=K.buffer,ee=K.type;b(z+0,1),b(z+1,1),b(z+2,1),b(z+3,1),r.bindBuffer(34962,q),r.vertexAttribPointer(z+0,4,ee,!1,64,0),r.vertexAttribPointer(z+1,4,ee,!1,64,16),r.vertexAttribPointer(z+2,4,ee,!1,64,32),r.vertexAttribPointer(z+3,4,ee,!1,64,48)}else if(W==="instanceColor"){let K=t.get(P.instanceColor);if(K===void 0)continue;let q=K.buffer,ee=K.type;b(z,1),r.bindBuffer(34962,q),r.vertexAttribPointer(z,3,ee,!1,12,0)}else if(le!==void 0){let K=le[W];if(K!==void 0)switch(K.length){case 2:r.vertexAttrib2fv(z,K);break;case 3:r.vertexAttrib3fv(z,K);break;case 4:r.vertexAttrib4fv(z,K);break;default:r.vertexAttrib1fv(z,K)}}}}w()}function A(){C();for(let P in a){let R=a[P];for(let G in R){let B=R[G];for(let j in B)f(B[j].object),delete B[j];delete R[G]}delete a[P]}}function T(P){if(a[P.id]===void 0)return;let R=a[P.id];for(let G in R){let B=R[G];for(let j in B)f(B[j].object),delete B[j];delete R[G]}delete a[P.id]}function L(P){for(let R in a){let G=a[R];if(G[P.id]===void 0)continue;let B=G[P.id];for(let j in B)f(B[j].object),delete B[j];delete G[P.id]}}function C(){U(),c!==l&&(c=l,d(c.object))}function U(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:u,reset:C,resetDefaultState:U,dispose:A,releaseStatesOfGeometry:T,releaseStatesOfProgram:L,initAttributes:y,enableAttribute:x,disableUnusedAttributes:w}}function UE(r,e,t,n){let i=n.isWebGL2,s;function o(c){s=c}function a(c,u){r.drawArrays(s,c,u),t.update(u,s,1)}function l(c,u,h){if(h===0)return;let d,f;if(i)d=r,f="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,c,u,h),t.update(u,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function kE(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let S=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(S){if(S==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";S="mediump"}return S==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext!="undefined"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(34930),d=r.getParameter(35660),f=r.getParameter(3379),p=r.getParameter(34076),m=r.getParameter(34921),v=r.getParameter(36347),g=r.getParameter(36348),y=r.getParameter(36349),x=d>0,b=o||e.has("OES_texture_float"),w=x&&b,_=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:v,maxVaryings:g,maxFragmentUniforms:y,vertexTextures:x,floatFragmentTextures:b,floatVertexTextures:w,maxSamples:_}}function VE(r){let e=this,t=null,n=0,i=!1,s=!1,o=new ni,a=new Dt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,f){let p=h.length!==0||d||n!==0||i;return i=d,t=u(h,f,0),n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,c()},this.setState=function(h,d,f){let p=h.clippingPlanes,m=h.clipIntersection,v=h.clipShadows,g=r.get(h);if(!i||p===null||p.length===0||s&&!v)s?u(null):c();else{let y=s?0:n,x=y*4,b=g.clippingState||null;l.value=b,b=u(p,d,x,f);for(let w=0;w!==x;++w)b[w]=t[w];g.clippingState=b,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,f,p){let m=h!==null?h.length:0,v=null;if(m!==0){if(v=l.value,p!==!0||v===null){let g=f+m*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(v===null||v.length0){let c=r.getRenderTarget(),u=new Lf(l.height/2);return u.fromEquirectangularTexture(r,o),e.set(o,u),r.setRenderTarget(c),o.addEventListener("dispose",i),t(u.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var Rr=class extends Dr{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super();this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};Rr.prototype.isOrthographicCamera=!0;var fa=class extends _t{constructor(e){super(e);this.type="RawShaderMaterial"}};fa.prototype.isRawShaderMaterial=!0;var pa=4,cs=8,lr=Math.pow(2,cs),yy=[.125,.215,.35,.446,.526,.582],vy=cs-pa+1+yy.length,ma=20,cr={[ln]:0,[Fi]:1,[Rl]:2,[Mu]:3,[Au]:4,[_u]:5,[Qs]:6},to=new dn({side:kt,depthWrite:!1,depthTest:!1}),jE=new gt(new jn,to),Pf=new Rr,{_lodPlanes:Hl,_sizeLods:xy,_sigmas:Ju}=JE(),by=new fe,Df=null,no=(1+Math.sqrt(5))/2,ga=1/no,wy=[new M(1,1,1),new M(-1,1,1),new M(1,1,-1),new M(-1,1,-1),new M(0,no,ga),new M(0,no,-ga),new M(ga,0,no),new M(-ga,0,no),new M(no,ga,0),new M(-no,ga,0)];function Sy(r){let e=Math.max(r.r,r.g,r.b),t=Math.min(Math.max(Math.ceil(Math.log2(e)),-128),127);return r.multiplyScalar(Math.pow(2,-t)),(t+128)/255}var My=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=XE(ma),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Df=this._renderer.getRenderTarget();let s=this._allocateTargets();return this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=Ty(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=_y(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e2?lr:0,lr,lr),u.setRenderTarget(i),p&&u.render(jE,a),u.render(e,a)}u.toneMapping=f,u.outputEncoding=d,u.autoClear=h}_textureToCubeUV(e,t){let n=this._renderer;e.isCubeTexture?this._cubemapShader==null&&(this._cubemapShader=Ty()):this._equirectShader==null&&(this._equirectShader=_y());let i=e.isCubeTexture?this._cubemapShader:this._equirectShader,s=new gt(Hl[0],i),o=i.uniforms;o.envMap.value=e,e.isCubeTexture||o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=cr[e.encoding],o.outputEncoding.value=cr[t.texture.encoding],Xu(t,0,0,3*lr,2*lr),n.setRenderTarget(t),n.render(s,Pf)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;ima&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${ma}`);let g=[],y=0;for(let _=0;_cs-pa?i-cs+pa:0);Xu(t,b,w,3*x,2*x),l.setRenderTarget(t),l.render(h,Pf)}};function WE(r){return r===void 0||r.type!==At?!1:r.encoding===ln||r.encoding===Fi||r.encoding===Qs}function JE(){let r=[],e=[],t=[],n=cs;for(let i=0;ics-pa?o=yy[i-cs+pa-1]:i==0&&(o=0),t.push(o);let a=1/(s-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,d=6,f=3,p=2,m=1,v=new Float32Array(f*d*h),g=new Float32Array(p*d*h),y=new Float32Array(m*d*h);for(let b=0;b2?0:-1,S=[w,_,0,w+2/3,_,0,w+2/3,_+1,0,w,_,0,w+2/3,_+1,0,w,_+1,0];v.set(S,f*d*b),g.set(u,p*d*b);let A=[b,b,b,b,b,b];y.set(A,m*d*b)}let x=new we;x.setAttribute("position",new Re(v,f)),x.setAttribute("uv",new Re(g,p)),x.setAttribute("faceIndex",new Re(y,m)),r.push(x),n>pa&&n--}return{_lodPlanes:r,_sizeLods:e,_sigmas:t}}function Ay(r){let e=new bt(3*lr,3*lr,r);return e.texture.mapping=Js,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Xu(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function XE(r){let e=new Float32Array(r),t=new M(0,1,0);return new fa({name:"SphericalGaussianBlur",defines:{n:r},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t},inputEncoding:{value:cr[ln]},outputEncoding:{value:cr[ln]}},vertexShader:Rf(),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; ${Bf()} #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 ); } gl_FragColor = linearToOutputTexel( gl_FragColor ); } `,blending:It,depthTest:!1,depthWrite:!1})}function _y(){let r=new O(1,1);return new fa({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:r},inputEncoding:{value:cr[ln]},outputEncoding:{value:cr[ln]}},vertexShader:Rf(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform vec2 texelSize; ${Bf()} #include void main() { gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); vec2 f = fract( uv / texelSize - 0.5 ); uv -= f * texelSize; vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; uv.x += texelSize.x; vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; uv.y += texelSize.y; vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; uv.x -= texelSize.x; vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; vec3 tm = mix( tl, tr, f.x ); vec3 bm = mix( bl, br, f.x ); gl_FragColor.rgb = mix( tm, bm, f.y ); gl_FragColor = linearToOutputTexel( gl_FragColor ); } `,blending:It,depthTest:!1,depthWrite:!1})}function Ty(){return new fa({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:cr[ln]},outputEncoding:{value:cr[ln]}},vertexShader:Rf(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform samplerCube envMap; ${Bf()} void main() { gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb; gl_FragColor = linearToOutputTexel( gl_FragColor ); } `,blending:It,depthTest:!1,depthWrite:!1})}function Rf(){return` precision mediump float; precision mediump int; attribute vec3 position; attribute vec2 uv; 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 Bf(){return` uniform int inputEncoding; uniform int outputEncoding; #include vec4 inputTexelToLinear( vec4 value ) { if ( inputEncoding == 0 ) { return value; } else if ( inputEncoding == 1 ) { return sRGBToLinear( value ); } else if ( inputEncoding == 2 ) { return RGBEToLinear( value ); } else if ( inputEncoding == 3 ) { return RGBMToLinear( value, 7.0 ); } else if ( inputEncoding == 4 ) { return RGBMToLinear( value, 16.0 ); } else if ( inputEncoding == 5 ) { return RGBDToLinear( value, 256.0 ); } else { return GammaToLinear( value, 2.2 ); } } vec4 linearToOutputTexel( vec4 value ) { if ( outputEncoding == 0 ) { return value; } else if ( outputEncoding == 1 ) { return LinearTosRGB( value ); } else if ( outputEncoding == 2 ) { return LinearToRGBE( value ); } else if ( outputEncoding == 3 ) { return LinearToRGBM( value, 7.0 ); } else if ( outputEncoding == 4 ) { return LinearToRGBM( value, 16.0 ); } else if ( outputEncoding == 5 ) { return LinearToRGBD( value, 256.0 ); } else { return LinearToGamma( value, 2.2 ); } } vec4 envMapTexelToLinear( vec4 color ) { return inputTexelToLinear( color ); } `}function qE(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture&&a.isRenderTargetTexture===!1){let l=a.mapping,c=l===vu||l===xu,u=l===js||l===Ws;if(c||u){if(e.has(a))return e.get(a).texture;{let h=a.image;if(c&&h&&h.height>0||u&&h&&i(h)){let d=r.getRenderTarget();t===null&&(t=new My(r));let f=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),r.setRenderTarget(d),a.addEventListener("dispose",s),f.texture}else return null}}}return a}function i(a){let l=0,c=6;for(let u=0;u65535?is:Mf)(d,1);v.version=m;let g=s.get(h);g&&e.remove(g),s.set(h,v)}function u(h){let d=s.get(h);if(d){let f=h.index;f!==null&&d.version0)return r;let i=e*t,s=Cy[i];if(s===void 0&&(s=new Float32Array(i),Cy[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Wn(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t0)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(jl).join(` `)}function KN(r){let e=[];for(let t in r){let n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function QN(r,e){let t={},n=r.getProgramParameter(e,35721);for(let i=0;i/gm;function zf(r){return r.replace(ZN,$N)}function $N(r,e){let t=at[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return zf(t)}var eC=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,tC=/#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 Hy(r){return r.replace(tC,jy).replace(eC,nC)}function nC(r,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),jy(r,e,t,n)}function jy(r,e,t,n){let i="";for(let s=parseInt(e);s0?r.gammaFactor:1,f=t.isWebGL2?"":YN(t),p=KN(s),m=i.createProgram(),v,g,y=t.glslVersion?"#version "+t.glslVersion+` `:"";t.isRawShaderMaterial?(v=[p].filter(jl).join(` `),v.length>0&&(v+=` `),g=[f,p].filter(jl).join(` `),g.length>0&&(g+=` `)):(v=[Wy(t),"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+t.maxBones,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularTintMap?"#define USE_SPECULARTINTMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.useVertexTexture?"#define BONE_TEXTURE":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#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_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(jl).join(` `),g=[f,Wy(t),"#define SHADER_NAME "+t.shaderName,p,t.alphaTest?"#define ALPHATEST "+t.alphaTest+(t.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularTintMap?"#define USE_SPECULARTINTMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.sheen?"#define USE_SHEEN":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Hs?"#define TONE_MAPPING":"",t.toneMapping!==Hs?at.tonemapping_pars_fragment:"",t.toneMapping!==Hs?qN("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",at.encodings_pars_fragment,t.map?va("mapTexelToLinear",t.mapEncoding):"",t.matcap?va("matcapTexelToLinear",t.matcapEncoding):"",t.envMap?va("envMapTexelToLinear",t.envMapEncoding):"",t.emissiveMap?va("emissiveMapTexelToLinear",t.emissiveMapEncoding):"",t.specularTintMap?va("specularTintMapTexelToLinear",t.specularTintMapEncoding):"",t.lightMap?va("lightMapTexelToLinear",t.lightMapEncoding):"",XN("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(jl).join(` `)),o=zf(o),o=ky(o,t),o=Vy(o,t),a=zf(a),a=ky(a,t),a=Vy(a,t),o=Hy(o),a=Hy(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es `,v=["#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+v,g=["#define varying in",t.glslVersion===Zg?"":"out highp vec4 pc_fragColor;",t.glslVersion===Zg?"":"#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(` `)+` `+g);let x=y+v+o,b=y+g+a,w=zy(i,35633,x),_=zy(i,35632,b);if(i.attachShader(m,w),i.attachShader(m,_),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),r.debug.checkShaderErrors){let T=i.getProgramInfoLog(m).trim(),L=i.getShaderInfoLog(w).trim(),C=i.getShaderInfoLog(_).trim(),U=!0,P=!0;if(i.getProgramParameter(m,35714)===!1){U=!1;let R=Uy(i,w,"vertex"),G=Uy(i,_,"fragment");console.error("THREE.WebGLProgram: shader error: ",i.getError(),"35715",i.getProgramParameter(m,35715),"gl.getProgramInfoLog",T,R,G)}else T!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",T):(L===""||C==="")&&(P=!1);P&&(this.diagnostics={runnable:U,programLog:T,vertexShader:{log:L,prefix:v},fragmentShader:{log:C,prefix:g}})}i.deleteShader(w),i.deleteShader(_);let S;this.getUniforms=function(){return S===void 0&&(S=new us(i,m)),S};let A;return this.getAttributes=function(){return A===void 0&&(A=QN(i,m)),A},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=WN++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=_,this}function lC(r,e,t,n,i,s,o){let a=[],l=i.isWebGL2,c=i.logarithmicDepthBuffer,u=i.floatVertexTextures,h=i.maxVertexUniforms,d=i.vertexTextures,f=i.precision,p={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"},m=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","specularIntensityMap","specularTintMap","specularTintMapEncoding","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmission","transmissionMap","thicknessMap"];function v(S){let T=S.skeleton.bones;if(u)return 1024;{let C=Math.floor((h-20)/4),U=Math.min(C,T.length);return U0,maxBones:B,useVertexTexture:u,morphTargets:!!C.geometry&&!!C.geometry.morphAttributes.position,morphNormals:!!C.geometry&&!!C.geometry.morphAttributes.normal,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&T.length>0,shadowMapType:r.shadowMap.type,toneMapping:S.toneMapped?r.toneMapping:Hs,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:S.premultipliedAlpha,alphaTest:S.alphaTest,doubleSided:S.side===Xt,flipSided:S.side===kt,depthPacking:S.depthPacking!==void 0?S.depthPacking:!1,index0AttributeName:S.index0AttributeName,extensionDerivatives:S.extensions&&S.extensions.derivatives,extensionFragDepth:S.extensions&&S.extensions.fragDepth,extensionDrawBuffers:S.extensions&&S.extensions.drawBuffers,extensionShaderTextureLOD:S.extensions&&S.extensions.shaderTextureLOD,rendererExtensionFragDepth:l||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:l||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:l||n.has("EXT_shader_texture_lod"),customProgramCacheKey:S.customProgramCacheKey()}}function x(S){let A=[];if(S.shaderID?A.push(S.shaderID):(A.push(S.fragmentShader),A.push(S.vertexShader)),S.defines!==void 0)for(let T in S.defines)A.push(T),A.push(S.defines[T]);if(S.isRawShaderMaterial===!1){for(let T=0;T0?i.push(x):m.transparent===!0?s.push(x):n.push(x)}function u(f,p,m,v,g,y){let x=l(f,p,m,v,g,y);m.transmission>0?i.unshift(x):m.transparent===!0?s.unshift(x):n.unshift(x)}function h(f,p){n.length>1&&n.sort(f||uC),i.length>1&&i.sort(p||Jy),s.length>1&&s.sort(p||Jy)}function d(){for(let f=t,p=e.length;f=e.get(i).length?(o=new Xy(r),e.get(i).push(o)):o=e.get(i)[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}function dC(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new M,color:new fe};break;case"SpotLight":t={position:new M,direction:new M,color:new fe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new M,color:new fe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new M,skyColor:new fe,groundColor:new fe};break;case"RectAreaLight":t={color:new fe,position:new M,halfWidth:new M,halfHeight:new M};break}return r[e.id]=t,t}}}function fC(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new O};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new O};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new O,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var pC=0;function mC(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function gC(r,e){let t=new dC,n=fC(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let u=0;u<9;u++)i.probe.push(new M);let s=new M,o=new me,a=new me;function l(u){let h=0,d=0,f=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let p=0,m=0,v=0,g=0,y=0,x=0,b=0,w=0;u.sort(mC);for(let S=0,A=u.length;S0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=be.LTC_FLOAT_1,i.rectAreaLTC2=be.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=be.LTC_HALF_1,i.rectAreaLTC2=be.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=f;let _=i.hash;(_.directionalLength!==p||_.pointLength!==m||_.spotLength!==v||_.rectAreaLength!==g||_.hemiLength!==y||_.numDirectionalShadows!==x||_.numPointShadows!==b||_.numSpotShadows!==w)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=g,i.point.length=m,i.hemi.length=y,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=b,i.spotShadowMatrix.length=w,_.directionalLength=p,_.pointLength=m,_.spotLength=v,_.rectAreaLength=g,_.hemiLength=y,_.numDirectionalShadows=x,_.numPointShadows=b,_.numSpotShadows=w,i.version=pC++)}function c(u,h){let d=0,f=0,p=0,m=0,v=0,g=h.matrixWorldInverse;for(let y=0,x=u.length;y=t.get(s).length?(a=new qy(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}var Yu=class extends nn{constructor(e){super();this.type="MeshDepthMaterial",this.depthPacking=Kr,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}};Yu.prototype.isMeshDepthMaterial=!0;var Ku=class extends nn{constructor(e){super();this.type="MeshDistanceMaterial",this.referencePosition=new M,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};Ku.prototype.isMeshDistanceMaterial=!0;var vC=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { float mean = 0.0; float squared_mean = 0.0; float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) ); for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) { #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 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, i ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean * HALF_SAMPLE_RATE; squared_mean = squared_mean * HALF_SAMPLE_RATE; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`,xC=`void main() { gl_Position = vec4( position, 1.0 ); }`;function Yy(r,e,t){let n=new Vl,i=new O,s=new O,o=new Qe,a=new Yu({depthPacking:z_}),l=new Ku,c={},u=t.maxTextureSize,h={0:kt,1:Oi,2:Xt},d=new _t({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new O},radius:{value:4}},vertexShader:xC,fragmentShader:vC}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new we;p.setAttribute("position",new Re(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new gt(p,d),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Pg,this.render=function(b,w,_){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||b.length===0)return;let S=r.getRenderTarget(),A=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),L=r.state;L.setBlending(It),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);for(let C=0,U=b.length;Cu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/G.x),i.x=s.x*G.x,R.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/G.y),i.y=s.y*G.y,R.mapSize.y=s.y)),R.map===null&&!R.isPointLightShadow&&this.type===Dl){let j={minFilter:$e,magFilter:$e,format:zt};R.map=new bt(i.x,i.y,j),R.map.texture.name=P.name+".shadowMap",R.mapPass=new bt(i.x,i.y,j),R.camera.updateProjectionMatrix()}if(R.map===null){let j={minFilter:Pt,magFilter:Pt,format:zt};R.map=new bt(i.x,i.y,j),R.map.texture.name=P.name+".shadowMap",R.camera.updateProjectionMatrix()}r.setRenderTarget(R.map),r.clear();let B=R.getViewportCount();for(let j=0;j=1):G.indexOf("OpenGL ES")!==-1&&(R=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),P=R>=2);let B=null,j={},ne=r.getParameter(3088),le=r.getParameter(2978),W=new Qe().fromArray(ne),z=new Qe().fromArray(le);function D(J,xe,he){let Ne=new Uint8Array(4),Be=r.createTexture();r.bindTexture(J,Be),r.texParameteri(J,10241,9728),r.texParameteri(J,10240,9728);for(let ke=0;kere||N.height>re)&&(ye=re/Math.max(N.width,N.height)),ye<1||E===!0)if(typeof HTMLImageElement!="undefined"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&N instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&N instanceof ImageBitmap){let pe=E?ey:Math.floor,Ie=pe(ye*N.width),ve=pe(ye*N.height);f===void 0&&(f=m(Ie,ve));let Fe=Y?m(Ie,ve):f;return Fe.width=Ie,Fe.height=ve,Fe.getContext("2d").drawImage(N,0,0,Ie,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+Ie+"x"+ve+")."),Fe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function g(N){return rf(N.width)&&rf(N.height)}function y(N){return a?!1:N.wrapS!==Zt||N.wrapT!==Zt||N.minFilter!==Pt&&N.minFilter!==$e}function x(N,E){return N.generateMipmaps&&E&&N.minFilter!==Pt&&N.minFilter!==$e}function b(N,E,Y,re,ye=1){r.generateMipmap(N);let pe=n.get(E);pe.__maxMipLevel=Math.log2(Math.max(Y,re,ye))}function w(N,E,Y){if(a===!1)return E;if(N!==null){if(r[N]!==void 0)return r[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let re=E;return E===6403&&(Y===5126&&(re=33326),Y===5131&&(re=33325),Y===5121&&(re=33321)),E===6407&&(Y===5126&&(re=34837),Y===5131&&(re=34843),Y===5121&&(re=32849)),E===6408&&(Y===5126&&(re=34836),Y===5131&&(re=34842),Y===5121&&(re=32856)),(re===33325||re===33326||re===34842||re===34836)&&e.get("EXT_color_buffer_float"),re}function _(N){return N===Pt||N===Xs||N===qs?9728:9729}function S(N){let E=N.target;E.removeEventListener("dispose",S),T(E),E.isVideoTexture&&d.delete(E),o.memory.textures--}function A(N){let E=N.target;E.removeEventListener("dispose",A),L(E)}function T(N){let E=n.get(N);E.__webglInit!==void 0&&(r.deleteTexture(E.__webglTexture),n.remove(N))}function L(N){let E=N.texture,Y=n.get(N),re=n.get(E);if(!!N){if(re.__webglTexture!==void 0&&(r.deleteTexture(re.__webglTexture),o.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++)r.deleteFramebuffer(Y.__webglFramebuffer[ye]),Y.__webglDepthbuffer&&r.deleteRenderbuffer(Y.__webglDepthbuffer[ye]);else r.deleteFramebuffer(Y.__webglFramebuffer),Y.__webglDepthbuffer&&r.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&r.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer&&r.deleteRenderbuffer(Y.__webglColorRenderbuffer),Y.__webglDepthRenderbuffer&&r.deleteRenderbuffer(Y.__webglDepthRenderbuffer);if(N.isWebGLMultipleRenderTargets)for(let ye=0,pe=E.length;ye=l&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+l),C+=1,N}function R(N,E){let Y=n.get(N);if(N.isVideoTexture&&$(N),N.version>0&&Y.__version!==N.version){let re=N.image;if(re===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(re.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{D(Y,N,E);return}}t.activeTexture(33984+E),t.bindTexture(3553,Y.__webglTexture)}function G(N,E){let Y=n.get(N);if(N.version>0&&Y.__version!==N.version){D(Y,N,E);return}t.activeTexture(33984+E),t.bindTexture(35866,Y.__webglTexture)}function B(N,E){let Y=n.get(N);if(N.version>0&&Y.__version!==N.version){D(Y,N,E);return}t.activeTexture(33984+E),t.bindTexture(32879,Y.__webglTexture)}function j(N,E){let Y=n.get(N);if(N.version>0&&Y.__version!==N.version){K(Y,N,E);return}t.activeTexture(33984+E),t.bindTexture(34067,Y.__webglTexture)}let ne={[di]:10497,[Zt]:33071,[qr]:33648},le={[Pt]:9728,[Xs]:9984,[qs]:9986,[$e]:9729,[jo]:9985,[Ai]:9987};function W(N,E,Y){if(Y?(r.texParameteri(N,10242,ne[E.wrapS]),r.texParameteri(N,10243,ne[E.wrapT]),(N===32879||N===35866)&&r.texParameteri(N,32882,ne[E.wrapR]),r.texParameteri(N,10240,le[E.magFilter]),r.texParameteri(N,10241,le[E.minFilter])):(r.texParameteri(N,10242,33071),r.texParameteri(N,10243,33071),(N===32879||N===35866)&&r.texParameteri(N,32882,33071),(E.wrapS!==Zt||E.wrapT!==Zt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(N,10240,_(E.magFilter)),r.texParameteri(N,10241,_(E.minFilter)),E.minFilter!==Pt&&E.minFilter!==$e&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let re=e.get("EXT_texture_filter_anisotropic");if(E.type===Tr&&e.has("OES_texture_float_linear")===!1||a===!1&&E.type===Jo&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||n.get(E).__currentAnisotropy)&&(r.texParameterf(N,re.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy)}}function z(N,E){N.__webglInit===void 0&&(N.__webglInit=!0,E.addEventListener("dispose",S),N.__webglTexture=r.createTexture(),o.memory.textures++)}function D(N,E,Y){let re=3553;E.isDataTexture2DArray&&(re=35866),E.isDataTexture3D&&(re=32879),z(N,E),t.activeTexture(33984+Y),t.bindTexture(re,N.__webglTexture),r.pixelStorei(37440,E.flipY),r.pixelStorei(37441,E.premultiplyAlpha),r.pixelStorei(3317,E.unpackAlignment),r.pixelStorei(37443,0);let ye=y(E)&&g(E.image)===!1,pe=v(E.image,ye,!1,u),Ie=g(pe)||a,ve=s.convert(E.format),Fe=s.convert(E.type),Ce=w(E.internalFormat,ve,Fe);W(re,E,Ie);let J,xe=E.mipmaps;if(E.isDepthTexture)Ce=6402,a?E.type===Tr?Ce=36012:E.type===Wo?Ce=33190:E.type===Ys?Ce=35056:Ce=33189:E.type===Tr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===Xo&&Ce===6402&&E.type!==bu&&E.type!==Wo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=bu,Fe=s.convert(E.type)),E.format===Ks&&Ce===6402&&(Ce=34041,E.type!==Ys&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=Ys,Fe=s.convert(E.type))),t.texImage2D(3553,0,Ce,pe.width,pe.height,0,ve,Fe,null);else if(E.isDataTexture)if(xe.length>0&&Ie){for(let he=0,Ne=xe.length;he0&&Ie){for(let he=0,Ne=xe.length;hef+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},Ky=class extends cn{constructor(e,t){super();let n=this,i=e.state,s=null,o=1,a=null,l="local-floor",c=null,u=null,h=null,d=null,f=null,p=[],m=new Map,v=new Vt;v.layers.enable(1),v.viewport=new Qe;let g=new Vt;g.layers.enable(2),g.viewport=new Qe;let y=[v,g],x=new Gf;x.layers.enable(1),x.layers.enable(2);let b=null,w=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(B){let j=p[B];return j===void 0&&(j=new Qu,p[B]=j),j.getTargetRaySpace()},this.getControllerGrip=function(B){let j=p[B];return j===void 0&&(j=new Qu,p[B]=j),j.getGripSpace()},this.getHand=function(B){let j=p[B];return j===void 0&&(j=new Qu,p[B]=j),j.getHandSpace()};function _(B){let j=m.get(B.inputSource);j&&j.dispatchEvent({type:B.type,data:B.inputSource})}function S(){m.forEach(function(B,j){B.disconnect(j)}),m.clear(),b=null,w=null,i.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),G.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(B){o=B,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(B){l=B,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getSession=function(){return s},this.setSession=async function(B){if(s=B,s!==null){s.addEventListener("select",_),s.addEventListener("selectstart",_),s.addEventListener("selectend",_),s.addEventListener("squeeze",_),s.addEventListener("squeezestart",_),s.addEventListener("squeezeend",_),s.addEventListener("end",S),s.addEventListener("inputsourceschange",A);let j=t.getContextAttributes();if(j.xrCompatible!==!0&&await t.makeXRCompatible(),s.renderState.layers===void 0){let ne={antialias:j.antialias,alpha:j.alpha,depth:j.depth,stencil:j.stencil,framebufferScaleFactor:o};f=new XRWebGLLayer(s,t,ne),s.updateRenderState({baseLayer:f})}else{let ne=0;if(j.antialias){let le={antialias:!0,alpha:j.alpha,depth:j.depth,stencil:j.stencil,framebufferScaleFactor:o};f=new XRWebGLLayer(s,t,le),s.updateRenderState({layers:[f]})}else{j.depth&&(ne=j.stencil?34041:6402);let le={colorFormat:j.alpha?6408:6407,depthFormat:ne,scaleFactor:o};u=new XRWebGLBinding(s,t),d=u.createProjectionLayer(le),h=t.createFramebuffer(),s.updateRenderState({layers:[d]})}}a=await s.requestReferenceSpace(l),G.setContext(s),G.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function A(B){let j=s.inputSources;for(let ne=0;ne0&&(g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height)),g.thickness.value=y.thickness,y.thicknessMap&&(g.thicknessMap.value=y.thicknessMap),g.attenuationDistance.value=y.attenuationDistance,g.attenuationTint.value.copy(y.attenuationTint),g.specularIntensity.value=y.specularIntensity,g.specularTint.value.copy(y.specularTint),y.specularIntensityMap&&(g.specularIntensityMap.value=y.specularIntensityMap),y.specularTintMap&&(g.specularTintMap.value=y.specularTintMap)}function f(g,y){y.matcap&&(g.matcap.value=y.matcap),y.bumpMap&&(g.bumpMap.value=y.bumpMap,g.bumpScale.value=y.bumpScale,y.side===kt&&(g.bumpScale.value*=-1)),y.normalMap&&(g.normalMap.value=y.normalMap,g.normalScale.value.copy(y.normalScale),y.side===kt&&g.normalScale.value.negate()),y.displacementMap&&(g.displacementMap.value=y.displacementMap,g.displacementScale.value=y.displacementScale,g.displacementBias.value=y.displacementBias)}function p(g,y){y.displacementMap&&(g.displacementMap.value=y.displacementMap,g.displacementScale.value=y.displacementScale,g.displacementBias.value=y.displacementBias)}function m(g,y){y.displacementMap&&(g.displacementMap.value=y.displacementMap,g.displacementScale.value=y.displacementScale,g.displacementBias.value=y.displacementBias),g.referencePosition.value.copy(y.referencePosition),g.nearDistance.value=y.nearDistance,g.farDistance.value=y.farDistance}function v(g,y){y.bumpMap&&(g.bumpMap.value=y.bumpMap,g.bumpScale.value=y.bumpScale,y.side===kt&&(g.bumpScale.value*=-1)),y.normalMap&&(g.normalMap.value=y.normalMap,g.normalScale.value.copy(y.normalScale),y.side===kt&&g.normalScale.value.negate()),y.displacementMap&&(g.displacementMap.value=y.displacementMap,g.displacementScale.value=y.displacementScale,g.displacementBias.value=y.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function _C(){let r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.style.display="block",r}function wt(r={}){let e=r.canvas!==void 0?r.canvas:_C(),t=r.context!==void 0?r.context:null,n=r.alpha!==void 0?r.alpha:!1,i=r.depth!==void 0?r.depth:!0,s=r.stencil!==void 0?r.stencil:!0,o=r.antialias!==void 0?r.antialias:!1,a=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,l=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,c=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,h=null,d=null,f=[],p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=ln,this.physicallyCorrectLights=!1,this.toneMapping=Hs,this.toneMappingExposure=1;let m=this,v=!1,g=0,y=0,x=null,b=-1,w=null,_=new Qe,S=new Qe,A=null,T=e.width,L=e.height,C=1,U=null,P=null,R=new Qe(0,0,T,L),G=new Qe(0,0,T,L),B=!1,j=[],ne=new Vl,le=!1,W=!1,z=null,D=new me,K=new M,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ee(){return x===null?C:1}let V=t;function de(I,oe){for(let k=0;k0&&Nn(Z,I,oe),ue.length>0&&Ft(Z,ue,I,oe),Me.length>0&&Nn(Me,I,oe),x!==null&&(H.updateMultisampleRenderTarget(x),H.updateRenderTargetMipmap(x)),I.isScene===!0&&I.onAfterRender(m,I,oe),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1),Ne.resetDefaultState(),b=-1,w=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function et(I,oe,k,Z){if(I.visible===!1)return;if(I.layers.test(oe.layers)){if(I.isGroup)k=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(oe);else if(I.isLight)d.pushLight(I),I.castShadow&&d.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||ne.intersectsSprite(I)){Z&&K.setFromMatrixPosition(I.matrixWorld).applyMatrix4(D);let _e=E.update(I),Se=I.material;Se.visible&&h.push(I,_e,Se,k,K.z,null)}}else if(I.isImmediateRenderObject)Z&&K.setFromMatrixPosition(I.matrixWorld).applyMatrix4(D),h.push(I,null,I.material,k,K.z,null);else if((I.isMesh||I.isLine||I.isPoints)&&(I.isSkinnedMesh&&I.skeleton.frame!==se.render.frame&&(I.skeleton.update(),I.skeleton.frame=se.render.frame),!I.frustumCulled||ne.intersectsObject(I))){Z&&K.setFromMatrixPosition(I.matrixWorld).applyMatrix4(D);let _e=E.update(I),Se=I.material;if(Array.isArray(Se)){let De=_e.groups;for(let Ve=0,Oe=De.length;Ve=0&&oe<=I.width-Z&&k>=0&&k<=I.height-ue&&V.readPixels(oe,k,Z,ue,he.convert(Ve),he.convert(Oe),Me):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{let De=x!==null?$.get(x).__webglFramebuffer:null;X.bindFramebuffer(36160,De)}}},this.copyFramebufferToTexture=function(I,oe,k=0){let Z=Math.pow(2,-k),ue=Math.floor(oe.image.width*Z),Me=Math.floor(oe.image.height*Z),_e=he.convert(oe.format);te.isWebGL2&&(_e===6407&&(_e=32849),_e===6408&&(_e=32856)),H.setTexture2D(oe,0),V.copyTexImage2D(3553,k,_e,I.x,I.y,ue,Me,0),X.unbindTexture()},this.copyTextureToTexture=function(I,oe,k,Z=0){let ue=oe.image.width,Me=oe.image.height,_e=he.convert(k.format),Se=he.convert(k.type);H.setTexture2D(k,0),V.pixelStorei(37440,k.flipY),V.pixelStorei(37441,k.premultiplyAlpha),V.pixelStorei(3317,k.unpackAlignment),oe.isDataTexture?V.texSubImage2D(3553,Z,I.x,I.y,ue,Me,_e,Se,oe.image.data):oe.isCompressedTexture?V.compressedTexSubImage2D(3553,Z,I.x,I.y,oe.mipmaps[0].width,oe.mipmaps[0].height,_e,oe.mipmaps[0].data):V.texSubImage2D(3553,Z,I.x,I.y,_e,Se,oe.image),Z===0&&k.generateMipmaps&&V.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(I,oe,k,Z,ue=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Me=I.max.x-I.min.x+1,_e=I.max.y-I.min.y+1,Se=I.max.z-I.min.z+1,De=he.convert(Z.format),Ve=he.convert(Z.type),Oe;if(Z.isDataTexture3D)H.setTexture3D(Z,0),Oe=32879;else if(Z.isDataTexture2DArray)H.setTexture2DArray(Z,0),Oe=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,Z.flipY),V.pixelStorei(37441,Z.premultiplyAlpha),V.pixelStorei(3317,Z.unpackAlignment);let He=V.getParameter(3314),Ge=V.getParameter(32878),Kt=V.getParameter(3316),vt=V.getParameter(3315),bn=V.getParameter(32877),wn=k.isCompressedTexture?k.mipmaps[0]:k.image;V.pixelStorei(3314,wn.width),V.pixelStorei(32878,wn.height),V.pixelStorei(3316,I.min.x),V.pixelStorei(3315,I.min.y),V.pixelStorei(32877,I.min.z),k.isDataTexture||k.isDataTexture3D?V.texSubImage3D(Oe,ue,oe.x,oe.y,oe.z,Me,_e,Se,De,Ve,wn.data):k.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(Oe,ue,oe.x,oe.y,oe.z,Me,_e,Se,De,wn.data)):V.texSubImage3D(Oe,ue,oe.x,oe.y,oe.z,Me,_e,Se,De,Ve,wn),V.pixelStorei(3314,He),V.pixelStorei(32878,Ge),V.pixelStorei(3316,Kt),V.pixelStorei(3315,vt),V.pixelStorei(32877,bn),ue===0&&Z.generateMipmaps&&V.generateMipmap(Oe),X.unbindTexture()},this.initTexture=function(I){H.setTexture2D(I,0),X.unbindTexture()},this.resetState=function(){g=0,y=0,x=null,X.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Qy=class extends wt{};Qy.prototype.isWebGL1Renderer=!0;var io=class{constructor(e,t=25e-5){this.name="",this.color=new fe(e),this.density=t}clone(){return new io(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}};io.prototype.isFogExp2=!0;var hs=class{constructor(e,t=1,n=1e3){this.name="",this.color=new fe(e),this.near=t,this.far=n}clone(){return new hs(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}};hs.prototype.isFog=!0;var An=class extends Ke{constructor(){super();this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}};An.prototype.isScene=!0;var Vi=class{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Bl,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=fi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;ie.far||t.push({distance:l,point:Wl.clone(),uv:qt.getUV(Wl,$u,Xl,eh,$y,Uf,ev,new O),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};kf.prototype.isSprite=!0;function th(r,e,t,n,i,s){Sa.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Jl.x=s*Sa.x-i*Sa.y,Jl.y=i*Sa.x+s*Sa.y):Jl.copy(Sa),r.copy(e),r.x+=Jl.x,r.y+=Jl.y,r.applyMatrix4(Zy)}var nh=new M,tv=new M,nv=class extends Ke{constructor(){super();this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){nh.setFromMatrixPosition(this.matrixWorld);let i=e.ray.origin.distanceTo(nh);this.getObjectForDistance(i).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){nh.setFromMatrixPosition(e.matrixWorld),tv.setFromMatrixPosition(this.matrixWorld);let n=nh.distanceTo(tv)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;il)continue;d.applyMatrix4(this.matrixWorld);let A=e.ray.origin.distanceTo(d);Ae.far||t.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,o.start),y=Math.min(v.count,o.start+o.count);for(let x=g,b=y-1;xl)continue;d.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(d);_e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Hi.prototype.isLine=!0;var fv=new M,pv=new M,ji=class extends Hi{constructor(e,t){super(e,t);this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Kl.prototype.isPoints=!0;function gv(r,e,t,n,i,s,o){let a=jf.distanceSqToPoint(r);if(ai.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}var ah=class extends xt{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c);this.format=a!==void 0?a:Nt,this.minFilter=o!==void 0?o:$e,this.magFilter=s!==void 0?s:$e,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};ah.prototype.isVideoTexture=!0;var yv=class extends xt{constructor(e,t,n,i,s,o,a,l,c,u,h,d){super(null,o,a,l,c,u,i,s,h,d);this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};yv.prototype.isCompressedTexture=!0;var vv=class extends xt{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c);this.needsUpdate=!0}};vv.prototype.isCanvasTexture=!0;var so=class extends xt{constructor(e,t,n,i,s,o,a,l,c,u){if(u=u!==void 0?u:Xo,u!==Xo&&u!==Ks)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Xo&&(n=bu),n===void 0&&u===Ks&&(n=Ys);super(null,i,s,o,a,l,u,n,c);this.image={width:e,height:t},this.magFilter=a!==void 0?a:Pt,this.minFilter=l!==void 0?l:Pt,this.flipY=!1,this.generateMipmaps=!1}};so.prototype.isDepthTexture=!0;var Ql=class extends we{constructor(e=1,t=8,n=0,i=Math.PI*2){super();this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);let s=[],o=[],a=[],l=[],c=new M,u=new O;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){let f=n+h/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new ge(o,3)),this.setAttribute("normal",new ge(a,3)),this.setAttribute("uv",new ge(l,2))}static fromJSON(e){return new Ql(e.radius,e.segments,e.thetaStart,e.thetaLength)}},ds=class extends we{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super();this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let u=[],h=[],d=[],f=[],p=0,m=[],v=n/2,g=0;y(),o===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new ge(h,3)),this.setAttribute("normal",new ge(d,3)),this.setAttribute("uv",new ge(f,2));function y(){let b=new M,w=new M,_=0,S=(t-e)/n;for(let A=0;A<=s;A++){let T=[],L=A/s,C=L*(t-e)+e;for(let U=0;U<=i;U++){let P=U/i,R=P*l+a,G=Math.sin(R),B=Math.cos(R);w.x=C*G,w.y=-L*n+v,w.z=C*B,h.push(w.x,w.y,w.z),b.set(G,S,B).normalize(),d.push(b.x,b.y,b.z),f.push(P,1-L),T.push(p++)}m.push(T)}for(let A=0;A.9&&S<.1&&(x<.2&&(o[y+0]+=1),b<.2&&(o[y+2]+=1),w<.2&&(o[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,x){let b=y*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let y=new M,x=new M,b=new M,w=new M,_=new O,S=new O,A=new O;for(let T=0,L=0;T0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let u=n[i],d=n[i+1]-u,f=(o-u)/d;return(i+f)/(s-1)}getTangent(e,t){let n=1e-4,i=e-n,s=e+n;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new O:new M);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new M,i=[],s=[],o=[],a=new M,l=new me;for(let f=0;f<=e;f++){let p=f/e;i[f]=this.getTangentAt(p,new M),i[f].normalize()}s[0]=new M,o[0]=new M;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Ln(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(Ln(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},lo=class extends gi{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super();this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new O,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(hh.subVectors(i[0],i[1]).add(i[0]),c=hh);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(bv(a,l.x,c.x,u.x,h.x),bv(a,l.y,c.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t80*t){a=c=r[0],l=u=r[1];for(let p=t;pc&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?1/f:0}return ec(s,o,t,a,l,f),o}};function wv(r,e,t,n,i){let s,o;if(i===QC(r,e,t,n)>0)for(s=e;s=e;s-=n)o=Av(s,r[s],r[s+1],o);return o&&fh(o,o.next)&&(nc(o),o=o.next),o}function fs(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(fh(t,t.next)||Yt(t.prev,t,t.next)===0)){if(nc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ec(r,e,t,n,i,s,o){if(!r)return;!o&&s&&WC(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?FC(r,n,i,s):OC(r)){e.push(l.i/t),e.push(r.i/t),e.push(c.i/t),nc(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=zC(fs(r),e,t),ec(r,e,t,n,i,s,2)):o===2&&GC(r,e,t,n,i,s):ec(fs(r),e,t,n,i,s,1);break}}}function OC(r){let e=r.prev,t=r,n=r.next;if(Yt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if(Na(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Yt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function FC(r,e,t,n){let i=r.prev,s=r,o=r.next;if(Yt(i,s,o)>=0)return!1;let a=i.xs.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,u=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,h=tp(a,l,e,t,n),d=tp(c,u,e,t,n),f=r.prevZ,p=r.nextZ;for(;f&&f.z>=h&&p&&p.z<=d;){if(f!==r.prev&&f!==r.next&&Na(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Yt(f.prev,f,f.next)>=0||(f=f.prevZ,p!==r.prev&&p!==r.next&&Na(i.x,i.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Yt(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;f&&f.z>=h;){if(f!==r.prev&&f!==r.next&&Na(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Yt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=d;){if(p!==r.prev&&p!==r.next&&Na(i.x,i.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Yt(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function zC(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!fh(i,s)&&Sv(i,n,n.next,s)&&tc(i,s)&&tc(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),nc(n),nc(n.next),n=r=s),n=n.next}while(n!==r);return fs(n)}function GC(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&qC(o,a)){let l=Mv(o,a);o=fs(o,o.next),l=fs(l,l.next),ec(o,e,t,n,i,s),ec(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function UC(r,e,t,n){let i=[],s,o,a,l,c;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){let d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x=t.x&&t.x>=l&&n!==t.x&&Na(io.x||t.x===o.x&&jC(o,t)))&&(o=t,u=h)),t=t.next;while(t!==a);return o}function jC(r,e){return Yt(r.prev,r,e.prev)<0&&Yt(e.next,r,r.next)<0}function WC(r,e,t,n){let i=r;do i.z===null&&(i.z=tp(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,JC(i)}function JC(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function tp(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function XC(r){let e=r,t=r;do(e.x=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function qC(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!YC(r,e)&&(tc(r,e)&&tc(e,r)&&KC(r,e)&&(Yt(r.prev,r,e.prev)||Yt(r,e.prev,e))||fh(r,e)&&Yt(r.prev,r,r.next)>0&&Yt(e.prev,e,e.next)>0)}function Yt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function fh(r,e){return r.x===e.x&&r.y===e.y}function Sv(r,e,t,n){let i=mh(Yt(r,e,t)),s=mh(Yt(r,e,n)),o=mh(Yt(t,n,r)),a=mh(Yt(t,n,e));return!!(i!==s&&o!==a||i===0&&ph(r,t,e)||s===0&&ph(r,n,e)||o===0&&ph(t,r,n)||a===0&&ph(t,e,n))}function ph(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function mh(r){return r>0?1:r<0?-1:0}function YC(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Sv(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function tc(r,e){return Yt(r.prev,r,r.next)<0?Yt(r,e,r.next)>=0&&Yt(r,r.prev,e)>=0:Yt(r,e,r.prev)<0||Yt(r,r.next,e)<0}function KC(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Mv(r,e){let t=new np(r.i,r.x,r.y),n=new np(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Av(r,e,t,n){let i=new np(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function nc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function np(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function QC(r,e,t,n){let i=0;for(let s=e,o=t-n;s2&&r[e-1].equals(r[0])&&r.pop()}function Tv(r,e){for(let t=0;tNumber.EPSILON){let ve=Math.sqrt(pe),Fe=Math.sqrt(re*re+ye*ye),Ce=H.x-Y/ve,J=H.y+E/ve,xe=Q.x-ye/Fe,he=Q.y+re/Fe,Ne=((xe-Ce)*ye-(he-J)*re)/(E*ye-Y*re);ce=Ce+E*Ne-$.x,ie=J+Y*Ne-$.y;let Be=ce*ce+ie*ie;if(Be<=2)return new O(ce,ie);N=Math.sqrt(Be/2)}else{let ve=!1;E>Number.EPSILON?re>Number.EPSILON&&(ve=!0):E<-Number.EPSILON?re<-Number.EPSILON&&(ve=!0):Math.sign(Y)===Math.sign(ye)&&(ve=!0),ve?(ce=-Y,ie=E,N=Math.sqrt(pe)):(ce=E,ie=Y,N=Math.sqrt(pe/2))}return new O(ce/N,ie/N)}let le=[];for(let $=0,H=R.length,Q=H-1,ce=$+1;$=0;$--){let H=$/v,Q=f*Math.cos(H*Math.PI/2),ce=p*Math.sin(H*Math.PI/2)+m;for(let ie=0,N=R.length;ie=0;){let ce=Q,ie=Q-1;ie<0&&(ie=$.length-1);for(let N=0,E=u+v*2;N=0?(e(y-l,v,h),d.subVectors(u,h)):(e(y+l,v,h),d.subVectors(h,u)),v-l>=0?(e(y,v-l,h),f.subVectors(u,h)):(e(y,v+l,h),f.subVectors(h,u)),c.crossVectors(d,f).normalize(),o.push(c.x,c.y,c.z),a.push(y,v)}}for(let m=0;m0)&&f.push(x,b,_),(g!==n-1||l=n)){h.push(c.times[f]);for(let m=0;ms.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l=a.times[p]){let g=p*h+u,y=g+h-u;m=Ht.arraySlice(a.values,g,y)}else{let g=a.createInterpolant(),y=u,x=h-u;g.evaluate(s),m=Ht.arraySlice(g.resultBuffer,y,x)}l==="quaternion"&&new Tt().fromArray(m).normalize().conjugate().toArray(m);let v=c.times.length;for(let g=0;g=s)){let a=t[1];e=s)break t}o=n,n=0;break n}break e}for(;n>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Ht.arraySlice(n,s,o),this.values=Ht.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&Ht.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=Ht.arraySlice(this.times),t=Ht.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===Zd,s=e.length-1,o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=Ht.arraySlice(e,0,o),this.values=Ht.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=Ht.arraySlice(this.times,0),t=Ht.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Yi.prototype.TimeBufferType=Float32Array;Yi.prototype.ValueBufferType=Float32Array;Yi.prototype.DefaultInterpolation=Er;var fo=class extends Yi{};fo.prototype.ValueTypeName="bool";fo.prototype.ValueBufferType=Array;fo.prototype.DefaultInterpolation=Yr;fo.prototype.InterpolantFactoryMethodLinear=void 0;fo.prototype.InterpolantFactoryMethodSmooth=void 0;var fp=class extends Yi{};fp.prototype.ValueTypeName="color";var po=class extends Yi{};po.prototype.ValueTypeName="number";var Pv=class extends qi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),c=e*a;for(let u=c+a;c!==u;c+=4)Tt.slerpFlat(s,0,o,c-a,o,c,l);return s}},ms=class extends Yi{InterpolantFactoryMethodLinear(e){return new Pv(this.times,this.values,this.getValueSize(),e)}};ms.prototype.ValueTypeName="quaternion";ms.prototype.DefaultInterpolation=Er;ms.prototype.InterpolantFactoryMethodSmooth=void 0;var mo=class extends Yi{};mo.prototype.ValueTypeName="string";mo.prototype.ValueBufferType=Array;mo.prototype.DefaultInterpolation=Yr;mo.prototype.InterpolantFactoryMethodLinear=void 0;mo.prototype.InterpolantFactoryMethodSmooth=void 0;var go=class extends Yi{};go.prototype.ValueTypeName="vector";var Ca=class{constructor(e,t=-1,n,i=$d){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=fi(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(iL(n[o]).scale(i));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Yi.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let s=t.length,o=[];for(let a=0;a1){let h=u[1],d=i[h];d||(i[h]=d=[]),d.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,d,f,p,m){if(f.length!==0){let v=[],g=[];Ht.flattenJSON(f,v,g,p),v.length!==0&&m.push(new h(d,v,g))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let h=0;h0||e.search(/^data\:image\/jpeg/)===0;s.format=l?Nt:zt,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}},Rv=class extends gi{constructor(){super();this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new ri(t,e))}getPoint(e){let t=e*this.getLength(),n=this.getCurveLengths(),i=0;for(;i=t){let s=n[i]-t,o=this.curves[i],a=o.getLength(),l=a===0?0:1-s/a;return o.getPointAt(l)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},yi=class extends cc{constructor(e){super(e);this.uuid=fi(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(i.uniforms[s]={},o.type){case"t":i.uniforms[s].value=n(o.value);break;case"c":i.uniforms[s].value=new fe().setHex(o.value);break;case"v2":i.uniforms[s].value=new O().fromArray(o.value);break;case"v3":i.uniforms[s].value=new M().fromArray(o.value);break;case"v4":i.uniforms[s].value=new Qe().fromArray(o.value);break;case"m3":i.uniforms[s].value=new Dt().fromArray(o.value);break;case"m4":i.uniforms[s].value=new me().fromArray(o.value);break;default:i.uniforms[s].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(let s in e.extensions)i.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(i.flatShading=e.shading===1),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new O().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularTintMap!==void 0&&(i.specularTintMap=n(e.specularTintMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new O().fromArray(e.clearcoatNormalScale)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),i}setTextures(e){return this.textures=e,this}},Ei=class{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n0){let l=new yo(t);s=new lc(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c0){i=new lc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;oNumber.EPSILON){if(C<0&&(A=x[S],L=-L,T=x[_],C=-C),y.yT.y)continue;if(y.y===A.y){if(y.x===A.x)return!0}else{let U=C*(y.x-A.x)-L*(y.y-A.y);if(U===0)return!0;if(U<0)continue;w=!w}}else{if(y.y!==A.y)continue;if(T.x<=y.x&&y.x<=A.x||A.x<=y.x&&y.x<=T.x)return!0}}return w}let s=ur.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return n(o);let a,l,c,u=[];if(o.length===1)return l=o[0],c=new yi,c.curves=l.curves,u.push(c),u;let h=!s(o[0].getPoints());h=e?!h:h;let d=[],f=[],p=[],m=0,v;f[m]=void 0,p[m]=[];for(let y=0,x=o.length;y1){let y=!1,x=[];for(let b=0,w=f.length;b0&&(y||(p=d))}let g;for(let y=0,x=f.length;y0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){a.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,o=i;s!==o;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){Tt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){let o=this._workIndex*s;Tt.multiplyQuaternionsFlat(e,o,e,t,e,n),Tt.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,s){let o=1-i;for(let a=0;a!==s;++a){let l=t+a;e[l]=e[l]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[n+o]*i}}},Np="\\[\\]\\.:\\/",lL=new RegExp("["+Np+"]","g"),Cp="[^"+Np+"]",cL="[^"+Np.replace("\\.","")+"]",uL=/((?:WC+[\/:])*)/.source.replace("WC",Cp),hL=/(WCOD+)?/.source.replace("WCOD",cL),dL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cp),fL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cp),pL=new RegExp("^"+uL+hL+dL+fL+"$"),mL=["material","materials","bones"],Kv=class{constructor(e,t,n){let i=n||nt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},nt=class{constructor(e,t,n){this.path=t,this.parsedPath=n||nt.parseTrackName(t),this.node=nt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new nt.Composite(e,t,n):new nt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(lL,"")}static parseTrackName(e){let t=pL.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);mL.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o=s){let h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let f=0,p=i;f!==p;++f){let m=n[f],v=m[h],g=m[u];m[u]=v,m[h]=g}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){let c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[f.uuid]=h),e[h]=f,e.pop();for(let p=0,m=i;p!==m;++p){let v=n[p];v[h]=v[d],v.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],s=this._bindings;if(i!==void 0)return s[i];let o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);i=s.length,n[e]=i,o.push(e),a.push(t),s.push(h);for(let d=u,f=l.length;d!==f;++d){let p=l[d];h[d]=new nt(p,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let i=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=n,o[n]=l,o.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}};Qv.prototype.isAnimationObjectGroup=!0;var Zv=class{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let s=t.tracks,o=s.length,a=new Array(o),l={endingStart:qo,endingEnd:qo};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=B_,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let i=this._clip.duration,s=e._clip.duration,o=s/i,a=i/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,s=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/o,c[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let l=(e-s)*n;if(l<0||n===0)return;this._startTime=null,t=n*l}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Qg:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case $d:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,s=this._loopCount,o=n===O_;if(e===0)return s===-1?i:o&&(s&1)==1?t-i:i;if(n===R_){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){let a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)==1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=Yo,i.endingEnd=Yo):(e?i.endingStart=this.zeroSlopeAtStart?Yo:qo:i.endingStart=wu,t?i.endingEnd=this.zeroSlopeAtEnd?Yo:qo:i.endingEnd=wu)}_scheduleFading(e,t,n){let i=this._mixer,s=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=n,this}},$v=class extends cn{constructor(e){super();this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=i[h],f=d.name,p=u[f];if(p!==void 0)o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=t&&t._propertyBindings[h].binding.parsedPath;p=new Yv(nt.create(n,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let s=t[n];s.useCount++==0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let s=t[n];--s.useCount==0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ix.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};Pa.prototype.isBox2=!0;var rx=new M,wh=new M,qn=class{constructor(e=new M,t=new M){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){rx.subVectors(e,this.start),wh.subVectors(this.end,this.start);let n=wh.dot(wh),s=wh.dot(rx)/n;return t&&(s=Ln(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},sx=class extends Ke{constructor(e){super();this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}};sx.prototype.isImmediateRenderObject=!0;var ox=new M,Pp=class extends Ke{constructor(e,t){super();this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new we,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o=0,fc=new M,fx=new M,vL=new O,px=new M,mx=new Tt,pc=2*Math.PI,Gp=class extends cn{constructor(e,t){super();t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.enabled=!0,this.useKeyEvents=!0,this.target=new M,this.object.getTarget(this.target),this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0+1*Ee.DEG2RAD,this.maxPolarAngle=Math.PI-1*Ee.DEG2RAD,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.125,this.enableZoom=!0,this.zoomSpeed=2,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.autoRotateClockwise=!0,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Us.ROTATE,MIDDLE:Us.DOLLY,RIGHT:Us.PAN},this.touches={ONE:ks.ROTATE,TWO:ks.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return f.phi},this.getAzimuthalAngle=function(){return f.theta},this.saveState=function(){l.target0.copy(l.target),l.position0.copy(l.object.position),l.zoom0=l.object.zoom},this.reset=function(){l.target.copy(l.target0),l.object.position.copy(l.position0),l.object.zoom=l.zoom0,n=0,l.object.updateProjectionMatrix(),l.dispatchEvent(Fp),l.update(),u=c.NONE},this.update=function(){let F=l.object.position;fc.copy(F).sub(l.target),f.setFromVector3(fc),l.object.isUpVectorFlipped&&(f.phi*=-1,f.theta-=Math.PI),l.autoRotate&&u===c.NONE&&(l.autoRotateClockwise===!0?R(U()):G(U())),l.rotationLimitsMode!==l.rotationLimitsOptions.HORIZONTAL&&(f.phi+=p.phi),(l.rotationLimitsMode!==l.rotationLimitsOptions.VERTICAL||l.autoRotate===!0)&&(f.theta+=p.theta),(l.rotationLimitsMode===l.rotationLimitsOptions.VERTICAL||l.rotationLimitsMode===l.rotationLimitsOptions.BOTH)&&(f.phi=Math.max(i,Math.min(s,f.phi))),(l.rotationLimitsMode===l.rotationLimitsOptions.HORIZONTAL||l.rotationLimitsMode===l.rotationLimitsOptions.BOTH)&&(n+=p.theta,n>l.rotationHorizontalOffset.max?(f.theta=a,n=l.rotationHorizontalOffset.max):n<-l.rotationHorizontalOffset.min&&(f.theta=o,n=-l.rotationHorizontalOffset.min));let Pe=l.minAzimuthAngle,et=l.maxAzimuthAngle;isFinite(Pe)&&isFinite(et)&&(Pe<-Math.PI?Pe+=pc:Pe>Math.PI&&(Pe-=pc),et<-Math.PI?et+=pc:et>Math.PI&&(et-=pc),Pe<=et?f.theta=Math.max(Pe,Math.min(et,f.theta)):f.theta=f.theta>(Pe+et)/2?Math.max(Pe,f.theta):Math.min(et,f.theta)),f.radius*=m,f.radius=Math.max(l.minDistance,Math.min(l.maxDistance,f.radius)),l.target.add(v),fc.setFromSpherical(f),F.copy(l.target).add(fc);let Ft=f.phi%pc;return fx.copy(fc).normalize(),l.object.up.copy(Ke.DefaultUp).applyAxisAngle(fx,l.object.angleOffsetFromUp),Ft>0&&Ft>Math.PI||Ft<0&&Ft>-Math.PI?(l.object.up.negate(),l.object.lookAt(l.target),l.object.isUpVectorFlipped=!0):(l.object.lookAt(l.target),l.object.isUpVectorFlipped=!1),l.enableDamping===!0?(p.theta*=1-l.dampingFactor,p.phi*=1-l.dampingFactor):p.set(0,0,0),v.set(0,0,0),m=1,g||px.distanceToSquared(l.object.position)>d||8*(1-mx.dot(l.object.quaternion))>h?(l.dispatchEvent(Fp),g&&l.dispatchEvent(yL),px.copy(l.object.position),mx.copy(l.object.quaternion),g=!1,!0):(p.set(0,0,0),!1)},this.dispose=function(){l.domElement.removeEventListener("contextmenu",xn),l.domElement.removeEventListener("pointerdown",xe),l.domElement.removeEventListener("wheel",Bn),l.domElement.removeEventListener("touchstart",En),l.domElement.removeEventListener("touchend",_r),l.domElement.removeEventListener("touchmove",Di),l.domElement.ownerDocument.removeEventListener("pointermove",he),l.domElement.ownerDocument.removeEventListener("pointerup",Ne),l.domElement.removeEventListener("gesturestart",X),l.domElement.removeEventListener("gesturechange",X),l.domElement.removeEventListener("gestureend",X),window.removeEventListener("keydown",Mt,!1),window.removeEventListener("keyup",Tn,!1)},this.zoomOut=function(){W(P())},this.zoomIn=function(){z(P())},this.setEnableDampingSpeed=function(F){this.enableDamping=F,this.rotateSpeed=F===!0?.2:1},this.resetTo=function(F,Pe,et){l.target.copy(F),l.object.position.copy(Pe),l.object.zoom=et,l.object.updateProjectionMatrix(),l.dispatchEvent(Fp),l.update(),u=c.NONE},this.stopDamping=function(){p.theta=0,p.phi=0};let n,i,s,o,a;this.rotationVerticalOffset={min:Math.PI*.5,max:Math.PI*.5},this.rotationHorizontalOffset={min:Math.PI*.5,max:Math.PI*.5},this.rotationLimitsOptions={DEFAULT:0,VERTICAL:1,HORIZONTAL:2,BOTH:3},this.rotationLimitsMode=this.rotationLimitsOptions.DEFAULT,this.updateRotationOffetLimits=function(){n=0,i=Th(f.phi-l.rotationVerticalOffset.min),s=Th(f.phi+l.rotationVerticalOffset.max),i<0&&(i=l.minPolarAngle),s<0&&(s=l.maxPolarAngle),o=Th(f.theta-l.rotationHorizontalOffset.min),a=Th(f.theta+l.rotationHorizontalOffset.max)},this.toJSON=function(){let F={};return l.useKeyEvents&&(F.useKeyEvents=!0),l.enableDamping&&(F.enableDamping=!0),l.enablePan&&(F.enablePan=!0),l.enableZoom&&(F.enableZoom=!0),l.enableRotate&&(F.enableRotate=!0),F.rotationLimitsMode=l.rotationLimitsMode,(l.rotationLimitsMode===l.rotationLimitsOptions.VERTICAL||l.rotationLimitsMode===l.rotationLimitsOptions.BOTH)&&(F.rotationVerticalOffset={min:l.rotationVerticalOffset.min,max:l.rotationVerticalOffset.max}),(l.rotationLimitsMode===l.rotationLimitsOptions.HORIZONTAL||l.rotationLimitsMode===l.rotationLimitsOptions.BOTH)&&(F.rotationHorizontalOffset={min:l.rotationHorizontalOffset.min,max:l.rotationHorizontalOffset.max}),l.autoRotate&&(F.autoRotate=!0,F.autoRotateSpeed=l.autoRotateSpeed,l.autoRotateClockwise&&(F.autoRotateClockwise=!0)),F},this.fromJSON=function(F){l.useKeyEvents=F.useKeyEvents===!0,l.setEnableDampingSpeed(F.enableDamping===!0),l.enablePan=F.enablePan===!0,l.enableZoom=F.enableZoom===!0,l.enableRotate=F.enableRotate===!0,F.rotationLimitsMode!==void 0&&(l.rotationLimitsMode=F.rotationLimitsMode),F.rotationVerticalOffset&&(l.rotationVerticalOffset={min:F.rotationVerticalOffset.min,max:F.rotationVerticalOffset.max}),F.rotationHorizontalOffset&&(l.rotationHorizontalOffset={min:F.rotationHorizontalOffset.min,max:F.rotationHorizontalOffset.max}),l.autoRotate=F.autoRotate===!0,F.autoRotateSpeed&&(l.autoRotateSpeed=F.autoRotateSpeed),l.autoRotateClockwise=F.autoRotateClockwise===!0,l.updateRotationOffetLimits()};let l=this,c={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},u=c.NONE,h=1e-8,d=.01,f=new bh,p=new bh,m=1,v=new M,g=!1,y=new O,x=new O,b=new O,w=new O,_=new O,S=new O,A=new O,T=new O,L=new O,C={};function U(){return 2*Math.PI/60/60*l.autoRotateSpeed}function P(){return Math.pow(.95,l.zoomSpeed)}function R(F){p.theta-=F*(l.object.isUpVectorFlipped?-1:1)}function G(F){p.theta+=F}function B(F){p.phi-=F}let j=function(){let F=new M;return function(et,Ft){F.setFromMatrixColumn(Ft,0),F.multiplyScalar(-et),v.add(F)}}(),ne=function(){let F=new M;return function(et,Ft){l.screenSpacePanning===!0?F.setFromMatrixColumn(Ft,1):(F.setFromMatrixColumn(Ft,0),F.crossVectors(l.object.up,F)),F.multiplyScalar(et),v.add(F)}}(),le=function(){let F=new M;return function(et,Ft){let Nn=l.domElement;if(l.object.isPerspectiveCamera){let Gs=l.object.position;F.copy(Gs).sub(l.target);let sr=F.length();sr*=Math.tan(l.object.fov/2*Math.PI/180),j(2*et*sr/Nn.clientHeight,l.object.matrix),ne(2*Ft*sr/Nn.clientHeight,l.object.matrix)}else l.object.isOrthographicCamera?(j(et*(l.object.right-l.object.left)/l.object.zoom/Nn.clientWidth,l.object.matrix),ne(Ft*(l.object.top-l.object.bottom)/l.object.zoom/Nn.clientHeight,l.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),l.enablePan=!1)}}();function W(F){l.object.isPerspectiveCamera?m/=F:l.object.isOrthographicCamera?(l.object.zoom=Math.max(l.minZoom,Math.min(l.maxZoom,l.object.zoom*F)),l.object.updateProjectionMatrix(),g=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),l.enableZoom=!1)}function z(F){l.object.isPerspectiveCamera?m*=F:l.object.isOrthographicCamera?(l.object.zoom=Math.max(l.minZoom,Math.min(l.maxZoom,l.object.zoom/F)),l.object.updateProjectionMatrix(),g=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),l.enableZoom=!1)}function D(F){y.set(F.clientX,F.clientY)}function K(F){A.set(F.clientX,F.clientY)}function q(F){w.set(F.clientX,F.clientY)}function ee(F){x.set(F.clientX,F.clientY),b.subVectors(x,y).multiplyScalar(l.rotateSpeed).rotateAround(vL,-l.object.angleOffsetFromUp);let Pe=l.domElement;R(2*Math.PI*b.x/Pe.clientHeight),B(2*Math.PI*b.y/Pe.clientHeight),y.copy(x),l.update()}function V(F){T.set(F.clientX,F.clientY),L.subVectors(T,A),L.y>0?W(P()):L.y<0&&z(P()),A.copy(T),l.update()}function de(F){_.set(F.clientX,F.clientY),S.subVectors(_,w).multiplyScalar(l.panSpeed),le(S.x,S.y),w.copy(_),l.update()}function ae(){}let te=0;function X(F){if(F.preventDefault(),F.type==="gesturechange"){if(l.enableZoom===!1)return;F.scale>te?z(P()):F.scale0&&W(P())}else{if(l.enablePan===!1)return;S.set(-F.deltaX,-F.deltaY).multiplyScalar(l.panSpeed),F.altKey?le(0,S.y):F.shiftKey?le(S.x,0):le(S.x,S.y)}l.update()}$&&window.clearTimeout($),$=window.setTimeout(()=>{se=!1,H=void 0},200)}function ie(F){let Pe=!1;switch(F.code){case l.keys.UP:le(0,l.keyPanSpeed),Pe=!0;break;case l.keys.BOTTOM:le(0,-l.keyPanSpeed),Pe=!0;break;case l.keys.LEFT:le(l.keyPanSpeed,0),Pe=!0;break;case l.keys.RIGHT:le(-l.keyPanSpeed,0),Pe=!0;break;default:break}Pe&&(F.preventDefault(),l.update())}function N(F){if(F.touches.length===1)y.set(F.touches[0].pageX,F.touches[0].pageY);else{let Pe=.5*(F.touches[0].pageX+F.touches[1].pageX),et=.5*(F.touches[0].pageY+F.touches[1].pageY);y.set(Pe,et)}}function E(F){if(F.touches.length===1)w.set(F.touches[0].pageX,F.touches[0].pageY);else{let Pe=.5*(F.touches[0].pageX+F.touches[1].pageX),et=.5*(F.touches[0].pageY+F.touches[1].pageY);w.set(Pe,et)}}function Y(F){let Pe=F.touches[0].pageX-F.touches[1].pageX,et=F.touches[0].pageY-F.touches[1].pageY,Ft=Math.sqrt(Pe*Pe+et*et);A.set(0,Ft)}function re(F){l.enableZoom&&Y(F),l.enablePan&&E(F)}function ye(F){l.enableZoom&&Y(F),l.enableRotate&&N(F)}function pe(F){if(F.touches.length===1)x.set(F.touches[0].pageX,F.touches[0].pageY);else{let et=.5*(F.touches[0].pageX+F.touches[1].pageX),Ft=.5*(F.touches[0].pageY+F.touches[1].pageY);x.set(et,Ft)}b.subVectors(x,y).multiplyScalar(l.rotateSpeed);let Pe=l.domElement;R(2*Math.PI*b.x/Pe.clientHeight),B(2*Math.PI*b.y/Pe.clientHeight),y.copy(x)}function Ie(F){if(F.touches.length===1)_.set(F.touches[0].pageX,F.touches[0].pageY);else{let Pe=.5*(F.touches[0].pageX+F.touches[1].pageX),et=.5*(F.touches[0].pageY+F.touches[1].pageY);_.set(Pe,et)}S.subVectors(_,w).multiplyScalar(l.panSpeed),le(S.x,S.y),w.copy(_)}function ve(F){let Pe=F.touches[0].pageX-F.touches[1].pageX,et=F.touches[0].pageY-F.touches[1].pageY,Ft=Math.sqrt(Pe*Pe+et*et);T.set(0,Ft),L.set(0,Math.pow(T.y/A.y,l.zoomSpeed)),W(L.y),A.copy(T)}function Fe(F){l.enableZoom&&ve(F),l.enablePan&&Ie(F)}function Ce(F){l.enableZoom&&ve(F),l.enableRotate&&pe(F)}function J(){}function xe(F){if(l.enabled!==!1)switch(F.pointerType){case"mouse":case"pen":l.useKeyEvents===!1?Be(F):ke(F);break;default:break}}function he(F){if(l.enabled!==!1)switch(F.pointerType){case"mouse":case"pen":ht(F);break;default:break}}function Ne(F){switch(F.pointerType){case"mouse":case"pen":ft(F);break;default:break}l.domElement.ownerDocument.removeEventListener("pointermove",he),l.domElement.ownerDocument.removeEventListener("pointerup",Ne)}function Be(F){F.preventDefault(),l.domElement.focus?l.domElement.focus():window.focus();let Pe;switch(F.button){case 0:Pe=l.mouseButtons.LEFT;break;case 1:Pe=l.mouseButtons.MIDDLE;break;case 2:Pe=l.mouseButtons.RIGHT;break;default:Pe=-1}switch(Pe){case Us.DOLLY:if(l.enablePan===!1)return;q(F),u=c.PAN;break;case Us.ROTATE:if(F.ctrlKey||F.metaKey||F.shiftKey){if(l.enablePan===!1)return;q(F),u=c.PAN}else{if(l.enableRotate===!1)return;D(F),u=c.ROTATE}break;case Us.PAN:if(F.ctrlKey||F.metaKey||F.shiftKey){if(l.enableRotate===!1)return;D(F),u=c.ROTATE}else{if(l.enablePan===!1)return;q(F),u=c.PAN}break;default:u=c.NONE}u!==c.NONE&&(l.domElement.ownerDocument.addEventListener("pointermove",he),l.domElement.ownerDocument.addEventListener("pointerup",Ne),l.dispatchEvent(_h))}function ke(F){if(l.enabled!==!1){switch(F.preventDefault(),l.domElement.focus?l.domElement.focus():window.focus(),F.button){case l.mouseButtons.MIDDLE:if(l.enablePan===!1)return;q(F),u=c.PAN;break;case l.mouseButtons.LEFT:if(F.altKey===!0&&!F.shiftKey&&!(dx?F.metaKey:F.ctrlKey)){if(l.enableRotate===!1)return;D(F),u=c.ROTATE}else if(C.code==="Space"){if(l.enablePan===!1)return;q(F),u=c.PAN}break;default:u=c.NONE}u!==c.NONE&&(l.domElement.ownerDocument.addEventListener("pointermove",he),l.domElement.ownerDocument.addEventListener("pointerup",Ne),l.dispatchEvent(_h))}}function ht(F){if(l.enabled!==!1)switch(F.preventDefault(),u){case c.ROTATE:if(l.enableRotate===!1)return;ee(F);break;case c.DOLLY:if(l.enableZoom===!1)return;V(F);break;case c.PAN:if(l.enablePan===!1)return;de(F);break;default:break}}function ft(F){l.enabled!==!1&&(ae(F),l.dispatchEvent(zp),u=c.NONE)}function Bn(F){l.enabled===!1||l.enableZoom===!1||u!==c.NONE&&u!==c.ROTATE||(F.preventDefault(),l.dispatchEvent(_h),ce(F),l.dispatchEvent(zp))}function Mt(F){l.enabled!==!1&&(C=F)}function Tn(){l.enabled!==!1&&(C={},u!==c.NONE&&ft(new PointerEvent("pointerover")))}function En(F){if(l.enabled!==!1){switch(F.preventDefault(),F.touches.length){case 1:switch(l.touches.ONE){case ks.ROTATE:if(l.enableRotate===!1)return;N(F),u=c.TOUCH_ROTATE;break;case ks.PAN:if(l.enablePan===!1)return;E(F),u=c.TOUCH_PAN;break;default:u=c.NONE}break;case 2:switch(l.touches.TWO){case ks.DOLLY_PAN:if(l.enableZoom===!1&&l.enablePan===!1)return;re(F),u=c.TOUCH_DOLLY_PAN;break;case ks.DOLLY_ROTATE:if(l.enableZoom===!1&&l.enableRotate===!1)return;ye(F),u=c.TOUCH_DOLLY_ROTATE;break;default:u=c.NONE}break;default:u=c.NONE}u!==c.NONE&&l.dispatchEvent(_h)}}function Di(F){if(l.enabled!==!1)switch(F.preventDefault(),u){case c.TOUCH_ROTATE:if(l.enableRotate===!1)return;pe(F),l.update();break;case c.TOUCH_PAN:if(l.enablePan===!1)return;Ie(F),l.update();break;case c.TOUCH_DOLLY_PAN:if(l.enableZoom===!1&&l.enablePan===!1)return;Fe(F),l.update();break;case c.TOUCH_DOLLY_ROTATE:if(l.enableZoom===!1&&l.enableRotate===!1)return;Ce(F),l.update();break;default:u=c.NONE}}function _r(F){l.enabled!==!1&&(J(F),l.dispatchEvent(zp),u=c.NONE)}function xn(F){l.enabled!==!1&&F.preventDefault()}l.domElement.addEventListener("contextmenu",xn),l.domElement.addEventListener("pointerdown",xe),l.domElement.addEventListener("wheel",Bn,{passive:!1}),l.domElement.addEventListener("touchstart",En,{passive:!1}),l.domElement.addEventListener("touchend",_r),l.domElement.addEventListener("touchmove",Di,{passive:!1}),l.domElement.addEventListener("gesturestart",X),l.domElement.addEventListener("gesturechange",X),l.domElement.addEventListener("gestureend",X),window.addEventListener("keydown",Mt,!1),window.addEventListener("keyup",Tn,!1),this.update(),this.updateRotationOffetLimits(),this.setEnableDampingSpeed(!0)}};function Th(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}var xL=3,Up=class extends Lp{constructor(){super();this.layers.enable(xL)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,n=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,n)}),n}createRaycastLineHelper(){let e=new Gn({color:65280,linewidth:10}),t=new M(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new M(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new M().addVectors(t,n.multiplyScalar(i)),o=new we;return o.setFromPoints([t,s]),new Hi(o,e)}};var gx=r=>class{constructor(t=pp){this.manager=t;this.loader=new r(t)}};var ze=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ee.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n!=null?n:{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n!=null?n:{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t!=null?t:this.getType(e,t);let i=e.getNodeData(n!=null?n:this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof ze&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;it)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let n={};return n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=n),n}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var je=class extends ze{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,n,i){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=Ee.generateUUID()),n=e.getUUID(n!=null?n:this.getUUID(),!s);let o=e.getNodeData(n),a=o.output||this.getType(e);if(e.analyzing)return(o.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,o,t),this.generate(e,t,n)):super.build(e,t,n);if(s)return o.name=o.name||super.build(e,t,n),o.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||o.deps===1))return super.build(e,t,n);n=this.getUUID(!1);let l=this.getTemp(e,n);if(l)return e.format(l,a,t);{l=super.generate(e,t,n,o.output,i);let c=this.generate(e,a,n);return e.addNodeCode(l+" = "+c+";"),e.format(l,a,t)}}return super.build(e,t,n)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let n=e.getVars()[t];return n?n.name:void 0}generate(e,t,n,i,s){return this.getShared(e,t)||console.error("TempNode is not shared"),n=n!=null?n:this.uuid,e.getTempVar(n,i!=null?i:this.getType(e),s,this.getLabel()).name}};var Ct=class extends je{constructor(e,t){t=t!=null?t:{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,n,i,s,o){n=e.getUUID(n!=null?n:this.getUUID()),i=i!=null?i:this.getType(e);let a=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,n,i,s,o):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(i,this,s,o,this.getLabel())),e.format(a.vertex.name,i,t)):(a.fragment||(a.fragment=e.createFragmentUniform(i,this,s,o,this.getLabel())),e.format(a.fragment.name,i,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var Un=class extends Ct{constructor(e=0,t,n){super("v3");this.nodeType="Vector3";this.value=e instanceof M?e:new M(e,t,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,n,i,s,o){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,t.z=this.value.z,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),e.z&&(this.value.z=e.z),this}};var In=class extends Ct{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof O?e:new O(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,n,i,s,o){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),this}};var it=class extends Ct{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,t,n,i,s,o){return e.format(this.value.toString(),i,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var Te=class extends Ct{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,t,n,i,s,o){return e.format(this.value+(this.value%1?"":".0"),i,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var lt;(function(m){m.POSITION="position",m.LIGHTING="light",m.COLOR="color",m.GRADIENT="gradient",m.NORMAL="normal",m.DEPTH="depth",m.TEXTURE="texture",m.NOISE="noise",m.FRESNEL="fresnel",m.RAINBOW="rainbow",m.TRANSMISSION="transmission",m.POINTS="points",m.MATCAP="matcap",m.LINES="lines",m.DISPLACE="displace"})(lt||(lt={}));var Gt;(function(n){n.POSITION="position",n.LIGHTING="light",n.COLOR="color"})(Gt||(Gt={}));var jt=class{constructor(e,t,n){this.next=void 0;this.uniforms={};this.textures={};this.defines={};this.backLayer=void 0;this.isBack=!1;if(this.id=e,t){this.type=t.type;for(let i in t)i!=="type"&&i!=="calpha"&&(this.uniforms[`f${this.id}_${i}`]=t[i]);for(let i in n)this.defines[i]=n[i]}}copy(e){this.id=e.id,this.type=e.type,this.defines=Ue({},e.defines);for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new jt(this.id).copy(this)}fromJSON(e,t){this.id=e.id,this.defines=Ue({},e.defines);for(let n in e.uniforms)this.uniforms[n]=t.getNode(e.uniforms[n]);if(e.type===lt.TEXTURE){if(!(`f${this.id}_textureSize`in this.uniforms)){let n=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${e.id}_textureSize`]=new Un(n.width,n.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new In(200,200)),`f${e.id}_axis`in this.uniforms||(this.uniforms[`f${e.id}_axis`]=new it(0)),`f${e.id}_projection`in this.uniforms||(this.uniforms[`f${e.id}_projection`]=new it(0))}else e.type===lt.NOISE?(`f${e.id}_noiseType`in this.uniforms||(this.uniforms[`f${e.id}_noiseType`]=new it(0)),`f${e.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new Un(-1,-1,-1))):e.type===lt.DEPTH&&(`f${e.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${e.id}_isWorldSpace`]=new Te(1)));return this}toJSON(e){let t={};for(let i in this.uniforms)t[i]=this.uniforms[i].toJSON(e).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:t,next:this.next==null?void 0:this.next.toJSON(e)}}copyUniforms(e){for(let t in this.uniforms){let n=this.getName(t);n!==void 0&&e.uniforms[`f${e.id}_${n}`]&&n!=="transmissionDepthMap"&&n!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${n}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;this.hasValueByKey(n)&&t!==void 0&&(this.uniforms[n].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let n=this.getName(t);if(n===void 0)continue;let s=this.uniforms[`f${this.id}_${n}`].value;s!==void 0&&(Array.isArray(s)?e[n]=s.map(o=>o.clone?o.clone():o):e[n]=s.clone?s.clone():s)}return e}getName(e){let n=/f\d+_(.*)/.exec(e);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}isEqual(e){for(let t in e.uniforms){let n=e.getName(t);if(!n)return!1;let i=this.getValue(n),s=e.uniforms[t].value;if(s.value instanceof xt){if(i.image!==s.image)return!1}else if(Array.isArray(s)){let o=i;for(let a=0,l=o.length;at.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.map(n=>({x:n.x,y:n.y,z:n.z,w:n.w}))),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value.map(n=>new Qe(n.x,n.y,n.z,n.w)),this.size=this.value.length),this}};var Ba=class extends Ct{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.size=this.size,t.value=[...this.value]),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=[...e.value]),e.size?this.size=e.size:e.value&&(this.size=this.value.length),this}};var yx=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},pn=new yx;var bo=class extends je{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,t){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(i,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}};pn.addKeyword("uv",function(){return new bo});pn.addKeyword("uv2",function(){return new bo(1)});var bL=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,vx=/[a-z_0-9]+/gi,Le=class extends je{constructor(e,t,n,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,n,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,n,i,s){let o,a=0,l=this.src;if(this.includes)for(let u=0;ut.getNode(n))),this}};var wL=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Vp=class extends je{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Vp.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,n,i,s){this.src=e||"";let o,a,l="",c=wL.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",c&&c.length>1?(a=c[1],o=c[2],l=c[3]):(o=this.src,a="f"),this.name=o,this.type=a,this.value=l}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,n,i,s){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src,t.useDefine=this.useDefine,t.value=this.value,t.name=this.name),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.src&&(this.src=e.src),e.value&&(this.value=e.value),e.name&&(this.name=e.name),e.useDefine!==void 0&&(this.useDefine=e.useDefine),this}},rt=Vp;rt.PI="PI",rt.PI2="PI2",rt.RECIPROCAL_PI="RECIPROCAL_PI",rt.RECIPROCAL_PI2="RECIPROCAL_PI2",rt.LOG2="LOG2",rt.EPSILON="EPSILON";var yt=class extends Le{constructor(e="",t,n,i,s){super(e,s,i,n,t);this.nodeType="Expression"}};var wo=class extends je{constructor(e=new ze,t){super("v4");this.nodeType="ColorSpace";this.factor=new ze;this.input=e,this.method=t!=null?t:wo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case ln:return["Linear"];case Fi:return["sRGB"];case Rl:return["RGBE"];case Mu:return["RGBM",new Te(7).setReadonly(!0)];case Au:return["RGBM",new Te(16).setReadonly(!0)];case _u:return["RGBD",new Te(256).setReadonly(!0)];case Qs:return["Gamma",new yt("float( GAMMA_FACTOR )","f")];default:return[]}}generate(e,t){let n=this.input.build(e,"v4"),i=this.getType(e),s=wo.Nodes[this.method],o=e.include(s);if(o===wo.LINEAR_TO_LINEAR)return e.format(n,i,t);if(s.inputs.length===2){let a=this.factor.build(e,"f");return e.format(o+"( "+n+", "+a+" )",i,t)}else return e.format(o+"( "+n+" )",i,t)}fromEncoding(e){let t=wo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=wo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.input=this.input.toJSON(e).uuid,t.factor=this.factor.toJSON(e).uuid,t.method=this.method),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.input&&(this.input=t.getNode(e.input)),e.factor&&(this.factor=t.getNode(e.factor)),e.method&&(this.method=e.method),this}},Bt=wo;Bt.Nodes={LinearToLinear:new Le(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(` `)),GammaToLinear:new Le(["vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {"," return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );","}"].join(` `)),LinearToGamma:new Le(["vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {"," return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );","}"].join(` `)),sRGBToLinear:new Le(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(` `)),LinearTosRGB:new Le(["vec4 LinearTosRGB( 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.w );","}"].join(` `)),RGBEToLinear:new Le(["vec4 RGBEToLinear( in vec4 value ) {"," return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );","}"].join(` `)),LinearToRGBE:new Le(["vec4 LinearToRGBE( in vec4 value ) {"," float maxComponent = max( max( value.r, value.g ), value.b );"," float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );"," return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );","}"].join(` `)),RGBMToLinear:new Le(["vec3 RGBMToLinear( in vec4 value, in float maxRange ) {"," return vec4( value.xyz * value.w * maxRange, 1.0 );","}"].join(` `)),LinearToRGBM:new Le(["vec3 LinearToRGBM( in vec4 value, in float maxRange ) {"," float maxRGB = max( value.x, max( value.g, value.b ) );"," float M = clamp( maxRGB / maxRange, 0.0, 1.0 );"," M = ceil( M * 255.0 ) / 255.0;"," return vec4( value.rgb / ( M * maxRange ), M );","}"].join(` `)),RGBDToLinear:new Le(["vec3 RGBDToLinear( in vec4 value, in float maxRange ) {"," return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );","}"].join(` `)),LinearToRGBD:new Le(["vec3 LinearToRGBD( in vec4 value, in float maxRange ) {"," float maxRGB = max( value.x, max( value.g, value.b ) );"," float D = max( maxRange / maxRGB, 1.0 );"," D = clamp( floor( D ) / 255.0, 0.0, 1.0 );"," return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );","}"].join(` `)),cLogLuvM:new rt("const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );"),LinearToLogLuv:new Le(["vec4 LinearToLogLuv( in vec4 value ) {"," vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;"," Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));"," vec4 vResult;"," vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;"," float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;"," vResult.w = fract(Le);"," vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;"," return vResult;","}"].join(` `),[new rt("const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );")]),cLogLuvInverseM:new rt("const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );"),LogLuvToLinear:new Le(["vec4 LogLuvToLinear( in vec4 value ) {"," float Le = value.z * 255.0 + value.w;"," vec3 Xp_Y_XYZp;"," Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);"," Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;"," Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;"," vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;"," return vec4( max(vRGB, 0.0), 1.0 );","}"].join(` `),[new rt("const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );")])},Bt.LINEAR_TO_LINEAR="LinearToLinear",Bt.GAMMA_TO_LINEAR="GammaToLinear",Bt.LINEAR_TO_GAMMA="LinearToGamma",Bt.SRGB_TO_LINEAR="sRGBToLinear",Bt.LINEAR_TO_SRGB="LinearTosRGB",Bt.RGBE_TO_LINEAR="RGBEToLinear",Bt.LINEAR_TO_RGBE="LinearToRGBE",Bt.RGBM_TO_LINEAR="RGBMToLinear",Bt.LINEAR_TO_RGBM="LinearToRGBM",Bt.RGBD_TO_LINEAR="RGBDToLinear",Bt.LINEAR_TO_RGBD="LinearToRGBD",Bt.LINEAR_TO_LOG_LUV="LinearToLogLuv",Bt.LOG_LUV_TO_LINEAR="LogLuvToLinear";var bi=class extends xt{toJSON(e){let t=super.toJSON(e),n=e===void 0||typeof e=="string";if(this.image!==void 0&&!n){let i=this.image;if(Array.isArray(i)){e.images[i.uuid].url=[];for(let s=0;s 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; }`);n=e.include(s);break;default:n=e.include(gc.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){let s=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexParsCode(`varying vec2 ${s}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${s}_vCustomUv;`),e.addVertexFinalCode(` vec3 ${s}_posN = transformed; ${this.axis.value===0?` float ${s}_u = (1. + (${s}_posN.z)) / 2.; float ${s}_v = (1. + (${s}_posN.y)) / 2.; `:""} ${this.axis.value===1?` float ${s}_u = (1. + (${s}_posN.x)) / 2.; float ${s}_v = (1. - (${s}_posN.z)) / 2.; `:""} ${this.axis.value===2?` float ${s}_u = (1. + (${s}_posN.x)) / 2.; float ${s}_v = (1. + (${s}_posN.y)) / 2.; `:""} ${s}_vCustomUv = vec2(${s}_u, ${s}_v); `)}e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.texture.getTexture(e,"t")),i.push(this.textureSize.build(e,"v2")),i.push(this.crop.build(e,"f")),i.push(this.mat.build(e,"mat3")),i.push(this.size.build(e,"v2")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+i.join(",")+")",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.crop=this.crop.toJSON(e).uuid,t.projection=this.projection.toJSON(e).uuid,t.axis=this.axis.toJSON(e).uuid,t.size=this.size.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture),this.texture.value.updateMatrix(),this.mat=new zr(this.texture.value.matrix)),e.textureSize&&(this.textureSize=t.getNode(e.textureSize)),e.crop&&(this.crop=t.getNode(e.crop)),e.projection&&(this.projection=t.getNode(e.projection)),e.axis&&(this.axis=t.getNode(e.axis)),e.size&&(this.size=t.getNode(e.size)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize=e.textureSize.clone(),this.crop=e.crop.clone(),this.projection=e.projection.clone(),this.axis=e.axis.clone(),this.size=e.size.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this}},za=gc;za.Nodes=function(){let e=new Le(` vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec3 posN = normalize(position); float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); float scaledHeight = position.y / (size.y * 0.5); float v = (scaledHeight / 2.) + .5; vec2 calculatedUv = vec2(u,v); vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; vec2 df = fwidth(uvs); if(df.x > 0.5) df.x = 0.; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #else vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; } `),t=new Le(` vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec3 posN = normalize(vPosition); float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); float v = 0.5 + asin(posN.y) / 3.1415; vec2 calculatedUv = vec2(u,v); vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; vec2 df = fwidth(uvs); if(df.x > 0.5) df.x = 0.; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #else vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; } `),n=new Le(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; vec4 tmp = texture2D( tex, uvs ); vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; }`);return{cylindrical:e,spherical:t,uv:n}}();var Hp=class extends je{constructor(e,t,n,i,s,o,a){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=n,this.intensity=i,this.factor=s,this.alpha=o,this.mode=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("vWorldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(Hp.Nodes.fresnel),i=[];return i.push(this.color.build(e,"c")),i.push(this.bias.build(e,"f")),i.push(this.scale.build(e,"f")),i.push(this.intensity.build(e,"f")),i.push(this.factor.build(e,"f")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.color=this.color.toJSON(e).uuid,t.bias=this.bias.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid,t.intensity=this.intensity.toJSON(e).uuid,t.factor=this.factor.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.color&&(this.color=t.getNode(e.color)),e.bias&&(this.bias=t.getNode(e.bias)),e.scale&&(this.scale=t.getNode(e.scale)),e.intensity&&(this.intensity=t.getNode(e.intensity)),e.factor&&(this.factor=t.getNode(e.factor)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.color=e.color.clone(),this.bias=e.bias.clone(),this.scale=e.scale.clone(),this.intensity=e.intensity.clone(),this.factor=e.factor.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},Ga=Hp;Ga.Nodes=function(){return{fresnel:new Le(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) { float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWorldNormal ) ) ), intensity ); float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha; calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0); accumAlpha += (1.0 - accumAlpha) * lalpha; return color; }`)}}();var Ua;(function(s){s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin"})(Ua||(Ua={}));var si=function(){let r=5,e=new Le(`vec3 random3(vec3 c) { float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); vec3 r; r.z = fract(512.0*j); j *= .125; r.x = fract(512.0*j); j *= .125; r.y = fract(512.0*j); return r-0.5; }`),t=new Le(`float simplex3d(vec3 p) { vec3 s = floor(p + dot(p, vec3(F3))); vec3 x = p - s + dot(s, vec3(G3)); vec3 e = step(vec3(0.0), x - x.yzx); vec3 i1 = e*(1.0 - e.zxy); vec3 i2 = 1.0 - e.zxy*(1.0 - e); vec3 x1 = x - i1 + G3; vec3 x2 = x - i2 + 2.0*G3; vec3 x3 = x - 1.0 + 3.0*G3; vec4 w, d; w.x = dot(x, x); w.y = dot(x1, x1); w.z = dot(x2, x2); w.w = dot(x3, x3); w = max(0.6 - w, 0.0); d.x = dot(random3(s), x); d.y = dot(random3(s + i1), x1); d.z = dot(random3(s + i2), x2); d.w = dot(random3(s + 1.0), x3); w *= w; w *= w; d *= w; return dot(d, vec4(52.0)); }`,[e]);t.keywords.F3=new rt("float F3 0.3333333"),t.keywords.G3=new rt("float G3 0.1666667");let n=new Le(`float simplex3dFractal(vec3 m) { mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4); mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63); mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56); return 0.5333333 * simplex3d(m * rot1) + 0.2666667 * simplex3d(2.0 * m * rot2) + 0.1333333 * simplex3d(4.0 * m * rot3) + 0.0666667 * simplex3d(8.0 * m); }`,[t]),i=new Le("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new Le("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new Le(`float simplexAshima(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); vec3 x1 = x0 - i1 + 1.0 * C.xxx; vec3 x2 = x0 - i2 + 2.0 * C.xxx; vec3 x3 = x0 - 1. + 3.0 * C.xxx; i = mod(i, 289.0 ); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); float n_ = 1.0/7.0; // N=7 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); }`,[i,s]),a=new Le("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new Le("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new Le(`float noise(vec3 p){ vec3 a = floor(p); vec3 d = p - a; d = d * d * (3.0 - 2.0 * d); vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); vec4 k1 = perm(b.xyxy); vec4 k2 = perm(k1.xyxy + b.zzww); vec4 c = k2 + a.zzzz; vec4 k3 = perm(c); vec4 k4 = perm(c + 1.0); vec4 o1 = fract(k3 * (1.0 / 41.0)); vec4 o2 = fract(k4 * (1.0 / 41.0)); vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); return o4.y * d.y + o4.x * (1.0 - d.y); }`,[l]),u=new Le(`float fbm(vec3 x) { float v = 0.0; float a = 0.5; vec3 shift = vec3(100); for (int i = 0; i < NUM_OCTAVES; ++i) { v += a * noise(x); x = x * 2.0 + shift; a *= 0.5; } return v; }`,[c]);u.keywords.NUM_OCTAVES=new rt(`int NUM_OCTAVES ${r}`);let h=new Le("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new Le(`float perlin(vec3 P){ vec3 Pi0 = floor(P); vec3 Pi1 = Pi0 + vec3(1.0); Pi0 = mod(Pi0, 289.0); Pi1 = mod(Pi1, 289.0); vec3 Pf0 = fract(P); vec3 Pf1 = Pf0 - vec3(1.0); vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); vec4 iy = vec4(Pi0.yy, Pi1.yy); vec4 iz0 = Pi0.zzzz; vec4 iz1 = Pi1.zzzz; vec4 ixy = permute(permute(ix) + iy); vec4 ixy0 = permute(ixy + iz0); vec4 ixy1 = permute(ixy + iz1); vec4 gx0 = ixy0 / 7.0; vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5; gx0 = fract(gx0); vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); vec4 sz0 = step(gz0, vec4(0.0)); gx0 -= sz0 * (step(0.0, gx0) - 0.5); gy0 -= sz0 * (step(0.0, gy0) - 0.5); vec4 gx1 = ixy1 / 7.0; vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5; gx1 = fract(gx1); vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); vec4 sz1 = step(gz1, vec4(0.0)); gx1 -= sz1 * (step(0.0, gx1) - 0.5); gy1 -= sz1 * (step(0.0, gy1) - 0.5); vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); g000 *= norm0.x; g010 *= norm0.y; g100 *= norm0.z; g110 *= norm0.w; vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); g001 *= norm1.x; g011 *= norm1.y; g101 *= norm1.z; g111 *= norm1.w; float n000 = dot(g000, Pf0); float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); float n111 = dot(g111, Pf1); vec3 fade_xyz = fade(Pf0); vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); return 2.2 * n_xyz; }`,[i,s,h]);return{simplex:t,simplexFractal:n,simplexAshima:o,fbm:u,perlin:d}}();var jp=class extends je{constructor(e,t,n,i,s,o,a){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=n,this.noiseStrength=i,this.noiseScale=s,this.offset=o,this.alpha=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(jp.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.filmThickness=this.filmThickness.toJSON(e).uuid,t.movement=this.movement.toJSON(e).uuid,t.wavelengths=this.wavelengths.toJSON(e).uuid,t.noiseStrength=this.noiseStrength.toJSON(e).uuid,t.noiseScale=this.noiseScale.toJSON(e).uuid,t.offset=this.offset.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.filmThickness&&(this.filmThickness=t.getNode(e.filmThickness)),e.movement&&(this.movement=t.getNode(e.movement)),e.wavelengths&&(this.wavelengths=t.getNode(e.wavelengths)),e.noiseStrength&&(this.noiseStrength=t.getNode(e.noiseStrength)),e.noiseScale&&(this.noiseScale=t.getNode(e.noiseScale)),e.offset&&(this.offset=t.getNode(e.offset)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ka=jp;ka.Nodes=function(){let e=new Le(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) { vec3 viewDir = normalize(-(cameraPosition + offset)); vec3 st = position / noiseScale; vec3 q = vec3(simplex3d(st), simplex3d(st + vec3(1.0)), simplex3d(st + vec3(1.0))); vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)), simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)), simplex3d(st * q)); float noise = simplex3d(st + r); return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vObjectNormal), viewDir)) + movement); }`,[si.simplex]);return{rainbow:new Le(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) { vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0); float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0); float lalpha = alpha * rainbowContribution; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return res; }`,[e])}}();var Wp=class extends je{constructor(e,t,n,i,s,o,a,l){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=n,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=o,this.aspectRatio=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let n=e.include(Wp.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.thickness=this.thickness.toJSON(e).uuid,t.ior=this.ior.toJSON(e).uuid,t.roughness=this.roughness.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.thickness&&(this.thickness=t.getNode(e.thickness)),e.ior&&(this.ior=t.getNode(e.ior)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(this),this.thickness=e.thickness.clone(),this.ior=e.ior.clone(),this.roughness=e.roughness.clone(),this.transmissionSamplerSize=e.transmissionSamplerSize.clone(),this.transmissionSamplerMap=e.transmissionSamplerMap,this.transmissionDepthMap=e.transmissionDepthMap,this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Va=Wp;Va.Nodes=function(){let e=new Le(` float gaussian(vec2 i) { const float sigma = float(NUM_SAMPLES) * .25; return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma ); }`),t=new Le(` vec4 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) { // Slightly modified version of this: // https://www.shadertoy.com/view/ltScRG const int LOD = 2; const int sLOD = 4; // tile size = 2^LOD vec4 O = vec4(0); const int s = NUM_SAMPLES/sLOD; for ( int i = 0; i < s*s; i++ ) { int modulo = (i)-((i)/(s))*(s); vec2 d = vec2(float(modulo), float(i/s))*float(sLOD) - float(NUM_SAMPLES)/2.; vec2 uv = U + (scale * aspectRatio) * d; // What is the depth of the opaque object we're trying to sample float opaqueDepth = texture2D(dm, uv).r; if (opaqueDepth < gl_FragCoord.z) { uv = unrefractedU + ((scale * min(lod / 2., 1.)) * aspectRatio) * d; lod = lod > 4.0 ? lod : lod / 2.0; } #ifdef TEXTURE_LOD_EXT O += gaussian(d) * texture2DLodEXT( sp, uv, lod); #else O += gaussian(d) * textureLod( sp, uv, lod); #endif } return O / O.a; }`,[e]),n=new Le(` vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { // Direction of refracted light. vec3 refractionVector = refract( -v, n, 1.0 / ior ); // Compute rotation-independant scaling of the model matrix. vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); // The thickness is specified in local space. return normalize( refractionVector ) * thickness * modelScale; }`),i=new Le(` float applyIorToRoughness( float roughness, float ior ) { // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and // an IOR of 1.5 results in the default amount of microfacet refraction. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } `),s=new Le(` vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); float lod = applyIorToRoughness(roughness, ior); return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio); }`,[i,t]),o=new Le(` vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 ); vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w; unrefractedCoords += 1.0; unrefractedCoords /= 2.0; // Sample framebuffer to get pixel the refracted ray hits. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio ); // Get the specular component. return vec4( ( 1.0 ) * transmittedLight.rgb, transmittedLight.a ); }`,[s,n]);return{transmission:new Le(` vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) { vec3 v = vec3(0.); if (isOrthographic) { v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { v = normalize(vWPosition - cameraPosition); } vec4 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio ); float lalpha = alpha; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return transmission.rgb; }`,[o])}}();var Jp=class extends je{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){let n=e.include(Jp.Nodes.customNormal),i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.alpha.build(e,"f")),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.cnormal=this.cnormal.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.cnormal&&(this.cnormal=t.getNode(e.cnormal)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}},Ha=Jp;Ha.Nodes=function(){return{customNormal:new Le(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) { vec3 normal = packNormalToRGB( norm ).rgb; normal *= step( vec3(0.5), cnormal ); accumAlpha += ( 1.0 - accumAlpha ) * alpha; return normal; }`)}}();var Xp=class extends je{constructor(e,t,n,i,s,o,a,l,c){super("v3");this.nodeType="Gradient";this.glType=e,this.num=t,this.smooth=n,this.colors=i,this.steps=s,this.offset=o,this.morph=a,this.angle=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(Xp.Nodes.gradient),i=[];return i.push(this.glType.build(e,"i")),i.push(this.num.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.glType=this.glType.toJSON(e).uuid,t.num=this.num.toJSON(e).uuid,t.smooth=this.smooth.toJSON(e).uuid,t.colors=this.colors.toJSON(e).uuid,t.steps=this.steps.toJSON(e).uuid,t.offset=this.offset.toJSON(e).uuid,t.morph=this.morph.toJSON(e).uuid,t.angle=this.angle.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}copy(e){return super.copy(e),this.glType=e.glType.clone(),this.num=e.num.clone(),this.smooth=e.smooth.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.offset=e.offset.clone(),this.morph=e.morph.clone(),this.angle=e.angle.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}fromJSON(e,t){return super.fromJSON(e,t),e.calpha&&(this.calpha=e.calpha),e.glType&&(this.glType=t.getNode(e.glType)),e.num&&(this.num=t.getNode(e.num)),e.smooth&&(this.smooth=t.getNode(e.smooth)),e.colors&&(this.colors=t.getNode(e.colors)),e.steps&&(this.steps=t.getNode(e.steps)),e.offset&&(this.offset=t.getNode(e.offset)),e.morph&&(this.morph=t.getNode(e.morph)),e.angle&&(this.angle=t.getNode(e.angle)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}},ja=Xp;ja.Nodes=function(){return{gradient:new Le(`vec3 gradient(int glType, int num, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) { vec4 color = colors[0]; vec2 m = morph / vUv.xy; vec2 rot = vec2( 0.5 + m.x, m.y ); vec2 dt = vec2( cos( angle ) * rot.x - sin( angle ) * rot.y, sin( angle ) * rot.x + cos( angle ) * rot.y ); vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0; float t = dot( pt, dt ) / dot( dt, dt ); if ( glType == 1 ) { t = distance ( ( vUv + morph ) * 3.0, ( vUv + offset ) + 1.0 ) + angle; } else if ( glType == 2 ) { float polar = atan( vUv.x + morph.x - 0.5 + offset.x, vUv.y + morph.y - 0.5 + offset.y ) * -1.0; t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) ); } float p; if (smoothed) { for ( int i = 1; i < GRAD_MAX; i++ ) { p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } } else { for ( int i = 1; i < GRAD_MAX; i++ ) { p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], p); } } float lalpha = alpha * color.a; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return color.xyz; }`)}}();var So;(function(t){t.NOISE="noise",t.MAP="map"})(So||(So={}));var qp=class extends je{constructor(e=new it(0),t,n,i,s,o){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=t,this.movementOrTexture=n,Object.values(So)[this.displacementTypeIndex.value]===So.MAP&&(this.mat=new zr(this.movementOrTexture.value.matrix)),this.cropOrOffset=i,this.scale=s,this.noiseFunctionIndex=o}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(So)[this.displacementTypeIndex.value]){case So.MAP:{n=e.include(qp.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case So.NOISE:{let o=Object.values(Ua)[this.noiseFunctionIndex.value],a=new Le(`vec3 orthogonal(vec3 v) { return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); }`),l=new Le(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) { return p + n * ${o}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity; }`,[si.simplex,si.simplexFractal,si.simplexAshima,si.fbm,si.perlin]),c=new Le(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) { vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement); vec3 tangent1 = orthogonal(normal); vec3 tangent2 = normalize(cross(normal, tangent1)); // TODO(Max): The distance to the neighbors was originally scaled by 0.1. // This caused some small oval/circular visual artifacts in the lighting. // For now, simply using neighbors further away betters the problem, // but we should figure out the underlying cause when we have some time. // Maybe its related to how we calculate the tangent and bitangent? vec3 nearby1 = position + tangent1; vec3 nearby2 = position + tangent2; vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement); vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement); displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); return displaced_position; }`,[l,a]);n=e.include(c),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){var n;let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.intensity=this.intensity.toJSON(e).uuid,t.scale=(n=this.scale)==null?void 0:n.toJSON(e).uuid,t.movementOrTexture=this.movementOrTexture.toJSON(e).uuid,t.cropOrOffset=this.cropOrOffset.toJSON(e).uuid),t.displacementTypeIndex=this.displacementTypeIndex,t.noiseFunctionIndex=this.noiseFunctionIndex,t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),this.displacementTypeIndex=e.displacementTypeIndex,this.noiseFunctionIndex=e.noiseFunctionIndex,e.cropOrOffset&&(this.cropOrOffset=t.getNode(e.cropOrOffset)),e.intensity&&(this.intensity=t.getNode(e.intensity)),e.movementOrTexture&&(this.displacementTypeIndex.value===1?(this.movementOrTexture=t.getNode(e.movementOrTexture),this.movementOrTexture.value.updateMatrix(),this.mat=new zr(this.movementOrTexture.value.matrix)):this.displacementTypeIndex.value===0&&(this.movementOrTexture=t.getNode(e.movementOrTexture))),e.scale&&(this.scale=t.getNode(e.scale)),this}copy(e){var t,n;return super.copy(e),this.noiseFunctionIndex=(t=e.noiseFunctionIndex)==null?void 0:t.clone(),this.scale=(n=e.scale)==null?void 0:n.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},Mo=qp;Mo.Nodes=function(){let e=new Le(`vec3 orthogonal(vec3 v) { return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); }`),t=new Le(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) { vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset; vec4 tmp = texture2D(tex, uvs); vec3 col = tmp.rgb; if (crop > 0.5) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { return 0.0; } } return col.r; }`);return{map:new Le(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) { vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity; vec3 tangent1 = normalize(orthogonal(normal)); vec3 tangent2 = normalize(cross(normal, tangent1)); vec3 nearby1 = position + tangent1 * 0.1; vec3 nearby2 = position + tangent2 * 0.1; vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); return displaced_position; }`,[e,t])}}();var Wa=class extends je{constructor(e=new ze,t=new ze,n=new ze,i=new ze,s=new ze,o=new ze,a=new ze,l=new ze,c=new ze,u=new ze,h=new ze,d=new ze,f=new ze,p=new ze,m=new ze,v=new ze){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=n,this.fA=i,this.fB=s,this.distortion=o,this.colorA=a,this.colorB=l,this.colorC=c,this.colorD=u,this.intA=h,this.intB=d,this.intC=f,this.intD=p,this.alpha=m,this.noiseFunctionIndex=v}generate(e,t,n,i,s){e.require("uv"),e.requires.uv=[!0];let o=Object.values(Ua)[this.noiseFunctionIndex.value],a=new Le(`vec3 ${o}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec3 colorA, vec3 colorB, vec3 colorC, vec3 colorD, float intA, float intB, float intC, float intD, float alpha) { vec3 st = position / size; st /= scale; vec3 q = vec3(${o}(st), ${o}(st + vec3(1.0)), ${o}(st + vec3(1.0))); vec3 r = vec3(${o}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move), ${o}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), ${o}(st * q)); float f = ${o}(st + r); vec3 color; color = mix(colorA * intA, colorB * intB, clamp((f * f) * 4.0, 0.0, 1.0)); color = mix(color, colorC * intC, clamp(length(q), 0.0, 1.0)); color = mix(color, colorD * intD, clamp(length(r.x), 0.0, 1.0)); accumAlpha += (1.0 - accumAlpha) * alpha; return clamp(color, 0.0, 1.0); }`,[si.simplex,si.simplexFractal,si.simplexAshima,si.fbm,si.perlin]),l=e.include(a),c=[];return c.push(this.scale.build(e,"f")),c.push(this.size.build(e,"v3")),c.push(this.move.build(e,"f")),c.push(this.fA.build(e,"v2")),c.push(this.fB.build(e,"v2")),c.push(this.distortion.build(e,"v2")),c.push(this.colorA.build(e,"c")),c.push(this.colorB.build(e,"c")),c.push(this.colorC.build(e,"c")),c.push(this.colorD.build(e,"c")),c.push(this.intA.build(e,"f")),c.push(this.intB.build(e,"f")),c.push(this.intC.build(e,"f")),c.push(this.intD.build(e,"f")),c.push(this.alpha.build(e,"f")),e.format(l+"("+c.join(",")+")",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scale=this.scale.toJSON(e).uuid,t.size=this.size.toJSON(e).uuid,t.move=this.move.toJSON(e).uuid,t.fA=this.fA.toJSON(e).uuid,t.fB=this.fB.toJSON(e).uuid,t.distortion=this.distortion.toJSON(e).uuid,t.colorA=this.colorA.toJSON(e).uuid,t.colorB=this.colorB.toJSON(e).uuid,t.colorC=this.colorC.toJSON(e).uuid,t.colorD=this.colorD.toJSON(e).uuid,t.intA=this.intA.toJSON(e).uuid,t.intB=this.intB.toJSON(e).uuid,t.intC=this.intC.toJSON(e).uuid,t.intD=this.intD.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.noiseFunction=this.noiseFunctionIndex,t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scale&&(this.scale=t.getNode(e.scale)),e.size&&(this.size=t.getNode(e.size)),e.move&&(this.move=t.getNode(e.move)),e.fA&&(this.fA=t.getNode(e.fA)),e.fB&&(this.fB=t.getNode(e.fB)),e.distortion&&(this.distortion=t.getNode(e.distortion)),e.colorA&&(this.colorA=t.getNode(e.colorA)),e.colorB&&(this.colorB=t.getNode(e.colorB)),e.colorC&&(this.colorC=t.getNode(e.colorC)),e.colorD&&(this.colorD=t.getNode(e.colorD)),e.intA&&(this.intA=t.getNode(e.intA)),e.intB&&(this.intB=t.getNode(e.intB)),e.intC&&(this.intC=t.getNode(e.intC)),e.intD&&(this.intD=t.getNode(e.intD)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.noiseFunctionIndex&&(this.noiseFunctionIndex=t.getNode(e.noiseFunctionIndex)),this}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.intA.copy(e.intA),this.intB.copy(e.intB),this.intC.copy(e.intC),this.intD.copy(e.intD),this.alpha.copy(e.alpha),this.noiseFunctionIndex.copy(e.noiseFunctionIndex),this}};Wa.numOctaves=5;var Ja;(function(i){i.ADD="+",i.SUB="-",i.MUL="*",i.DIV="/"})(Ja||(Ja={}));var Yp=class extends je{constructor(e=new ze,t=new ze,n=Yp.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=n}getType(e){let t=this.a.getType(e),n=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(n)>e.getTypeLength(t)?n:t}generate(e,t){let n=this.getType(e);this.type=n;let i=this.a.build(e,n),s=this.b.build(e,n);return e.format("( "+i+" "+this.op+" "+s+" )",n,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),this}},Yn=Yp;Yn.ADD=Ja.ADD,Yn.SUB=Ja.SUB,Yn.MUL=Ja.MUL,Yn.DIV=Ja.DIV;var Xa=class extends je{constructor(e=new ze,t=new ze,n=new ze,i=new ze){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=n,this.mode=i}generate(e,t){if(e.isShader("fragment")){let n=[];return n.push(this.a.build(e,"c")),n.push(this.b.build(e,"c")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),e.format("spe_blend("+n.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),this}};var Kp=class extends je{constructor(e,t,n,i,s,o,a,l){super("v3");this.nodeType="Depth";this.near=e,this.far=t,this.isVector=n,this.isWorldSpace=i,this.origin=s,this.colorA=o,this.colorB=a,this.alpha=l}generate(e,t){if(e.isShader("fragment")){e.require("worldPosition");let n=e.include(Kp.Nodes.sdepth),i=[];return i.push(this.near.build(e,"f")),i.push(this.far.build(e,"f")),i.push(this.isVector.build(e,"f")),i.push(this.isWorldSpace.build(e,"f")),i.push(this.origin.build(e,"v3")),i.push(this.colorA.build(e,"v3")),i.push(this.colorB.build(e,"v3")),i.push(this.alpha.build(e,"f")),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.near=this.near.toJSON(e).uuid,t.far=this.far.toJSON(e).uuid,t.isVector=this.isVector.toJSON(e).uuid,t.isWorldSpace=this.isWorldSpace.toJSON(e).uuid,t.origin=this.origin.toJSON(e).uuid,t.colorA=this.colorA.toJSON(e).uuid,t.colorB=this.colorB.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.near&&(this.near=t.getNode(e.near)),e.far&&(this.far=t.getNode(e.far)),e.isVector&&(this.isVector=t.getNode(e.isVector)),e.isWorldSpace&&(this.isWorldSpace=t.getNode(e.isWorldSpace)),e.origin&&(this.origin=t.getNode(e.origin)),e.colorA&&(this.colorA=t.getNode(e.colorA)),e.colorB&&(this.colorB=t.getNode(e.colorB)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}copy(e){return super.copy(e),this.near=e.near.clone(),this.far=e.far.clone(),this.isVector=e.isVector.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.origin=e.origin.clone(),this.colorA=e.colorA.clone(),this.colorB=e.colorB.clone(),this.alpha=e.alpha.clone(),this}},qa=Kp;qa.Nodes=function(){return{sdepth:new Le(`vec3 sdepth(float near, float far, float isVector, float isWorldSpace, vec3 origin, vec3 colorA, vec3 colorB, float alpha) { float dist; if (isVector > 0.5) { dist = (isWorldSpace > 0.5) ? length(vWPosition - origin) : length(position - origin); } else { dist = length (vWPosition - cameraPosition); } float dep = ( dist - near ) / ( far - near ); vec3 depth = mix( colorB, colorA, 1.0 - clamp( dep, 0., 1. ) ); accumAlpha += ( 1.0 - accumAlpha ) * alpha; return depth; }`)}}();var Qp=class extends je{constructor(e,t,n,i){super("v3");this.nodeType="Matcap";this.color=e,this.texture=t,this.alpha=n,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(Qp.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.color.build(e,"v3")),i.push(this.texture.getTexture(e,"t")),i.push("normal"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.texture=e.texture.clone(),this.color=e.color.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.toJSON(e).uuid,t.color=this.color.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.calpha&&(this.calpha=e.calpha),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.texture&&(this.texture=t.getNode(e.texture)),e.color&&(this.color=t.getNode(e.color)),e.mode&&(this.mode=t.getNode(e.mode)),this}},Ya=Qp;Ya.Nodes=function(){return{matcap:new Le(`vec3 matcap(vec3 color, sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) { 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; // 0.495 to remove artifacts caused by undersized matcap disks vec4 matcapColor = texture2D( matcapTex, uv ); // matcapColor = matcapTexelToLinear( matcapColor ); matcapColor.rgb *= color; calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * alpha; return matcapColor.rgb; } `)}}();var Kn=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Ee.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:lt.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new Te(1));let n=new Te(1),i=new it(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=n,this._material.shadingBlend=i),this._layerNodes.push({id:0,type:Gt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:Gt.LIGHTING,alpha:n,mode:i}),this.head=t.layer,this.head.next=new jt(1,{type:lt.LIGHTING,alpha:n,mode:i}),this.attachLightNodes()}get material(){return this._material}set material(e){this._material=e;let t,n,i=this.head;for(;i!==void 0;){if(i.type===lt.LIGHTING){t=i.uniforms[`f${i.id}_alpha`],n=i.uniforms[`f${i.id}_mode`];break}i=i.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=n),this.attachLightNodes(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],n=this.head;for(;n;)n.type===e&&t.push(n),n=n.next;return t}addLayer(e){var i;if(e.id=(i=e.id)!=null?i:++this.id,this.layerCount++,e.type===lt.LIGHTING){let s=this.createLightLayer(e);return this.uuid=Ee.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}let t=this._createLayer(e),n=t.layer;if(this.head===void 0)this.head=n;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=n}return t.color&&this._layerNodes.push({id:n.id,type:Gt.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:n.id,type:Gt.POSITION,position:t.position}),this.uuid=Ee.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerBeforeAt(e,t){var a;let n=this.head;e.id=(a=e.id)!=null?a:++this.id,this.layerCount++;let i=this._createLayer(e),s=i.layer;s.next=t;let o=0;if(n===t)this.head=s,i.color&&this._layerNodes.splice(0,0,{id:s.id,type:Gt.COLOR,color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(0,0,{id:s.id,type:Gt.POSITION,position:i.position});else{for(o=1;(n==null?void 0:n.next)!==t;)n=n==null?void 0:n.next,o++;n.next=s,i.color&&this._layerNodes.splice(o,0,{id:s.id,type:Gt.COLOR,color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(o,0,{id:s.id,type:Gt.POSITION,position:i.position})}return this.uuid=Ee.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){var s;t.id=(s=t.id)!=null?s:++this.id,this.layerCount++;let n=this._createLayer(t),i=n.layer;if(n.color&&this._layerNodes.splice(e,0,{id:i.id,type:Gt.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(e,0,{id:i.id,type:Gt.POSITION,position:n.position}),e==0)i.next=this.head,this.head=i;else{let o=this.head,a=this.head.next;for(let l=0;ll.clone&&!n?l.clone():l);else{let l=t.uniforms[a].value;if(o==="transmissionDepthMap"){i[o]=l;continue}l!=null&&(i[o]=l.clone&&!n&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(i)}}attachLightNodes(e){var i,s,o,a,l,c,u,h,d,f,p;let t={},n=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new ct((s=(i=e==null?void 0:e.getValue("emissive"))==null?void 0:i.clone())!=null?s:0);break;case"Phong":t.shininess=new Te((o=e==null?void 0:e.getValue("shininess"))!=null?o:30),t.specular=new ct((l=(a=e==null?void 0:e.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":t.shininess=new Te((c=e==null?void 0:e.getValue("shininess"))!=null?c:30),t.specular=new ct((h=(u=e==null?void 0:e.getValue("specular"))==null?void 0:u.clone())!=null?h:1118481);break;case"Physical":t.roughness=new Te((d=e==null?void 0:e.getValue("roughness"))!=null?d:.3),t.metalness=new Te((f=e==null?void 0:e.getValue("metalness"))!=null?f:0),t.reflectivity=new Te((p=e==null?void 0:e.getValue("reflectivity"))!=null?p:.5);break;default:break}Object.keys(t).forEach(m=>{this._material[m]=t[m],n.uniforms[`f${n.id}_${m}`]=t[m]})}clone(e){return new Kn(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,n){let i=new jt(e.head.id,{type:e.head.type}).fromJSON(e.head,t),s=e.head.next,o=i;for(;s!=null;)o.next=new jt(s.id,{type:s.type}).fromJSON(s,t),s=s.next,o=o.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,i,!0);let a=i;for(o=this.head;a.next!=null;)this.rebuildLayerNodes(o,a.next,!0),o=o.next,a=a.next;return this._material=n,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var n,i,s,o,a,l,c,u,h,d,f,p,m,v,g,y,x,b,w,_,S,A,T,L,C,U,P,R,G,B,j,ne,le,W,z,D,K,q,ee,V,de,ae,te,X,se,$,H,Q,ce,ie,N,E,Y,re,ye,pe,Ie,ve,Fe,Ce,J,xe,he,Ne,Be,ke,ht,ft,Bn,Mt,Tn,En,Di,_r,xn,F,Pe,et,Ft,Nn,Gs,sr,Ll,Il,mu,gu,I,oe;let t=e.type;switch(t){case lt.COLOR:{let k=new ct((n=e.color)!=null?n:5855577),Z=new Te((i=e.alpha)!=null?i:1),ue=new yt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");ue.keywords.alpha=Z;let Me=new it((s=e.mode)!=null?s:0);return k.alpha=Z,{layer:new jt(e.id,{type:t,color:k,alpha:Z,calpha:ue,mode:Me}),color:k,alpha:ue,mode:Me}}case lt.TEXTURE:{let k=(o=e.texture)!=null?o:new bi,Z=k.matrix;e.mat&&Z.copy(e.mat),k.needsUpdate=!0;let ue=new Te((a=e.crop)!=null?a:0),Me=new it((l=e.projection)!=null?l:0),_e=new it((c=e.axis)!=null?c:0),Se=new In((u=e.size)!=null?u:new O(100,100)),De=new Te((h=e.alpha)!=null?h:1),Ve=new it((d=e.mode)!=null?d:0),Oe=new kn(k),He=new Un((f=e.textureSize)!=null?f:new M(k.image?k.image.width:0,k.image?k.image.height:0)),Ge=new za(Oe,He,ue,Me,_e,Se,De,Ve),Kt=new yt(Ge.calpha,"f");return{layer:new jt(e.id,{type:t,texture:Oe,textureSize:He,crop:ue,projection:Me,axis:_e,size:Se,mat:Ge.mat,alpha:De,calpha:Kt,mode:Ve}),color:Ge,alpha:Kt,mode:Ve}}case lt.MATCAP:{let k=new ct((p=e.color)!=null?p:16777215),Z=(m=e.texture)!=null?m:new bi;Z.needsUpdate=!0;let ue=new Te((v=e.alpha)!=null?v:1),Me=new kn(Z),_e=new it((g=e.mode)!=null?g:0),Se=new Ya(k,Me,ue,_e),De=new yt(Se.calpha,"f");return{layer:new jt(e.id,{type:t,texture:Me,color:k,alpha:ue,calpha:De,mode:_e}),color:Se,alpha:De,mode:_e}}case lt.FRESNEL:{let k=new ct((y=e.color)!=null?y:16777215),Z=new Te((x=e.bias)!=null?x:.1),ue=new Te((b=e.scale)!=null?b:1),Me=new Te((w=e.intensity)!=null?w:2),_e=new Te((_=e.factor)!=null?_:1),Se=new Te((S=e.alpha)!=null?S:1),De=new it((A=e.mode)!=null?A:0),Ve=new Ga(k,Z,ue,Me,_e,Se,De),Oe=new yt(Ve.calpha,"f");return{layer:new jt(e.id,{type:t,color:k,bias:Z,scale:ue,intensity:Me,factor:_e,alpha:Se,calpha:Oe,mode:De}),color:Ve,alpha:Oe,mode:De}}case lt.RAINBOW:{let k=new Te((T=e.filmThickness)!=null?T:30),Z=new Te((L=e.movement)!=null?L:0),ue=new Un((C=e.wavelengths)!=null?C:new M(0,0,0)),Me=new Te((U=e.noiseStrength)!=null?U:0),_e=new Te((P=e.noiseScale)!=null?P:1),Se=new Un((R=e.offset)!=null?R:new M(0,0,0)),De=new Te((G=e.alpha)!=null?G:1),Ve=new ka(k,Z,ue,Me,_e,Se,De),Oe=new yt(Ve.calpha,"f"),He=new it((B=e.mode)!=null?B:0);return{layer:new jt(e.id,{type:t,filmThickness:k,movement:Z,wavelengths:ue,noiseStrength:Me,noiseScale:_e,offset:Se,alpha:De,calpha:Oe,mode:He}),color:Ve,alpha:Oe,mode:He}}case lt.TRANSMISSION:{let k=new Te((j=e.thickness)!=null?j:10),Z=new Te((ne=e.ior)!=null?ne:1.5),ue=new Te((le=e.roughness)!=null?le:.5),Me=new In((W=e.transmissionSamplerSize)!=null?W:new O(2048,2048)),_e=(z=e.transmissionSamplerMap)!=null?z:new bi,Se=(D=e.transmissionDepthMap)!=null?D:new bi,De=new kn(_e),Ve=new kn(Se),Oe=window.innerWidth,He=window.innerHeight,Ge=Oe>=He?new In(He/Oe,1):new In(1,Oe/He),Kt=new Te((K=e.alpha)!=null?K:1),vt=new Va(k,Z,ue,Me,De,Ve,Ge,Kt),bn=new yt(vt.calpha,"f"),wn=new it((q=e.mode)!=null?q:0);return{layer:new jt(e.id,{type:t,thickness:k,ior:Z,roughness:ue,transmissionSamplerSize:Me,transmissionSamplerMap:De,transmissionDepthMap:Ve,aspectRatio:Ge,alpha:Kt,calpha:bn,mode:wn}),color:vt,alpha:bn,mode:wn}}case lt.DEPTH:{let k=new Te((ee=e.near)!=null?ee:50),Z=new Te((V=e.far)!=null?V:200),ue=new Te((de=e.isVector)!=null?de:1),Me=new Te((ae=e.isWorldSpace)!=null?ae:0),_e=new Un((te=e.origin)!=null?te:new M),Se=new ct((X=e.colorA)!=null?X:new fe),De=new ct((se=e.colorB)!=null?se:new fe(0,0,0)),Ve=new Te(($=e.alpha)!=null?$:1),Oe=new it((H=e.mode)!=null?H:0),He=new yt("alpha / clamp(alpha + accumAlpha, 0.001, 1.0 )","f");He.keywords.alpha=Ve;let Ge=new qa(k,Z,ue,Me,_e,Se,De,Ve);return{layer:new jt(e.id,{type:t,near:k,far:Z,isVector:ue,isWorldSpace:Me,origin:_e,colorA:Se,colorB:De,alpha:Ve,calpha:He,mode:Oe}),color:Ge,alpha:He,mode:Oe}}case lt.NOISE:{let k=new Te((Q=e.scale)!=null?Q:1),Z=new Un((ce=e.size)!=null?ce:new M(100,100,100)),ue=new Te((ie=e.move)!=null?ie:1),Me=new In((N=e.fA)!=null?N:new O(1.7,9.2)),_e=new In((E=e.fB)!=null?E:new O(8.3,2.8)),Se=new In((Y=e.distortion)!=null?Y:new O(1,1)),De=new ct((re=e.colorA)!=null?re:new fe(.4,.4,.4)),Ve=new ct((ye=e.colorB)!=null?ye:new fe(.4,.4,.4)),Oe=new ct((pe=e.colorC)!=null?pe:new fe(1,1,1)),He=new ct((Ie=e.colorD)!=null?Ie:new fe(1,1,1)),Ge=new Te((ve=e.intA)!=null?ve:1),Kt=new Te((Fe=e.intB)!=null?Fe:1),vt=new Te((Ce=e.intC)!=null?Ce:1),bn=new Te((J=e.intD)!=null?J:1),wn=new Te((xe=e.alpha)!=null?xe:1),Ri=new it((he=e.mode)!=null?he:0),Bi=new it((Ne=e.noiseType)!=null?Ne:0),Qt=new yt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");Qt.keywords.alpha=wn;let Mi=new Wa(k,Z,ue,Me,_e,Se,De,Ve,Oe,He,Ge,Kt,vt,bn,wn,Bi);return{layer:new jt(e.id,{type:t,scale:k,size:Z,move:ue,fA:Me,fB:_e,distortion:Se,colorA:De,colorB:Ve,colorC:Oe,colorD:He,intA:Ge,intB:Kt,intC:vt,intD:bn,alpha:wn,calpha:Qt,mode:Ri,noiseType:Bi}),color:Mi,alpha:Qt,mode:Ri}}case lt.NORMAL:{let k=new Un((Be=e.cnormal)!=null?Be:new M(1,1,1)),Z=new Te((ke=e.alpha)!=null?ke:1),ue=new it((ht=e.mode)!=null?ht:0),Me=new Ha(k,Z),_e=new yt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return _e.keywords.alpha=Z,{layer:new jt(e.id,{type:t,cnormal:k,alpha:Z,calpha:_e,mode:ue}),color:Me,alpha:_e,mode:ue}}case lt.GRADIENT:{let k=new it((ft=e.gl_type)!=null?ft:0),Z=new it((Bn=e.num)!=null?Bn:2),ue=new mc((Mt=e.smooth)!=null?Mt:!1),Me;e.colors?Me=new Ra(e.colors.length,e.colors):(Me=new Ra(10,new Qe(0,0,0,1)),Me.value[1]=new Qe(1,1,1,1));for(let bn=Z.value;bn<10;bn++)Me.value[bn]=Me.value[Z.value-1];let _e;e.steps?_e=new Ba(e.steps.length,e.steps):(_e=new Ba(10,1),_e.value[0]=0);let Se=new In((Tn=e.offset)!=null?Tn:new O(0,0)),De=new In((En=e.morph)!=null?En:new O(0,0)),Ve=new Te((Di=e.angle)!=null?Di:0),Oe=new Te((_r=e.alpha)!=null?_r:1),He=new it((xn=e.mode)!=null?xn:0),Ge=new ja(k,Z,ue,Me,_e,Se,De,Ve,Oe),Kt=new yt(Ge.calpha,"f");return{layer:new jt(e.id,{type:t,gl_type:k,num:Z,smooth:ue,colors:Me,steps:_e,offset:Se,morph:De,angle:Ve,alpha:Oe,calpha:Kt,mode:He}),color:Ge,alpha:Kt,mode:He}}case lt.DISPLACE:{let k=new it((F=e.displacementType)!=null?F:0);if(k.value===0){let Z=new Un((Pe=e.offset)!=null?Pe:new M(0,0,0)),ue=new Te((et=e.scale)!=null?et:10),Me=new Te((Ft=e.intensity)!=null?Ft:8),_e=new Te((Nn=e.movement)!=null?Nn:1),Se=new Te((Gs=e.alpha)!=null?Gs:1),De=new it((sr=e.mode)!=null?sr:0),Ve=new it((Ll=e.noiseType)!=null?Ll:0),Oe=new Mo(k,Me,_e,Z,ue,Ve);return{layer:new jt(e.id,{displacementType:k,type:t,offset:Z,scale:ue,intensity:Me,movement:_e,alpha:Se,mode:De,noiseType:Ve}),position:Oe}}else if(k.value===1){let Z=(Il=e.texture)!=null?Il:new bi,ue=Z.matrix;e.mat&&ue.copy(e.mat),Z.needsUpdate=!0;let Me=new Te((mu=e.intensity)!=null?mu:8),_e=new kn(Z),Se=new Te((gu=e.crop)!=null?gu:0),De=new Te((I=e.alpha)!=null?I:1),Ve=new it((oe=e.mode)!=null?oe:0),Oe=new Mo(k,Me,_e,Se);return{layer:new jt(e.id,{displacementType:k,type:t,intensity:Me,texture:_e,crop:Se,mat:Oe.mat,alpha:De,mode:Ve}),position:Oe}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(n=>n.type===Gt.COLOR),t=this._layerNodes.findIndex(n=>n.type===Gt.LIGHTING);if(e!==-1&&en.type===Gt.LIGHTING);if(this._layerNodes.length>t+1){for(let n=t+1;nt.type===Gt.POSITION);if(e.length>0){let t=e[0].position;for(let n=1;nt.id!==e.id),e.type){case lt.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var Nh=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var yc=class extends Ct{constructor(e=0,t,n,i){super("v4");this.nodeType="Vector4";this.value=e instanceof Qe?e:new Qe(e,t,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}get w(){return this.value.w}set w(e){this.value.w=e}generateReadonly(e,t,n,i,s,o){return e.format("vec4("+this.value.x+", "+this.value.y+", "+this.value.z+", "+this.value.w+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,t.z=this.value.z,t.w=this.value.w,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),e.z&&(this.value.z=e.z),e.w&&(this.value.w=e.w),e.readonly!==void 0&&(this.readonly=e.readonly),this}};var ML=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.| )*?)}`,"gim"),AL=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ao=class extends je{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,n,i,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=ML.exec(e);if(t){let n=t[2],i;for(;i=AL.exec(n);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.src&&(this.src=e.src,this.parse(this.src)),this}};var Ch=class extends je{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t!=null?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,n,i,s){i=this.getType(e);let o=this.value,a=o.build(e,t)+"( ",l=[];if(o.inputs){for(let c=0;ct.clone()),this}toJSON(e){var n;let t=this.getJSONNode(e);if(!t){let i=this.value;if(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,(n=i.inputs)==null?void 0:n.length){t.inputs={};for(let s=0;sn&&t>i?this.a.getType(e):n>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case St.LENGTH:case St.DISTANCE:case St.DOT:return"f";case St.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let n,i,s,o=this.a?e.getTypeLength(this.a.getType(e)):0,a=this.b?e.getTypeLength(this.b.getType(e)):0,l=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),u=this.getType(e);switch(this.type=u,this.method){case St.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,t);case St.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,t);case St.CROSS:n=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case St.STEP:n=this.a.build(e,o===1?"f":c),i=this.b.build(e,c);break;case St.MIN:case St.MAX:case St.MOD:n=this.a.build(e,c),i=this.b.build(e,a===1?"f":c);break;case St.REFRACT:n=this.a.build(e,c),i=this.b.build(e,c),s=this.c.build(e,"f");break;case St.MIX:n=this.a.build(e,c),i=this.b.build(e,c),s=this.c.build(e,l===1?"f":c);break;default:n=this.a.build(e,c),this.b&&(i=this.b.build(e,c)),this.c&&(s=this.c.build(e,c));break}let h=[];h.push(n),i&&h.push(i),s&&h.push(s);let d=this.getNumInputs(e);if(h.length!==d)throw Error(`Arguments not match used in "${this.method}". Require ${d}, currently ${h.length}.`);return e.format(this.method+"( "+h.join(", ")+" )",u,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof ze?e.b.clone():e.b,this.c=e.c instanceof ze?e.c.clone():e.c,this.method=e.method,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,this.b&&(t.b=this.b.toJSON(e).uuid),this.c&&(t.c=this.c.toJSON(e).uuid),t.method=this.method),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.c&&(this.c=t.getNode(e.c)),e.method&&(this.method=e.method),this}},Ye=St;Ye.RAD=st.RAD,Ye.DEG=st.DEG,Ye.EXP=st.EXP,Ye.EXP2=st.EXP2,Ye.LOG=st.LOG,Ye.LOG2=st.LOG2,Ye.SQRT=st.SQRT,Ye.INV_SQRT=st.INV_SQRT,Ye.FLOOR=st.FLOOR,Ye.CEIL=st.CEIL,Ye.NORMALIZE=st.NORMALIZE,Ye.FRACT=st.FRACT,Ye.SATURATE=st.SATURATE,Ye.SIN=st.SIN,Ye.COS=st.COS,Ye.TAN=st.TAN,Ye.ASIN=st.ASIN,Ye.ACOS=st.ACOS,Ye.ARCTAN=st.ARCTAN,Ye.ABS=st.ABS,Ye.SIGN=st.SIGN,Ye.LENGTH=st.LENGTH,Ye.NEGATE=st.NEGATE,Ye.INVERT=st.INVERT,Ye.MIN=st.MIN,Ye.MAX=st.MAX,Ye.MOD=st.MOD,Ye.STEP=st.STEP,Ye.REFLECT=st.REFLECT,Ye.DISTANCE=st.DISTANCE,Ye.DOT=st.DOT,Ye.CROSS=st.CROSS,Ye.POW=st.POW,Ye.MIX=st.MIX,Ye.CLAMP=st.CLAMP,Ye.REFRACT=st.REFRACT,Ye.SMOOTHSTEP=st.SMOOTHSTEP,Ye.FACEFORWARD=st.FACEFORWARD;var Ka=class extends je{constructor(e=new ze,t=new ze,n=new ze){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=n}bilinearCubeUV(e,t,n,i){var l,c,u,h;let s=new Ch(Ka.Nodes.bilinearCubeUV,[t,n,i]);this.colorSpaceTL=(l=this.colorSpaceTL)!=null?l:new Bt(new yt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=(c=this.colorSpaceTR)!=null?c:new Bt(new yt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=(u=this.colorSpaceBL)!=null?u:new Bt(new yt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=(h=this.colorSpaceBR)!=null?h:new Bt(new yt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let o={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(o),this.colorSpaceTLExp=new yt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new yt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new yt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new yt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let a=new yt("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return a.keywords.cubeUV_TL=this.colorSpaceTLExp,a.keywords.cubeUV_TR=this.colorSpaceTRExp,a.keywords.cubeUV_BL=this.colorSpaceBLExp,a.keywords.cubeUV_BR=this.colorSpaceBRExp,a.keywords.cubeUV=s,a}generate(e,t){if(e.isShader("fragment")){let n=this.uv,i=this.bias||e.context.roughness,s=new Ch(Ka.Nodes.roughnessToMip,[i]),o=new Ye(s,Ka.Nodes.m0,Ka.Nodes.cubeUV_maxMipLevel,Ye.CLAMP),a=new Ye(o,Ye.FLOOR),l=new Ye(o,Ye.FRACT),c=this.bilinearCubeUV(e,this.value,n,a),u=this.bilinearCubeUV(e,this.value,n,new Yn(a,new Te(1).setReadonly(!0),Yn.ADD)),h=new Ye(c,u,l,Ye.MIX);return e.format(h.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,t.uv=this.uv.toJSON(e).uuid,t.bias=this.bias.toJSON(e).uuid,this.colorSpaceTL&&this.colorSpaceTL.toJSON(e).uuid,this.colorSpaceTR&&this.colorSpaceTR.toJSON(e).uuid,this.colorSpaceBL&&this.colorSpaceBL.toJSON(e).uuid,this.colorSpaceBR&&this.colorSpaceBR.toJSON(e).uuid,this.colorSpaceTLExp&&this.colorSpaceTLExp.toJSON(e).uuid,this.colorSpaceTRExp&&this.colorSpaceTRExp.toJSON(e).uuid,this.colorSpaceBLExp&&this.colorSpaceBLExp.toJSON(e).uuid,this.colorSpaceBRExp&&this.colorSpaceBRExp.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),e.colorSpaceTL&&(this.colorSpaceTL=t.getNode(e.colorSpaceTL)),e.colorSpaceTR&&(this.colorSpaceTR=t.getNode(e.colorSpaceTR)),e.colorSpaceBL&&(this.colorSpaceBL=t.getNode(e.colorSpaceBL)),e.colorSpaceBR&&(this.colorSpaceBR=t.getNode(e.colorSpaceBR)),e.colorSpaceTLExp&&(this.colorSpaceTLExp=t.getNode(e.colorSpaceTLExp)),e.colorSpaceTRExp&&(this.colorSpaceTRExp=t.getNode(e.colorSpaceTRExp)),e.colorSpaceBLExp&&(this.colorSpaceBLExp=t.getNode(e.colorSpaceBLExp)),e.colorSpaceBRExp&&(this.colorSpaceBRExp=t.getNode(e.colorSpaceBRExp)),this}},_o=Ka;_o.Nodes=function(){let e=new Ao(`struct TextureCubeUVData { vec4 tl; vec4 tr; vec4 br; vec4 bl; vec2 f; }`),t=new rt("float cubeUV_maxMipLevel 8.0",!0),n=new rt("float cubeUV_minMipLevel 4.0",!0),i=new rt("float cubeUV_maxTileSize 256.0",!0),s=new rt("float cubeUV_minTileSize 16.0",!0),o=new Le(`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; }`);o.useKeywords=!1;let a=new Le(`vec2 getUV(vec3 direction, float face) { vec2 uv; if (face == 0.0) { uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x } else if (face == 1.0) { uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y } else if (face == 2.0) { uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z } else if (face == 3.0) { uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x } else if (face == 4.0) { uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y } else { uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z } return 0.5 * (uv + 1.0); }`);a.useKeywords=!1;let l=new Le(`TextureCubeUVData 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); float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize); vec2 uv = getUV(direction, face) * (faceSize - 1.0); vec2 f = fract(uv); uv += 0.5 - f; if (face > 2.0) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; if(mipInt < cubeUV_maxMipLevel){ uv.y += 2.0 * cubeUV_maxTileSize; } uv.y += filterInt * 2.0 * cubeUV_minTileSize; uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize); uv *= texelSize; vec4 tl = texture2D(envMap, uv); uv.x += texelSize; vec4 tr = texture2D(envMap, uv); uv.y += texelSize; vec4 br = texture2D(envMap, uv); uv.x -= texelSize; vec4 bl = texture2D(envMap, uv); return TextureCubeUVData( tl, tr, br, bl, f ); }`,[e,o,a,t,n,i,s]);l.useKeywords=!1;let c=new rt("float r0 1.0",!0),u=new rt("float v0 0.339",!0),h=new rt("float m0 -2.0",!0),d=new rt("float r1 0.8",!0),f=new rt("float v1 0.276",!0),p=new rt("float m1 -1.0",!0),m=new rt("float r4 0.4",!0),v=new rt("float v4 0.046",!0),g=new rt("float m4 2.0",!0),y=new rt("float r5 0.305",!0),x=new rt("float v5 0.016",!0),b=new rt("float m5 3.0",!0),w=new rt("float r6 0.21",!0),_=new rt("float v6 0.0038",!0),S=new rt("float m6 4.0",!0),A=[c,u,h,d,f,p,m,v,g,y,x,b,w,_,S],T=new Le(`float roughnessToMip(float roughness) { float mip = 0.0; if (roughness >= r1) { mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0; } else if (roughness >= r4) { mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1; } else if (roughness >= r5) { mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4; } else if (roughness >= r6) { mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5; } else { mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25 } return mip; }`,A);return{bilinearCubeUV:l,roughnessToMip:T,m0:h,cubeUV_maxMipLevel:t}}();var To=class extends je{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:To.VIEW}getShared(){return this.scope===To.WORLD}build(e,t,n,i){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,n,i):super.build(e,t,n)}generate(e,t,n,i,s){let o;switch(this.scope){case To.VIEW:e.isShader("vertex")?o="transformedNormal":o="geometryNormal";break;case To.LOCAL:e.isShader("vertex")?o="objectNormal":(e.requires.normal=!0,o="vObjectNormal");break;case To.WORLD:e.isShader("vertex")?o="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,o="vWNormal");break}return e.format(o,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},mn=To;mn.LOCAL="local",mn.WORLD="world",mn.VIEW="view",mn.NORMAL="normal";pn.addKeyword("viewNormal",function(){return new mn(mn.VIEW)});pn.addKeyword("localNormal",function(){return new mn(mn.NORMAL)});pn.addKeyword("worldNormal",function(){return new mn(mn.WORLD)});var dr=class extends je{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:dr.LOCAL}getType(){switch(this.scope){case dr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case dr.LOCAL:case dr.WORLD:return!1}return!0}generate(e,t,n,i,s){let o;switch(this.scope){case dr.LOCAL:e.isShader("vertex")?o="transformed":(e.requires.position=!0,o="vPosition");break;case dr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,o="vWPosition";break;case dr.VIEW:o=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case dr.PROJECTION:o=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(o,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},_n=dr;_n.LOCAL="local",_n.WORLD="world",_n.VIEW="view",_n.PROJECTION="projection";pn.addKeyword("position",function(){return new _n});pn.addKeyword("worldPosition",function(){return new _n(_n.WORLD)});pn.addKeyword("viewPosition",function(){return new _n(_n.VIEW)});var Zi=class extends je{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:Zi.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Zi.SPHERE:return"v2"}return this.type}generate(e,t){let n=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case Zi.VECTOR:{let s=new mn(mn.VIEW),o=e.context.roughness,a=s.build(e,"v3"),l=new _n(_n.VIEW).build(e,"v3"),c=o?o.build(e,"f"):void 0,u=`reflect( -normalize( ${l} ), ${a} )`;c&&(u=`normalize( mix( ${u}, ${a}, ${c} * ${c} ) )`);let h=`inverseTransformDirection( ${u}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${h};`),i="reflectVec"):i=h;break}case Zi.CUBE:{let s=new Zi(Zi.VECTOR).build(e,"v3"),o="vec3( -"+s+".x, "+s+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${o};`),i="reflectCubeVec"):i=o;break}case Zi.SPHERE:{let s=new Zi(Zi.VECTOR).build(e,"v3"),o="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(e.addNodeCode(`vec2 reflectSphereVec = ${o};`),i="reflectSphereVec"):i=o;break}}return e.format(i,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},Qi=Zi;Qi.CUBE="cube",Qi.SPHERE="sphere",Qi.VECTOR="vector";var vc=class extends je{constructor(e=new kn,t,n){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new _o(this.value,t!=null?t:new Qi(Qi.VECTOR),n),this.irradianceNode=new _o(this.value,new mn(mn.WORLD),new Te(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,this.radianceNode&&(t.radianceNode=this.radianceNode.toJSON(e).uuid),this.irradianceNode&&(t.irradianceNode=this.irradianceNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),e.radianceNode&&(this.radianceNode=t.getNode(e.radianceNode)),e.irradianceNode&&(this.irradianceNode=t.getNode(e.irradianceNode)),this}};var xc=class extends Ct{constructor(e=new as,t,n){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new Qi,this.bias=n}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var c,u;if(t==="samplerCube")return this.getTexture(e,t);let n=this.getTexture(e,t),i=(c=this.uv)==null?void 0:c.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let o;s?o="texCubeBias( "+n+", "+i+", "+s+" )":o="texCube( "+n+", "+i+" )";let a={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(a),this.colorSpace=(u=this.colorSpace)!=null?u:new Bt(new yt("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(o),o=this.colorSpace.build(e,l),e.removeContext(),e.format(o,l,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}toJSON(e){var n;let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value.uuid),t.uv=(n=this.uv)==null?void 0:n.toJSON(e).uuid,this.bias&&(t.bias=this.bias.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getTexture(e.value)),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),this}};var bx=["x","y","z","w"],_L=["float","vec2","vec3","vec4"],TL={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},EL={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Zp=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,n){return t.deps.length-n.deps.length}return function(n,i){let s=this.getIncludes(n,i);if(!s)return"";let o="";s=s.sort(e);for(let a=0;a","#include "].join(` `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(` `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) { accumAlpha += (1.0 - accumAlpha) * alpha; }`,""].join(` `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.buildShader("vertex",e),this.buildShader("fragment",t);for(let n=0;n0?n+1:"";this.addVaryCode("varying vec2 vUv"+i+";"),n>0&&this.addVertexParsCode("attribute vec2 uv"+i+";"),this.addVertexFinalCode("vUv"+i+" = uv"+i+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.requires.vWorldNormal&&(this.addVaryCode("varying vec3 vWorldNormal;"),this.addVertexFinalCode("vWorldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );")),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.material=e,this.renderer=t,this.requires.lights=e.lights,this.requires.fog=e.fog,this.mergeDefines(e.defines),this}addFlow(e,t,n){return this.addSlot(e).addCache(t).addContext(n)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e!=null?e:"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){this.fragmentVariables[e]===void 0&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t!=null?t:this.shader]+=e+` `}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t!=null?t:this.shader]+=e+` `}clearNodeCode(e){e=e!=null?e:this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t!=null?t:this.shader]+=e+` `}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t!=null?t:this.shader]+=e+` `}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,n,i="varying",s="V",o=""){let a=this.getVars(i),l=a[e];if(!l){let c=a.length;l={name:n||"node"+s+c+(o?"_"+o:""),type:t},a.push(l),a[e]=l}return l}getTempVar(e,t,n,i){return this.getVar(e,t,n,this.shader,"T",i)}getAttribute(e,t){if(!this.attributes[e]){let n=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(n.name+" = "+e+";"),this.attributes[e]={varying:n,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(` `)}getVarListCode(e,t){t=t!=null?t:"";let n="";for(let i=0,s=e.length;i{for(;e.image===void 0;)await new Promise(n=>requestAnimationFrame(n));t.addLayerAt(1,{type:lt.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let n=(i,s,o)=>Math.min(Math.max(i,s),o);if(this.userData.layers){for(let i of this.userData.layers.getLayers())if(i.type==lt.DISPLACE){this.uniformsBackup[`f${i.id}_intensity`]=i.uniforms[`f${i.id}_intensity`].value;let s=n(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==lt.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;tVs,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let n in e)this[n]=e[n];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let n=super.toJSON(e);return n.type="ShaderMaterial",n.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},n.vertex=this.vertex.toJSON(e).uuid,n.fragment=this.fragment.toJSON(e).uuid,delete n.vertexShader,delete n.fragmentShader,delete n.color,delete n.shininess,delete n.specular,delete n.roughness,delete n.metalness,delete n.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=n),this.userData.layers=t,n}fromJSON(e,t){var n;this.defines=(n=e.defines)!=null?n:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:Oi,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(Ni.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(r){r===!0&&this.version++,this.needsCompile=r},get:function(){return this.needsCompile}}});var bc=class extends ze{constructor(){super("basic");this.nodeType="Basic";this.color=new ct(5855577)}generate(e){let t;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ki.merge([be.fog])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#include "].join(` `));let i=["#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `,"#ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );","#endif",` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ `];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include "),t=i.join(` `)}else{this.color===void 0&&(this.color=new ct(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let n=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["#include ","#include ","varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif"].join(` `));let o=["#include ",n.code];i&&o.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?o.push(s.code,`vec3 outgoingLight = ${n.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):o.push(`vec3 finalColor = ${n.result};`),i?o.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} );`):o.push("gl_FragColor = vec4("+n.result+", 1.0 );"),o.push("#include ","#include "),t=o.join(` `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.color&&(t.color=this.color.toJSON(e).uuid),this.position&&(t.position=this.position.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),this}};var $p=class extends Ni{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}constructor(e=new bc,t){super(e,e,t);this.type="BasicNodeMaterial",this.fragment=e}};var oi=class extends $p{constructor(e,t,n){super(t,e);this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=n!=null?n:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Kn){let t=e.userData.layers,n=e.fragment;super.copy(e);let i=n.clone();this.fragment=i,this.vertex=i;let s=t.clone(this);this.userData.layers=s}else super.copy(e);return this}static fromJSON(e,t,n){let i=n.getNode(t.vertex),s=new oi(void 0,i);return s.fromJSON(t,n),s}static fromMaterial(e){let t=new oi(e.map?{map:e.map}:{}),n=t.fragment;return n.color.value.copy(e.color),n.alpha.value=e.opacity,t}dispose(){super.dispose()}};var wc=class extends ze{constructor(){super("phong");this.nodeType="Phong";this.color=new ct(5855577),this.specular=new ct(1118481),this.shininess=new Te(30),this.shadingAlpha=new Te(1),this.shadingBlend=new it(0)}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ki.merge([be.fog,be.lights])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#include ","#include ","#include "].join(` `));let i=["#include ",` #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );","#endif",` #ifndef USE_LAYER_DISPLACE #include #endif `];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),t=i.join(` `)}else{this.color===void 0&&(this.color=new ct(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let u=["#include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `," BlinnPhongMaterial material;"];u.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("material.diffuseColor = diffuseColor;"),u.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),u.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result}, ${a.result} ); } `),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include ","#include ","#include "),t=u.join(` `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid,t.shadingBlend=this.shadingBlend.toJSON(e).uuid,this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.specular&&(this.specular=t.getNode(e.specular)),e.shininess&&(this.shininess=t.getNode(e.shininess)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var em=class extends Ni{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new wc,t){super(e,e,t);this.type="PhongNodeMaterial",this.fragment=e}};var Ci=class extends em{constructor(e,t,n){super(t,e);this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=n!=null?n:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Kn){let t=e.userData.layers,n=e.fragment;super.copy(e);let i=n.clone();this.fragment=i,this.vertex=i;let s=t.clone(this);this.userData.layers=s,i.shadingAlpha.value=n.shadingAlpha.value,i.shadingBlend.value=n.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,n){let i=n.getNode(t.vertex),s=new Ci(void 0,i);return s.fromJSON(t,n),s}static fromMaterial(e){let t=new Ci(e.map?{map:e.map}:{}),n=t.fragment;return n.color.value.copy(e.color),n.alpha.value=e.opacity,t}dispose(){super.dispose()}};var Sc=class extends ze{constructor(){super("lambert");this.nodeType="Lambert";this.color=new ct(5855577),this.emissive=new ct(0),this.emissiveIntensity=new Te(1),this.shadingAlpha=new Te(1),this.shadingBlend=new it(0)}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ki.merge([be.fog,be.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let i=["#include ",` #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );","#endif",` #ifndef USE_LAYER_DISPLACE #include #endif `];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include ",` vec3 diffuse = vec3( 1.0 ); GeometricContext geometry; geometry.position = mvPosition.xyz; geometry.normal = normalize( transformedNormal ); geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); GeometricContext backGeometry; backGeometry.position = geometry.position; backGeometry.normal = -geometry.normal; backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); #endif IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = PI * directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_HEMI_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); #ifdef DOUBLE_SIDED vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry ); #endif } #pragma unroll_loop_end #endif `," #include "," #include "),t=i.join(` `)}else{this.color===void 0&&(this.color=new ct(5855577)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),o=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let u=["#include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx, viewdy)); bool isFrontFacing = (dot(normal, faceNormal) >= 0.0); `,"#include "];u.push(n.code,"vec3 diffuseColor = "+n.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += (isFrontFacing) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include ","reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = (isFrontFacing) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&u.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+s.result+";"),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),u.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result}, ${a.result} ); } `),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include ","#include ","#include "),t=u.join(` `)}return t}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.emissiveIntensity=this.emissiveIntensity.toJSON(e).uuid,t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid,t.shadingBlend=this.shadingBlend.toJSON(e).uuid,this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.emissiveIntensity&&(this.emissiveIntensity=t.getNode(e.emissiveIntensity)),this}};var tm=class extends Ni{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}constructor(e=new Sc,t){super(e,e,t);this.type="LambertNodeMaterial",this.fragment=e}};var Mc=class extends tm{constructor(e,t,n){super(t,e);this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=n!=null?n:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Kn){let t=e.userData.layers,n=e.fragment;super.copy(e);let i=n.clone();this.fragment=i,this.vertex=i;let s=t.clone(this);this.userData.layers=s,i.shadingAlpha.value=n.shadingAlpha.value,i.shadingBlend.value=n.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,n){let i=n.getNode(t.vertex),s=new Mc(void 0,i);return s.fromJSON(t,n),s}dispose(){super.dispose()}};var Ac=class extends ze{constructor(){super("toon");this.nodeType="Toon";this.color=new ct(5855577),this.specular=new ct(1118481),this.shininess=new Te(30),this.shadingAlpha=new Te(1),this.shadingBlend=new it(0)}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ki.merge([be.fog,be.lights])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#include ","#include ","#include "].join(` `));let i=["#include ",` #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );","#endif",` #ifndef USE_LAYER_DISPLACE #include #endif `];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include "," #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),t=i.join(` `)}else{this.color===void 0&&(this.color=new ct(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["#include ","#include ","#include ","#include ","#include ",` varying vec3 vViewPosition; #ifndef FLAT_SHADED varying vec3 vNormal; #endif struct ToonMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; #ifndef PHYSICALLY_CORRECT_LIGHTS irradiance *= PI; #endif reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon #define Material_LightProbeLOD( material ) (0) `,"#include ","#include ","#include "].join(` `));let u=["#include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `," ToonMaterial material;"];u.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("material.diffuseColor = diffuseColor;"),u.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),u.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result}, ${a.result} ); } `),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include ","#include ","#include "),t=u.join(` `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.specular&&(this.specular=t.getNode(e.specular)),e.shininess&&(this.shininess=t.getNode(e.shininess)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var nm=class extends Ni{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new Ac,t){super(e,e,t);this.type="ToonNodeMaterial",this.fragment=e}};var _c=class extends nm{constructor(e,t,n){super(t,e);this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=n!=null?n:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Kn){let t=e.userData.layers,n=e.fragment;super.copy(e);let i=n.clone();this.fragment=i,this.vertex=i;let s=t.clone(this);this.userData.layers=s,i.shadingAlpha.value=n.shadingAlpha.value,i.shadingBlend.value=n.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,n){let i=n.getNode(t.vertex),s=new _c(void 0,i);return s.fromJSON(t,n),s}dispose(){super.dispose()}};var Tc=class extends ze{constructor(){super("standard");this.nodeType="Standard";this.color=new ct(5855577),this.roughness=new Te(.3),this.metalness=new Te(0),this.reflectivity=new Te(.5),this.shadingAlpha=new Te(1),this.shadingBlend=new it(0)}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(ki.merge([be.fog,be.lights])),be.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#include ","#include ","#include "].join(` `));let i=["#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `,"#ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );","#endif",` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ `];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include ","#include "),t=i.join(` `)}else{let n={gamma:!0};this.color===void 0&&(this.color=new ct(5855577)),this.color.analyze(e,{slot:"color",context:n}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let i=this.color.flow(e,"c",{slot:"color",context:n}),s=this.roughness.flow(e,"f"),o=this.metalness.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let d=["#include "," #include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];d.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",o.code," float metalnessFactor = "+o.result+";"),u&&d.push(u.code,"#ifdef ALPHATEST"," if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),d.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),d.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.specularRoughness = max( roughnessFactor, 0.0525 );","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );"),h?d.push(h.code,"material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( "+h.result+" ) ), diffuseColor, metalnessFactor );"):d.push("material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor, metalnessFactor );"),d.push("#include "),d.push("#include "),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),d.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} ); } `),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include ","#include ","#include "),t=d.join(` `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.roughness=this.roughness.toJSON(e).uuid,t.metalness=this.metalness.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.reflectivity&&(t.reflectivity=this.reflectivity.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.metalness&&(this.metalness=t.getNode(e.metalness)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.reflectivity&&(this.reflectivity=t.getNode(e.reflectivity)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var im=class extends Ni{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new Tc,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var Ec=class extends im{constructor(e,t,n){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=n!=null?n:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Kn){let t=e.userData.layers,n=e.fragment;super.copy(e);let i=n.clone();this.fragment=i,this.vertex=i;let s=t.clone(this);this.userData.layers=s,i.shadingAlpha.value=n.shadingAlpha.value,i.shadingBlend.value=n.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,n){let i=n.getNode(t.vertex),s=new Ec(void 0,i);return s.fromJSON(t,n),s}dispose(){super.dispose()}};var wx={BasicMaterial:oi,PhongMaterial:Ci,LambertMaterial:Mc,ToonMaterial:_c,PhysicalMaterial:Ec};var Sx=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var o,a,l,c,u;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=(a=t.radiusTop)!=null?a:n,s=(l=t.radiusBottom)!=null?l:n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs((u=t.depth)!=null?u:t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=r.parameters,p;return h||f?p=new Lh(c,u,n,i,s,o,a,l*Math.PI/180,h,h,d,f):p=new ds(c,u,n,i,s,o,a,l*Math.PI/180),p.scale(1,1,t/e),Object.assign(p,{userData:tt(Ue({},r),{type:"CylinderGeometry"})})}};function ys(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function Mx(r){return new O(r.y,-r.x)}var Lh=class extends we{constructor(e,t,n,i,s,o,a,l,c,u,h,d,f=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let p=[],m=[],v=[],g=[],y=0,x=n/2,b=new M,w=new M;f&&e==0&&(e=c),f&&t==0&&(t=u);let _=new O(e,x),S=new O(t,-x),A=null,T=null,L=null,C=null,U=_.clone().sub(S),P=0,R=0,G=0;d>0&&(P=Math.min(e,t)*(1-d),R=e-P,G=t-P);let B=_.clone();B.x-=P;let j=Math.PI-U.angle(),ne=U.angle(),le=Math.tan(ne/2),W=Math.tan(j/2),z=le+W,D=d?z:W,K=d?z:le;if(c=Math.min(c,(e-R)/D,U.length()/z),u=Math.min(u,(t-G)/K,U.length()/z),c>0){let te=c/le;A=_.clone().sub(new O(te,c)),d&&(L=A.clone(),L.x-=P-z*c),_.sub(U.clone().setLength(te))}if(u>0){let te=u/W;T=S.clone().sub(new O(te,-u)),S.add(U.clone().setLength(te)),d&&(C=T.clone(),C.x-=P-z*u,B.sub(U.clone().setLength(te)))}U=_.clone().sub(S);let q=U.length()<.5,ee=[];for(let te=0;te<=i;te++){let X=[],se=te/i,$=se*l+a,H=new O(Math.sin($),Math.cos($));C&&T?(V(X,se,H,j,u,C,-1,!0),V(X,se,H,ne,u,T,-1,!1)):T?(de(X,H,T.x,0,-1),V(X,se,H,ne,u,T,-1,!1)):o||de(X,H,t,G,-1);let Q=Mx(U).normalize();if(ys(Q,H,b),!q)for(let ce=0;ce<=s;ce++){let ie=ce/s,N=U.clone().multiplyScalar(ie).add(S);ys(N,H,w),m.push(w.x,w.y,w.z),v.push(b.x,b.y,b.z),g.push(se,.5+w.y/n),X.push(y++)}if(L&&A?(V(X,se,H,j,c,A,1,!1),V(X,se,H,ne,c,L,1,!0)):A?(V(X,se,H,j,c,A,1,!1),de(X,H,A.x,0,1)):o||de(X,H,e,R,1),d&&!q){let ce=Mx(U).multiplyScalar(-1).normalize();ys(ce,H,b);for(let ie=0;ie<=s;ie++){let N=ie/s,E=U.clone().multiplyScalar(-N).add(B);ys(E,H,w),m.push(w.x,w.y,w.z),v.push(b.x,b.y,b.z),g.push(se,.5+w.y/n),X.push(y++)}}d&&!o&&X.push(X[0]),ee.push(X)}for(let te=0;tep.push(E,Y,re):(E,Y,re)=>p.push(E,re,Y),ie=new O((e+t+R+G)/4,0);ys(ie,$,Q),m.push(Q.x,Q.y,Q.z),v.push(H.x,0,H.y),g.push(.5,.5);let N=y++;for(let E of X){let Y=m.slice(E*3,E*3+3);m.push(...Y),v.push(H.x,0,H.y);let re=g.slice(E*2,E*2+2);g.push(...re),y++}for(let E=N+1;E0||u>0||l<360?d=new Lh(0,e/2,n,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new oo(e/2,n,i,s,o),d.scale(1,1,t/e),Object.assign(d,{userData:tt(Ue({},r),{type:"ConeGeometry"})})}};var _x=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var n,i,s;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((i=t.height)!=null?i:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,c;return a==0?c=new jn(e,t,n,i,s,o):c=new Tx(e,t,n,i,s,o,a,l),Object.assign(c,{userData:tt(Ue({},r),{type:"CubeGeometry"})})}},rm=Math.PI/2,Tx=class extends we{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super();this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let u=[],h=[],d=[],f=[],p=0,m=0;v("z","y","x",-1,-1,n,t,e,o,s,0),v("z","y","x",1,-1,n,t,-e,o,s,1),v("x","z","y",1,1,e,n,t,i,o,2),v("x","z","y",1,-1,e,n,-t,i,o,3),v("x","y","z",1,-1,e,t,n,i,s,4),v("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(g("z","y","x",-1,-1,1,n,t,e,o,0),g("z","y","x",1,-1,-1,n,t,e,o,1),g("z","y","x",-1,1,-1,n,t,e,o,1),g("z","y","x",1,1,1,n,t,e,o,0),g("x","y","z",-1,-1,-1,e,t,n,i,0),g("x","y","z",1,-1,1,e,t,n,i,1),g("x","y","z",-1,1,1,e,t,n,i,0),g("x","y","z",1,1,-1,e,t,n,i,1),g("y","x","z",-1,-1,1,t,e,n,s,0),g("y","x","z",1,-1,-1,t,e,n,s,1),g("y","x","z",1,1,1,t,e,n,s,1),g("y","x","z",-1,1,-1,t,e,n,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new ge(h,3)),this.setAttribute("normal",new ge(d,3)),this.setAttribute("uv",new ge(f,2));function v(x,b,w,_,S,A,T,L,C,U,P){let R=(A-2*a)/C,G=(T-2*a)/U,B=A/2-a,j=T/2-a,ne=L/2,le=C+1,W=U+1,z=0,D=0,K=new M;for(let q=0;q0?1:-1,d.push(K.x,K.y,K.z),f.push(V/C),f.push(1-q/U),z+=1}}for(let q=0;q0?(C,U,P)=>u.push(C,U,P):(C,U,P)=>u.push(C,P,U);for(let C=0;C<=l;C++){let U=[],P=rm*(1-C/l),R=Math.cos(P),G=Math.sin(P),B=0;for(let j=0;j<=C;j++){let ne=Math.cos(B),le=Math.sin(B);_.x=R*ne,_.y=G,_.z=R*le;let W=S.clone().addScaledVector(_,a);h.push(x*W.x,b*W.y,w*W.z),d.push(x*_.x,b*_.y,w*_.z),f.push(0,0),U.push(p++),B+=rm/C}A.push(U)}let L=A.length-1;for(let C=0;Cb.subVectors(W,z).normalize(),_=(W,z)=>Array(W).fill(void 0).map(z),S=_(e.length/3,(W,z)=>new M().fromArray(e,z*3).setLength(i)),A=[],T=1e6;for(let W=0;WH[0]==q)}A.push(ae)}let L=[];{let W=0,z=0,D,K,q=f==3;for(let ee=0;ee<=o;ee++){D=ee*(ee+1)/2,K=(ee+1)*(ee+2)/2;for(let V=0;V_(f,()=>p.clone()));for(let W=0;Wae.add(te),ee).multiplyScalar(1/f);for(let ae=0;aese[H]);a.push(...$.map(H=>[H.x,H.y,H.z]).flat()),c.push(...$.map(H=>(w(H,C),[b.x,b.y,b.z])).flat())}}let ne=[];for(let W=0;WV%T==W),q=B[W][z],ee=B[D][K];for(let V=0;V{a.push(se[0].x,se[0].y,se[0].z),c.push(se[1].x,se[1].y,se[1].z)})}ne.push(q[0][0],ee[x][0],q[x][0],ee[0][0])}}for(;ne.length;){let W,z,D,K;[W,z]=ne.splice(0,2);let q=[W];for(;W!=z;)q.push(z),D=ne.indexOf(z),K=D%2,z=ne.splice(D-K,2)[1-K];b.subVectors(q[0],q[1]).cross(p.subVectors(q[0],q[2])).normalize();let ee=b.dot(q[0])<0;ee&&b.negate();for(let V=1;V<=q.length-2;V++)[q[V+ +ee],q[V+1-+ee],q[0]].forEach(de=>{a.push(de.x,de.y,de.z),c.push(b.x,b.y,b.z)})}}function h(){let d=new M;for(let S=0;S{L<0&&S.x===1&&(l[A]=S.x-1),T.x===0&&T.z===0&&(l[A]=L/2/Math.PI+.5)};for(let S=0,A=0;S.9&&U<.1&&(A<.2&&(l[S+0]+=1),T<.2&&(l[S+2]+=1),L<.2&&(l[S+4]+=1))}function w(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new Eo(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var Ex=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var n,i,s;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((i=t.height)!=null?i:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Ih(e*.5,s,o):new ao(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:tt(Ue({},r),{type:"DodecahedronGeometry"})})}},Ih=class extends Eo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n);this.type=l}static fromJSON(e){return new Ih(e.radius,e.corner,e.cornerSides)}};var Nc=1e-12,Cc=class{constructor(e){this.position=new O;this.startPosition=new O;this.uuid=Ee.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Cc(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Lc=class extends Cc{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Lc(this.parent).copy(this)}},vs=class extends Cc{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Lc(this),new Lc(this))}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let n=0,i=this.controls.length;nr,Ic=new O,om=new O,NL=new O,CL=new O,LL=new O,IL=new O,Nx=new M,Cx=new M;function Lx(r){let e=new O;e.addVectors(r.v0,Ic.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new O;return t.addVectors(r.v2,om.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new ii(r.v0,e,t,r.v2)}function Pc(r,e,t=Number.EPSILON){return Math.abs(r-e)Math.PI&&(u*=-1),Pc(c,a)?h=(a+c)*(n/u-.5)*8/3/(o-l):h=(o+l)*(n/u-.5)*8/3/(c-a),i.set(e.x-h*a,e.y+h*o),s.set(t.x+h*c,t.y-h*l),[i,s]}function lm(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function Rx(r,e,t,n,i=.5){let s=Ic.subVectors(e,r).multiplyScalar(i).add(r),o=om.subVectors(t,e).multiplyScalar(i).add(e),a=NL.subVectors(n,t).multiplyScalar(i).add(t),l=s,c=CL.subVectors(o,s).multiplyScalar(i).add(s),u=LL.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=IL.subVectors(u,c).multiplyScalar(i).add(c);return[r.x,r.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,n.x,n.y]}function Bx(r,e,t=12,n=!0){let i=Cx.set(0,0,0),s,o=0,a=[];for(let l=0;l1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function Ox(r,e,t,n=12,i=!0){let s=Cx.set(0,0,0),o=0,a=[];for(let l=0;l1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function cm(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=xs(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=xs(r[0].roundedCurveCorner,e)*.5),n}function xs(r,e=12){return r&&r instanceof lo?e*2:r&&(r instanceof ri||r instanceof dh)?1:r&&r instanceof Ea?e*r.points.length:e}function Fx(r,e,t=12,n=!0){let i,s=0;for(let o=0;o1&&!(Pc(r[s-1],r[1],Nc)&&Pc(r[s-2],r[0],Nc))&&(r.push(r[0],r[1]),s++),r}var um=new O,RL=new O,BL=new O,OL=new O,FL=new O,zL=new O,Lt=class extends yi{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new cn;this.plane=new ni(new M(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ee.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,n=this.points.length;t0)for(let t=0,n=this.shapeHoles.length;t=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let n=0,i=this.shapeHoles.length;n=0)return t+o;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this.applyScale(e/this.width,t/this.height),this._width=e,this._height=t}applyScale(e,t){let n=um.set(e,t);for(let i=0,s=this.points.length;i=0&&this.points.splice(t,1),this.needsUpdate=!0}update(e=!0){for(let t=0,n=this.shapeHoles.length;ts+o,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=cm(this.points,e,!1),this.roundedCurveDivisions=cm(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,n=12){return Ox(e,this.curves,t,n,this.autoClose).reduce((s,o)=>s+o,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Fx(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=xs(this.points[0].roundedCurveCorner,this.subdivision)*.5);let o=e-s;o<0&&(o+=i.reduce((a,l)=>a+l,0));for(let a=0,l=i.length;a=this.points.length-1?0:e+1],o=this.curveDivisions,a=o[e];if(lm(i,s)){let u=i.position.distanceTo(s.position);return i.position.distanceTo(um.set(n.x,n.y))/u}let l=0;for(let u=0;u2){let i=0;for(let s=0,o=this.points.length;s0){let c=a.curveBefore,u=a.curveAfter;if(c===void 0||u===void 0)continue;let h=a.roundedCurveBefore,d=a.roundedCurveAfter,f=c.getLength(),p=u.getLength(),m=Math.min(l,f*.499),v=Math.min(l,p*.499),g=Math.min(m,v),y=1-g/f,x=g/p,b=c.getPointAt(y,um),w=u.getPointAt(x,RL);this._subSplitCurve(c,h,y,b,void 0),this._subSplitCurve(u,d,x,void 0,w);let _;if(this.useCubicForRoundedCorners){let S=am(b,a.position,w)/2,A=Math.tan(S)*b.distanceTo(a.position),[T,L]=Ix(b,w,A,BL,OL),C=Px(T,L,a.position),[U,P]=Dx(C,b,w,A,FL,zL);_=new ii(b.clone(),U.clone(),P.clone(),w.clone())}else _=new Wi(b.clone(),a.position.clone(),w.clone());a.roundedCurveCorner=_,this.roundedCurves.splice(s+i,0,_),i++}}}e&&((n=this.eventDispatcher)==null||n.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,n,i,s){if(e instanceof ri)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let o=e,a=t,l=o.getUtoTmapping(n,0),c=Rx(o.v0,o.v1,o.v2,o.v3,l);return i!==void 0&&(a.v0.set(c[0],c[1]),a.v1.set(c[2],c[3]),a.v2.set(c[4],c[5]),a.v3.set(c[6],c[7])),s!==void 0&&(a.v0.set(c[6],c[7]),a.v1.set(c[8],c[9]),a.v2.set(c[10],c[11]),a.v3.set(c[12],c[13])),a}return t}clone(){let e=new Lt(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var n;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i{let s=new Lt;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof ii&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},n=i=>{let s=[],o,a;for(o=0,a=i.length;o0?i[o-1]:null,d;u instanceof ii?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof ri&&(d=this.createPoint(u.v1)),d!==void 0&&(h!==null&&t(d,h),s.push(d))}let l=i[i.length-1],c=!1;return l instanceof ii?l.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(l.v2),c=!0):l instanceof ri&&l.v2.equals(s[0].position)&&(c=!0),this.isClosed=c,s};return this.points=n(e.curves),e instanceof yi&&(this.shapeHoles=e.holes.map(i=>{let s=new Lt;return s.fromShape(i),s})),this.update(),this}};var hm=Math.PI*2;function dm({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function GL(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function zx(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function UL(r,e,t,n,i,s,o,a,l,c){let u=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let m=p*i/s*a,v=p*-s/i*o,g=m+(r+t)/2,y=v+(e+n)/2,x=(o-m)/i,b=(a-v)/s,w=(-o-m)/i,_=(-a-v)/s,S=zx(1,0,x,b),A=zx(x,b,w,_);return!c&&A>0&&(A-=hm),c&&A<0&&(A+=hm),{centerx:g,centery:y,ang1:S,ang2:A}}function Gx({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(r-t)/2,u=(e-n)/2;if(c===0&&u===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=UL(r,e,t,n,i,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:v}=d,g=Math.abs(p)/(hm/4);Math.abs(1-g)<1e-7&&(g=1);let y=Math.max(Math.ceil(g),1);p/=y;for(let x=0;x{let{x:b,y:w}=dm(x[0],i,s,m,v),{x:_,y:S}=dm(x[1],i,s,m,v),{x:A,y:T}=dm(x[2],i,s,m,v);return{x1:b,y1:w,x2:_,y2:S,x:A,y:T}})}var Wt;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Wt||(Wt={}));var gn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(gn||(gn={}));function Xe(r,e){if(!r)throw e||"Assertion Failed!"}var We=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s0?i0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){Xe(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),Dc=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Ph=function(){function r(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),Za=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),Ux=function(){function r(){var e=new Za,t=new Dc,n=new Ph(0),i=new Ph(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Ph(0),n=new Ph(1);e.Sym.sidethis.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;Xe(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),fm=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),Hx=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),VL=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new Hx,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new Hx;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),HL=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?We.vertLeq(s.Org,o.Org)?We.edgeSign(o.Dst,s.Org,o.Org)<=0:We.edgeSign(s.Dst,o.Org,s.Org)>=0:We.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return We.edgeSign(s.Dst,i,s.Org)>=0;var a=We.edgeEval(s.Dst,i,s.Org),l=We.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&Xe(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){Xe(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new fm;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case Wt.ODD:return(t&1)!=0;case Wt.NONZERO:return t!==0;case Wt.POSITIVE:return t>0;case Wt.NEGATIVE:return t<0;case Wt.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,c,u,h=!0;c=n;do Xe(We.vertLeq(c.Org,c.Dst)),r.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,u=s;a=r.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!h&&r.checkForRightSplice(e,l)&&(r.addWinding(c,u),r.deleteRegion(e,l),e.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,Xe(l.windingNumber-c.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=We.vertL1dist(t,e),s=We.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(We.vertLeq(i.Org,s.Org)){if(We.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;We.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(We.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(Xe(!We.vertEq(i.Dst,s.Dst)),We.vertLeq(i.Dst,s.Dst)){if(We.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(We.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,u,h,d=new Za,f,p;if(Xe(!We.vertEq(c,l)),Xe(We.edgeSign(l,e.event,o)<=0),Xe(We.edgeSign(c,e.event,a)>=0),Xe(o!==e.event&&a!==e.event),Xe(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(We.vertLeq(o,a)){if(We.edgeSign(c,o,a)>0)return!1}else if(We.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),We.intersect(l,o,c,a,d),Xe(Math.min(o.t,l.t)<=d.t),Xe(d.t<=Math.max(a.t,c.t)),Xe(Math.min(c.s,l.s)<=d.s),Xe(d.s<=Math.max(a.s,o.s)),We.vertLeq(d,e.event)&&(d.s=e.event.s,d.t=e.event.t),f=We.vertLeq(o,a)?o:a,We.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),We.vertEq(d,o)||We.vertEq(d,a)?(r.checkForRightSplice(e,t),!1):!We.vertEq(l,e.event)&&We.edgeSign(l,e.event,d)>=0||!We.vertEq(c,e.event)&&We.edgeSign(c,e.event,d)<=0?c===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),p=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,p,!0),!0):(We.edgeSign(l,e.event,d)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),We.edgeSign(c,e.event,d)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,c),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),We.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),c=!0),We.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),c=!0),c){r.addRightEdges(e,t,n.Onext,s,s,!0);return}We.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,We.vertEq(i.Org,n)){Xe(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!We.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}Xe(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Xe(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),We.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,c=new fm;if(c.eUp=t.anEdge.Sym,n=e.dict.search(c).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,We.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=We.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var u=e.mesh.connect(a.Dnext,t.anEdge);l=u.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);Xe(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new fm,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new VL(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(Xe(t.fixUpperEdge),Xe(++n==1)),Xe(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,We.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new kL(s,We.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,Xe(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!We.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),jL=function(){function r(){this.mesh=new Ux,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Wt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;t=m.next;for(var v=0;v<3;++v)s=t.coords[v],c[v]=s,p[v]=t,l[v]=s,f[v]=t;for(t=m.next;t!==m;t=t.next)for(var g=0;g<3;++g)s=t.coords[g],sl[g]&&(l[g]=s,f[g]=t);var y=0;if(l[1]-c[1]>l[0]-c[0]&&(y=1),l[2]-c[2]>l[y]-c[y]&&(y=2),c[y]>=l[y]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=p[y],i=f[y],u[0]=n.coords[0]-i.coords[0],u[1]=n.coords[1]-i.coords[1],u[2]=n.coords[2]-i.coords[2],t=m.next;t!==m;t=t.next)h[0]=t.coords[0]-i.coords[0],h[1]=t.coords[1]-i.coords[1],h[2]=t.coords[2]-i.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,e[0]=d[0],e[1]=d[1],e[2]=d[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(u)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.sthis.bmax[0]&&(this.bmax[0]=c.s),c.tthis.bmax[1]&&(this.bmax[1]=c.t))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;We.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;We.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(We.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(We.edgeGoesLeft(i.Lnext)||We.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(We.edgeGoesRight(n.Lprev)||We.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var u=e.fHead.next;u!==e.fHead;u=u.next)if(u.n=-1,!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>n)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,t===gn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=e.fHead.next;u!==e.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[u++]=s,this.elements[u++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new Ux),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=Wt.ODD),t===void 0&&(t=gn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),HL.computeInterior(this,o);var a=this.mesh;return t===gn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===gn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function No(r){var e=r.windingRule,t=e===void 0?Wt.ODD:e,n=r.elementType,i=n===void 0?gn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,c=r.normal,u=c===void 0?[0,0,1]:c,h=r.contours,d=h===void 0?[]:h,f=r.strict,p=f===void 0?!0:f,m=r.debug,v=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var g=new jL;r.edgeCreateCallback&&(g.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(g.vertexIdCallback=r.vertexIdCallback);for(var y=0;yl.extractShapePointsToFlatArray([],this._curveSegments)),n,i=!0,s=!0,o,a;for(let l=0,c=e.length/2;lc&&(c=g),yh&&(h=y)}let d=c-l,f=h-u;for(let p=0,m=n.vertexCount;pthis._maxDrawCount}};var Rh=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*Rh.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(ethis.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Dh=Rh;Dh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var pm=(r,e)=>([t,n])=>(n=t?r:r+e)<=n),mm=class extends we{constructor(e,t,n=0,i=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,n<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(n,t/2-1e-12),this._bevelSegments=Math.floor(s));let o=this._shape.extractShapePointsToFlatArray([],i),a=this._shape.shapeHoles.map(_=>{let S=_.extractShapePointsToFlatArray([],i),A=[];for(let T=S.length-1;T>=1;T-=2){let L=S[T-1],C=S[T-0];A.push(L,C)}return A}),l=No({windingRule:Wt.ODD,elementType:gn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]}),c=No({windingRule:Wt.ODD,elementType:gn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]});if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let _=0;_d&&(d=T),Lp&&(p=L)}this._minX=h,this._minY=f,this._width=d-h,this._height=p-f;let m=l.vertexCount*2*(2+this._bevelSegments);this._buffer=new Dh(m);let v=[],g=[];for(let _=l.elementCount-1,S=l.elementCount;_>=0;_--){let A=_>=u,T=_*2,L=l.elements[T+0],C=l.elements[T+1],U=L+C,P={start:L,count:C,normals:[],continuous:[],concave:[]},R=L,G=U-1,B=L+1,j=this._shape.roundedCurves.length;do{let z=R-L,D=l.vertices[G*2+0],K=l.vertices[G*2+1],q=l.vertices[R*2+0],ee=l.vertices[R*2+1],V=l.vertices[B*2+0],de=l.vertices[B*2+1],ae=q-D,te=ee-K,X=Math.sqrt(ae*ae+te*te);ae/=X,te/=X;let se=q-V,$=ee-de,H=Math.sqrt(se*se+$*$);se/=H,$/=H,P.normals[z*2+0]=-$,P.normals[z*2+1]=se,P.concave[z]=ae*$-te*se>0;let Q=l.vertexIndices[R];if(Array.isArray(Q))P.continuous[z]=!1;else{let[ce,ie]=this._shape.getCurveIndexFromVertexId(Q-1,!0);if(ie>0&&ie<1)P.continuous[z]=!0;else{let N=ie===1?ce+1:ce-1;N=(N+j)%j;let E=ie===1?0:1,Y=this._shape.roundedCurves[ce].getTangent(ie),re=this._shape.roundedCurves[N].getTangent(E);P.continuous[z]=Y.dot(re)>.95}}A&&(P.normals[z*2+0]*=-1,P.normals[z*2+1]*=-1),[G,R,B]=[R,B,B+1],B>=U&&(B-=C)}while(B!==L+1);let ne=[];ne.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(L*2,U*2),vertexCount:C,vertexIndices:new Array(C).fill(!0).map((z,D)=>[D,D]),elements:[0,C],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(L*2,U*2)});for(let z=1;z<=this._bevelSegments;z++){let D=z/this._bevelSegments*Math.PI/2,K=(1-Math.cos(D))*this._bevelSize,q=[],ee=[],V=[],de=[],ae=0;for(let X=0;XY&&(re-=Math.PI*2);let ye=re-Y;if(P.continuous[X]||A){let pe=Y+ye/2,Ie=Math.cos(pe)*K,ve=Math.sin(pe)*K;q[2*ae+0]=H+Ie*(A?-1:1),q[2*ae+1]=Q+ve*(A?-1:1),de[ae]=X,ae++}else{let pe=Math.max(1,Math.floor(i/4*Math.abs(ye)/Math.PI));for(let Ie=0;Ie<=pe;Ie++){let ve=Y+ye*(Ie/pe),Fe=Math.cos(ve)*K,Ce=Math.sin(ve)*K;q[2*ae+0]=H+Fe,q[2*ae+1]=Q+Ce,de[ae]=X,ae++}}}else q[2*ae+0]=H+ce,q[2*ae+1]=Q+ie,de[ae]=X,ee[X]=ae,ae++,q[2*ae+0]=H,q[2*ae+1]=Q,de[ae]=X,ae++,q[2*ae+0]=H+N,q[2*ae+1]=Q+E,de[ae]=X,V[X]=ae,ae++}let te=No({windingRule:Wt.POSITIVE,elementType:gn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[q],edgeCreateCallback:X=>{let $=X.Org.idx,H=de[$],Q=de[($+1)%de.length];X.idx=[H,Q],X.Sym.idx=[Q,H]},vertexIdCallback:X=>{let se=X.Lprev.idx;return[se?se[1]:0,X.idx[0]]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${z}'th loop`);if(!te.vertexCount)break;for(let X=0;X{let q=0,ee=z.boundary.vertexIndices.length;for(;qre){let pe=Y/re,Ie=0;for(let ve=1;ve(Ie+1)*pe&&(Ie++,N=this.buildBevelVert(P,K,(X+Ie)%ee,Ie/(re-1)),v.push(ce.topN,ie.topP,N.topP),v.push(ie.bottomP,ce.bottomN,N.bottomP),ce=N)}else{let pe=re/Y,Ie=0;for(let ve=1;ve(Ie+1)*pe&&(Ie++,ie=this.buildBevelVert(P,D,(te+Ie)%q,Ie/(Y-1)),v.push(Q.topN,ie.topP,ce.topN),v.push(ie.bottomP,Q.bottomN,ce.bottomN),Q=ie)}te=(te+Y)%q,X=(X+re)%ee,de=(de+1)%V}while(de!==se)}{let z=ne[0];for(let D=0,K=z.boundary.vertexCount;D=W+2;D-=3){let K=v[D-2],q=v[D-1],ee=v[D-0];z.push(ee,q,K)}v.splice(W,v.length-W,...z)}if(A){let z=[];for(let D=ne[ne.length-1].boundary.vertices.length-1;D>=1;D-=2){let K=ne[ne.length-1].boundary.vertices[D-1],q=ne[ne.length-1].boundary.vertices[D-0];z.push(K,q)}g.push(z)}if(!A){let z=ne[ne.length-1],D=No({windingRule:ne.length>1?Wt.POSITIVE:Wt.ODD,elementType:gn.POLYGONS,vertexSize:2,strict:!0,contours:[z.insetPoints,...g]});if(!D)throw new Error("Error generating geometry for surface");for(let K=0;K0,u=e.continuous[l]||h);let d=Math.cos(t.angle),f=Math.sin(t.angle),p=n*2,m=l*2,v=c*2,g=t.boundary.vertices[p+0],y=t.boundary.vertices[p+1],x=(1-f)*this._bevelSize,b=(g-this._minX)/this._width,w=(y-this._minY)/this._height,_=e.normals[m+0],S=e.normals[m+1],A=e.normals[v+0],T=e.normals[v+1];if(h){let R=A-_,G=T-S;_=_+R*(1-i),S=S+G*(1-i);let B=Math.sqrt(_*_+S*S);_/=B,S/=B}let L=this._buffer.get(u?2:4),C=L*3,U=L*2,P={i:n,fi:l,topP:L+0,topN:L+0,bottomP:L+1,bottomN:L+1};return this._buffer.positions[C+0]=g,this._buffer.positions[C+1]=y,this._buffer.positions[C+2]=this._depth-x,this._buffer.normals[C+0]=_*d,this._buffer.normals[C+1]=S*d,this._buffer.normals[C+2]=f,this._buffer.uvs[U+0]=b,this._buffer.uvs[U+1]=w,this._buffer.positions[C+3]=g,this._buffer.positions[C+4]=y,this._buffer.positions[C+5]=x,this._buffer.normals[C+3]=_*d,this._buffer.normals[C+4]=S*d,this._buffer.normals[C+5]=-f,this._buffer.uvs[U+2]=w,this._buffer.uvs[U+3]=b,u||(L+=2,C+=6,U+=4,P.topP=L+0,P.bottomP=L+1,this._buffer.positions[C+0]=g,this._buffer.positions[C+1]=y,this._buffer.positions[C+2]=this._depth-x,this._buffer.normals[C+0]=A*d,this._buffer.normals[C+1]=T*d,this._buffer.normals[C+2]=f,this._buffer.uvs[U+0]=b,this._buffer.uvs[U+1]=w,this._buffer.positions[C+3]=g,this._buffer.positions[C+4]=y,this._buffer.positions[C+5]=x,this._buffer.normals[C+3]=A*d,this._buffer.normals[C+4]=T*d,this._buffer.normals[C+5]=-f,this._buffer.uvs[U+2]=w,this._buffer.uvs[U+3]=b),this.vertexCache[s]=P,P}};var Pn=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var c,u,h,d,f,p,m;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(t.width),i=Math.abs((u=t.height)!=null?u:t.width),s=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(h=t.depth)!=null?h:0),o=(d=r.shape)!=null?d:e==null?void 0:e.shape,a=(f=o==null?void 0:o.roundness)!=null?f:t.roundness;o!==void 0&&(o instanceof Lt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new Lt(n,i).fromJSON(o),((p=r.parameters)==null?void 0:p.roundness)!==void 0&&((m=r.parameters)==null?void 0:m.roundness)>0&&o.update(!1));let l=o!=null?o:new Lt(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,extrudeDepth:s,roundness:a}),shape:l}}static build(r){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s,surfaceMaxCount:o}=r.parameters;r.shape.roundness=s;let a;return e<=0?a=new Rc(r.shape,i,o):a=new mm(r.shape,e,t,i,n),Object.assign(a,{userData:tt(Ue({},r),{type:"VectorGeometry"})})}};var jx=Math.PI*2,Wx=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var i,s,o;let t=Object.assign({},(i=e==null?void 0:e.parameters)!=null?i:{width:100,depth:0,spikes:128,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},r.parameters);return{shape:r.shape&&r.shape instanceof Lt?r.shape:new Lt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(o=t.depth)!=null?o:0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=r.parameters,u=r.shape,h=e*.5,d=t*.5,f=WL(u,h,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let p=Pn.create({shape:u,parameters:{subdivisions:f,surfaceMaxCount:c,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(p,{userData:tt(Ue({},r),{type:"EllipseGeometry"})})}};function WL(r,e,t,n,i,s){if(n>=jx)return i>30||i%4==0?(XL(r,e,t,s),Math.round(i/4)):Jx(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=Gx({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%c.length==0?JL(r,o.x,o.y,c,i,e,t,s):Jx(r,n,i,e,t,s)}function JL(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint($a(e,t));for(let c=0,u=n.length;c0?Xx(r,s,o,a):r.addPoint($a(0,0)),l}function Jx(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,c=Math.sin(l)*n,u=Math.cos(l)*i;r.addPoint($a(c,u))}return e0?Xx(r,n,i,s):r.addPoint($a(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&qx(r,n,i,s)),1}function XL(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(Bh(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(Bh(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(Bh(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(Bh(i,s-t,i+a,s-t,i-a,s-t)),n>0&&qx(r,e,t,n)}function $a(r,e){return new vs(Ee.generateUUID(),new O(r,e))}function Bh(r,e,t,n,i,s){let o=$a(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function Xx(r,e,t,n){Yx(r,e,t,n).forEach(s=>r.addPoint(s))}function qx(r,e,t,n){let i=Yx(r,e,t,n),s=new Lt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function Yx(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new O(i/e,s/t),a=r.points.map(l=>l.clone()).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),u=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}var Kx=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var a,l,c;let t=Object.assign({},(a=e==null?void 0:e.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs((l=t.height)!=null?l:n),s=Math.abs((c=t.depth)!=null?c:n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:h}=r.parameters,d=new Oh(!1,e,t,n,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:tt(Ue({},r),{type:"HelixGeometry"})})}},Oh=class extends we{constructor(e,t,n,i,s,o,a,l,c,u,h,d){super();let f=e&&o===1;f&&(d=0),h>100&&(h=100);let p=()=>new M,m=new M,v=p(),g=p(),y=p(),x,b,w,_,S,A,T,L,C=p(),U=p(),P=p(),R=p(),G=p(),B=p(),j=p(),ne=p(),le=n-2*l+.001,W=le/o,z=Math.ceil(a*o),D=z+1,K=le/z,q=-le/2,ee=u+1,V=2*Math.PI/u,de=Math.PI/2/d,ae=.01,te=Math.min((1-h/100)*l,l-ae),X=l-te,se=0,$=2,H=d*$+$,Q=ee*H/$,ce=Q+ee*D,ie=ee*(D+H),[N,E,Y]=[3,3,2].map(ke=>Array(ie*ke).fill(0)),re=[],ye=s-l;function pe(ke,ht){let ft=Math.PI/2;A=ht*K,L=2*Math.PI*(A%W)/W+ft,A+=q,T=Math.sin(L)*ye,S=Math.cos(L)*ye,e?ke.set(S,T,A):ke.set(S,A,T)}pe(m,-1e-10),pe(v,0),C.copy(m),pe(m,1);let Ie=m.distanceTo(v),ve=X+te,Fe=Ie*z+2*ve,Ce=te,J=Fe-ve;for(let ke=0;ke<=z;ke++){pe(g,ke),ne.subVectors(g,C).normalize(),C.copy(g),B.copy(g).setComponent(+e+1,0).normalize(),j.crossVectors(ne,B).normalize();let ht=ke===0,ft=ke===z,Bn=ht?3*Math.PI/2:de,Mt=ht?Ce:J,Tn=ht?ee:ce,En=ht?0:ie-ee,Di=ne.clone().multiplyScalar(ht?-X:X).add(g),_r=ne.clone().multiplyScalar(ht?-1:1).normalize();for(let xn=0;xn{N[se*3+Pe]=Di.getComponent(Pe),E[se*3+Pe]=_r.getComponent(Pe)}),Y[se*2]=+ft,Y[se*2+1]=xn/u),v.copy(P).multiplyScalar(te),y.addVectors(g,v);for(let Pe=0;Pe{N[se*3+Nn]=v.getComponent(Nn),E[se*3+Nn]=G.getComponent(Nn)});let Ft=+ht+Math.sin(et);Y[se*2]=(Mt+X*Ft)/Fe,Y[se*2+1]=xn/u}}v.addVectors(g,U),se=Q+ke*ee+xn,[0,1,2].forEach(Pe=>{N[se*3+Pe]=v.getComponent(Pe),E[se*3+Pe]=P.getComponent(Pe)}),Y[se*2]=(ve+ke*Ie)/Fe,Y[se*2+1]=xn/u}}let xe=D+2*d+$,he=1,[Ne,Be]=f?[he,he+D-1]:[0,xe-1];for(let ke=Ne;ke<=Be-1;ke++){let ht=f&&ke===Be-1;for(let ft=0;ft{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((a=t.depth)!=null?a:t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new yi;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new uo(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:tt(Ue({},r),{type:"LatheGeometry"})})}};var fr=new me,gm=new Ke,zh=new M,Co=class extends cn{constructor(){super();this.uuid=Ee.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Dt().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n0)for(let d=0;d0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u0,b=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,_=m.vertexColors.length>0,S=0;if(S=u(S,0,0),S=u(S,1,v),S=u(S,2,g),S=u(S,3,y),S=u(S,4,x),S=u(S,5,b),S=u(S,6,w),S=u(S,7,_),n.push(S),n.push(m.a,m.b,m.c),n.push(m.materialIndex),y){let A=this.faceVertexUvs[0][p];n.push(f(A[0]),f(A[1]),f(A[2]))}if(x&&n.push(h(m.normal)),b){let A=m.vertexNormals;n.push(h(A[0]),h(A[1]),h(A[2]))}if(w&&n.push(d(m.color)),_){let A=m.vertexColors;n.push(d(A[0]),d(A[1]),d(A[2]))}}function u(p,m,v){return v?p|1<0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new Co().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,f=t.length;d0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Re(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Re(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Re(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Re(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a0){let i=new ge(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new ge(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new we,n=e.geometry;if(e.isPoints||e.isLine){let i=new ge(n.vertices.length*3,3),s=new ge(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new ge(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};Co.prototype.isGeometry=!0;var $x=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,i,s,o=e.faces;for(i=0;i0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,c;if(l>0){c=[];for(let g=0;g0){d=[];for(let g=0;g0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new M,n,i,s,o,a,l=e.vertices,c=e.faces,u=e.faceVertexUvs[0],h=u!==void 0&&u.length>0,d=[],f=new Map;KL(l,c,d,f);let p=[],m,v,g,y,x,b,w;for(let ae of Array.from(f.keys())){for(v=f.get(ae),g=new M,x=3/8,b=1/8,w=v.faces.length,w!=2&&(x=.5,b=0,w!=1),g.addVectors(v.a,v.b).multiplyScalar(x),t.set(0,0,0),o=0;o3&&(_=3/(8*n)),S=1-n*Number(_),A=_,n<=2&&(n==2?(S=3/4,A=1/8):n==1||n==0),U=C.clone().multiplyScalar(S),t.set(0,0,0),o=0;o0?(a===void 0||(o==null?void 0:o.subdivisions)>i)&&(a===void 0&&(a=s),s=new xm(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:tt(Ue({},r),{type:"NonParametricGeometry"})})}static loadFromUrl(r,e,t){new Ia(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(yn);let o=100/yn.x;Object.assign(s.parameters,{width:100,height:yn.y*o,depth:yn.z*o}),e(this.build(s))})}};var e0=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var i,s,o,a;let t=Object.assign({},(i=e==null?void 0:e.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof Lt?r.shape:new Lt,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a,surfaceMaxCount:l}=r.parameters,c=r.shape,u=e*.5,h=t*.5,d=0,f=0,p=2*Math.PI/n;for(let v=0;v0){{let E=z.clone().add(D).multiplyScalar(.5),Y=b.clone().sub(E).normalize(),ye=x.clone().sub(E).normalize().add(Y).normalize().multiplyScalar(-1),pe=ee.clone().sub(q);ne(E,pe,ye,S.angle())}let ie,N;{let E=new M;Oc(L,$,E);let Y=ee.clone().add(K).multiplyScalar(.5);Y=QL(Y,D,b);let re=ee.clone().sub(K);[ie,N]=ne(Y,re,E,P,K.y)}{let E=ie,Y=E.clone().setY(0).normalize(),re=new M(0,-1,0),ye=Y.clone().cross(re);le(E,Y,re,ye)}j.concat(N);{let E=S.angle(),Y=Math.PI-E,re=b.clone();re.y-=o/Math.sin(E-Math.PI/2);let ye=new M,pe=[];for(let ve=0;veh+d,0);return{shape:r.shape&&r.shape instanceof Lt?r.shape:new Lt,parameters:Object.assign(t,{surfaceMaxCount:((l=t.surfaceMaxCount)!=null?l:i>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(u=t.depth)!=null?u:0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=r.parameters,u={x:t*.5,y:n*.5},h={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function f(w,_,S){return _>t&&S>n?Math.min(w*t/_,w*n/S):_>t?w*t/_:S>n?w*n/S:w}let p=[];p[0]=i[0]===0?0:f(i[0],i[0]+i[3],i[0]+i[1]),p[1]=i[1]===0?0:f(i[1],i[1]+i[2],i[1]+i[0]),p[2]=i[2]===0?0:f(i[2],i[2]+i[1],i[2]+i[3]),p[3]=i[3]===0?0:f(i[3],i[3]+i[0],i[3]+i[2]);let m=h.x,v=d.x,g=d.y,y=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(v,g)),e.addPoint(e.createPoint(v,y)),e.addPoint(e.createPoint(m,y)),e.isClosed=!0;let x=!0;for(let w=0,_=e.points.length;w<_;w++)e.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(x=!1);x&&(e.roundness=p[0]),e.useCubicForRoundedCorners=s!==1,e.update();let b=Pn.create({shape:e,parameters:{surfaceMaxCount:c,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(b,{userData:tt(Ue({},r),{type:"RectangleGeometry"})})}};var i0=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var n,i,s;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((i=t.height)!=null?i:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=r.parameters,u=new Ji(.5*e,i,s,o,a,l,c);return u.scale(1,t/e,n/e),Object.assign(u,{userData:tt(Ue({},r),{type:"SphereGeometry"})})}};var r0=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var i,s,o,a;let t=Object.assign({},(i=e==null?void 0:e.parameters)!=null?i:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof Lt?r.shape:new Lt,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:u}=r.parameters,h=r.shape,d=e*.5,f=t*.5,p=0,m=0,v=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=d*n/100,x=f*n/100;if(i==3&&n==50){v=2*Math.PI/i;for(let w=0;w0)?1e3:100,width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a,surfaceMaxCount:l}=r.parameters,c=r.shape,u=e*.5,h=t*.5;a?(c.addPoint(c.createPoint(-u,h)),c.addPoint(c.createPoint(u,-h)),c.addPoint(c.createPoint(-u,-h))):(c.addPoint(c.createPoint(0,h)),c.addPoint(c.createPoint(u,-h)),c.addPoint(c.createPoint(-u,-h))),c.isClosed=!0;for(let f=0,p=c.points.length;f[]))}let f=Math.log10(1/t),p=Math.pow(10,f);for(let v=0;v{$L=r});var ot;c0.then(r=>{ot=r});var Fc=new M,pr=new M,zc=new me;function u0(r,...e){let t=0;for(let s of e)t+=s.length;let n=new r(t),i=0;for(let s of e)n.set(s,i),i+=s.length;return n}var nl,Qn=(nl=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){var a,l;let t=(a=r.geometry)!=null?a:e==null?void 0:e.geometry,{width:n,height:i,depth:s}=t.userData.parameters,o=Ue(Ue({},(l=e==null?void 0:e.parameters)!=null?l:{width:n,height:i,depth:s,subdivisions:1}),r.parameters);return{parameters:tt(Ue({},o),{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth)}),geometry:t,subdivPointer:e==null?void 0:e.subdivPointer,smoothShading:e==null?void 0:e.smoothShading}}static build(r){let e=r.geometry,t=r.geometry.originalGeometry,{width:n,height:i,depth:s,subdivisions:o}=r.parameters,a=e.userData.parameters;Fc.set(a.width,a.height,a.depth),(n!==Fc.x||i!==Fc.y||s!==Fc.z)&&(pr.set(n,i,s).divide(Fc),zc.makeScale(isNaN(pr.x)||pr.x===0?1:pr.x,isNaN(pr.y)||pr.y===0?1:pr.y,isNaN(pr.z)||pr.z===0?1:pr.z),e.applyMatrix4(zc),t?(t.applyMatrix4(zc),t.getAttribute("positionWASM").applyMatrix4(zc)):e.getAttribute("positionWASM").applyMatrix4(zc));let l,c;return t!==void 0?(c=e,l=t):l=e,r.subdivPointer===void 0&&(this.allocate(l),l==null||l.dispose(),l=this.buildLevel(!0,r.smoothShading),l.computeBoundingSphere(),r.subdivPointer=this.activeSubdivPtr,this.getTopologicalMesh(l)),o>0?((o!==(a==null?void 0:a.subdivisions)||t===void 0)&&(r.subdivPointer!==this.activeSubdivPtr&&(this.activeSubdivPtr=r.subdivPointer),c==null||c.dispose(),ot.set_destination_refinement_level(r.subdivPointer,o),c=this.buildLevel(!1,r.smoothShading),c.boundingSphere=l.boundingSphere),e=c,t=l,delete t.userData.parameters):(e=l,c==null||c.dispose(),t=void 0),Object.assign(e,{originalGeometry:t,subdivPointer:this.activeSubdivPtr,userData:{parameters:r.parameters,type:"SubdivGeometry"}})}static allocate(r){var x;let e,t,n,i=[],s=[];if(r.userData.type!=="SubdivGeometry"){let b=tl.mergeVertices(r,(x=this.mergeVerticesToleranceExceptions[r.userData.type])!=null?x:1.1);e=b.attributes.position.array;let w=b.getIndex().array,_=w.length;switch(r.userData.type){case"TorusGeometry":case"TorusKnotGeometry":case"CubeGeometry":t=new Uint32Array(_/3*2),n=new Uint8Array(_/6).fill(4);for(let U=0,P=0;U<_;U+=6)t[P++]=w[U],t[P++]=w[U+1],t[P++]=w[U+4],t[P++]=w[U+5];break;case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let S,A;if(r.userData.type==="SphereGeometry")A=r.parameters.heightSegments,S=r.parameters.widthSegments;else if(r.userData.type==="CylinderGeometry")A=r.parameters.heightSegments+2,S=r.parameters.radialSegments;else if(r.userData.type==="ConeGeometry")A=r.parameters.heightSegments+1,S=r.parameters.radialSegments;else{let{pathSegments:U,segments:P,revolutions:R}=r.userData.parameters;A=Math.ceil(P*R)+2,S=U}t=new Uint32Array(2*S*3+(A-2)*S*4),n=new Uint8Array(2*S+(A-2)*S);let T=0,L=0,C=0;if(r.userData.type==="SphereGeometry"||r.userData.type==="HelixGeometry"){for(;L<3*S;)t[L++]=w[T++],t[L++]=w[T++],t[L++]=w[T++],n[C++]=3;for(;L<3*S+4*(A-2)*S;T+=6)t[L++]=w[T],t[L++]=w[T+1],t[L++]=w[T+4],t[L++]=w[T+5],n[C++]=4}else for(;L<4*(A-2)*S;T+=6)t[L++]=w[T],t[L++]=w[T+1],t[L++]=w[T+4],t[L++]=w[T+5],n[C++]=4;for(;L>2,(n>>2)+i),o=s.subarray(4,4+4),a=0,l=ot.HEAPU32[s[a]>>2],c=ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let u=ot.HEAPU32[s[a]>>2],h=ot.HEAPF32.subarray(u>>2,(u>>2)+o[a]);a++;let d=ot.HEAPU32[s[a]>>2],f=ot.HEAPU32.subarray(d>>2,(d>>2)+o[a]);a++;let p=ot.HEAPU32[s[a]>>2],m=ot.HEAPU32.subarray(p>>2,(p>>2)+o[a]);if(a++,t===void 0){let v=new we;if(v.setIndex(new is(m,1)),v.setAttribute("position",new ge(c,3)),v.setAttribute("normal",new ge(h,3)),r){v.setAttribute("faceMap",new is(f,1));let g=new Float32Array(h.length/3*4).fill(0);v.setAttribute("color",new Re(g,4))}return ot.free_mesh_data(n),v.userData.type="SubdivGeometry",v}t.getAttribute("position").copyArray(c),t.getAttribute("normal").copyArray(h),t.attributes.position.needsUpdate=!0,t.attributes.normal.needsUpdate=!0,ot.free_mesh_data(n)}static buildControlCageWireframe(r,e){let t=ot.get_wireframe_data_for_base_level(this.activeSubdivPtr),n=4,i=ot.HEAPU32.subarray(t>>2,(t>>2)+n),s=i.subarray(2,2+2),o=0,a=ot.HEAPU32[i[o]>>2],l=ot.HEAPF32.subarray(a>>2,(a>>2)+s[o]);o++;let c=ot.HEAPU32[i[o]>>2],u=ot.HEAPU32.subarray(c>>2,(c>>2)+s[o]);if(r===void 0){let h=new we;h.setAttribute("position",new ge(l,3));let d=new Float32Array(l.length);for(let f=0,p=l.length;f0?(o=this.buildLevel(!1,t),i=o,s=n,delete s.userData.parameters):(i=n,s=void 0),Object.assign(i,{originalGeometry:s,userData:{parameters:r,type:"SubdivGeometry"}})}static getTopologicalMesh(r){let e=ot.get_topological_data(this.activeSubdivPtr),t=6,n=ot.HEAPU32.subarray(e>>2,(e>>2)+t),i=n.subarray(3,3+3),s=0,o=ot.HEAPU32[n[s]>>2],a=ot.HEAPF32.subarray(o>>2,(o>>2)+i[s]);s++;let l=ot.HEAPU32[n[s]>>2],c=ot.HEAPU32.subarray(l>>2,(l>>2)+i[s]);s++;let u=ot.HEAPU32[n[s]>>2],h=ot.HEAPU32.subarray(u>>2,(u>>2)+i[s]);r.setAttribute("positionWASM",new ge(a,3)),r.setAttribute("indexWASM",new is(c,1)),r.setAttribute("verticesPerFaceWASM",new Sf(h,1)),ot.free_topological_data(e)}},nl.checkpoints=[],nl.checkpointCurrentIndex=-1,nl.maxCheckpoints=30,nl.mergeVerticesToleranceExceptions={DodecahedronGeometry:2},nl);var Gc={};fA(Gc,{addBarycentricAttribute:()=>n2,fixUvs:()=>r2,loadFromUrl:()=>i2,resizeGeometry:()=>t2,roundShapePolygon:()=>e2});var h0=function(r,e){let t=e.x-r.x,n=e.y-r.y,i=Math.sqrt(t*t+n*n),s=t/i,o=n/i,a=Math.atan2(o,s);return{x:t,y:n,len:i,nx:s,ny:o,ang:a}},e2=(r,e,t)=>{let n,i,s,o,a,l,c,u,h,d,f,p,m,v,g=e.length;for(o=e[g-2],r.curves=[],n=1;n0&&(h=-1,d=!0),p=f/2,v=Math.abs(Math.cos(p)*t/Math.sin(p)),v>Math.min(y.len/2,x.len/2)?(v=Math.min(y.len/2,x.len/2),m=Math.abs(v*Math.sin(p)/Math.cos(p))):m=t,i=a.x+x.nx*v,s=a.y+x.ny*v,i+=-x.ny*m*h,s+=x.nx*m*h,r.absarc(i,s,m,y.ang+Math.PI/2*h,x.ang-Math.PI/2*h,d),o=a,a=l}r.closePath()},t2=(r,{width:e,height:t,depth:n})=>{e=Math.abs(e),t=Math.abs(t),n=Math.abs(n);let i=r.userData.parameters,s,o,a;e===0?(e=i.width,s=1):s=e/i.width,t===0?(t=i.height,o=1):o=t/i.height,n===0?(n=i.depth,a=1):a=n/i.depth,r.scale(s,o,a),i.width=e,i.height=t,i.depth=n},n2=(r,e)=>{let t=[new M(1,0,0),new M(0,1,0),new M(0,0,1)],n=r.attributes.position,i=new Float32Array(n.count*3);for(let s=0,o=n.count;snew Promise(e=>{new Ia().load(r,n=>e(n))}),r2=(r,e,t)=>{let n=r.getAttribute("uv");if(n)for(let i=0;iUc[r.type].create(r);var Vh=r=>"isEntity"in r,ai=r=>"isAbstractMesh"in r;var Hh=r=>"objectHelper"in r;var il=new tn,Dn=new M,Je=new M,vn=new me;function s2(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t;ua&&(a=h),d>l&&(l=d),f>c&&(c=f)}return r.min.set(i,s,o),r.max.set(a,l,c),r}var d0=(r,e,t,n)=>{var i,s;if(ai(r)){let o=r.geometry.userData.parameters,a=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?Dn.copy(((i=r.geometry.originalGeometry)!=null?i:r.geometry).boundingSphere.center):(s2(il,a,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:a.count),il.getCenter(Dn)),r.forceComputeSize?il.getSize(Je).multiplyScalar(.5):Je.set(o.width,o.height,(s=o.depth)!=null?s:0).multiplyScalar(.5)}else if(Hh(r)&&n===!0){let o=r.geometryHelper.getAttribute("position");il.setFromArray(o.array),il.getCenter(Dn),il.getSize(Je).multiplyScalar(.5)}else Dn.setScalar(0),Je.setScalar(0);vn.copy(e).multiply(r.matrixWorld),Je.x===0&&Je.y===0&&Je.z===0?t.push(new M(Dn.x,Dn.y,Dn.z).applyMatrix4(vn)):t.push(new M(-Je.x,Je.y,Je.z).add(Dn).applyMatrix4(vn),new M(-Je.x,-Je.y,Je.z).add(Dn).applyMatrix4(vn),new M(Je.x,-Je.y,Je.z).add(Dn).applyMatrix4(vn),new M(Je.x,Je.y,Je.z).add(Dn).applyMatrix4(vn),new M(-Je.x,Je.y,-Je.z).add(Dn).applyMatrix4(vn),new M(-Je.x,-Je.y,-Je.z).add(Dn).applyMatrix4(vn),new M(Je.x,-Je.y,-Je.z).add(Dn).applyMatrix4(vn),new M(Je.x,Je.y,-Je.z).add(Dn).applyMatrix4(vn))},jh=class extends tn{constructor(e,t){super(e,t);this.transform=new me;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,!1),this.makeEmpty(),this.transform=e.matrixWorld;let n=new me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,t)}expandByObjectSize(e,t,n=!1){let i=[];return n===!0?e.traverseEntity(s=>d0(s,t,i,"enableHelper"in e&&e.enableHelper)):d0(e,t,i,"enableHelper"in e&&e.enableHelper),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.transform),e}getPositionToCenter(e){return e=super.getCenter(e),e}computeVertices(){this.getSize(Je).multiplyScalar(.5),this.getCenter(Dn),vn.copy(this.transform).setPosition(Dn),this.vertices=[new M(-Je.x,Je.y,Je.z).applyMatrix4(vn),new M(-Je.x,-Je.y,Je.z).applyMatrix4(vn),new M(Je.x,-Je.y,Je.z).applyMatrix4(vn),new M(Je.x,Je.y,Je.z).applyMatrix4(vn),new M(-Je.x,Je.y,-Je.z).applyMatrix4(vn),new M(-Je.x,-Je.y,-Je.z).applyMatrix4(vn),new M(Je.x,-Je.y,-Je.z).applyMatrix4(vn),new M(Je.x,Je.y,-Je.z).applyMatrix4(vn)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new qn(this.vertices[0],this.vertices[3]),new qn(this.vertices[1],this.vertices[2]),new qn(this.vertices[5],this.vertices[6]),new qn(this.vertices[4],this.vertices[7]),new qn(this.vertices[0],this.vertices[1]),new qn(this.vertices[3],this.vertices[2]),new qn(this.vertices[7],this.vertices[6]),new qn(this.vertices[4],this.vertices[5]),new qn(this.vertices[0],this.vertices[4]),new qn(this.vertices[1],this.vertices[5]),new qn(this.vertices[2],this.vertices[6]),new qn(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new M().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new M().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new M().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new M().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new M().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new M().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};function wm(r,e,t,n){if(n===0)return t.copy(r);if(n===1)return t.copy(e);let i=r.w*e.w+r.x*e.x+r.y*e.y+r.z*e.z;if(i>=1)return t.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let u=1-n;return t.w=u*r.w+n*e.w,t.x=u*r.x+n*e.x,t.y=u*r.y+n*e.y,t.z=u*r.z+n*e.z,t.normalize(),t}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,c=Math.sin(n*a)/o;return t.w=r.w*l+e.w*c,t.x=r.x*l+e.x*c,t.y=r.y*l+e.y*c,t.z=r.z*l+e.z*c,t}function o2(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.dot(i)/e.distanceTo(t)}function a2(r,e){return r.clone().dot(e)/e.length()}function l2(r,e,t,n,i=!1){let s=t-r,o=n-e,a=Math.atan2(o,s)*(180/Math.PI);return i&&a<0&&(a=360+a),a}function c2(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e),s=e.distanceTo(r),o=e.distanceTo(t),a=n.dot(i)/(s*o);return Math.acos(a)}function u2(r,e){let t=(r+"e").split("e");return t=(Math.round(Number(t[0]+"e"+(+t[1]+e)))+"e").split("e"),+(t[0]+"e"+(+t[1]-e))}function h2(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}var d2=str=>eval(str.replace(/[^0-9()+\-*/.]/g,"")),C5={slerp:wm,getProjection:o2,projectOnVector:a2,angle2D:l2,angle3D:c2,round:u2,swapArrayValues:h2,evaluate:d2};var Io=new Set;var $i;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})($i||($i={}));var rl=class{constructor(){this.easing=4;this.duration=1e3;this.delay=0;this.cubicControls=[.5,.05,.1,.3];this.springParameters={mass:1,stiffness:80,damping:10,velocity:0};this.repeat=!1;this.cycle=!1;this.rewind=!1}get sp_mass(){return this.springParameters.mass}set sp_mass(e){this.springParameters.mass=e}get sp_stiffness(){return this.springParameters.stiffness}set sp_stiffness(e){this.springParameters.stiffness=e}get sp_damping(){return this.springParameters.damping}set sp_damping(e){this.springParameters.damping=e}get sp_velocity(){return this.springParameters.velocity}set sp_velocity(e){this.springParameters.velocity=e}copy(e){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters=Ue({},e.springParameters),this.repeat=e.repeat,this.cycle=e.cycle,this.rewind=e.rewind,this}clone(){return new rl().copy(this)}toJSON(){let e={easing:this.easing,duration:this.duration,delay:this.delay,cubicControls:this.cubicControls,springParameters:Ue({},this.springParameters)};return this.repeat===!0&&(e.repeat=!0),this.cycle===!0&&(e.cycle=!0),this.rewind===!0&&(e.rewind=!0),this.object!==void 0&&(e.object=this.object.uuid),this.state!==void 0&&(e.state=this.state.uuid),e}fromJSON(e,t,n){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters.mass=e.springParameters.mass,this.springParameters.stiffness=e.springParameters.stiffness,this.springParameters.damping=e.springParameters.damping,this.springParameters.velocity=e.springParameters.velocity,e.repeat!==void 0&&(this.repeat=e.repeat),e.cycle!==void 0&&(this.cycle=e.cycle),e.rewind!==void 0&&(this.rewind=e.rewind),e.object!==void 0&&(this.object=t[e.object]),e.state!==void 0&&(this.state=n[e.state]),this}};function f2(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Ze;(function(h){h[h.MOUSE_DOWN=0]="MOUSE_DOWN",h[h.MOUSE_UP=1]="MOUSE_UP",h[h.MOUSE_HOVER=2]="MOUSE_HOVER",h[h.MOUSE_ENTER=3]="MOUSE_ENTER",h[h.MOUSE_LEAVE=4]="MOUSE_LEAVE",h[h.KEY_DOWN=5]="KEY_DOWN",h[h.KEY_UP=6]="KEY_UP",h[h.START=7]="START",h[h.OPEN_LINK=8]="OPEN_LINK",h[h.LOOK_AT=9]="LOOK_AT",h[h.FOLLOW=10]="FOLLOW"})(Ze||(Ze={}));var sl=class{constructor(e,t){this.targets=[];this.ui={isCollapsed:!1};this._type=e,this.key=t}get type(){return this._type}set type(e){this._type=e,e===9?this.distance=1e3:this.distance=void 0,e!==5&&e!==6&&(this.key=void 0)}newTarget(e){let t=new rl;if(t.object=e,e!==void 0){let n=e.interaction.states;n.length>0&&(t.state=n[n.length-1])}return this.targets.push(t),Io.add(t),t}addTarget(e,t=0){this.targets.splice(t,0,e),Io.add(e)}removeTarget(e){Io.delete(this.targets[e]),this.targets.splice(e,1)}dispatchReverse(){for(let e=0,t=this.targets.length;e0){e.targets=[];for(let t=0,n=this.targets.length;ti.clone())})}else this.material={layersList:e.material.layersList.map(t=>t.clone())};return e.camera!==void 0&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho,targetOffset:e.camera.targetOffset}),this}clone(){return new bs().copy(this)}toJSON(e){let t={uuid:this.uuid,name:this.name,position:this.position.toArray(),rotation:this.rotation.toArray(),scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};if(this.geometry!==void 0&&(t.geometry={width:this.geometry.width,height:this.geometry.height,depth:this.geometry.depth}),this.material!==void 0)if(this.material instanceof Array){t.material=[];for(let n=0,i=this.material.length;ns.toJSON(e))})}else t.material={layersList:this.material.layersList.map(n=>n.toJSON(e))};return this.camera!==void 0&&(t.camera={zoomPersp:this.camera.zoomPersp,zoomOrtho:this.camera.zoomOrtho,targetOffset:this.camera.targetOffset}),t}fromJSON(e,t){var n;if(this.uuid=e.uuid,this.name=e.name,this.position.fromArray(e.position),this.rotation.fromArray(e.rotation),this.scale.fromArray(e.scale),this.hiddenMatrix.fromArray(e.hiddenMatrix),e.geometry!==void 0&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),e.material!==void 0)if(e.material instanceof Array){this.material=[];for(let i=0,s=e.material.length;ikp(o,t))})}else this.material={layersList:e.material.layersList.map(i=>kp(i,t))};return e.camera!==void 0&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho,targetOffset:(n=e.camera.targetOffset)!=null?n:-1}),this}};"use strict";var f0={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Sm={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},p2=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Wh={CSS:{},springs:{}};function mr(r,e,t){return Math.min(Math.max(r,e),t)}function Vc(r,e){return r.indexOf(e)>-1}function Mm(r,e){return r.apply(null,e)}var qe={arr:function(r){return Array.isArray(r)},obj:function(r){return Vc(Object.prototype.toString.call(r),"Object")},pth:function(r){return qe.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||qe.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r=="undefined"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return qe.hex(r)||qe.rgb(r)||qe.hsl(r)},key:function(r){return!f0.hasOwnProperty(r)&&!Sm.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function p0(r){var e=/\(([^)]+)\)/.exec(r);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function m0(r,e){var t=p0(r),n=mr(qe.und(t[0])?1:t[0],.1,100),i=mr(qe.und(t[1])?100:t[1],.1,100),s=mr(qe.und(t[2])?10:t[2],.1,100),o=mr(qe.und(t[3])?0:t[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,h=l<1?(l*a+-o)/c:-o+a;function d(p){var m=e?e*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(u*Math.cos(c*m)+h*Math.sin(c*m)):m=(u+h*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=Wh.springs[r];if(p)return p;for(var m=1/6,v=0,g=0;;)if(v+=m,d(v)===1){if(g++,g>=16)break}else g=0;var y=v*m*1e3;return Wh.springs[r]=y,y}return e?d:f}function m2(r){return r===void 0&&(r=10),function(e){return Math.ceil(mr(e,1e-6,1)*r)*(1/r)}}var g2=function(){var r=11,e=1/(r-1);function t(u,h){return 1-3*h+3*u}function n(u,h){return 3*h-6*u}function i(u){return 3*u}function s(u,h,d){return((t(h,d)*u+n(h,d))*u+i(h))*u}function o(u,h,d){return 3*t(h,d)*u*u+2*n(h,d)*u+i(h)}function a(u,h,d,f,p){var m,v,g=0;do v=h+(d-h)/2,m=s(v,f,p)-u,m>0?d=v:h=v;while(Math.abs(m)>1e-7&&++g<10);return v}function l(u,h,d,f){for(var p=0;p<4;++p){var m=o(h,d,f);if(m===0)return h;var v=s(h,d,f)-u;h-=v/m}return h}function c(u,h,d,f){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var p=new Float32Array(r);if(u!==h||d!==f)for(var m=0;m=.001?l(g,_,u,d):S===0?_:a(g,y,y+e,u,d)}return function(g){return u===h&&d===f||g===0||g===1?g:s(v(g),h,f)}}return c}(),g0=function(){var r={linear:function(){return function(n){return n}}},e={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=mr(n,1,10),o=mr(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(n,i){e[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(e).forEach(function(n){var i=e[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function Am(r,e){if(qe.fnc(r))return r;var t=r.split("(")[0],n=g0[t],i=p0(r);switch(t){case"spring":return m0(r,e);case"cubicBezier":return Mm(g2,i);case"steps":return Mm(m2,i);default:return Mm(n,i)}}function y0(r){try{var e=document.querySelectorAll(r);return e}catch(t){return}}function Jh(r,e){for(var t=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*6:d}var a,l,c;if(n==0)a=l=c=i;else{var u=i<.5?i*(1+n):i+n-i*n,h=2*i-u;a=o(h,u,t+1/3),l=o(h,u,t),c=o(h,u,t-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function b2(r){if(qe.rgb(r))return y2(r);if(qe.hex(r))return v2(r);if(qe.hsl(r))return x2(r)}function Gr(r){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(e)return e[1]}function w2(r){if(Vc(r,"translate")||r==="perspective")return"px";if(Vc(r,"rotate")||Vc(r,"skew"))return"deg"}function Nm(r,e){return qe.fnc(r)?r(e.target,e.id,e.total):r}function gr(r,e){return r.getAttribute(e)}function Cm(r,e,t){var n=Gr(e);if(_m([t,"deg","rad","turn"],n))return e;var i=Wh.CSS[e+t];if(!qe.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(e);return Wh.CSS[e+t]=c,c}function x0(r,e,t){if(e in r.style){var n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[e]||getComputedStyle(r).getPropertyValue(n)||"0";return t?Cm(r,i,t):i}}function Lm(r,e){if(qe.dom(r)&&!qe.inp(r)&&(gr(r,e)||qe.svg(r)&&r[e]))return"attribute";if(qe.dom(r)&&_m(p2,e))return"transform";if(qe.dom(r)&&e!=="transform"&&x0(r,e))return"css";if(r[e]!=null)return"object"}function b0(r){if(!!qe.dom(r)){for(var e=r.style.transform||"",t=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=t.exec(e);)n.set(i[1],i[2]);return n}}function S2(r,e,t,n){var i=Vc(e,"scale")?1:0+w2(e),s=b0(r).get(e)||i;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),n?Cm(r,s,n):s}function Im(r,e,t,n){switch(Lm(r,e)){case"transform":return S2(r,e,n,t);case"css":return x0(r,e,t);case"attribute":return gr(r,e);default:return r[e]||0}}function Pm(r,e){var t=/^(\*=|\+=|-=)/.exec(r);if(!t)return r;var n=Gr(r)||0,i=parseFloat(e),s=parseFloat(r.replace(t[0],""));switch(t[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function w0(r,e){if(qe.col(r))return b2(r);if(/\s/g.test(r))return r;var t=Gr(r),n=t?r.substr(0,r.length-t.length):r;return e?n+e:n}function Dm(r,e){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function M2(r){return Math.PI*2*gr(r,"r")}function A2(r){return gr(r,"width")*2+gr(r,"height")*2}function _2(r){return Dm({x:gr(r,"x1"),y:gr(r,"y1")},{x:gr(r,"x2"),y:gr(r,"y2")})}function S0(r){for(var e=r.points,t=0,n,i=0;i0&&(t+=Dm(n,s)),n=s}return t}function T2(r){var e=r.points;return S0(r)+Dm(e.getItem(e.numberOfItems-1),e.getItem(0))}function M0(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return M2(r);case"rect":return A2(r);case"line":return _2(r);case"polyline":return S0(r);case"polygon":return T2(r)}}function E2(r){var e=M0(r);return r.setAttribute("stroke-dasharray",e),e}function N2(r){for(var e=r.parentNode;qe.svg(e)&&qe.svg(e.parentNode);)e=e.parentNode;return e}function A0(r,e){var t=e||{},n=t.el||N2(r),i=n.getBoundingClientRect(),s=gr(n,"viewBox"),o=i.width,a=i.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function C2(r,e){var t=qe.str(r)?y0(r)[0]:r,n=e||100;return function(i){return{property:i,el:t,svg:A0(t),totalLength:M0(t)*(n/100)}}}function L2(r,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return r.el.getPointAtLength(l)}var n=A0(r.el,r.svg),i=t(),s=t(-1),o=t(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function _0(r,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=w0(qe.pth(r)?r.totalLength:r,e)+"";return{original:n,numbers:n.match(t)?n.match(t).map(Number):[0],strings:qe.str(r)||e?n.split(t):[]}}function T0(r){var e=r?Xh(qe.arr(r)?r.map(v0):v0(r)):[];return Jh(e,function(t,n,i){return i.indexOf(t)===n})}function E0(r){var e=T0(r);return e.map(function(t,n){return{target:t,id:n,total:e.length,transforms:{list:b0(t)}}})}function I2(r,e){var t=Tm(e);if(/^spring/.test(t.easing)&&(t.duration=m0(t.easing)),qe.arr(r)){var n=r.length,i=n===2&&!qe.obj(r[0]);i?r={value:r}:qe.fnc(e.duration)||(t.duration=e.duration/n)}var s=qe.arr(r)?r:[r];return s.map(function(o,a){var l=qe.obj(o)&&!qe.pth(o)?o:{value:o};return qe.und(l.delay)&&(l.delay=a?0:e.delay),qe.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return qh(o,t)})}function P2(r){for(var e=Jh(Xh(r.map(function(s){return Object.keys(s)})),function(s){return qe.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},n=function(s){var o=e[s];t[o]=r.map(function(a){var l={};for(var c in a)qe.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},i=0;i-1&&(li.splice(o,1),n=li.length)}i++}r()}else Yh=cancelAnimationFrame(Yh)}return r}();function U2(){document.hidden?(li.forEach(function(r){return r.pause()}),P0=li.slice(0),un.running=li=[]):P0.forEach(function(r){return r.play()})}typeof document!="undefined"&&document.addEventListener("visibilitychange",U2);function un(r){r===void 0&&(r={});var e=0,t=0,n=0,i,s=0,o=null;function a(x){var b=window.Promise&&new Promise(function(w){return o=w});return x.finished=b,b}var l=z2(r),c=a(l);function u(){var x=l.direction;x!=="alternate"&&(l.direction=x!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,i.forEach(function(b){return b.reversed=l.reversed})}function h(x){return l.reversed?l.duration-x:x}function d(){e=0,t=h(l.currentTime)*(1/un.speed)}function f(x,b){b&&b.seek(x-b.timelineOffset)}function p(x){if(l.reversePlayback)for(var w=s;w--;)f(x,i[w]);else for(var b=0;b2||(W=Math.round(W*G)/G)),B.push(W)}var K=R.length;if(!K)ne=B[0];else{ne=R[0];for(var q=0;q0&&(l.began=!0,v("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,v("loopBegin")),S<=w&&l.currentTime!==0&&m(0),(S>=_&&l.currentTime!==b||!b)&&m(b),S>w&&S<_?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,v("changeBegin")),v("change"),m(S)):l.changeBegan&&(l.changeCompleted=!0,l.changeBegan=!1,v("changeComplete")),l.currentTime=mr(S,0,b),l.began&&v("update"),x>=b&&(t=0,g(),l.remaining?(e=n,v("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&u()):(l.paused=!0,l.completed||(l.completed=!0,v("loopComplete"),v("complete"),!l.passThrough&&"Promise"in window&&(o(),c=a(l)))))}return l.reset=function(){var x=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=x==="reverse",l.remaining=l.loop,i=l.children,s=i.length;for(var b=s;b--;)l.children[b].reset();(l.reversed&&l.loop!==!0||x==="alternate"&&l.loop===1)&&l.remaining++,m(l.reversed?l.duration:0)},l.set=function(x,b){return C0(x,b),l},l.tick=function(x){n=x,e||(e=n),y((n+(t-e))*un.speed)},l.seek=function(x){y(h(x))},l.pause=function(){l.paused=!0,d()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,li.push(l),d(),Yh||G2())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function D0(r,e){for(var t=e.length;t--;)_m(r,e[t].animatable.target)&&e.splice(t,1)}function k2(r){for(var e=T0(r),t=li.length;t--;){var n=li[t],i=n.animations,s=n.children;D0(e,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;D0(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function V2(r,e){e===void 0&&(e={});var t=e.direction||"normal",n=e.easing?Am(e.easing):null,i=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",c=o==="last",u=qe.arr(r),h=parseFloat(u?r[0]:r),d=u?parseFloat(r[1]):0,f=Gr(u?r[1]:r)||0,p=e.start||0+(u?h:0),m=[],v=0;return function(g,y,x){if(a&&(o=0),l&&(o=(x-1)/2),c&&(o=x-1),!m.length){for(var b=0;b-1&&li.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;aa.id===e.id);o==null||o.copy(e)}pushMaterialLayer(e){if(this.i.states.length===0||ai(this.i.object)===!1)return;let t=this.i.object;if(t.material instanceof Array){let n=t.selectedMaterial;if(n!==void 0)for(let i=0,s=this.i.states.length;i{let l=a.count,c=new we,u=new Float32Array(l*3),h=new Float32Array(l*3),d=new Float32Array(l*2);for(let f=0;f255?32:i}return e.buffer}function Y2(r){return Wc(r.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function K2(r,e,t){let n={min:new Array(r.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(r.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i4?o=r.array[i*r.itemSize+s]:s===0?o=r.getX(i):s===1?o=r.getY(i):s===2?o=r.getZ(i):s===3&&(o=r.getW(i)),n.min[s]=Math.min(n.min[s],o),n.max[s]=Math.max(n.max[s],o)}return n}function z0(r){return Math.ceil(r/4)*4}function Bm(r,e=0){let t=z0(r.byteLength);if(t!==r.byteLength){let n=new Uint8Array(t);if(n.set(new Uint8Array(r)),e!==0)for(let i=r.byteLength;i0&&(this.options.trs=!0),this.processInput(e);let i=this;Promise.all(this.pending).then(function(){let s=i.buffers,o=i.json,a=i.options,l=i.extensionsUsed,c=new Blob(s,{type:"application/octet-stream"}),u=Object.keys(l);if(u.length>0&&(o.extensionsUsed=u),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),a.binary===!0){let h=new window.FileReader;h.readAsArrayBuffer(c),h.onloadend=function(){let d=Bm(h.result),f=new DataView(new ArrayBuffer(F0));f.setUint32(0,d.byteLength,!0),f.setUint32(4,X2,!0);let p=Bm(q2(JSON.stringify(o)),32),m=new DataView(new ArrayBuffer(F0));m.setUint32(0,p.byteLength,!0),m.setUint32(4,J2,!0);let v=new ArrayBuffer(O0),g=new DataView(v);g.setUint32(0,j2,!0),g.setUint32(4,W2,!0);let y=O0+m.byteLength+p.byteLength+f.byteLength+d.byteLength;g.setUint32(8,y,!0);let x=new Blob([v,m,p,f,d],{type:"application/octet-stream"}),b=new window.FileReader;b.readAsArrayBuffer(x),b.onloadend=function(){t(b.result)}}}else if(o.buffers&&o.buffers.length>0){let h=new window.FileReader;h.readAsDataURL(c),h.onloadend=function(){let d=h.result;o.buffers[0].uri=d,t(o)}}else t(o)})}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,i=this.extensionsUsed;try{let s=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],i[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new M;for(let i=0,s=e.count;i5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new M;for(let s=0,o=n.count;s4?m=e.array[f*e.itemSize+p]:p===0?m=e.getX(f):p===1?m=e.getY(f):p===2?m=e.getZ(f):p===3&&(m=e.getW(f)),t===Et.FLOAT?c.setFloat32(u,m,!0):t===Et.UNSIGNED_INT?c.setUint32(u,m,!0):t===Et.UNSIGNED_SHORT?c.setUint16(u,m,!0):t===Et.UNSIGNED_BYTE&&c.setUint8(u,m),u+=a}let h={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return s!==void 0&&(h.target=s),s===Et.ARRAY_BUFFER&&(h.byteStride=e.itemSize*a),this.byteOffset+=l,o.bufferViews.push(h),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(i){let s=new window.FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){let o=Bm(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,i(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,i){let s=this.options,o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"},l;if(e.array.constructor===Float32Array)l=Et.FLOAT;else if(e.array.constructor===Uint32Array)l=Et.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)l=Et.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)l=Et.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(n===void 0&&(n=0),i===void 0&&(i=e.count),s.truncateDrawRange&&t!==void 0&&t.index===null){let f=n+i,p=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;n=Math.max(n,t.drawRange.start),i=Math.min(f,p)-n,i<0&&(i=0)}if(i===0)return null;let c=K2(e,n,i),u;t!==void 0&&(u=e===t.index?Et.ELEMENT_ARRAY_BUFFER:Et.ARRAY_BUFFER);let h=this.processBufferView(e,l,n,i,u),d={bufferView:h.id,byteOffset:h.byteOffset,componentType:l,count:i,max:c.max,min:c.min,type:a[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(d)-1}processImage(e,t,n){let i=this,s=i.cache,o=i.json,a=i.options,l=i.pending;s.images.has(e)||s.images.set(e,{});let c=s.images.get(e),u=t===zt?"image/png":"image/jpeg",h=u+":flipY/"+n.toString();if(c[h]!==void 0)return c[h];o.images||(o.images=[]);let d={mimeType:u};if(a.embedImages){let p=G0=G0||document.createElement("canvas");p.width=Math.min(e.width,a.maxTextureSize),p.height=Math.min(e.height,a.maxTextureSize);let m=p.getContext("2d");if(n===!0&&(m.translate(0,p.height),m.scale(1,-1)),typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)m.drawImage(e,0,0,p.width,p.height);else{t!==zt&&t!==Nt&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let v=new Uint8ClampedArray(e.height*e.width*4);if(t===zt)for(let g=0;g1&&(a.multiplyScalar(1/l),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),l>0&&(i.emissiveFactor=a.toArray()),e.emissiveMap){let c={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(c,e.emissiveMap),i.emissiveTexture=c}}if(e.normalMap){let a={index:this.processTexture(e.normalMap)};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){let a={index:this.processTexture(e.aoMap),texCoord:1};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===Xt&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});let o=n.materials.push(i)-1;return t.materials.set(e,o),o}processMesh(e){let t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let x=0,b=e.material.length;x0){let x=[],b=[],w={};if(e.morphTargetDictionary!==void 0)for(let _ in e.morphTargetDictionary)w[e.morphTargetDictionary[_]]=_;for(let _=0;_0&&(l.extras={},l.extras.targetNames=b)}let m=Array.isArray(e.material);if(m&&o.groups.length===0)return null;let v=m?e.material:[e.material],g=m?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let x=0,b=g.length;x0&&(w.targets=h),o.index!==null){let S=this.getUID(o.index);(g[x].start!==void 0||g[x].count!==void 0)&&(S+=":"+g[x].start+":"+g[x].count),t.attributes.has(S)?w.indices=t.attributes.get(S):(w.indices=this.processAccessor(o.index,o,g[x].start,g[x].count),t.attributes.set(S,w.indices)),w.indices===null&&delete w.indices}let _=this.processMaterial(v[g[x].materialIndex]);_!==null&&(w.material=_),u.push(w)}l.primitives=u,n.meshes||(n.meshes=[]),this._invokeAll(function(x){x.writeMesh&&x.writeMesh(e,l)});let y=n.meshes.push(l)-1;return t.meshes.set(s,y),y}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:Ee.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]),e=jc.Utils.mergeMorphTargetTracks(e.clone(),t);let s=e.tracks,o=[],a=[];for(let l=0;l0){let a=[];for(let l=0,c=e.children.length;l0&&(s.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,s)});let o=t.nodes.push(s)-1;return i.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let i={};e.name!==""&&(i.name=e.name),t.scenes.push(i);let s=[];for(let o=0,a=e.children.length;o0&&(i.nodes=s),this.serializeUserData(e,i)}processObjects(e){let t=new An;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let i=0;i0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},s[this.name]=!0);let a=i.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},V0=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},H0=class{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;let n=this.writer,i=n.extensionsUsed,s={};t.pbrMetallicRoughness.baseColorFactor&&(s.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);let o=[1,1,1];if(e.specular.toArray(o,0),s.specularFactor=o,s.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(s.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){let a={index:n.processTexture(e.specularMap)};n.applyTextureTransform(a,e.specularMap),s.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}},j0=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,i=n.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){let o={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}},W0=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.thickness===0)return;let n=this.writer,i=n.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){let o={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationTint.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,i[this.name]=!0}};jc.Utils={insertKeyframe:function(r,e){let t=.001,n=r.getValueSize(),i=new r.TimeBufferType(r.times.length+1),s=new r.ValueBufferType(r.values.length+n),o=r.createInterpolant(new r.ValueBufferType(n)),a;if(r.times.length===0){i[0]=e;for(let l=0;lr.times[r.times.length-1]){if(Math.abs(r.times[r.times.length-1]-e)e){i.set(r.times.slice(0,l+1),0),i[l+1]=e,i.set(r.times.slice(l+1),l+2),s.set(r.values.slice(0,(l+1)*n),0),s.set(o.evaluate(e),(l+1)*n),s.set(r.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return r.times=i,r.values=s,a},mergeMorphTargetTracks:function(r,e){let t=[],n={},i=r.tracks;for(let s=0;sl.arrayBuffer())]),o=new r,a=await i({wasmBinary:s});return o.registerExtensions(e).registerDependencies({"draco3d.encoder":a}),Kh=o,Qh=t,Zh=n({tolerance:1e-4}),{gltfTransform:Kh,DracoMeshCompressionExtension:Qh,addIndex:Zh}}var vS=Cg(Y0());var rI=typeof global=="object"&&global&&global.Object===Object&&global,ed=rI;var sI=typeof self=="object"&&self&&self.Object===Object&&self,oI=ed||sI||Function("return this")(),en=oI;var aI=en.Symbol,Zn=aI;var K0=Object.prototype,lI=K0.hasOwnProperty,cI=K0.toString,Jc=Zn?Zn.toStringTag:void 0;function uI(r){var e=lI.call(r,Jc),t=r[Jc];try{r[Jc]=void 0;var n=!0}catch(s){}var i=cI.call(r);return n&&(e?r[Jc]=t:delete r[Jc]),i}var Q0=uI;var hI=Object.prototype,dI=hI.toString;function fI(r){return dI.call(r)}var Z0=fI;var pI="[object Null]",mI="[object Undefined]",$0=Zn?Zn.toStringTag:void 0;function gI(r){return r==null?r===void 0?mI:pI:$0&&$0 in Object(r)?Q0(r):Z0(r)}var er=gI;function yI(r){return r!=null&&typeof r=="object"}var $n=yI;var vI="[object Symbol]";function xI(r){return typeof r=="symbol"||$n(r)&&er(r)==vI}var tr=xI;function bI(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t-1&&r%1==0&&r-1&&r%1==0&&r<=pP}var ll=mP;function gP(r){return r!=null&&ll(r.length)&&!nd(r)}var Ss=gP;var yP=Object.prototype;function vP(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||yP;return r===t}var cl=vP;function xP(r,e){for(var t=-1,n=Array(r);++t-1}var Ob=GD;function UD(r,e){var t=this.__data__,n=As(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var Fb=UD;function fl(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ea))return!1;var c=s.get(r),u=s.get(e);if(c&&u)return c==e&&u==r;var h=-1,d=!0,f=t&rO?new zw:void 0;for(s.set(r,e),s.set(e,r);++h=e||S<0||h&&A>=s}function g(){var _=Nd();if(v(_))return y(_);a=setTimeout(g,m(_))}function y(_){return a=void 0,d&&n?f(_):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,n=l=i=a=void 0}function b(){return a===void 0?o:y(Nd())}function w(){var _=Nd(),S=v(_);if(n=arguments,i=this,l=_,S){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(g,e),f(l)}return a===void 0&&(a=setTimeout(g,e)),o}return w.cancel=x,w.flush=b,w}var Wm=t3;function n3(r,e){var t=-1,n=Ss(r)?Array(r.length):[];return dS(r,function(i,s,o){n[++t]=e(i,s,o)}),n}var fS=n3;function i3(r,e){var t=r.length;for(r.sort(e);t--;)r[t]=r[t].value;return r}var pS=i3;function r3(r,e){if(r!==e){var t=r!==void 0,n=r===null,i=r===r,s=tr(r),o=e!==void 0,a=e===null,l=e===e,c=tr(e);if(!a&&!c&&!s&&r>e||s&&o&&l&&!a&&!c||n&&o&&l||!t&&l||!i)return 1;if(!n&&!s&&!c&&r=a)return l;var c=t[n];return l*(c=="desc"?-1:1)}}return r.index-e.index}var gS=s3;function o3(r,e,t){e.length?e=ol(e,function(s){return Jt(s)?function(o){return ml(o,s.length===1?s[0]:s)}:s}):e=[td];var n=-1;e=ol(e,Ms(aS));var i=fS(r,function(s,o,a){var l=ol(e,function(c){return c(s)});return{criteria:l,index:++n,value:s}});return pS(i,function(s,o){return gS(s,o,t)})}var yS=o3;function a3(r,e,t,n){return r==null?[]:(Jt(e)||(e=e==null?[]:[e]),t=n?void 0:t,Jt(t)||(t=t==null?[]:[t]),yS(r,e,t))}var Jm=a3;var Cd={isPublish:!1,gltfQueue:[]};function Yc(r,e,t){return r[e.uuid]===void 0&&(r[e.uuid]=e.toJSON(t)),e.uuid}var l3=new jc;function xS(r,e,t){if(r[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(Cd.isPublish)e=Lo.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let i=e.originalGeometry;if(i){let s=e.userData;e=i.clone(),e.userData=s}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let n=e.originalGeometry;if(n!==void 0){let i=e.userData;e=n,e.userData=i}if(!Cd.isPublish)r[e.uuid]=e.toJSON();else{let i={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(i.name=e.name),Object.keys(e.userData).length>0&&(i.userData=Ue({},e.userData));let s=e.index===null,o=new Jn;if(Array.isArray(t))R0(e).forEach((l,c)=>{let u=new gt(l,new Xi);o.add(u),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(s=!0)});else{let a=new gt(e,new Xi);o.add(a)}Cd.gltfQueue.push(new Promise(async a=>{await Promise.all(Cd.gltfQueue),l3.parse(o,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:u,addIndex:h}=await J0(),d=c.readJSON({json:Hm(l),resources:{}});d.createExtension(u).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),s&&await d.transform(h);try{let{json:f,resources:p}=c.writeJSON(d),m=vS.default.fromByteArray(new Uint8Array(p[".bin"]));f.buffers[0].uri=`data:application/octet-stream;base64,${m}`,i.gltf=f,a()}catch(f){i.gltf=l,a()}},{})})),r[e.uuid]=i}}else{let n=e.userData;if(n.type==="VectorGeometry"){let i=e.userData.shape;n=Object.assign({},n,{shape:i.toJSON()})}r[e.uuid]={uuid:e.uuid,userData:n}}return e.uuid}function bl(r){let e=[];for(let t in r){let n=r[t];delete n.metadata,e.push(n)}return e}function bS(r){let e=[];for(let t in r)e.push(r[t]);return e}var Is=class{constructor(e){this.object=e;this.uuid=Ee.generateUUID();this.states=[];this.events=[];this._interpolateMaterialBetweenValues=(e,t,n,i=t.getNames())=>{var s,o,a,l,c;for(let u=0,h=i.length;u{var c,u,h;let i=e.layersList;if(t.backLayer===void 0){let d=n.getValues();d.alpha=0,t.backLayer=i.addLayerBeforeAt(d,t),t.backLayer.isBack=!0,e.dispose()}let s=`f${t.id}_alpha`,o=`f${(c=t.backLayer)==null?void 0:c.id}_alpha`,a=t.uniforms[s],l=(u=t.backLayer)==null?void 0:u.uniforms[o];(h=this._animation)==null||h.add({targets:a,value:0},0).add({targets:l,value:n.uniforms[`f${n.id}_alpha`].value},0)};this._interpolateMaterialTexture=(e,t,n)=>{var d;let i=`f${t.id}_texture`,s=t.uniforms[i].value,o=n.uniforms[`f${n.id}_texture`].value,a=t.uniforms[`f${t.id}_crop`],l=n.uniforms[`f${n.id}_crop`];a&&l&&a.value!==l.value&&(a.value=Number(l.value)),(s.wrapS!==o.wrapS||s.wrapT!==o.wrapT)&&(s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.needsUpdate=!0);let c=s.matrix,u=o.matrix;if(c.equals(u)===!1){let f={repeatX:s.repeat.x,repeatY:s.repeat.y,offsetX:s.offset.x,offsetY:s.offset.y};(d=this._animation)==null||d.add({targets:f,repeatX:o.repeat.x,repeatY:o.repeat.y,offsetX:o.offset.x,offsetY:o.offset.y,update:()=>{s.repeat.set(f.repeatX,f.repeatY),s.offset.set(f.offsetX,f.offsetY),s.updateMatrix(),s.needsUpdate=!0}},0)}let h=["alpha","mode"];t.type==="displace_map"&&h.push("intensity"),this._interpolateMaterialBetweenValues(e,t,n,h)};this._interpolateMaterialGradient=(e,t,n)=>{var p;let i=t.uniforms[`f${t.id}_num`],s=n.uniforms[`f${n.id}_num`],o=`f${t.id}_steps`,a=`f${n.id}_steps`,l=t.uniforms[o],c=n.uniforms[a],u=`f${t.id}_colors`,h=`f${n.id}_colors`,d=t.uniforms[u],f=n.uniforms[h];if(i.value<=s.value){let m=d.value[i.value-1];for(let v=Number(i.value);v{l.value[v]=x.value}},0)}}}else{let m=[];for(let g=0;g{var _;(_=this._animation)==null||_.add({targets:[b,y],value:c.value[g],x:x.x,y:x.y,z:x.z,w:x.w,update:()=>{l.value[g]=b.value},complete:()=>{w(g)}},0)}))}}let v=f.value[s.value-1];for(let g=Number(s.value);g{var w;let b={value:l.value[g]};(w=this._animation)==null||w.add({targets:[b,y],value:1,x:v.x,y:v.y,z:v.z,w:v.w,update:()=>{l.value[g]=b.value},complete:()=>{x(g)}},0)}))}Promise.all(m).then(()=>{i.value=Number(s.value)},()=>{})}this._interpolateMaterialBetweenValues(e,t,n,["alpha","mode","gl_type","smooth","offset","morph","angle"])};this.statesManager=new Rm(this)}static get isAllAnimationsEnded(){let e;for(let t in Is.isAnimating){if(Is.isAnimating[t])return!1;e=!0}return e}computeCache(){return this.cache={mouseDown:this.events.find(e=>e.type===Ze.MOUSE_DOWN),mouseUp:this.events.find(e=>e.type===Ze.MOUSE_UP),mouseHover:this.events.find(e=>e.type===Ze.MOUSE_HOVER),start:this.events.find(e=>e.type===Ze.START),lookAt:this.events.find(e=>e.type===Ze.LOOK_AT),follow:this.events.find(e=>e.type===Ze.FOLLOW),keyDown:this.events.filter(e=>e.type===Ze.KEY_DOWN),keyUp:this.events.filter(e=>e.type===Ze.KEY_UP)},this.cache}newState(e){let t=new bs;return t.name=e,t.update(this.object),this.selectedState=this.states.length,this.states.push(t),t}addState(e,t){this.states.splice(t,0,e)}removeState(e){this.selectedState===e&&(this.selectedState=void 0),this.states.splice(e,1)}selectState(e){e!==void 0&&this.states[e].execute(this.object),this.selectedState=e}hasEventType(e,t){return e===Ze.KEY_DOWN||e===Ze.KEY_UP?t===void 0?!1:this.events.some(n=>n.type===e&&n.key===t):this.events.some(n=>n.type===e)}newEvent(){let e=[Ze.MOUSE_DOWN,Ze.MOUSE_UP,Ze.MOUSE_HOVER,Ze.KEY_DOWN].find(n=>this.hasEventType(n)===!1),t=new sl(e);return this.events.push(t),t}addEvent(e,t){this.events.splice(t,0,e);let n=this.events[t].targets;for(let i=0,s=n.length;i0){t.states=[];for(let n=0,i=this.states.length;n0){t.events=[];for(let n=0,i=this.events.length;n1?(this.states[0].execute(this.object),this._currentState=this.states[0],this._prevState=void 0):this._state0!==void 0?this._state0.execute(this.object):this.events.some(e=>e.type===Ze.LOOK_AT||e.type===Ze.FOLLOW)&&(this._state0=new bs,this._state0.update(this.object))}end(){var e;this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._removeBackLayer()),this.states.length>1?this.states[(e=this.selectedState)!=null?e:0].execute(this.object):this._state0!==void 0&&(this._state0.execute(this.object),this._state0=void 0),this._currentState=void 0,this._prevState=void 0}lookAt(e){var t;this.object.lookAt(e),(t=this._animation)==null||t.finished.then(()=>{this.lookAt(e)})}follow(e){this.object.position.copy(e),this.object.parent!==null&&this.object.position.applyMatrix4(new me().copy(this.object.parent.matrixWorld).invert()),this.object.position.applyMatrix4(new me().copy(this.object.hiddenMatrix).invert())}play(e){this.object.visible&&e.state!==void 0&&this.animate(e.state,e)}reverse(e){this.object.visible&&this._prevState!==void 0&&this.animate(this._prevState,e)}_removeBackLayer(){if("material"in this.object){let e=this.object.material;if(e instanceof Array)for(let t=0,n=e.length;t{this._removeBackLayer(),this._animation=void 0,Is.isAnimating[e.uuid]=!1}),this.animateMatrix(e),this.animateGeometry(e),this.animateMaterial(e),this.animateCamera(e)}animateMatrix(e){var s,o,a,l;if(this.object.position.equals(e.position)===!1){let c=this.object.position.clone(),u={t:0};(s=this._animation)==null||s.add({targets:u,t:1,update:()=>{this.object.position.lerpVectors(c,e.position,u.t)}},0)}if(this.object.scale.equals(e.scale)===!1){let c=this.object.scale.clone(),u={t:0};(o=this._animation)==null||o.add({targets:u,t:1,update:()=>{this.object.scale.lerpVectors(c,e.scale,u.t)}},0)}if(this.object.rotation.equals(e.rotation)===!1){let c=this.object.quaternion.clone(),u={t:0},h={x:this.object.rotation.x-e.rotation.x,y:this.object.rotation.y-e.rotation.y,z:this.object.rotation.z-e.rotation.z},d=e.rotation.clone(),f=.01*Ee.DEG2RAD,p=359.99*Ee.DEG2RAD;h.x===Math.PI*2?d.x===0?d.x=f:d.x===Math.PI*2&&(d.x=p):h.x===-Math.PI*2&&(d.x===0?d.x=-f:d.x===Math.PI*2&&(d.x=-p)),h.y===Math.PI*2?d.y===0?d.y=f:d.y===Math.PI*2&&(d.y=p):h.y===-Math.PI*2&&(d.y===0?d.y=-f:d.y===Math.PI*2&&(d.y=-p)),h.z===Math.PI*2?d.z===0?d.z=f:d.z===Math.PI*2&&(d.z=p):h.z===-Math.PI*2&&(d.z===0?d.z=-f:d.z===Math.PI*2&&(d.z=-p));let m=new Tt().setFromEuler(d);(a=this._animation)==null||a.add({targets:u,t:1,update:()=>{wm(c,m,this.object.quaternion,u.t)}},0)}let t=new M,n=new Tt,i=new M;if(e.hiddenMatrix.decompose(t,n,i),"hiddenMatrix"in this.object){let c=new M,u=new Tt,h=new M;if(this.object.hiddenMatrix.decompose(c,u,h),this.object.hiddenMatrix.equals(e.hiddenMatrix)===!1){let d=new M,f=new Tt,p=new M,m={t:0},v=this.object.hiddenMatrix;(l=this._animation)==null||l.add({targets:m,t:1,update:()=>{f.slerpQuaternions(u,n,m.t),d.lerpVectors(c,t,m.t),p.lerpVectors(h,i,m.t),v.compose(d,f,p)}},0)}}}animateGeometry(e){var t;if("geometry"in this.object&&e.geometry!==void 0){let i=this.object.geometry.userData.parameters,s=e.geometry;if(s.width!==i.width||s.height!==i.height||s.depth!==i.depth){let o=this.object;(t=this._animation)==null||t.add({targets:i,width:s.width,height:s.height,depth:s.depth,update:()=>{o.updateGeometry({parameters:{width:i.width,height:i.height,depth:i.depth}})}},0)}}}animateMaterial(e){if("material"in this.object)if(this.object.material instanceof Array)for(let t=0,n=this.object.material.length;t{i.updateProjectionMatrix()}},0)),i.targetOffset!==e.camera.targetOffset&&((n=this._animation)==null||n.add({targets:i,targetOffset:e.camera.targetOffset},0))}}},Ls=Is;Ls.isAnimating={};var Ld=r=>class extends r{hasEntityChild(){return this.children.some(t=>Vh(t))}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Vh(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!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.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.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i0){s.children=[];for(let o of this.children)(Vh(o)||o instanceof vi)&&s.children.push(o.toJSON(t).object)}if(n){let o=bl(t.geometries),a=bl(t.materials),l=bl(t.textures),c=bl(t.images),u=bl(t.interactionStates),h=bS(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),u.length>0&&(i.interactionStates=u),h.length>0&&(i.nodes=h)}return i.object=s,i}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var ei=r=>"isEntity"in r,wS=r=>"isAbstractMesh"in r,Xm=r=>"objectHelper"in r,Ii=r=>class extends Ld(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new me;this.interaction=new Ls(this);this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let n of this.children)ei(n)&&n.traverseEntity(i=>{Xm(i)&&i.visible&&(i.objectHelper.visible=t)})}get visibility(){return this.visible}get interactionCache(){return this.interaction.cache===void 0&&this.interaction.computeCache(),this.interaction.cache}traverseEntity(t){t(this);for(let n of this.children)ei(n)&&n.traverseEntity(t)}computeSingleBoundingBox(){this.singleBoundingBox||(this.singleBoundingBox=new jh),this.singleBoundingBox.setFromObjectSize(this,!1),this.singleBoundingBox.computeVertices(),this.singleBoundingBox.computeEdges(),this.singleBoundingBox.computeFaces()}computeComplexBoundingBox(t){this.complexBoundingBox||(this.complexBoundingBox=new jh),this.complexBoundingBox.setFromObjectSize(this,t),this.complexBoundingBox.computeVertices(),this.complexBoundingBox.computeEdges(),this.complexBoundingBox.computeFaces()}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let n of this.children)n.updateMatrixWorld(t)}updateWorldMatrix(t,n){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),n)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,n=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),t.interaction!==void 0&&this.interaction.copy(t.interaction),n===!0)for(let i of t.children)ei(i)&&this.add(i.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,n=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),t.interaction!==void 0&&this.interaction.copy(t.interaction),n===!0)for(let i of t.children)ei(i)&&this.add(i.clone());return this}keepChildrenMatrixWorld(){let t=new me,n=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(n);for(let i of this.children)ei(i)&&i.hiddenMatrix.premultiply(t)}toJSON(t){let n=super.toJSON(t),i=n.object;return this.raycastLock===!0&&(i.raycastLock=!0),this.scaleLock===!0&&(i.scaleLock=!0),i.hiddenMatrix=this.hiddenMatrix.toArray(),this.interaction!==void 0&&(i.interaction=this.interaction.toJSON(t)),n}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let n=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new me}),this.copy(t),t.children=n,this}};var Id=class extends Ke{constructor(e,t={}){super();this.object=e,e.computeComplexBoundingBox(!0);let n=e.complexBoundingBox.getSize(new M),i=.1;this.parameters={type:t.type!==void 0?t.type:"radial",hideBase:t.hideBase!==void 0?t.hideBase:!1,count:t.count!==void 0?t.count:3,ra_radius:t.ra_radius!==void 0?t.ra_radius:Math.max(n.x,n.y)*2,ra_startAngle:t.ra_startAngle!==void 0?t.ra_startAngle:0,ra_endAngle:t.ra_endAngle!==void 0?t.ra_endAngle:360,ra_align:t.ra_align!==void 0?t.ra_align:!1,ra_axis:t.ra_axis!==void 0?t.ra_axis:"y",ra_scale:t.ra_scale!==void 0?t.ra_scale.clone():new M,ra_rotation:t.ra_rotation!==void 0?t.ra_rotation.clone():new On,ra_position:t.ra_position!==void 0?t.ra_position.clone():new M,li_scale:t.li_scale!==void 0?t.li_scale.clone():new M,li_rotation:t.li_rotation!==void 0?t.li_rotation.clone():new On,li_position:t.li_position!==void 0?t.li_position.clone():new M(n.x+n.x*i,0,0).round(),gr_count:t.gr_count!==void 0?t.gr_count.clone():new M(2,2,2),gr_size:t.gr_size!==void 0?t.gr_size.clone():new M(n.x+n.x*i,n.y+n.y*i,n.z+n.z*i).round(),gr_fromCenter:t.gr_fromCenter!==void 0?t.gr_fromCenter:!0},this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(n=>n.clone());for(let n of this.children)n.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let n of this.children)n.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.gr_count.x*this.parameters.gr_count.y*this.parameters.gr_count.z:this.parameters.count;if(this.children.length!==e)if(this.children.lengths.clone()):this.material.clone();return new this.constructor(n,i).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new Id(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),n=t.object;if(this.cloner!==void 0&&(n.cloner=this.cloner.toJSON()),n.geometry=xS(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let i=[];for(let s=0,o=this.material.length;s{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new jn(30,30,30),e};var qm=new or,Ym=new ti,SS=new me,br=(r,e,t,n)=>{let i=e,s=r.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ym.copy(i.boundingSphere),Ym.applyMatrix4(s),t.ray.intersectsSphere(Ym)===!1||(SS.copy(s).invert(),qm.copy(t.ray).applyMatrix4(SS),i.boundingBox!==null&&qm.intersectsBox(i.boundingBox)===!1))return;let o,a,l,c,u=i.index,h=i.attributes.position,d=i.drawRange,f,p,m=Math.max(0,d.start),v=Math.min(u.count,d.start+d.count);for(f=m,p=v;fx.far?null:{faceIndex:1,distance:G,point:P.clone(),object:y}}};var Kc=class extends xr(xi){constructor(e){super(e);this.object=e;let t=new Ji(15,4,2),n=new dn({wireframe:!0,fog:!1,toneMapped:!1}),i=new gt(t,n);this.add(i);let s=new Ji(15,4,2),o=new dn({wireframe:!0,fog:!1,toneMapped:!1,depthTest:!1,depthWrite:!1}),a=new gt(s,o);this.add(a),this.targetHelper=a,this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e),this.targetHelper.position.copy(e),this.targetHelper.updateWorldMatrix(!1,!0)}raycast(e,t){br(this.object,Kc.geometryHelper,e,t)}};var Qc=class extends xr(Bp){constructor(e,t=15,n=10066329){super(e,t,n);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){br(this.object,Qc.geometryHelper,e,t)}};var Zc=class extends xr(Op){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){br(this.object,Zc.geometryHelper,e,t)}update(){}};var $c=class extends xr(Rp){constructor(e,t=15,n=6710886){super(e,t,n);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){br(this.object,$c.geometryHelper,e,t)}};var Dd=class extends xr(Pp){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){br(this.object,Dd.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Dd._vector,t=this.object.distance?this.object.distance:1e3,n=t*Math.tan(this.object.angle);this.cone.scale.set(n,n,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,o=this.cone.material.length;s{if(this.geometry instanceof Rc){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.computeSingleBoundingBox(),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var n;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(n=this.shape.eventDispatcher)==null||n.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,n;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(n=this.shape.eventDispatcher)==null||n.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),_S.getNormalMatrix(this.matrixWorld),MS.copy(c3).applyMatrix3(_S).normalize(),AS.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(MS,AS)}clone(e){let t=this.shape.clone(),n=this.material.clone(),i=this.geometry.userData,s=Pn.create(Object.assign({},i,{shape:t})),o=new Ps(s,n).copy(this,e);return o.shape=t,t.update(),o}raycast(e,t){Vn.prototype.raycast.call(this,e,t)}};var wr=(r,e)=>class extends r{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(n){this.visible=n,this.setHelperVisibility(n),this.setHelperChildrenVisibility(n)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(n){this.objectHelper.visible=n}setHelperChildrenVisibility(n){for(let i of this.children)ei(i)&&i.traverseEntity(s=>{Xm(s)&&s.visible&&(s.objectHelper.visible=n)})}raycast(n,i){this.objectHelper.raycast(n,i)}copy(n,i=!0){return super.copy(n,i),n.enableHelper!==void 0&&(this.enableHelper=n.enableHelper),n.objectHelper!==void 0&&(this.objectHelper.visible=n.objectHelper.visible),this}toJSON(n){let i=super.toJSON(n),s=i.object;return s.enableHelper=this.enableHelper,i}fromJSON(n){return super.fromJSON(n),n.enableHelper!==void 0&&(this.enableHelper=!0),this}};var wl=new M,Km=new M,Qm=class extends wr(Ii(Dr),Kc){constructor(e=100,t=100,n=45,i=50,s=5e4){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Qm.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=window.innerWidth,this.height=window.innerHeight,this.orthoCamera=new Rr(e*-.5,e*.5,t*.5,t*-.5,i,s),this.perspCamera=new Vt(n,e/t,i,s),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}setDefault(){this.name="Default Camera",this.isEntity=!1,this.enableHelper=!1,this.objectHelper.visible=!1}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wl),this.targetOffset=wl.distanceTo(e)}getTarget(e=new M){return this.getWorldDirection(Km),this.getWorldPosition(wl),Km.multiplyScalar(this.targetOffset),e.copy(wl).add(Km),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wl),wl.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new Tt),t=new M(0,0,1).applyQuaternion(e),n=new M().copy(Ke.DefaultUp).applyQuaternion(e),i=new M().copy(Ke.DefaultUp).projectOnPlane(t),s=new M().crossVectors(i,n).dot(t)>=0?1:-1;this.angleOffsetFromUp=i.angleTo(n)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new M),i=e.getWorldDirection(new M).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToObject(e){let t=e.getWorldPosition(new M),i=this.getWorldDirection(new M).multiplyScalar(this.targetOffset);return{position:t.clone().sub(i),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,n,i,s,o){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,n,i,s,o):this.orthoCamera.setViewOffset(e,t,n,i,s,o)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},n={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.isEntity=!0,this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=n.near,this.perspCamera.far=n.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),n=t.object;return n.objectType="CombinedCamera",n.cameraType=this.cameraType,n.targetOffset=this.targetOffset,n.isUpVectorFlipped=this.isUpVectorFlipped,n.angleOffsetFromUp=this.angleOffsetFromUp,n.left=this.left,n.right=this.right,n.top=this.top,n.bottom=this.bottom,this.view!==null&&(n.view=Object.assign({},this.view)),n.zoomOrtho=this.orthoCamera.zoom,n.nearOrtho=this.orthoCamera.near,n.far=this.far,n.aspect=this.aspect,n.fov=this.fov,n.focus=this.focus,n.filmGauge=this.filmGauge,n.filmOffset=this.filmOffset,n.zoomPersp=this.perspCamera.zoom,n.nearPersp=this.perspCamera.near,t}fromJSON(e){var t,n;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let i=this.getWorldPosition(new M),s=new M().fromArray(e.orbitControlsTarget);this.targetOffset=s.distanceTo(i)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=(t=e.isUpVectorFlipped)!=null?t:!1,this.angleOffsetFromUp=(n=e.angleOffsetFromUp)!=null?n:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}},Sr=Qm;Sr.DefaultTargetOffset=1e3;var Pi=class extends wr(Ii(Jn),Zc){constructor(){super(...arguments);this.objectType="EmptyObject"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};var Rd=class extends wr(Ii(Fr),Qc){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=1,n.far=2500;let i=new xi(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof xi&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof xi&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof xi&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),n=t.object;return n.objectType="LightDirectional",n.color=this.color.getHex(),n.intensity=this.intensity,n.shadow=this.shadow.toJSON(),t}fromJSON(e){var i;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(i=e.shadow.normalBias)!=null?i:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,n=e.shadow.camera;return t.near=n.near,t.far=n.far,t.zoom=n.zoom,t.left=n.left,t.right=n.right,t.top=n.top,t.bottom=n.bottom,n.view!==void 0&&(t.view=Object.assign({},n.view)),this}};var Bd=class extends wr(Ii(xo),$c){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let i=new M(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new M(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),o=new tn(i,s),a=new Da(o,new fe(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Da&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Da&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Da){let n=this.shadow.camera,i=new M(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new M(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);t.box.set(i,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),n=t.object;return n.objectType="LightPoint",n.color=this.color.getHex(),n.intensity=this.intensity,n.distance=this.distance,n.decay=this.decay,n.shadow=this.shadow.toJSON(),t}fromJSON(e){var i,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(i=e.shadow.normalBias)!=null?i:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]);let t=this.shadow.camera,n=e.shadow.camera;return t.near=n.near,t.far=n.far,t.zoom=n.zoom,t.fov=n.fov,t.focus=n.focus,t.aspect=n.aspect,t.filmGauge=n.filmGauge,t.filmOffset=n.filmOffset,n.view!==void 0&&(t.view=Object.assign({},n.view)),this}};var TS=new M,ES=new M,NS=new Tt,Od=class extends wr(Ii(vo),Pd){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let n=this.shadow.camera;n.fov=Ee.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let i=new xi(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof xi&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof xi&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof xi&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),ES.setFromMatrixPosition(this.matrixWorld),NS.setFromRotationMatrix(this.matrixWorld),TS.copy(this.up).applyQuaternion(NS).negate().multiplyScalar(this.distance),this.target.position.copy(ES).add(TS),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),n=t.object;return n.objectType="LightSpot",n.color=this.color.getHex(),n.intensity=this.intensity,n.distance=this.distance,n.angle=this.angle,n.decay=this.decay,n.penumbra=this.penumbra,n.shadow=this.shadow.toJSON(),t}fromJSON(e){var i;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(i=e.shadow.normalBias)!=null?i:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,n=e.shadow.camera;return t.near=n.near,t.far=n.far,t.zoom=n.zoom,t.fov=n.fov,t.focus=n.focus,t.aspect=n.aspect,t.filmGauge=n.filmGauge,t.filmOffset=n.filmOffset,n.view!==void 0&&(t.view=Object.assign({},n.view)),this}};var CS=r=>r.tagName==="VIDEO",Sl=class{static resize(e,t,n){let i=e/t,s;if(!n.image)return;let o=n.image;CS(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*s/i):n.repeat.set(1,1*s/i)),is?o={x:1,y:s/i}:io&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t*o/s):n.repeat.set(1/e,1/t*o/s)),so&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*o/s):n.repeat.set(1,1*o/s)),s{let o=()=>{s({error:!0,filename:r.name}),e.itemError(r.name),e.itemEnd(r.name)};switch(n.addEventListener("loadstart",()=>{e.itemStart(r.name)}),n.addEventListener("load",a=>{var c;let l=(c=a.target)==null?void 0:c.result;l!=null?i(l):o()},!1),n.addEventListener("error",o),t){case 0:n.readAsText(r);break;case 2:n.readAsBinaryString!==void 0&&n.readAsBinaryString(r);break;case 1:default:n.readAsArrayBuffer(r)}})}var Zm=class extends fn{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new DS(t)}),this.register(function(t){return new zS(t)}),this.register(function(t){return new GS(t)}),this.register(function(t){return new RS(t)}),this.register(function(t){return new BS(t)}),this.register(function(t){return new OS(t)}),this.register(function(t){return new FS(t)}),this.register(function(t){return new IS(t)}),this.register(function(t){return new US(t)})}load(e,t,n,i){let s=this,o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Ei.extractUrlBase(e),this.manager.itemStart(e);let a=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Xn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,o,function(u){t(u),s.manager.itemEnd(e)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s,o={},a={};if(typeof e=="string")s=e;else if(Ei.decodeText(new Uint8Array(e,0,4))===kS){try{o[dt.KHR_BINARY_GLTF]=new HS(e)}catch(h){i&&i(h);return}s=o[dt.KHR_BINARY_GLTF].content}else s=Ei.decodeText(new Uint8Array(e));let l=JSON.parse(s);if(l.asset===void 0||l.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new $S(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}};function u3(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}var dt={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_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",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",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"},IS=class{constructor(e){this.parser=e,this.name=dt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o,a)}},GS=class{constructor(e){this.parser=e,this.name=dt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=i.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,a,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},US=class{constructor(e){this.name=dt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([s,o.ready]).then(function(a){let l=i.byteOffset||0,c=i.byteLength||0,u=i.count,h=i.byteStride,d=new ArrayBuffer(u*h),f=new Uint8Array(a[0],l,c);return o.decodeGltfBuffer(new Uint8Array(d),u,h,f,i.mode,i.filter),d})}else return null}},kS="glTF",eu=12,VS={JSON:1313821514,BIN:5130562},HS=class{constructor(e){this.name=dt.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,eu);if(this.header={magic:Ei.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==kS)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let n=this.header.length-eu,i=new DataView(e,eu),s=0;for(;s",t).replace("#include ",n).replace("#include ",i).replace("#include ",s).replace("#include ",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(l){a.specular.value=l}},specularMap:{get:function(){return a.specularMap.value},set:function(l){a.specularMap.value=l,l?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(l){a.glossiness.value=l}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(l){a.glossinessMap.value=l,l?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}},JS=class{constructor(){this.name=dt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return zd}extendParams(e,t,n){let i=t.extensions[this.name];e.color=new fe(1,1,1),e.opacity=1;let s=[];if(Array.isArray(i.diffuseFactor)){let o=i.diffuseFactor;e.color.fromArray(o),e.opacity=o[3]}if(i.diffuseTexture!==void 0&&s.push(n.assignTexture(e,"map",i.diffuseTexture)),e.emissive=new fe(0,0,0),e.glossiness=i.glossinessFactor!==void 0?i.glossinessFactor:1,e.specular=new fe(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),i.specularGlossinessTexture!==void 0){let o=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",o)),s.push(n.assignTexture(e,"specularMap",o))}return Promise.all(s)}createMaterial(e){let t=new zd(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=Qr,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}},XS=class{constructor(){this.name=dt.KHR_MESH_QUANTIZATION}},Oo=class extends qi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}};Oo.prototype.beforeStart_=Oo.prototype.copySampleValue_;Oo.prototype.afterEnd_=Oo.prototype.copySampleValue_;Oo.prototype.interpolate_=function(r,e,t,n){let i=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,l=o*3,c=n-e,u=(t-e)/c,h=u*u,d=h*u,f=r*l,p=f-l,m=-2*d+3*h,v=d-h,g=1-m,y=v-h+u;for(let x=0;x!==o;x++){let b=s[p+x+o],w=s[p+x+a]*c,_=s[f+x+o],S=s[f+x]*c;i[x]=g*b+y*w+m*_+v*S}return i};var jr={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},tu={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},qS={9728:Pt,9729:$e,9984:Xs,9985:jo,9986:qs,9987:Ai},YS={33071:Zt,33648:qr,10497:di},KS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$m={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Rs={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},h3={CUBICSPLINE:void 0,LINEAR:Er,STEP:Yr},eg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function QS(r,e){return typeof r!="string"||r===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(r)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(r)||/^data:.*,.*$/i.test(r)||/^blob:.*$/i.test(r)?r:e+r)}function d3(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Xi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Oi})),r.DefaultMaterial}function nu(r,e,t){for(let n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Fo(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function f3(r,e,t){let n=!1,i=!1;for(let a=0,l=e.length;a=2&&v.setY(T,_[S*l+1]),l>=3&&v.setZ(T,_[S*l+2]),l>=4&&v.setW(T,_[S*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){let t=this.json,n=this.options,i=t.textures[e],s=t.images[i.source],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);a!==null&&(o=a)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){let i=this,s=this.json,o=this.options,a=s.textures[e],l=(t.uri||t.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];let c=self.URL||self.webkitURL,u=t.uri||"",h=!1,d=!0,f=u.search(/\.jpe?g($|\?)/i)>0||u.search(/^data\:image\/jpeg/)===0;if((t.mimeType==="image/jpeg"||f)&&(d=!1),t.bufferView!==void 0)u=i.getDependency("bufferView",t.bufferView).then(function(m){if(t.mimeType==="image/png"){let g=new DataView(m,25,1).getUint8(0,!1);d=g===6||g===4||g===3}h=!0;let v=new Blob([m],{type:t.mimeType});return u=c.createObjectURL(v),u});else if(t.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let p=Promise.resolve(u).then(function(m){return new Promise(function(v,g){let y=v;n.isImageBitmapLoader===!0&&(y=function(x){let b=new xt(x);b.needsUpdate=!0,v(b)}),n.load(QS(m,o.path),y,void 0,g)})}).then(function(m){h===!0&&c.revokeObjectURL(u),m.flipY=!1,a.name&&(m.name=a.name),d||(m.format=Nt);let g=(s.samplers||{})[a.sampler]||{};return m.magFilter=qS[g.magFilter]||$e,m.minFilter=qS[g.minFilter]||Ai,m.wrapS=YS[g.wrapS]||di,m.wrapT=YS[g.wrapT]||di,i.associations.set(m,{type:"textures",index:e}),m}).catch(function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null});return this.textureCache[l]=p,p}assignTexture(e,t,n){let i=this;return this.getDependency("texture",n.index).then(function(s){if(n.texCoord!==void 0&&n.texCoord!=0&&!(t==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[dt.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[dt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=i.associations.get(s);s=i.extensions[dt.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),i.associations.set(s,a)}}return e[t]=s,s})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=t.attributes.tangent!==void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Ta,nn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Gn,nn.prototype.copy.call(l,n),l.color.copy(n.color),this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(a+="specular-glossiness:"),i&&(a+="vertex-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}n.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Xi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,s=n.materials[e],o,a={},l=s.extensions||{},c=[];if(l[dt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){let h=i[dt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=h.getMaterialType(),c.push(h.extendParams(a,s,t))}else if(l[dt.KHR_MATERIALS_UNLIT]){let h=i[dt.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),c.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new fe(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let d=h.baseColorFactor;a.color.fromArray(d),a.opacity=d[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",h.baseColorTexture)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Xt);let u=s.alphaMode||eg.OPAQUE;return u===eg.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===eg.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==dn&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new O(1,-1),s.normalTexture.scale!==void 0&&a.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),s.occlusionTexture!==void 0&&o!==dn&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==dn&&(a.emissive=new fe().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&o!==dn&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture)),Promise.all(c).then(function(){let h;return o===zd?h=i[dt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):h=new o(a),s.name&&(h.name=s.name),h.map&&(h.map.encoding=Fi),h.emissiveMap&&(h.emissiveMap.encoding=Fi),Fo(h,s),t.associations.set(h,{type:"materials",index:e}),s.extensions&&nu(i,h,s),h})}createUniqueName(e){let t=nt.sanitizeNodeName(e||""),n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[dt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return tM(l,a,t)})}let o=[];for(let a=0,l=e.length;a0&&p3(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),Fo(g,s),v.extensions&&nu(i,g,v),t.assignFinalMaterial(g),h.push(g)}if(h.length===1)return h[0];let d=new Jn;for(let f=0,p=h.length;f1?l=new Jn:a.length===1?l=a[0]:l=new Ke,l!==a[0])for(let c=0,u=a.length;c{on.fontCache[e]=s,t(s)},void 0,n)})}static loadChar(e,t,n){if(on.charCache[e]){if(on.charCache[e][n]&&on.charCache[e][n].fontFamily===t)return on.charCache[e][n]}else on.charCache[e]={};let i=on.fontCache[t],s=i.generateShapes(e,1);return on.charCache[e][n]={geometry:new ps(s,n),fontFamily:t,resolution:i.data.resolution,glyphsHa:i.data.glyphs[e].ha},on.charCache[e][n]}},ui=on;ui.charCache={},ui.fontCache={},ui._fontPath="/_assets/_fonts/";var zo;(function(n){n[n.STANDARD=1]="STANDARD",n[n.UPPERCASE=2]="UPPERCASE",n[n.LOWERCASE=3]="LOWERCASE"})(zo||(zo={}));var Bs;(function(n){n[n.TOP=1]="TOP",n[n.MIDDLE=2]="MIDDLE",n[n.BOTTOM=3]="BOTTOM"})(Bs||(Bs={}));var hi;(function(i){i[i.LEFT=1]="LEFT",i[i.RIGHT=2]="RIGHT",i[i.CENTER=3]="CENTER",i[i.JUSTIFY=4]="JUSTIFY"})(hi||(hi={}));var Go;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(Go||(Go={}));var Gd=new O,_l=class{constructor(e,t,n){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=n,this.nextChar3DPos=new O(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=hi.LEFT}addChar3D(e,t,n=this.message.length){this.message.splice(n,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let n=t,i=this.message.length;n=0;){if(this.message[n].char!==" "){t=this.message[n];break}n-=1}return!!(n>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],n=!0,i;for(i=e;i>=0;i-=1)if(this.message[i].char===" "){n=!1,t.length===0&&(i-=1,t.splice(0,0,this.message[i]));break}else t.splice(0,0,this.message[i]);return n?t=[]:this.message.splice(i+1,t.length),t}getWord(e=0,t=1){let n=[],i=e;for(i=e;;i+=t){if(!this.message[i]||this.message[i].char===" "){n.length===0&&this.message[i]&&(n.push(this.message[i]),this.message.splice(i,1));break}t>0?(n.push(this.message[i]),this.message.splice(i,1),i-=t):(n.splice(0,0,this.message[i]),this.message.splice(i,1))}return n}getWordAtIndex(e){let t=[];for(let n=e;n=0&&this.message[n].char!==" ";n--)t.splice(0,0,this.message[n]);return t}wordSize(e=0,t=-1){let n=0,i=e;for(;i>=0&&i=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:n===0?999999999:n}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,n=this.message.length-1){for(let i=t;i<=n;i+=1)this.message[i].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t0){t.push(n[0]);return}let i=[];for(let s=0,o=this.children.length;s0)){i[0].object=this,t.push(i[0]);return}}updateGeometry(e){var c,u;let t=this.userData,n=this.geometry.userData,i=n.parameters.width,s=(c=e.parameters)==null?void 0:c.width,o=(u=e.parameters)==null?void 0:u.height,a=n.parameters.height,l=t.textFrame;super.updateGeometry(e),l.maxLineSize=n.parameters.width,l.textOrigin.set(n.parameters.width*-.5,n.parameters.height*.5,0),o!==void 0&&a!==o?(this.checkOverFlow(),this.checkCapacity()):s!==void 0&&(is&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,n=t.textFrame.textOrigin,i=t.textFrame.textLines;for(let s=e;s0){i[s+1]===void 0&&(i[s].isEndLine(!1),this.createTextLine());let a=0;for(let l=0;ls?this.checkOverFlow():e{let a=o.message.map(l=>({char:l.char,originalChar:l.originalChar,fontFamily:l.fontFamily,letterSpacing:l.letterSpacing,fontSize:l.fontSize,LOD:l.LOD}));return{align:o.align,endLine:o.endLine,lineHeight:o.lineHeight,maxCharSize:o.maxCharSize,yLinePos:o.yLinePos,message:a}});return n.userData.textFrame.textLinesData=s,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await ui.loadFont(t.fontFamily),t.textOrigin=new M(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let n=new dn({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:Xt});t.textLinesData&&(t.textLines=t.textLinesData.map((i,s)=>{let o=new _l(Number(i.yLinePos),Number(i.lineHeight),Number(i.maxCharSize)),a=i.message.map((l,c)=>{if(l.char===void 0){let d=t.textLines[s].message[c];if("geometries"in d){let f=d.geometries[0].userData.parameters;Object.assign(l,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let u={char:l.char,fontFamily:l.fontFamily,letterSpacing:Number(l.letterSpacing),fontSize:Number(l.fontSize),LOD:l.LOD},h=new ui(u,n.clone());return o.addChar3D(h,t.textOrigin),this.add(h),h});return o.message=a,o}),this.userData.textFrame=t),this.textFullUpdate()}return this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,n=new Pi;n.name="Text Shape";let i=ui.fontCache[e];for(let s of this.children)s instanceof ui&&i.generateShapes(s.char,1).forEach(o=>{var h;let a=new Lt().fromShape(o);a.applyScale(s.scale.x,s.scale.y);let l=Pn.create({shape:a}),c=new oi({side:Xt});(h=c.color)==null||h.value.setHex(t);let u=new Ps(l,c);u.name=s.char,u.position.copy(s.position),u.rotation.copy(s.rotation),n.attach(u)});return n}};Os.VERTICAL_ALIGN=Bs,Os.HORIZONTAL_ALIGN=hi,Os.TEXT_TRANSFORM=zo,Os.TRAVEL_DIRECTION=Go;var iM={RED:0,GREEN:1,BLUE:2,ALPHA:3};var iu="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var y3=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale; #if PASS == 1 uniform vec4 kernel64[32]; #else uniform vec4 kernel16[8]; #endif varying vec2 vUv;void main(){ #ifdef FOREGROUND vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale; #else float CoC=texture2D(cocBuffer,vUv).g*scale; #endif if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{ #ifdef FOREGROUND vec2 step=texelSize*max(CoC,CoCNearFar.g*scale); #else vec2 step=texelSize*CoC; #endif #if PASS == 1 vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0; #else vec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue; #endif }}`,Ud=class extends _t{constructor(r=!1,e=!1){super({type:"BokehMaterial",defines:{PASS:r?"2":"1"},uniforms:{kernel64:new Ae(null),kernel16:new Ae(null),inputBuffer:new Ae(null),cocBuffer:new Ae(null),texelSize:new Ae(new O),scale:new Ae(1)},fragmentShader:y3,vertexShader:iu,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1,e&&(this.defines.FOREGROUND="1"),this.generateKernel()}generateKernel(){let r=2.39996323,e=new Float32Array(128),t=new Float32Array(32),n=0,i=0;for(let a=0;a<80;++a){let l=a*r,c=Math.sqrt(a)/Math.sqrt(80),u=c*Math.cos(l),h=c*Math.sin(l);a%5==0?(t[i++]=u,t[i++]=h):(e[n++]=u,e[n++]=h)}let s=[],o=[];for(let a=0;a<128;)s.push(new Qe(e[a++],e[a++],e[a++],e[a++]));for(let a=0;a<32;)o.push(new Qe(t[a++],t[a++],t[a++],t[a++]));this.uniforms.kernel64.value=s,this.uniforms.kernel16.value=o}setTexelSize(r,e){this.uniforms.texelSize.value.set(r,e)}},v3=`#include #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform float focusDistance;uniform float focalLength;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }void main(){float depth=readDepth(vUv); #ifdef PERSPECTIVE_CAMERA float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar); #else float linearDepth=depth; #endif float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focalLength,abs(signedDistance));gl_FragColor.rg=vec2(step(signedDistance,0.0)*magnitude,step(0.0,signedDistance)*magnitude);}`,x3=class extends _t{constructor(r){super({type:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new Ae(null),focusDistance:new Ae(0),focalLength:new Ae(0),cameraNear:new Ae(.3),cameraFar:new Ae(1e3)},fragmentShader:v3,vertexShader:iu,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1,this.adoptCameraSettings(r)}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(r){this.defines.DEPTH_PACKING=r.toFixed(0),this.needsUpdate=!0}adoptCameraSettings(r=null){r!==null&&(this.uniforms.cameraNear.value=r.near,this.uniforms.cameraFar.value=r.far,r instanceof Vt?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},b3=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; #if EDGE_DETECTION_MODE != 0 varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; #endif #if EDGE_DETECTION_MODE == 1 #include #endif #if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1 #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);} #elif PREDICATION_MODE == 2 uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);} #endif #if PREDICATION_MODE != 0 vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);} #endif #if EDGE_DETECTION_MODE != 0 uniform sampler2D inputBuffer; #endif void main(){ #if EDGE_DETECTION_MODE == 0 const vec2 threshold=vec2(DEPTH_THRESHOLD); #elif PREDICATION_MODE != 0 vec2 threshold=calculatePredicatedThreshold(); #else const vec2 threshold=vec2(EDGE_THRESHOLD); #endif #if EDGE_DETECTION_MODE == 0 vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0); #elif EDGE_DETECTION_MODE == 1 float l=linearToRelativeLuminance(texture2D(inputBuffer,vUv).rgb);float lLeft=linearToRelativeLuminance(texture2D(inputBuffer,vUv0).rgb);float lTop=linearToRelativeLuminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=linearToRelativeLuminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=linearToRelativeLuminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=linearToRelativeLuminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=linearToRelativeLuminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); #elif EDGE_DETECTION_MODE == 2 vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); #endif }`,w3=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; #if EDGE_DETECTION_MODE != 0 varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; #endif void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0); #if EDGE_DETECTION_MODE != 0 vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0); #endif gl_Position=vec4(position.xy,1.0,1.0);}`;var S3=`#include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include }`,M3="uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",rM=class extends _t{constructor(r=new O){super({type:"ConvolutionMaterial",uniforms:{inputBuffer:new Ae(null),texelSize:new Ae(new O),halfTexelSize:new Ae(new O),kernel:new Ae(0),scale:new Ae(1)},fragmentShader:S3,vertexShader:M3,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1,this.setTexelSize(r.x,r.y),this.kernelSize=kd.LARGE}getKernel(){return A3[this.kernelSize]}setTexelSize(r,e){this.uniforms.texelSize.value.set(r,e),this.uniforms.halfTexelSize.value.set(r,e).multiplyScalar(.5)}},A3=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],kd={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},_3=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel; #include }`,sM=class extends _t{constructor(){super({type:"CopyMaterial",uniforms:{inputBuffer:new Ae(null),opacity:new Ae(1)},fragmentShader:_3,vertexShader:iu,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1}};var T3=class extends _t{constructor(r=new O,e=Vd.COLOR){super({type:"EdgeDetectionMaterial",defines:{LOCAL_CONTRAST_ADAPTATION_FACTOR:"2.0",EDGE_THRESHOLD:"0.1",DEPTH_THRESHOLD:"0.01",PREDICATION_MODE:"0",PREDICATION_THRESHOLD:"0.01",PREDICATION_SCALE:"2.0",PREDICATION_STRENGTH:"1.0",DEPTH_PACKING:"0"},uniforms:{inputBuffer:new Ae(null),depthBuffer:new Ae(null),predicationBuffer:new Ae(null),texelSize:new Ae(r)},fragmentShader:b3,vertexShader:w3,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1,this.setEdgeDetectionMode(e)}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(r){this.defines.DEPTH_PACKING=r.toFixed(0),this.needsUpdate=!0}setEdgeDetectionMode(r){this.defines.EDGE_DETECTION_MODE=r.toFixed(0),this.needsUpdate=!0}setLocalContrastAdaptationFactor(r){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=r.toFixed("6"),this.needsUpdate=!0}setEdgeDetectionThreshold(r){this.defines.EDGE_THRESHOLD=r.toFixed("6"),this.defines.DEPTH_THRESHOLD=(r*.1).toFixed("6"),this.needsUpdate=!0}setPredicationMode(r){this.defines.PREDICATION_MODE=r.toFixed(0),this.needsUpdate=!0}setPredicationBuffer(r){this.uniforms.predicationBuffer.value=r}setPredicationThreshold(r){this.defines.PREDICATION_THRESHOLD=r.toFixed("6"),this.needsUpdate=!0}setPredicationScale(r){this.defines.PREDICATION_SCALE=r.toFixed("6"),this.needsUpdate=!0}setPredicationStrength(r){this.defines.PREDICATION_STRENGTH=r.toFixed("6"),this.needsUpdate=!0}},Vd={DEPTH:0,LUMA:1,COLOR:2},oM={DISABLED:0,DEPTH:1,CUSTOM:2},E3=`#include #include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`,N3="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEADvoid main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORTgl_Position=vec4(position.xy,1.0,1.0);}",C3=class extends _t{constructor(r=null,e=null,t=null,n,i=!1){super({type:"EffectMaterial",defines:{DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new Ae(null),depthBuffer:new Ae(null),resolution:new Ae(new O),texelSize:new Ae(new O),cameraNear:new Ae(.3),cameraFar:new Ae(1e3),aspect:new Ae(1),time:new Ae(0)},blending:It,depthWrite:!1,depthTest:!1,dithering:i});this.toneMapped=!1,r!==null&&this.setShaderParts(r),e!==null&&this.setDefines(e),t!==null&&this.setUniforms(t),this.adoptCameraSettings(n)}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(r){this.defines.DEPTH_PACKING=r.toFixed(0),this.needsUpdate=!0}setShaderParts(r){return this.fragmentShader=E3.replace(pt.FRAGMENT_HEAD,r.get(pt.FRAGMENT_HEAD)).replace(pt.FRAGMENT_MAIN_UV,r.get(pt.FRAGMENT_MAIN_UV)).replace(pt.FRAGMENT_MAIN_IMAGE,r.get(pt.FRAGMENT_MAIN_IMAGE)),this.vertexShader=N3.replace(pt.VERTEX_HEAD,r.get(pt.VERTEX_HEAD)).replace(pt.VERTEX_MAIN_SUPPORT,r.get(pt.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(r){for(let e of r.entries())this.defines[e[0]]=e[1];return this.needsUpdate=!0,this}setUniforms(r){for(let e of r.entries())this.uniforms[e[0]]=e[1];return this}adoptCameraSettings(r=null){r!==null&&(this.uniforms.cameraNear.value=r.near,this.uniforms.cameraFar.value=r.far,r instanceof Vt?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(r,e){let t=Math.max(r,1),n=Math.max(e,1);this.uniforms.resolution.value.set(t,n),this.uniforms.texelSize.value.set(1/t,1/n),this.uniforms.aspect.value=t/n}},pt={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"};var L3=`#include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=linearToRelativeLuminance(texel.rgb); #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);l*=low*high; #elif defined(THRESHOLD) l=smoothstep(threshold,threshold+smoothing,l); #endif #ifdef COLOR gl_FragColor=vec4(texel.rgb*l,l); #else gl_FragColor=vec4(l); #endif }`,I3=class extends _t{constructor(r=!1,e=null){let t=e!==null;super({type:"LuminanceMaterial",uniforms:{inputBuffer:new Ae(null),threshold:new Ae(0),smoothing:new Ae(1),range:new Ae(t?e:new O)},fragmentShader:L3,vertexShader:iu,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1,this.colorOutput=r,this.useThreshold=!0,this.useRange=t}get threshold(){return this.uniforms.threshold.value}set threshold(r){this.uniforms.threshold.value=r}get smoothing(){return this.uniforms.smoothing.value}set smoothing(r){this.uniforms.smoothing.value=r}get useThreshold(){return this.defines.THRESHOLD!==void 0}set useThreshold(r){r?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.needsUpdate=!0}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(r){r?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}setColorOutputEnabled(r){this.colorOutput=r}get useRange(){return this.defines.RANGE!==void 0}set useRange(r){r?this.defines.RANGE="1":delete this.defines.RANGE,this.needsUpdate=!0}get luminanceRange(){return this.useRange}set luminanceRange(r){this.useRange=r}setLuminanceRangeEnabled(r){this.useRange=r}},P3=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef MASK_PRECISION_HIGH uniform mediump sampler2D maskTexture; #else uniform lowp sampler2D maskTexture; #endif #if MASK_FUNCTION != 0 uniform float strength; #endif varying vec2 vUv;void main(){ #if COLOR_CHANNEL == 0 float mask=texture2D(maskTexture,vUv).r; #elif COLOR_CHANNEL == 1 float mask=texture2D(maskTexture,vUv).g; #elif COLOR_CHANNEL == 2 float mask=texture2D(maskTexture,vUv).b; #else float mask=texture2D(maskTexture,vUv).a; #endif #if MASK_FUNCTION == 0 #ifdef INVERTED mask=step(mask,0.0); #else mask=1.0-step(mask,0.0); #endif #else mask=clamp(mask*strength,0.0,1.0); #ifdef INVERTED mask=1.0-mask; #endif #endif #if MASK_FUNCTION == 2 gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask); #else gl_FragColor=mask*texture2D(inputBuffer,vUv); #endif }`,D3=class extends _t{constructor(r=null){super({type:"MaskMaterial",uniforms:{maskTexture:new Ae(r),inputBuffer:new Ae(null),strength:new Ae(1)},fragmentShader:P3,vertexShader:iu,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1,this.colorChannel=iM.RED,this.maskFunction=aM.DISCARD}set maskTexture(r){this.uniforms.maskTexture.value=r,delete this.defines.MASK_PRECISION_HIGH,r.type!==At&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}set colorChannel(r){this.defines.COLOR_CHANNEL=r.toFixed(0),this.needsUpdate=!0}set maskFunction(r){this.defines.MASK_FUNCTION=r.toFixed(0),this.needsUpdate=!0}get inverted(){return this.defines.INVERTED!==void 0}set inverted(r){this.inverted&&!r?delete this.defines.INVERTED:r&&(this.defines.INVERTED="1"),this.needsUpdate=!0}get strength(){return this.uniforms.strength.value}set strength(r){this.uniforms.strength.value=r}},aM={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2};var R3=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize) #if __VERSION__ < 300 #define round(v) floor(v + 0.5) #endif #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;iend&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;iend&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ #if !defined(DISABLE_CORNER_DETECTION) vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0); #endif }void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ #if !defined(DISABLE_CORNER_DETECTION) vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0); #endif }void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){ #if !defined(DISABLE_DIAG_DETECTION) weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){ #endif vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d); #if !defined(DISABLE_DIAG_DETECTION) }else{e.r=0.0;} #endif }if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,B3="uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",O3=class extends _t{constructor(r=new O,e=new O){super({type:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new Ae(null),areaTexture:new Ae(null),searchTexture:new Ae(null),texelSize:new Ae(r),resolution:new Ae(e)},fragmentShader:R3,vertexShader:B3,blending:It,depthWrite:!1,depthTest:!1});this.toneMapped=!1}setOrthogonalSearchSteps(r){let e=Math.min(Math.max(r,0),112);this.defines.MAX_SEARCH_STEPS_INT=e.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=e.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(r){let e=Math.min(Math.max(r,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=e.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=e.toFixed("1"),this.needsUpdate=!0}setCornerRounding(r){let e=Math.min(Math.max(r,0),100);this.defines.CORNER_ROUNDING=e.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(e/100).toFixed("4"),this.needsUpdate=!0}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(r){r?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}get cornerRounding(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerRounding(r){r?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}};var F3=new Dr,Fs=null;function z3(){if(Fs===null){let r=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]);Fs=new we,Fs.setAttribute!==void 0?(Fs.setAttribute("position",new Re(r,3)),Fs.setAttribute("uv",new Re(e,2))):(Fs.addAttribute("position",new Re(r,3)),Fs.addAttribute("uv",new Re(e,2)))}return Fs}var Wr=class{constructor(r="Pass",e=new An,t=F3){this.name=r,this.scene=e,this.camera=t,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(r){if(this.rtt===r){let e=this.getFullscreenMaterial();e!==null&&(e.needsUpdate=!0),this.rtt=!r}}getFullscreenMaterial(){return this.screen!==null?this.screen.material:null}setFullscreenMaterial(r){let e=this.screen;e!==null?e.material=r:(e=new gt(z3(),r),e.frustumCulled=!1,this.scene===null&&(this.scene=new An),this.scene.add(e),this.screen=e)}getDepthTexture(){return null}setDepthTexture(r,e=0){}render(r,e,t,n,i){throw new Error("Render method not implemented!")}setSize(r,e){}initialize(r,e,t){}dispose(){let r=this.getFullscreenMaterial();r!==null&&r.dispose();for(let e of Object.keys(this)){let t=this[e];if(t!==null&&typeof t.dispose=="function"){if(t instanceof An)continue;this[e].dispose()}}}},lM=class extends Wr{constructor(r,e=!0){super("SavePass");this.setFullscreenMaterial(new sM),this.needsSwap=!1,this.renderTarget=r,r===void 0&&(this.renderTarget=new bt(1,1,{minFilter:$e,magFilter:$e,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="SavePass.Target"),this.resize=e}get texture(){return this.renderTarget.texture}render(r,e,t,n,i){this.getFullscreenMaterial().uniforms.inputBuffer.value=e.texture,r.setRenderTarget(this.renderToScreen?null:this.renderTarget),r.render(this.scene,this.camera)}setSize(r,e){if(this.resize){let t=Math.max(r,1),n=Math.max(e,1);this.renderTarget.setSize(t,n)}}initialize(r,e,t){if(!e&&t===At&&(this.renderTarget.texture.format=Nt),t!==void 0&&(this.renderTarget.texture.type=t,t!==At)){let n=this.getFullscreenMaterial();n.defines.FRAMEBUFFER_PRECISION_HIGH="1"}}};var Jr=-1,nr=class{constructor(r,e=Jr,t=Jr,n=1){this.resizable=r,this.base=new O(1,1),this.target=new O(e,t),this.s=n}get scale(){return this.s}set scale(r){this.s=r,this.target.x=Jr,this.target.y=Jr,this.resizable.setSize(this.base.x,this.base.y)}get width(){let r=this.base,e=this.target,t;return e.x!==Jr?t=e.x:e.y!==Jr?t=Math.round(e.y*(r.x/r.y)):t=Math.round(r.x*this.s),t}set width(r){this.target.x=r,this.resizable.setSize(this.base.x,this.base.y)}get height(){let r=this.base,e=this.target,t;return e.y!==Jr?t=e.y:e.x!==Jr?t=Math.round(e.x/(r.x/r.y)):t=Math.round(r.y*this.s),t}set height(r){this.target.y=r,this.resizable.setSize(this.base.x,this.base.y)}static get AUTO_SIZE(){return Jr}},cM=class extends Wr{constructor({resolutionScale:r=.5,width:e=nr.AUTO_SIZE,height:t=nr.AUTO_SIZE,kernelSize:n=kd.LARGE}={}){super("BlurPass");this.renderTargetA=new bt(1,1,{minFilter:$e,magFilter:$e,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B",this.resolution=new nr(this,e,t,r),this.convolutionMaterial=new rM,this.ditheredConvolutionMaterial=new rM,this.ditheredConvolutionMaterial.dithering=!0,this.dithering=!1,this.kernelSize=n}get width(){return this.resolution.width}set width(r){this.resolution.width=r}get height(){return this.resolution.height}set height(r){this.resolution.height=r}get scale(){return this.convolutionMaterial.uniforms.scale.value}set scale(r){this.convolutionMaterial.uniforms.scale.value=r,this.ditheredConvolutionMaterial.uniforms.scale.value=r}get kernelSize(){return this.convolutionMaterial.kernelSize}set kernelSize(r){this.convolutionMaterial.kernelSize=r,this.ditheredConvolutionMaterial.kernelSize=r}getResolutionScale(){return this.resolution.scale}setResolutionScale(r){this.resolution.scale=r}render(r,e,t,n,i){let s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB,c=this.convolutionMaterial,u=c.uniforms,h=c.getKernel(),d=e,f,p,m;for(this.setFullscreenMaterial(c),p=0,m=h.length-1;p=0;l?(ng.copy(r.getClearColor(ng)),r.setClearColor(s,c?o:a)):c&&r.setClearAlpha(o),r.setRenderTarget(this.renderToScreen?null:e),r.clear(this.color,this.depth,this.stencil),l?r.setClearColor(ng,a):c&&r.setClearAlpha(a)}},rg=!1,uM=class{constructor(r=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(r),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case Xt:t=this.materialsFlatShadedDoubleSide;break;case kt:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case Xt:t=this.materialsDoubleSide;break;case kt:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}setMaterial(r){if(this.disposeMaterials(),this.material=r,r!==null){let e=this.materials=[r.clone(),r.clone(),r.clone()];for(let t of e)t.uniforms=Object.assign({},r.uniforms),t.side=Oi;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.side=kt,n}),this.materialsDoubleSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.side=Xt,n}),this.materialsFlatShaded=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n.side=kt,n}),this.materialsFlatShadedDoubleSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n.side=Xt,n})}}render(r,e,t){let n=r.shadowMap.enabled;if(r.shadowMap.enabled=!1,rg){let i=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),r.render(e,t);for(let s of i)s[0].material=s[1];this.meshCount!==i.size&&i.clear()}else{let i=e.overrideMaterial;e.overrideMaterial=this.material,r.render(e,t),e.overrideMaterial=i}r.shadowMap.enabled=n}disposeMaterials(){if(this.material!==null){let r=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let e of r)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return rg}static set workaroundEnabled(r){rg=r}},sg=class extends Wr{constructor(r,e,t=null){super("RenderPass",r,e);this.needsSwap=!1,this.clearPass=new ig,this.overrideMaterialManager=t===null?null:new uM(t)}get renderToScreen(){return super.renderToScreen}set renderToScreen(r){super.renderToScreen=r,this.clearPass.renderToScreen=r}get overrideMaterial(){let r=this.overrideMaterialManager;return r!==null?r.material:null}set overrideMaterial(r){let e=this.overrideMaterialManager;r!==null?e!==null?e.setMaterial(r):this.overrideMaterialManager=new uM(r):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}get clear(){return this.clearPass.enabled}set clear(r){this.clearPass.enabled=r}getClearPass(){return this.clearPass}render(r,e,t,n,i){let s=this.scene,o=this.camera,a=s.background,l=this.renderToScreen?null:e;this.clear&&(this.clearPass.overrideClearColor!==null&&(s.background=null),this.clearPass.render(r,e)),r.setRenderTarget(l),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(r,s,o):r.render(s,o),s.background!==a&&(s.background=a)}};var w$=new Float32Array([255/256/256**3,255/256/256**2,255/256/256,255/256]);var ut={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},U3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}",k3="vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}",V3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",H3="float blend(const in float x,const in float y){return(y==0.0)? y : max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",j3="float blend(const in float x,const in float y){return(y==1.0)? y : min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",W3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",J3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",X3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}",q3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",Y3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",K3="float blend(const in float x,const in float y){return(y>0.0)? min(x/y,1.0): 1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",Q3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}",Z3="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",$3="float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",eF="float blend(const in float x,const in float y){return(y==1.0)? y : min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",tF="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}",nF="float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",iF="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}",rF=new Map([[ut.SKIP,null],[ut.ADD,U3],[ut.ALPHA,k3],[ut.AVERAGE,V3],[ut.COLOR_BURN,H3],[ut.COLOR_DODGE,j3],[ut.DARKEN,W3],[ut.DIFFERENCE,J3],[ut.EXCLUSION,X3],[ut.LIGHTEN,q3],[ut.MULTIPLY,Y3],[ut.DIVIDE,K3],[ut.NEGATION,Q3],[ut.NORMAL,Z3],[ut.OVERLAY,$3],[ut.REFLECT,eF],[ut.SCREEN,tF],[ut.SOFT_LIGHT,nF],[ut.SUBTRACT,iF]]),sF=class extends cn{constructor(r,e=1){super();this.blendFunction=r,this.opacity=new Ae(e)}getBlendFunction(){return this.blendFunction}setBlendFunction(r){this.blendFunction=r,this.dispatchEvent({type:"change"})}getShaderCode(){return rF.get(this.blendFunction)}},Mr=class extends cn{constructor(r,e,{attributes:t=ir.NONE,blendFunction:n=ut.SCREEN,defines:i=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super();this.name=r,this.attributes=t,this.fragmentShader=e,this.vertexShader=a,this.defines=i,this.uniforms=s,this.extensions=o,this.blendMode=new sF(n),this.blendMode.addEventListener("change",l=>this.setChanged())}setChanged(){this.dispatchEvent({type:"change"})}getAttributes(){return this.attributes}setAttributes(r){this.attributes=r,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(r){this.fragmentShader=r,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(r){this.vertexShader=r,this.setChanged()}setDepthTexture(r,e=0){}update(r,e,t){}setSize(r,e){}initialize(r,e,t){}dispose(){for(let r of Object.keys(this)){let e=this[r];if(e!==null&&typeof e.dispose=="function"){if(e instanceof An)continue;this[r].dispose()}}}},ir={NONE:0,DEPTH:1,CONVOLUTION:2};function og(r,e){let t=[],n;for(;(n=r.exec(e))!==null;)t.push(n[1]);return t}function hM(r,e,t){let n,i;for(let s of e){n="$1"+r+s.charAt(0).toUpperCase()+s.slice(1),i=new RegExp("([^\\.])(\\b"+s+"\\b)","g");for(let o of t.entries())o[1]!==null&&t.set(o[0],o[1].replace(i,n))}}function oF(r,e,t,n,i,s,o){let a=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,l=/(?:varying\s+\w+\s+(\w*))/g,c=e.blendMode,u=new Map([["fragment",e.getFragmentShader()],["vertex",e.getVertexShader()]]),h=u.get("fragment")!==void 0&&/mainImage/.test(u.get("fragment")),d=u.get("fragment")!==void 0&&/mainUv/.test(u.get("fragment")),f=[],p=[],m=!1,v=!1;if(u.get("fragment")===void 0)console.error("Missing fragment shader",e);else if(d&&(o&ir.CONVOLUTION)!=0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",e);else if(!h&&!d)console.error("The fragment shader contains neither a mainImage nor a mainUv function",e);else{if(d&&(t.set(pt.FRAGMENT_MAIN_UV,t.get(pt.FRAGMENT_MAIN_UV)+" "+r+`MainUv(UV); `),m=!0),u.get("vertex")!==null&&/mainSupport/.test(u.get("vertex"))){let g=" "+r+"MainSupport(";/mainSupport *\([\w\s]*?uv\s*?\)/.test(u.get("vertex"))&&(g+="vUv"),g+=`); `,t.set(pt.VERTEX_MAIN_SUPPORT,t.get(pt.VERTEX_MAIN_SUPPORT)+g),f=f.concat(og(l,u.get("vertex"))),p=p.concat(f).concat(og(a,u.get("vertex")))}if(p=p.concat(og(a,u.get("fragment"))).concat(Array.from(e.defines.keys()).map(g=>g.replace(/\([\w\s,]*\)/g,""))).concat(Array.from(e.uniforms.keys())),e.uniforms.forEach((g,y)=>s.set(r+y.charAt(0).toUpperCase()+y.slice(1),g)),e.defines.forEach((g,y)=>i.set(r+y.charAt(0).toUpperCase()+y.slice(1),g)),hM(r,p,i),hM(r,p,u),n.set(c.blendFunction,c),h){let g=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,y=r+"MainImage(color0, UV, ";(o&ir.DEPTH)!=0&&g.test(u.get("fragment"))&&(y+="depth, ",v=!0),y+=`color1); `;let x=r+"BlendOpacity";s.set(x,c.opacity),y+="color0 = blend"+c.getBlendFunction()+"(color0, color1, "+x+`); `,t.set(pt.FRAGMENT_MAIN_IMAGE,t.get(pt.FRAGMENT_MAIN_IMAGE)+y),t.set(pt.FRAGMENT_HEAD,t.get(pt.FRAGMENT_HEAD)+"uniform float "+x+`; `)}t.set(pt.FRAGMENT_HEAD,t.get(pt.FRAGMENT_HEAD)+u.get("fragment")+` `),u.get("vertex")!==null&&t.set(pt.VERTEX_HEAD,t.get(pt.VERTEX_HEAD)+u.get("vertex")+` `)}return{varyings:f,transformedUv:m,readDepth:v}}var Hd=class extends Wr{constructor(r,...e){super("EffectPass");this.setFullscreenMaterial(new C3(null,null,null,r)),this.effects=e.sort((t,n)=>n.attributes-t.attributes),this.skipRendering=!1,this.uniforms=0,this.varyings=0,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY}get encodeOutput(){return this.getFullscreenMaterial().defines.ENCODE_OUTPUT!==void 0}set encodeOutput(r){if(this.encodeOutput!==r){let e=this.getFullscreenMaterial();e.needsUpdate=!0,r?e.defines.ENCODE_OUTPUT="1":delete e.defines.ENCODE_OUTPUT}}get dithering(){return this.getFullscreenMaterial().dithering}set dithering(r){let e=this.getFullscreenMaterial();e.dithering!==r&&(e.dithering=r,e.needsUpdate=!0)}verifyResources(r){let e=r.capabilities,t=Math.min(e.maxFragmentUniforms,e.maxVertexUniforms);this.uniforms>t&&console.warn("The current rendering context doesn't support more than "+t+" uniforms, but "+this.uniforms+" were defined"),t=e.maxVaryings,this.varyings>t&&console.warn("The current rendering context doesn't support more than "+t+" varyings, but "+this.varyings+" were defined")}updateMaterial(){let r=/\bblend\b/g,e=new Map([[pt.FRAGMENT_HEAD,""],[pt.FRAGMENT_MAIN_UV,""],[pt.FRAGMENT_MAIN_IMAGE,""],[pt.VERTEX_HEAD,""],[pt.VERTEX_MAIN_SUPPORT,""]]),t=new Map,n=new Map,i=new Map,s=new Set,o=0,a=0,l=0,c=!1,u=!1,h;for(let f of this.effects)if(f.blendMode.getBlendFunction()===ut.SKIP)l|=f.getAttributes()&ir.DEPTH;else if((l&ir.CONVOLUTION)!=0&&(f.getAttributes()&ir.CONVOLUTION)!=0)console.error("Convolution effects cannot be merged",f);else if(l|=f.getAttributes(),h=oF("e"+o++,f,e,t,n,i,l),a+=h.varyings.length,c=c||h.transformedUv,u=u||h.readDepth,f.extensions!==null)for(let p of f.extensions)s.add(p);for(let f of t.values())e.set(pt.FRAGMENT_HEAD,e.get(pt.FRAGMENT_HEAD)+f.getShaderCode().replace(r,"blend"+f.getBlendFunction())+` `);(l&ir.DEPTH)!=0?(u&&e.set(pt.FRAGMENT_MAIN_IMAGE,`float depth = readDepth(UV); `+e.get(pt.FRAGMENT_MAIN_IMAGE)),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,c?(e.set(pt.FRAGMENT_MAIN_UV,`vec2 transformedUv = vUv; `+e.get(pt.FRAGMENT_MAIN_UV)),n.set("UV","transformedUv")):n.set("UV","vUv"),e.forEach((f,p,m)=>m.set(p,f.trim().replace(/^#/,` #`))),this.uniforms=i.size,this.varyings=a,this.skipRendering=o===0,this.needsSwap=!this.skipRendering;let d=this.getFullscreenMaterial();if(d.setShaderParts(e).setDefines(n).setUniforms(i),d.extensions={},s.size>0)for(let f of s)d.extensions[f]=!0;this.needsUpdate=!1}recompile(r){this.updateMaterial(),r!==void 0&&this.verifyResources(r)}getDepthTexture(){return this.getFullscreenMaterial().uniforms.depthBuffer.value}setDepthTexture(r,e=Kr){let t=this.getFullscreenMaterial();t.uniforms.depthBuffer.value=r,t.depthPacking=e,t.needsUpdate=!0;for(let n of this.effects)n.setDepthTexture(r,e)}render(r,e,t,n,i){let s=this.getFullscreenMaterial(),o=s.uniforms.time.value+n;this.needsUpdate&&this.recompile(r);for(let a of this.effects)a.update(r,e,n);(!this.skipRendering||this.renderToScreen)&&(s.uniforms.inputBuffer.value=e.texture,s.uniforms.time.value=o<=this.maxTime?o:this.minTime,r.setRenderTarget(this.renderToScreen?null:t),r.render(this.scene,this.camera))}setSize(r,e){this.getFullscreenMaterial().setSize(r,e);for(let t of this.effects)t.setSize(r,e)}initialize(r,e,t){for(let n of this.effects)n.initialize(r,e,t),n.addEventListener("change",i=>this.handleEvent(i));if(this.updateMaterial(),this.verifyResources(r),t!==void 0&&t!==At){let n=this.getFullscreenMaterial();n.defines.FRAMEBUFFER_PRECISION_HIGH="1"}}dispose(){super.dispose();for(let r of this.effects)r.dispose()}handleEvent(r){switch(r.type){case"change":this.needsUpdate=!0;break}}};var aF=class extends Wr{constructor({width:r=nr.AUTO_SIZE,height:e=nr.AUTO_SIZE,renderTarget:t,luminanceRange:n,colorOutput:i}={}){super("LuminancePass");this.setFullscreenMaterial(new I3(i,n)),this.needsSwap=!1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new bt(1,1,{minFilter:$e,magFilter:$e,format:i?zt:Qd,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1),this.resolution=new nr(this,r,e)}get texture(){return this.renderTarget.texture}render(r,e,t,n,i){let s=this.getFullscreenMaterial();s.uniforms.inputBuffer.value=e.texture,r.setRenderTarget(this.renderToScreen?null:this.renderTarget),r.render(this.scene,this.camera)}setSize(r,e){let t=this.resolution;t.base.set(r,e),this.renderTarget.setSize(t.width,t.height)}initialize(r,e,t){if(t!==void 0&&t!==At){let n=this.getFullscreenMaterial();n.defines.FRAMEBUFFER_PRECISION_HIGH="1"}}},lF=class extends Wr{constructor(r,e){super("MaskPass",r,e);this.needsSwap=!1,this.clearPass=new ig(!1,!1,!0),this.inverse=!1}get clear(){return this.clearPass.enabled}set clear(r){this.clearPass.enabled=r}render(r,e,t,n,i){let s=r.getContext(),o=r.state.buffers,a=this.scene,l=this.camera,c=this.clearPass,u=this.inverse?0:1,h=1-u;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,u,4294967295),o.stencil.setClear(h),o.stencil.setLocked(!0),this.clear&&(this.renderToScreen?c.render(r,null):(c.render(r,e),c.render(r,t))),this.renderToScreen?(r.setRenderTarget(null),r.render(a,l)):(r.setRenderTarget(e),r.render(a,l),r.setRenderTarget(t),r.render(a,l)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}};var Xr=class extends Wr{constructor(r,e="inputBuffer"){super("ShaderPass");this.setFullscreenMaterial(r),this.uniform=null,this.setInput(e)}setInput(r){let e=this.getFullscreenMaterial();if(this.uniform=null,e!==null){let t=e.uniforms;t!==void 0&&t[r]!==void 0&&(this.uniform=t[r])}}render(r,e,t,n,i){this.uniform!==null&&e!==null&&(this.uniform.value=e.texture),r.setRenderTarget(this.renderToScreen?null:t),r.render(this.scene,this.camera)}initialize(r,e,t){if(t!==void 0&&t!==At){let n=this.getFullscreenMaterial();n.defines.FRAMEBUFFER_PRECISION_HIGH="1"}}},dM=class{constructor(r=null,{depthBuffer:e=!0,stencilBuffer:t=!1,alpha:n=!1,multisampling:i=0,frameBufferType:s}={}){this.renderer=r,this.inputBuffer=null,this.outputBuffer=null,this.renderer!==null&&(this.renderer.autoClear=!1,this.inputBuffer=this.createBuffer(e,t,s,i),this.outputBuffer=this.inputBuffer.clone()),this.copyPass=new Xr(new sM),this.alpha=n,this.depthTexture=null,this.passes=[],this.autoRenderToScreen=!0}get multisampling(){return this.inputBuffer instanceof Zr?this.inputBuffer.samples:0}set multisampling(r){let e=this.inputBuffer,t=this.multisampling;t>0&&r>0?(this.inputBuffer.samples=r,this.outputBuffer.samples=r):t!==r&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,r),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getRenderer(){return this.renderer}replaceRenderer(r,e=!0){let t=this.renderer;if(t!==null&&t!==r){let n=t.getSize(new O),i=r.getSize(new O),s=t.domElement.parentNode;this.renderer=r,this.renderer.autoClear=!1,n.equals(i)||this.setSize(),e&&s!==null&&(s.removeChild(t.domElement),s.appendChild(r.domElement))}return t}createDepthTexture(){let r=this.depthTexture=new so;return this.inputBuffer.depthTexture=r,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(r.format=Ks,r.type=Ys):r.type=Wo,r}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let r of this.passes)r.setDepthTexture(null)}}createBuffer(r,e,t,n){let i=this.renderer,s=i.getContext(),o=i.getDrawingBufferSize(new O),l={format:!(this.alpha||s.getContextAttributes().alpha)&&t===At?Nt:zt,minFilter:$e,magFilter:$e,stencilBuffer:e,depthBuffer:r,type:t},c=n>0?new Zr(o.width,o.height,l):new bt(o.width,o.height,l);return n>0&&(c.samples=n),c.texture.name="EffectComposer.Buffer",c.texture.generateMipmaps=!1,c}addPass(r,e){let t=this.passes,n=this.renderer,i=n.getDrawingBufferSize(new O),s=n.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(r.setSize(i.width,i.height),r.initialize(n,s,o),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),r.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,r):t.push(r),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),r.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let a=this.createDepthTexture();for(r of t)r.setDepthTexture(a)}else r.setDepthTexture(this.depthTexture)}removePass(r){let e=this.passes,t=e.indexOf(r);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){let s=(a,l)=>a||l.needsDepthTexture;e.reduce(s,!1)||(r.getDepthTexture()===this.depthTexture&&r.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(r.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){let r=this.passes;this.deleteDepthTexture(),r.length>0&&(this.autoRenderToScreen&&(r[r.length-1].renderToScreen=!1),this.passes=[])}render(r){let e=this.renderer,t=this.copyPass,n=this.inputBuffer,i=this.outputBuffer,s=!1,o,a,l;for(let c of this.passes)c.enabled&&(c.render(e,n,i,r,s),c.needsSwap&&(s&&(t.renderToScreen=c.renderToScreen,o=e.getContext(),a=e.state.buffers.stencil,a.setFunc(o.NOTEQUAL,1,4294967295),t.render(e,n,i,r,s),a.setFunc(o.EQUAL,1,4294967295)),l=n,n=i,i=l),c instanceof lF?s=!0:c instanceof G3&&(s=!1))}setSize(r,e,t){let n=this.renderer;if(r===void 0||e===void 0){let s=n.getSize(new O);r=s.width,e=s.height}else n.setSize(r,e,t);let i=n.getDrawingBufferSize(new O);this.inputBuffer.setSize(i.width,i.height),this.outputBuffer.setSize(i.width,i.height);for(let s of this.passes)s.setSize(i.width,i.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(let r of this.passes)r.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose()}};var cF=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D map; #else uniform lowp sampler2D map; #endif uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}`,fM=class extends Mr{constructor({blendFunction:r=ut.SCREEN,luminanceThreshold:e=.9,luminanceSmoothing:t=.025,resolutionScale:n=.5,intensity:i=1,width:s=nr.AUTO_SIZE,height:o=nr.AUTO_SIZE,kernelSize:a=kd.LARGE}={}){super("BloomEffect",cF,{blendFunction:r,uniforms:new Map([["map",new Ae(null)],["intensity",new Ae(i)]])});this.renderTarget=new bt(1,1,{minFilter:$e,magFilter:$e,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.renderTarget.texture.generateMipmaps=!1,this.uniforms.get("map").value=this.renderTarget.texture,this.blurPass=new cM({resolutionScale:n,width:s,height:o,kernelSize:a}),this.blurPass.resolution.resizable=this,this.luminancePass=new aF({renderTarget:this.renderTarget,colorOutput:!0}),this.luminancePass.resolution=this.resolution,this.luminanceMaterial.threshold=e,this.luminanceMaterial.smoothing=t}get texture(){return this.renderTarget.texture}get luminanceMaterial(){return this.luminancePass.getFullscreenMaterial()}get resolution(){return this.blurPass.resolution}get width(){return this.resolution.width}set width(r){this.resolution.width=r}get height(){return this.resolution.height}set height(r){this.resolution.height=r}get dithering(){return this.blurPass.dithering}set dithering(r){this.blurPass.dithering=r}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(r){this.blurPass.kernelSize=r}get distinction(){return console.warn(this.name,"The distinction field has been removed, use luminanceMaterial.threshold and luminanceMaterial.smoothing instead."),1}set distinction(r){console.warn(this.name,"The distinction field has been removed, use luminanceMaterial.threshold and luminanceMaterial.smoothing instead.")}get intensity(){return this.uniforms.get("intensity").value}set intensity(r){this.uniforms.get("intensity").value=r}getResolutionScale(){return this.resolution.scale}setResolutionScale(r){this.resolution.scale=r}update(r,e,t){let n=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(r,e,n),this.blurPass.render(r,n,n)):this.blurPass.render(r,e,n)}setSize(r,e){this.blurPass.setSize(r,e),this.renderTarget.setSize(this.resolution.width,this.resolution.height)}initialize(r,e,t){this.blurPass.initialize(r,e,t),!e&&t===At&&(this.renderTarget.texture.format=Nt),t!==void 0&&(this.renderTarget.texture.type=t)}};var uF="uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(min(color+vec3(0.5),1.0),inputColor.a);}",pM=class extends Mr{constructor({blendFunction:r=ut.NORMAL,brightness:e=0,contrast:t=0}={}){super("BrightnessContrastEffect",uF,{blendFunction:r,uniforms:new Map([["brightness",new Ae(e)],["contrast",new Ae(t)]])})}},hF="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){float sum=inputColor.r+inputColor.g+inputColor.b;outputColor=vec4(vec3(sum/3.0),inputColor.a);}",mM=class extends Mr{constructor(r=ut.NORMAL){super("ColorAverageEffect",hF,{blendFunction:r})}};var dF=`varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor; #ifdef ALPHA vec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;color.r=ra.x;color.b=ba.x;color.a=max(max(ra.y,ba.y),inputColor.a); #else color.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b; #endif outputColor=color;}`,fF="uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vUvR=uv+offset;vUvB=uv-offset;}",gM=class extends Mr{constructor({blendFunction:r=ut.NORMAL,offset:e=new O(.001,5e-4)}={}){super("ChromaticAberrationEffect",dF,{vertexShader:fF,blendFunction:r,attributes:ir.CONVOLUTION,uniforms:new Map([["offset",new Ae(e)]])})}get offset(){return this.uniforms.get("offset").value}set offset(r){this.uniforms.get("offset").value=r}initialize(r,e,t){e?this.defines.set("ALPHA","1"):this.defines.delete("ALPHA")}};var pF=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer; #else uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer; #endif uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,yM=class extends Mr{constructor(r,{blendFunction:e=ut.NORMAL,focusDistance:t=0,focalLength:n=.1,bokehScale:i=1,width:s=nr.AUTO_SIZE,height:o=nr.AUTO_SIZE}={}){super("DepthOfFieldEffect",pF,{blendFunction:e,attributes:ir.DEPTH,uniforms:new Map([["nearColorBuffer",new Ae(null)],["farColorBuffer",new Ae(null)],["nearCoCBuffer",new Ae(null)],["scale",new Ae(1)]])});this.camera=r,this.renderTarget=new bt(1,1,{minFilter:$e,magFilter:$e,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.format=Nt,this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new Xr(new x3(r));let a=this.circleOfConfusionMaterial;a.uniforms.focusDistance.value=t,a.uniforms.focalLength.value=n,this.blurPass=new cM({width:s,height:o,kernelSize:kd.MEDIUM}),this.blurPass.resolution.resizable=this,this.maskPass=new Xr(new D3(this.renderTargetCoC.texture));let l=this.maskPass.getFullscreenMaterial();l.maskFunction=aM.MULTIPLY,l.colorChannel=iM.GREEN,this.bokehNearBasePass=new Xr(new Ud(!1,!0)),this.bokehNearFillPass=new Xr(new Ud(!0,!0)),this.bokehFarBasePass=new Xr(new Ud(!1,!1)),this.bokehFarFillPass=new Xr(new Ud(!0,!1)),this.bokehScale=i,this.target=null}get circleOfConfusionMaterial(){return this.cocPass.getFullscreenMaterial()}get resolution(){return this.blurPass.resolution}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(r){[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].map(t=>t.getFullscreenMaterial().uniforms.scale).forEach(t=>{t.value=r}),this.maskPass.getFullscreenMaterial().uniforms.strength.value=r,this.uniforms.get("scale").value=r}calculateFocusDistance(r){let e=this.camera,t=e.far-e.near,n=e.position.distanceTo(r);return Math.min(Math.max(n/t,0),1)}setDepthTexture(r,e=Kr){let t=this.circleOfConfusionMaterial;t.uniforms.depthBuffer.value=r,t.depthPacking=e}update(r,e,t){let n=this.renderTarget,i=this.renderTargetCoC,s=this.renderTargetCoCBlurred,o=this.renderTargetMasked,a=this.bokehFarBasePass,l=this.bokehFarFillPass,c=a.getFullscreenMaterial().uniforms,u=l.getFullscreenMaterial().uniforms,h=this.bokehNearBasePass,d=this.bokehNearFillPass,f=h.getFullscreenMaterial().uniforms,p=d.getFullscreenMaterial().uniforms;if(this.target!==null){let m=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.uniforms.focusDistance.value=m}this.cocPass.render(r,null,i),this.blurPass.render(r,i,s),this.maskPass.render(r,e,o),c.cocBuffer.value=u.cocBuffer.value=i.texture,a.render(r,o,n),l.render(r,n,this.renderTargetFar),f.cocBuffer.value=p.cocBuffer.value=s.texture,h.render(r,e,n),d.render(r,n,this.renderTargetNear)}setSize(r,e){let t=this.resolution,n=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];n.push(this.renderTargetCoC,this.renderTargetMasked),n.forEach(a=>a.setSize(r,e));let i=t.width,s=t.height;n=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],n.forEach(a=>a.setSize(i,s)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(a=>a.getFullscreenMaterial().setTexelSize(1/i,1/s))}initialize(r,e,t){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(i=>i.initialize(r,e,t)),this.blurPass.initialize(r,e,At),!e&&t===At&&(this.renderTargetNear.texture.type=Nt),t!==void 0&&(this.renderTarget.texture.type=t,this.renderTargetNear.texture.type=t,this.renderTargetFar.texture.type=t,this.renderTargetMasked.texture.type=t)}};var P$=new M,D$=new me;var mF="uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}",vM=class extends Mr{constructor({blendFunction:r=ut.NORMAL,hue:e=0,saturation:t=0}={}){super("HueSaturationEffect",mF,{blendFunction:r,uniforms:new Map([["hue",new Ae(new M)],["saturation",new Ae(t)]])});this.setHue(e)}setHue(r){let e=Math.sin(r),t=Math.cos(r);this.uniforms.get("hue").value.set(2*t,-Math.sqrt(3)*e-t,Math.sqrt(3)*e-t).addScalar(1).divideScalar(3)}};var O$=new fe;var gF=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time)); #ifdef PREMULTIPLY outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); #else outputColor=vec4(noise,inputColor.a); #endif }`,xM=class extends Mr{constructor({blendFunction:r=ut.SCREEN,premultiply:e=!1}={}){super("NoiseEffect",gF,{blendFunction:r});this.premultiply=e}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(r){this.premultiply!==r&&(r?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}};var yF="uniform bool active;uniform vec2 d;void mainUv(inout vec2 uv){if(active){uv=vec2(d.x*(floor(uv.x/d.x)+0.5),d.y*(floor(uv.y/d.y)+0.5));}}",bM=class extends Mr{constructor(r=30){super("PixelationEffect",yF,{uniforms:new Map([["active",new Ae(!1)],["d",new Ae(new O)]])});this.resolution=new O,this.granularity=r}getGranularity(){return this.granularity}setGranularity(r){r=Math.floor(r),r%2>0&&(r+=1);let e=this.uniforms;e.get("active").value=r>0,e.get("d").value.set(r,r).divide(this.resolution),this.granularity=r}setSize(r,e){this.resolution.set(r,e),this.setGranularity(this.granularity)}};var G$=Math.PI*.5,U$=new M,k$=new M;var wM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",SM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9CbhlV1ktOvbpq09DkiIkUBI6kxASIH0DlAQiIK1wRfSJTx+i4JX7vKIigs8HXpXvqVcvrcC9agQ7IDTSSWgqCQQliDRBJKkkhDSkqVPNqVOnP+8b//rH3P+eZ+199tlznVTlvVrft7+1T7OaueZY42/m37QALKNk2wHg1pITlB17mC+Pp11W3X/LHyT32vhg48/5SOv+PnwpsHA70JoGlueB1iKApeqzvOzn44GatTB76Xzhd7suBR7+WWADgDEAwwCG/L54b/poDLrHuvvm70Z2Avhsc+PVcxscBU8F8C8ADg5+ipIjD/PlGwfgju8B924E5seARUfLsiNmqQW0IjL8+7L2NYD/7COBzfcCm+aB8SVgdAkYIRCXKyDax4EdAanL5PuNPllNvXDlAHwFgP8Ac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/RyEqzw/4xhGL3hD++MmslgqCbgUfLKAcRrmTlBzDN0DA1tAXUlWcDm1IOIIJAjlT/Fd05lbFQFwjdtgGcewesFt7Rc/Gx8iWjUCjGCT1YvWT1MwgUqrf3NG45tTbcu0aximWx9xENcEQHGbcYAEwtSXSqY0gnCdgeuMI0cvuGx/FUGgFhwEYrR80QckWN+X0fjm1DwAWv8RgJFilJZBznz0pQg+AZAAlVWh1GvGka0XzB0cCQi30aSGVa9AF62fLOB7MhrfnJoPwPER59Px+o3e76mL5Kwp2G57xPl0kxc3er+nLvyKtLmhfUC78RHn081ONnq/pzcAR5xPR9mRRu/31IVgvgUccT4dNaobvd/TGYAjzqejumqj93s6A3DE+XRUg2VSCjdaGr3fUw+I+VPwiPPpqJjO8J1Nw43e7ymHwHoAKMFd7QErAeEE5NNJMb3R+z3lsGcNzgfgiPPpomJ6o/d76oGwPgCOKJ8uKqY3er+nKwBHmE+noqRG7/fUA199U/AI8+kEwEbv93QHoEhZTnA+nYqSGr3fBoAtaiqBUImdm5hPJwA2er+nKwBHnE+X1gUzSbnR+z11wPj/AeCpPDD3t7rvAAAAAElFTkSuQmCC",vF="uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}",xF="varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}",MM=class extends Mr{constructor(r,e,t=Uo.HIGH,n=Vd.COLOR){super("SMAAEffect",vF,{vertexShader:xF,blendFunction:ut.NORMAL,attributes:ir.CONVOLUTION|ir.DEPTH,uniforms:new Map([["weightMap",new Ae(null)]])});this.renderTargetEdges=new bt(1,1,{minFilter:$e,stencilBuffer:!1,depthBuffer:!1,format:Nt}),this.renderTargetEdges.texture.name="SMAA.Edges",this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name="SMAA.Weights",this.renderTargetWeights.texture.format=zt,this.uniforms.get("weightMap").value=this.renderTargetWeights.texture,this.clearPass=new ig(!0,!1,!1),this.clearPass.overrideClearColor=new fe(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new Xr(new T3(new O,n)),this.weightsPass=new Xr(new O3);let i=new xt(r);i.name="SMAA.Search",i.magFilter=Pt,i.minFilter=Pt,i.format=zt,i.generateMipmaps=!1,i.needsUpdate=!0,i.flipY=!0;let s=new xt(e);s.name="SMAA.Area",s.magFilter=$e,s.minFilter=$e,s.format=zt,s.generateMipmaps=!1,s.needsUpdate=!0,s.flipY=!1;let o=this.weightsPass.getFullscreenMaterial();o.uniforms.searchTexture.value=i,o.uniforms.areaTexture.value=s,this.applyPreset(t)}get edgeDetectionMaterial(){return this.edgeDetectionPass.getFullscreenMaterial()}get colorEdgesMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.getFullscreenMaterial()}setEdgeDetectionThreshold(r){this.edgeDetectionPass.getFullscreenMaterial().setEdgeDetectionThreshold(r)}setOrthogonalSearchSteps(r){this.weightsPass.getFullscreenMaterial().setOrthogonalSearchSteps(r)}applyPreset(r){let e=this.edgeDetectionMaterial,t=this.weightsMaterial;switch(r){case Uo.LOW:e.setEdgeDetectionThreshold(.15),t.setOrthogonalSearchSteps(4),t.diagonalDetection=!1,t.cornerRounding=!1;break;case Uo.MEDIUM:e.setEdgeDetectionThreshold(.1),t.setOrthogonalSearchSteps(8),t.diagonalDetection=!1,t.cornerRounding=!1;break;case Uo.HIGH:e.setEdgeDetectionThreshold(.1),t.setOrthogonalSearchSteps(16),t.setDiagonalSearchSteps(8),t.setCornerRounding(25),t.diagonalDetection=!0,t.cornerRounding=!0;break;case Uo.ULTRA:e.setEdgeDetectionThreshold(.05),t.setOrthogonalSearchSteps(32),t.setDiagonalSearchSteps(16),t.setCornerRounding(25),t.diagonalDetection=!0,t.cornerRounding=!0;break}}setDepthTexture(r,e=Kr){let t=this.edgeDetectionMaterial;t.uniforms.depthBuffer.value=r,t.depthPacking=e}update(r,e,t){this.clearPass.render(r,this.renderTargetEdges),this.edgeDetectionPass.render(r,e,this.renderTargetEdges),this.weightsPass.render(r,this.renderTargetEdges,this.renderTargetWeights)}setSize(r,e){let t=this.edgeDetectionPass.getFullscreenMaterial(),n=this.weightsPass.getFullscreenMaterial();this.renderTargetEdges.setSize(r,e),this.renderTargetWeights.setSize(r,e),n.uniforms.resolution.value.set(r,e),n.uniforms.texelSize.value.set(1/r,1/e),t.uniforms.texelSize.value.copy(n.uniforms.texelSize.value)}dispose(){let r=this.weightsPass.getFullscreenMaterial().uniforms;r.searchTexture.value.dispose(),r.areaTexture.value.dispose(),super.dispose()}static get searchImageDataURL(){return wM}static get areaImageDataURL(){return SM}},Uo={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3};var bF=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #ifdef ESKIL vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #else float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #endif outputColor=vec4(color,inputColor.a);}`,AM=class extends Mr{constructor(r={}){let e=Object.assign({blendFunction:ut.NORMAL,eskil:!1,offset:.5,darkness:.5},r);super("VignetteEffect",bF,{blendFunction:e.blendFunction,uniforms:new Map([["offset",new Ae(e.offset)],["darkness",new Ae(e.darkness)]])});this.eskil=e.eskil}get eskil(){return this.defines.has("ESKIL")}set eskil(r){this.eskil!==r&&(r?this.defines.set("ESKIL","1"):this.defines.delete("ESKIL"),this.setChanged())}},j$=[new Float32Array(3),new Float32Array(3)],W$=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],J$=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var X$=[new Float32Array(2),new Float32Array(2)];var q$=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),Y$=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],K$=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Q$=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Z$=new Map([[Hn(0,0,0,0),new Float32Array([0,0,0,0])],[Hn(0,0,0,1),new Float32Array([0,0,0,1])],[Hn(0,0,1,0),new Float32Array([0,0,1,0])],[Hn(0,0,1,1),new Float32Array([0,0,1,1])],[Hn(0,1,0,0),new Float32Array([0,1,0,0])],[Hn(0,1,0,1),new Float32Array([0,1,0,1])],[Hn(0,1,1,0),new Float32Array([0,1,1,0])],[Hn(0,1,1,1),new Float32Array([0,1,1,1])],[Hn(1,0,0,0),new Float32Array([1,0,0,0])],[Hn(1,0,0,1),new Float32Array([1,0,0,1])],[Hn(1,0,1,0),new Float32Array([1,0,1,0])],[Hn(1,0,1,1),new Float32Array([1,0,1,1])],[Hn(1,1,0,0),new Float32Array([1,1,0,0])],[Hn(1,1,0,1),new Float32Array([1,1,0,1])],[Hn(1,1,1,0),new Float32Array([1,1,1,0])],[Hn(1,1,1,1),new Float32Array([1,1,1,1])]]);function ag(r,e,t){return r+(e-r)*t}function Hn(r,e,t,n){let i=ag(r,e,1-.25),s=ag(t,n,1-.25);return ag(i,s,1-.125)}var _M=class extends fn{load(r=()=>{},e=null){arguments.length===4?(r=arguments[1],e=arguments[3]):(arguments.length===3||typeof arguments[0]!="function")&&(r=arguments[1],e=null);let t=this.manager,n=new yo;return new Promise((i,s)=>{let o=new Image,a=new Image;n.onError=l=>{t.itemError(l),e!==null?(e(`Failed to load ${l}`),i()):s(`Failed to load ${l}`)},n.onLoad=()=>{let l=[o,a];r(l),i(l)},o.addEventListener("error",l=>{n.itemError("smaa-search")}),a.addEventListener("error",l=>{n.itemError("smaa-area")}),o.addEventListener("load",()=>{t.itemEnd("smaa-search"),n.itemEnd("smaa-search")}),a.addEventListener("load",()=>{t.itemEnd("smaa-area"),n.itemEnd("smaa-area")}),t.itemStart("smaa-search"),t.itemStart("smaa-area"),n.itemStart("smaa-search"),n.itemStart("smaa-area"),o.src=wM,a.src=SM})}};var hn=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(n){this.effect.blendMode.opacity.value=n},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(n){this.effect.blendMode.setBlendFunction(Number(n))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=ut.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t=Ue({},this),n=Object.getPrototypeOf(this),i=Object.getOwnPropertyNames(n);for(let s of i){let o=Object.getOwnPropertyDescriptor(n,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var ru=class extends hn{constructor(){super(fM);this.blendFunction=ut.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var su=class extends hn{constructor(){super(pM)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var ou=class extends hn{constructor(){super(gM);this.effect.offset=new O(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var au=class extends hn{constructor(){super(mM)}};var lu=class extends hn{constructor(){super(vM);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var cu=class extends hn{constructor(){super(xM);this.blendFunction=ut.OVERLAY}};var uu=class extends hn{constructor(){super(AM)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var hu=class extends hn{constructor(e){super(yM,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var du=class extends hn{constructor(){super(bM)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function TM(r,e){return e&&e.enabled&&r.push(e.effect),r}var fu=class{constructor(){this._scene=new An;this._camera=new Sr;this.effects=new Map;this.loadingManager=new yo;this.smaaImageLoader=new _M(this.loadingManager);this.renderPass=new sg;this._renderToScreen=!0;this.clock=new Ep,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new ru),this.effects.set("chromaticAberration",new ou),this.effects.set("vignette",new uu),this.effects.set("noise",new cu),this.effects.set("colorAverage",new au),this.effects.set("hueSaturation",new lu),this.effects.set("brightnessContrast",new su),this.effects.set("depthOfField",new hu),this.effects.set("pixelation",new du)}get scene(){return this._scene}set scene(e){this._scene=e,this._initPasses()}get camera(){return this._camera}set camera(e){this._camera=e,this._initPasses()}_initSmaa(){let e=this.effectComposer.passes.length;this.smaaImageLoader.load(([t,n])=>{if(!this.effectComposer)return;let i=new MM(t,n,Uo.ULTRA,Vd.COLOR);i.edgeDetectionMaterial.setPredicationMode(oM.DEPTH),i.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),i.edgeDetectionMaterial.setPredicationThreshold(.002),i.edgeDetectionMaterial.setPredicationScale(1),this.effectComposer.addPass(new Hd(this.camera,i),e)})}_initPasses(){if(!(!this.effectComposer||!this.renderer))if(this.effectComposer.removeAllPasses(),this.renderPass=new sg(this.scene,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass),this._initSmaa();let e=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(TM,[]),t=[this.effects.get("pixelation")].reduce(TM,[]);t.length>0&&this.effectComposer.addPass(new Hd(this.camera,...t)),this.effectComposer.addPass(new Hd(this.camera,...e))}else this.effectComposer.addPass(this.renderPass)}reinit(){!this.renderer||(this.effectComposer=new dM(this.renderer),this._initPasses())}init({renderer:e,camera:t,scene:n}){this.renderer=e,this.scene=n,this.camera=t,this._initSavePass(),this.reinit()}_initSavePass(){if(this._savePass)return;let e=new O;this.renderer.getDrawingBufferSize(e);let t=this.renderer.capabilities.isWebGL2?Zr:bt;this._rt=new t(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:di,wrapT:di}),this._savePass=new lM(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){var n,i;let t=this.effectComposer;!t||(e===!0?(((n=this.renderer)==null?void 0:n.capabilities.isWebGL2)&&(t.multisampling=0),t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(((i=this.renderer)==null?void 0:i.capabilities.isWebGL2)&&(t.multisampling=4),t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(e){e&&(Object.keys(e).forEach(t=>{let n=e[t],i=this.effects.get(t);Object.keys(n).forEach(s=>{i[s]=n[s]})}),this.enabled=e.enabled)}toJSON(){let e={};return this.effects.forEach((t,n)=>{e[n]=t.toJSON()},e),Ue({enabled:this.enabled},e)}render(){var e;(e=this.effectComposer)==null||e.render(this.clock.getDelta())}setScissor(e,t,n,i){if(!this.effectComposer||!this.renderer)return;e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,n,i),this.effectComposer.outputBuffer.scissor.set(e,t,n,i));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,n,i)}setScissorTest(e){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e))}setViewport(e,t,n,i){!this.effectComposer||(e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,n,i),this.effectComposer.outputBuffer.viewport.set(e,t,n,i)))}resize(e,t){var n,i;if((n=this.effectComposer)==null||n.setSize(e,t),this._rt){let s=((i=this.renderer)==null?void 0:i.getPixelRatio())||window.devicePixelRatio;this._rt.setSize(e*s,t*s)}}};var EM;(function(e){function r(t){new Qe(t.r/255,t.g/255,t.b/255,t.a)}e.getThreeVector4=r})(EM||(EM={}));var jd;(function(t){function r(n,i){n.setRGB(i.r/255,i.g/255,i.b/255)}t.setThreeColor=r;function e(n){return new fe(n.r/255,n.g/255,n.b/255).getHex()}t.getHex=e})(jd||(jd={}));var zs=class extends Ld(An){constructor(){super();this.objectType="Scene";this.alpha=1;this.backupFog=new hs(16777215,.1,2e3);this.fogUseBGColor=!1;this.directionalLightState=!0;this.ambientLightState=!0;this.wireframeState=!1;this._color=new fe(1644825);this.canvas={mode:1,preset:"fullscreen",size:{width:512,height:512},editorSize:{width:1,height:1},color:[0,0,0,.5]};this.name="Untitled",this.postprocessing=new fu}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){this.camera=new Sr(e,t),this.camera.setDefault(),this.camera.orthoCamera.near=-5e4,this.camera.perspCamera.near=50,this.camera.orthoCamera.far=1e5,this.camera.perspCamera.far=1e5,this.camera.updateProjectionMatrix(),this.camera.position.set(0,0,Sr.DefaultTargetOffset),this.camera.lookAt(new M(0,0,-1)),this.add(this.camera),this.canvas.size.width=e,this.canvas.size.height=t,this.ambientLight=new uc(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.add(this.ambientLight),this.directionalLight=new Fr(16777215,.75),this.directionalLight.name="Default Directional Light",this.directionalLight.position.set(85e4,13e5,1e6),this.activeCamera=this.camera,this.activeCamera.add(this.directionalLight)}initFromObjectLoader(e){return this.traverse(t=>{t.uuid===e.ambientLight?this.ambientLight=t:t.uuid===e.directionalLight?this.directionalLight=t:(t.uuid===e.activeCamera&&(this.activeCamera=t),t.uuid===e.camera&&(this.camera=t,this.camera.setDefault()))}),this}raycast(e){let t=[],n=i=>{for(let s of i.children)ei(s)&&!s.raycastLock&&s.visible&&((ai(s)||Hh(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),n(s))};return n(this),t}traverseEntity(e){for(let t of this.children)ei(t)&&this.camera!==t&&t.traverseEntity(e)}updateFog(e){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.color):jd.setThreeColor(this.backupFog.color,e.color),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){var i,s,o,a,l;let t=super.toJSON(e),n=t.object;return n.objectType="Scene",n.activeCamera=(i=this.activeCamera)==null?void 0:i.uuid,n.camera=(s=this.camera)==null?void 0:s.uuid,n.directionalLight=(o=this.directionalLight)==null?void 0:o.uuid,n.ambientLight=(a=this.ambientLight)==null?void 0:a.uuid,n.color=this.color.toArray(),n.alpha=this.alpha,this.background instanceof xt?n.background=this.background.toJSON(e):this.background instanceof fe&&(n.background=this.background.toArray()),this.environment!==null&&(n.environment=this.environment.toJSON(e)),this.enableFog===!0&&(n.enableFog=!0,this.fogUseBGColor===!0&&(n.fogUseBGColor=!0),this.fog!==null&&(n.fog=this.fog.toJSON())),this.directionalLightState===!0&&(n.directionalLightState=!0),this.ambientLightState===!0&&(n.ambientLightState=!0),this.wireframeState===!0&&(n.wireframeState=!0),n.canvas={mode:this.canvas.mode,preset:this.canvas.preset,editorSize:{width:window.innerWidth,height:window.innerHeight},color:this.canvas.color},this.canvas.mode!==1&&(n.canvas.size={width:this.canvas.size.width,height:this.canvas.size.height}),n.postprocessing=(l=this.postprocessing)==null?void 0:l.toJSON(),t}fromJSON(e){var n,i,s,o,a;super.fromJSON(e),this.postprocessing=new fu,this.color.fromArray(e.color),this.alpha=e.alpha,e.background!==void 0&&Array.isArray(e.background)&&(this.background=new fe().fromArray(e.background)),e.fog!==void 0&&(e.fog.type==="FogExp2"?this.backupFog=new io(e.fog.color,e.fog.density):this.backupFog=new hs(e.fog.color,e.fog.near,e.fog.far)),this.fogUseBGColor=(n=e.fogUseBGColor)!=null?n:!1,this.enableFog=(i=e.enableFog)!=null?i:!1,this.directionalLightState=(s=e.directionalLightState)!=null?s:!1,this.ambientLightState=(o=e.ambientLightState)!=null?o:!1,this.wireframeState=(a=e.wireframeState)!=null?a:!1;let t=e.canvas;return this.canvas.mode=t.mode,this.canvas.preset=t.preset,t.size&&(this.canvas.size={width:t.size.width,height:t.size.height}),this.canvas.editorSize=t.editorSize?{width:t.editorSize.width,height:t.editorSize.height}:{width:window.innerWidth,height:window.innerHeight},t.color&&(this.canvas.color=[...t.color]),this.postprocessing.fromJSON(e.postprocessing),this}dispose(){this.traverseEntity(e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach(t=>t.dispose()):e.material.dispose())})}};var lg=class extends je{constructor(e="",t){super(t);this.nodeType="Attribute";this.name=e}getAttributeType(e){return typeof this.type=="number"?e.getConstructorFromLength(this.type):this.type}getType(e){let t=this.getAttributeType(e);return e.getTypeByFormat(t)}generate(e,t,n,i,s){i=this.getAttributeType(e);let o=e.getAttribute(this.name,i),a=e.isShader("vertex")?this.name:o.varying.name;return e.format(a,this.getType(e),t)}toJSON(e){let t=super.toJSON(e);return t.nodeType=this.nodeType,t.name=this.name,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),e.name&&(this.name=e.name),this}};var cg=class extends ze{constructor(e="",t=0){super(e);this.nodeType="Varying";this.value=t}getType(e){return e.getTypeByFormat(this.type)}generate(e,t,n,i,s){let o=e.getVar(this.uuid,this.type);return this.value&&e.isShader("vertex")&&e.addNodeCode(o.name+" = "+this.value.build(e,this.getType(e))+";"),e.format(o.name,this.getType(e),t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var ug=class extends Ct{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e!=null?e:new me}generateReadonly(e,t,n,i,s,o){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}copy(e){return super.copy(e),this.elements=e.elements,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.elements&&(this.elements=e.elements),this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Ar;(function(l){l.EQUAL="==",l.NOT_EQUAL="!=",l.GREATER=">",l.GREATER_EQUAL=">=",l.LESS="<",l.LESS_EQUAL="<=",l.AND="&&",l.OR="||"})(Ar||(Ar={}));var hg=class extends je{constructor(e=new ze,t=new ze,n=hg.GREATER,i=new ze,s=new ze){super();this.nodeType="Cond";this.a=e,this.b=t,this.op=n,this.ifNode=i,this.elseNode=s}getType(e){if(this.ifNode){let t=this.ifNode.getType(e),n=this.elseNode.getType(e);return e.getTypeLength(n)>e.getTypeLength(t)?n:t}return"b"}getCondType(e){return e.getTypeLength(this.b.getType(e))>e.getTypeLength(this.a.getType(e))?this.b.getType(e):this.a.getType(e)}generate(e,t){let n=this.getType(e),i=this.getCondType(e),s=this.a.build(e,i),o=this.b.build(e,i),a;if(this.type=n,this.ifNode){let l=this.ifNode.build(e,n),c=this.elseNode.build(e,n);a="( "+[s,this.op,o,"?",l,":",c].join(" ")+" )"}else a="( "+s+" "+this.op+" "+o+" )";return e.format(a,this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this.ifNode.copy(e.ifNode),this.elseNode.copy(e.elseNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op,this.ifNode&&(t.ifNode=this.ifNode.toJSON(e).uuid),this.elseNode&&(t.elseNode=this.elseNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),e.ifNode&&(this.ifNode=t.getNode(e.ifNode)),e.elseNode&&(this.elseNode=t.getNode(e.elseNode)),this}},rr=hg;rr.EQUAL=Ar.EQUAL,rr.NOT_EQUAL=Ar.NOT_EQUAL,rr.GREATER=Ar.GREATER,rr.GREATER_EQUAL=Ar.GREATER_EQUAL,rr.LESS=Ar.LESS,rr.LESS_EQUAL=Ar.LESS_EQUAL,rr.AND=Ar.AND,rr.OR=Ar.OR;var Tl=class extends Te{constructor(e){super();this.nodeType="MaxMIPLevel";this.texture=e,this.maxMIPLevel=0}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),t.maxMIPLevel=this.maxMIPLevel),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel!==void 0&&(this.maxMIPLevel=e.maxMIPLevel),this}};Object.defineProperties(Tl.prototype,{value:{get:function(){if(this.maxMIPLevel===0){let r=this.texture.value.image;Array.isArray(r)&&(r=r[0]),this.maxMIPLevel=r!==void 0?Math.log(Math.max(r.width,r.height))*Math.LOG2E:0}return this.maxMIPLevel},set:function(){}}});var dg=class extends je{constructor(e=new ze,t){super("f");this.nodeType="SpecularMIPLevel";this.roughness=e,this.texture=t}setTexture(e){return this.texture=e,this}generate(e,t){var n;if(e.isShader("fragment")){this.maxMIPLevel=(n=this.maxMIPLevel)!=null?n:new Tl,this.maxMIPLevel.texture=this.texture;let i=e.include(dg.Nodes.getSpecularMIPLevel);return e.format(i+"( "+this.roughness.build(e,"f")+", "+this.maxMIPLevel.build(e,"f")+" )",this.type,t)}else return console.warn("SpecularMIPLevelNode is not compatible with "+e.shader+" shader."),e.format("0.0",this.type,t)}copy(e){return super.copy(e),this.roughness=e.roughness,e.texture?this.texture?this.texture.copy(e.texture):this.texture=e.texture.clone():this.texture=void 0,e.maxMIPLevel?this.maxMIPLevel?this.maxMIPLevel.copy(e.maxMIPLevel):this.maxMIPLevel=e.maxMIPLevel.clone():this.maxMIPLevel=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),this.roughness&&(t.roughness=this.roughness.toJSON(e).uuid),this.maxMIPLevel&&(t.maxMIPLevel=this.maxMIPLevel.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel&&(this.maxMIPLevel=t.getNode(e.maxMIPLevel)),this}},Wd=dg;Wd.Nodes=function(){return{getSpecularMIPLevel:new Le(["float getSpecularMIPLevel( const in float roughness, const in float maxMIPLevelScalar ) {"," float sigma = PI * roughness * roughness / ( 1.0 + roughness );"," float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );"," return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );","}"].join(` `))}}();var NM={Int:it,Float:Te,Bool:mc,Vector2:In,Vector3:Un,Vector4:yc,Matrix3:zr,Matrix4:ug,FloatArray:Ba,Vector4Array:Ra,Normal:mn,Position:_n,Reflect:Qi,UV:bo,Attribute:lg,Const:rt,Struct:Ao,Varying:cg,SpecularMIPLevel:Wd,MaxMIPLevel:Tl,ColorSpace:Bt,Noise:Wa,TextureCubeUV:_o,TextureCube:vc,Operator:Yn,Math:Ye,Cond:rr,Fresnel:Ga,Rainbow:ka,Transmission:Va,Depth:qa,Blend:Xa,Raw:Qa,CubeTexture:xc,Texture:kn,CustomTexture:za,VertexDisplacement:Mo,CustomNormal:Ha,Gradient:ja,Matcap:Ya,Expression:yt,Color:ct,Phong:wc,Basic:bc,Lambert:Sc,Standard:Tc,Toon:Ac};var Jd=class{constructor(){this._nodes={};this._dataNodes={};this._textures={};this.uuid=Ee.generateUUID()}init(e,t){this._dataNodes=e,this._textures=t}clear(){this._nodes={},this._dataNodes={},this._textures={}}getNode(e){let t=this._nodes[e];return t||(t=this.createNode(e)),t}getNodeData(e){return this._dataNodes[e]}getTexture(e){let t=this._textures[e];return t||new bi}createNode(e){let t=this._dataNodes[e];if(!t)throw new Error("Failed to create Node from uuid: "+e+", its data does not seem to exist");let n=NM[t.nodeType];if(!n)throw new Error("Failed to create Node from uuid: "+e+" and nodeType: "+t.nodeType+", constructor for this not is not registered");let i=new n().fromJSON(t,this);return this._nodes[e]=i,i}};function CM(r){wF(r.geometries),SF(r.interactionStates),LM(r.object),MF(r.materials)}function wF(r){var e;if(r!==void 0){for(let t of r)if(((e=t.userData)==null?void 0:e.type)!==void 0){let n=t.userData.parameters;"extrudeDepth"in n||Object.assign(n,{extrudeDepth:0}),"extrudeBevelSize"in n||Object.assign(n,{extrudeBevelSize:0}),"extrudeBevelSegments"in n||Object.assign(n,{extrudeBevelSegments:1})}}}function SF(r){if(r!==void 0){for(let e of r)if(e.quaternion!==void 0){let t=new Tt().fromArray(e.quaternion);Object.assign(e,{rotation:new On().setFromQuaternion(t).toArray()})}}}function LM(r){var e,t,n,i;if(((e=r.userData)==null?void 0:e.type)===void 0)if(r.type==="OrthographicCamera"||r.type==="PerspectiveCamera"){let s=r;Object.assign(r,{objectType:"CombinedCamera",cameraType:s.type,isDefaultCamera:!0,hiddenMatrix:new me().toArray(),name:"Default Camera",far:1e5,zoomOrtho:s.zoom,zoomPersp:1,nearOrtho:-5e4,nearPersp:50}),delete r.type,s.typeCamera!==void 0&&(Object.assign(r,{cameraType:s.typeCamera}),delete r.typeCamera)}else r.type==="Scene"?(Object.assign(r,{objectType:r.type}),delete r.type):r.type==="HemisphereLight"?Object.assign(r,{isDefaultAmbientLight:!0}):r.type==="DirectionalLight"&&Object.assign(r,{isDefaultDirectionalLight:!0});if(r.userData!==void 0){let s=r.userData;s.type!==void 0&&(Object.assign(r,{objectType:s.type}),delete s.type),s.interaction!==void 0&&(Object.assign(r,{interaction:s.interaction}),delete s.interaction),s.isDefaultAmbientLight===!0?(Object.assign(r,{isDefaultAmbientLight:!0}),delete s.isDefaultAmbientLight):s.isDefaultDirectionalLight===!0?(Object.assign(r,{isDefaultDirectionalLight:!0}),delete s.isDefaultDirectionalLight):s.isDefaultCamera===!0&&(Object.assign(r,{isDefaultCamera:!0}),delete s.isDefaultCamera),Object.assign(r,{raycastLock:s.lock,scaleLock:s.scaleLock,hiddenMatrix:(n=(t=s.hiddenMatrix)==null?void 0:t.elements)!=null?n:new me().toArray()}),delete s.lock,delete s.scaleLock,delete s.hiddenMatrix,delete s.isEntity}if(((i=r.interaction)==null?void 0:i.events)!==void 0){for(let s of r.interaction.events)if(s.targets!==void 0)for(let o of s.targets)o.springControls!==void 0&&(Object.assign(o,{springParameters:{mass:o.springControls[0],stiffness:o.springControls[1],damping:o.springControls[2],velocity:o.springControls[3]}}),delete o.springControls)}if(r.children!==void 0)for(let s of r.children)LM(s)}function MF(r){if(r!==void 0)for(let e of r){let n=e.userData.layers.head;for(;n;){for(let i in n.uniforms){let s=`f${n.id}_tex`,o=`f${n.id}_texture`;i===s&&(n.uniforms[o]=n.uniforms[s],delete n.uniforms[s])}n=n.next}}}function IM(r){PM(r.object,r.object)}function PM(r,e){var t;if(r.type==="HemisphereLight"||r.isDefaultAmbientLight===!0?e.ambientLight=r.uuid:((t=r.userData)==null?void 0:t.isDefaultDirectionalLight)===!0||r.isDefaultDirectionalLight===!0?e.directionalLight=r.uuid:r.isDefaultCamera===!0&&(e.camera=r.uuid,e.activeCamera=r.uuid,Object.assign(r,{name:"Default Camera"})),r.children!==void 0)for(let n of r.children)PM(n,e)}function DM(r){AF(r.object)}function AF(r){var e,t,n,i,s,o,a;if(r.objectType==="Scene"){let l=r.userData,c=(e=l.rgb)!=null?e:{r:25,g:25,b:25},u=(t=l.fogColor)!=null?t:{r:25,g:25,b:25};Object.assign(r,{color:[c.r/255,c.g/255,c.b/255],alpha:l.alpha,enableFog:l.fogEnable,fogUseBGColor:l.fogUseBGColor,fog:{color:new fe().setRGB(u.r/255,u.g/255,u.b/255).getHex(),near:l.fogNear,far:l.fogFar},directionalLightState:l.directionalLightState,ambientLightState:l.ambientLightState,shadowsState:l.shadowsState,wireframeState:l.wireframeState,canvas:{mode:(n=l.canvasMode)!=null?n:1,size:{width:(s=(i=l.canvasCustomSize)==null?void 0:i.width)!=null?s:512,height:(a=(o=l.canvasCustomSize)==null?void 0:o.height)!=null?a:512}}}),delete l.rgb,delete l.alpha,delete l.fogEnable,delete l.fogUseBGColor,delete l.fogColor,delete l.fogNear,delete l.fogFar,delete l.directionalLightState,delete l.ambientLightState,delete l.shadowsState,delete l.wireframeState,delete l.canvasMode,delete l.canvasFullScreen,delete l.canvasCustomSize}}function RM(r){return{uuid:Ee.generateUUID(),type:"b",value:r,nodeType:"Bool"}}function Si(r,e){let t=new fe().set(r);return{uuid:Ee.generateUUID(),type:"c",r:t.r,g:t.g,b:t.b,value:r,alpha:e==null?void 0:e.uuid,nodeType:"Color"}}function BM(r,e){return{uuid:Ee.generateUUID(),type:"f[]",size:r,value:e,nodeType:"FloatArray"}}function mt(r){return{uuid:Ee.generateUUID(),type:"f",value:r,nodeType:"Float"}}function an(r){return{uuid:Ee.generateUUID(),type:"i",value:r,nodeType:"Int"}}function El(r){let{x:e,y:t}=r;return{uuid:Ee.generateUUID(),type:"v2",x:e,y:t,nodeType:"Vector2"}}function fg(r){let{x:e,y:t,z:n}=r;return{uuid:Ee.generateUUID(),type:"v3",x:e,y:t,z:n,nodeType:"Vector3"}}function OM(r,e){return{uuid:Ee.generateUUID(),type:"v4[]",size:r,value:e,nodeType:"Vector4Array"}}function FM(r){return{uuid:Ee.generateUUID(),type:"m3",elements:r.elements,nodeType:"Matrix3"}}function zM(r,e){return{uuid:Ee.generateUUID(),type:"v4",value:r,uv:e.uuid,project:!1,nodeType:"Texture"}}function GM(r){return{uuid:Ee.generateUUID(),type:"v2",index:r,nodeType:"UV"}}function pg(r,e){let t={uuid:Ee.generateUUID(),type:"v3",nodeType:"Blend",a:r==null?void 0:r.uuid,b:e.uuid};return"mode"in e&&(t.mode=e.mode),t}function UM(r,e){let t=r.uniforms,n=r.id,i=mt(t[`f${n}_alpha`].value),s=an(t[`f${n}_mode`].value);return[i,s].forEach(o=>e[o.uuid]=o),Object.assign(r,{uniforms:{[`f${n}_alpha`]:i.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"CustomTexture",alpha:i.uuid,mode:s.uuid}}function mg(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=Si(t[`f${n}_color`].value,s);return[o,s,i].forEach(a=>e[a.uuid]=a),Object.assign(r,{uniforms:{[`f${n}_color`]:o.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),o}function kM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=fg(t[`f${n}_cnormal`].value);return[o,s,i].forEach(a=>e[a.uuid]=a),Object.assign(r,{uniforms:{[`f${n}_cnormal`]:o.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"CustomNormal",cnormal:o.uuid,alpha:s.uuid,mode:i.uuid}}function VM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=mt(t[`f${n}_near`].value),a=mt(t[`f${n}_far`].value),l=mt(t[`f${n}_isVector`].value),c=fg(t[`f${n}_origin`].value),u=Si(t[`f${n}_colorA`].value),h=Si(t[`f${n}_colorB`].value);return[o,a,l,c,u,h,s,i].forEach(d=>e[d.uuid]=d),Object.assign(r,{uniforms:{[`f${n}_near`]:o.uuid,[`f${n}_far`]:a.uuid,[`f${n}_isVector`]:l.uuid,[`f${n}_origin`]:c.uuid,[`f${n}_colorA`]:u.uuid,[`f${n}_colorB`]:h.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Depth",near:o.uuid,far:a.uuid,isVector:l.uuid,origin:c.uuid,colorA:u.uuid,colorB:h.uuid,alpha:s.uuid,mode:i.uuid}}function HM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=Si(t[`f${n}_color`].value),a=mt(t[`f${n}_bias`].value),l=mt(t[`f${n}_scale`].value),c=mt(t[`f${n}_intensity`].value),u=mt(t[`f${n}_factor`].value);return[o,a,l,c,u,s,i].forEach(h=>e[h.uuid]=h),Object.assign(r,{uniforms:{[`f${n}_color`]:o.uuid,[`f${n}_bias`]:a.uuid,[`f${n}_scale`]:l.uuid,[`f${n}_intensity`]:c.uuid,[`f${n}_factor`]:u.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Fresnel",color:o.uuid,bias:a.uuid,scale:l.uuid,intensity:c.uuid,factor:u.uuid,alpha:s.uuid,mode:i.uuid}}function jM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=an(t[`f${n}_gl_type`].value),a=an(t[`f${n}_num`].value),l=RM(t[`f${n}_smooth`].value),c=OM(10,t[`f${n}_colors`].value),u=BM(10,t[`f${n}_steps`].value),h=El(t[`f${n}_offset`].value),d=El(t[`f${n}_morph`].value),f=mt(t[`f${n}_angle`].value);return[o,a,l,c,u,h,d,f,s,i].forEach(p=>e[p.uuid]=p),Object.assign(r,{uniforms:{[`f${n}_gl_type`]:o.uuid,[`f${n}_num`]:a.uuid,[`f${n}_smooth`]:l.uuid,[`f${n}_colors`]:c.uuid,[`f${n}_steps`]:u.uuid,[`f${n}_offset`]:h.uuid,[`f${n}_morph`]:d.uuid,[`f${n}_angle`]:f.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Gradient",gl_type:o.uuid,num:a.uuid,smooth:l.uuid,colors:c.uuid,steps:u.uuid,offset:h.uuid,morph:d.uuid,angle:f.uuid,alpha:s.uuid,mode:i.uuid}}function WM(r,e){let t=r.uniforms,n=r.id,i=Ee.generateUUID(),s=an(t[`f${n}_mode`].value),o=mt(t[`f${n}_alpha`].value),a=mt(t[`f${n}_crop`].value),l=GM(0),c=zM(t[`f${n}_texture`].value,l),u=FM(t[`f${n}_mat`].value);return[c,l,u,a,o,s].forEach(h=>e[h.uuid]=h),Object.assign(r,{uniforms:{[`f${n}_texture`]:c.uuid,[`f${n}_mat`]:u.uuid,[`f${n}_crop`]:a.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:i,type:"v3",nodeType:"CustomTexture",texture:c.uuid,crop:a.uuid,alpha:o.uuid,mode:s.uuid}}function JM(r,e){let t=r.uniforms,n=r.id,i=an(t[`f${n}_mode`].value),s=mt(t[`f${n}_alpha`].value),o=mt(t[`f${n}_scale`].value),a=mt(t[`f${n}_move`].value),l=El(t[`f${n}_fA`].value),c=El(t[`f${n}_fB`].value),u=El(t[`f${n}_distortion`].value),h=Si(t[`f${n}_colorA`].value),d=Si(t[`f${n}_colorB`].value),f=Si(t[`f${n}_colorC`].value),p=Si(t[`f${n}_colorD`].value),m=an(t[`f${n}_intA`].value),v=an(t[`f${n}_intB`].value),g=an(t[`f${n}_intC`].value),y=an(t[`f${n}_intD`].value);return[o,a,l,c,u,h,d,f,p,m,v,g,y,s,i].forEach(x=>e[x.uuid]=x),Object.assign(r,{uniforms:{[`f${n}_scale`]:o.uuid,[`f${n}_move`]:a.uuid,[`f${n}_fA`]:l.uuid,[`f${n}_fB`]:c.uuid,[`f${n}_distortion`]:u.uuid,[`f${n}_colorA`]:h.uuid,[`f${n}_colorB`]:d.uuid,[`f${n}_colorC`]:f.uuid,[`f${n}_colorD`]:p.uuid,[`f${n}_intA`]:m.uuid,[`f${n}_intB`]:v.uuid,[`f${n}_intC`]:g.uuid,[`f${n}_intD`]:y.uuid,[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:i.uuid}}),{uuid:Ee.generateUUID(),type:"v3",nodeType:"Noise",scale:o.uuid,move:a.uuid,fA:l.uuid,fB:c.uuid,distortion:u.uuid,colorA:h.uuid,colorB:d.uuid,colorC:f.uuid,colorD:p.uuid,intA:m.uuid,intB:v.uuid,intC:g.uuid,intD:y.uuid,alpha:s.uuid,mode:i.uuid}}function gg(r,e,t){let n=e.uniforms,i=e.id,s=mt(n[`f${i}_alpha`].value),o=an(n[`f${i}_mode`].value);return[s,o].forEach(a=>t[a.uuid]=a),Object.assign(e,{uniforms:{[`f${i}_alpha`]:s.uuid,[`f${i}_mode`]:o.uuid}}),{uuid:Ee.generateUUID(),type:"basic",nodeType:"Basic",shadingAlpha:s.uuid,shadingBlend:o.uuid}}function XM(r,e,t){var c,u;let n=e.uniforms,i=e.id,s=Si((c=r.specular)!=null?c:69905),o=mt((u=r.shininess)!=null?u:30),a=mt(n[`f${i}_alpha`].value),l=an(n[`f${i}_mode`].value);return[s,o,a,l].forEach(h=>t[h.uuid]=h),Object.assign(e,{uniforms:{[`f${i}_alpha`]:a.uuid,[`f${i}_mode`]:l.uuid}}),{uuid:Ee.generateUUID(),type:"phong",nodeType:"Phong",specular:s.uuid,shininess:o.uuid,shadingAlpha:a.uuid,shadingBlend:l.uuid}}function qM(r,e,t){var c,u;let n=e.uniforms,i=e.id,s=Si((c=r.emissive)!=null?c:0),o=mt((u=r.emissiveIntensity)!=null?u:1),a=mt(n[`f${i}_alpha`].value),l=an(n[`f${i}_mode`].value);return[o,s,a,l].forEach(h=>t[h.uuid]=h),Object.assign(e,{uniforms:{[`f${i}_alpha`]:a.uuid,[`f${i}_mode`]:l.uuid}}),{uuid:Ee.generateUUID(),type:"lambert",nodeType:"Lambert",emissiveIntensity:o.uuid,emissive:s.uuid,shadingAlpha:a.uuid,shadingBlend:l.uuid}}function YM(r,e,t){var c,u;let n=e.uniforms,i=e.id,s=Si((c=r.specular)!=null?c:69905),o=mt((u=r.shininess)!=null?u:30),a=mt(n[`f${i}_alpha`].value),l=an(n[`f${i}_mode`].value);return[s,o,a,l].forEach(h=>t[h.uuid]=h),Object.assign(e,{uniforms:{[`f${i}_alpha`]:a.uuid,[`f${i}_mode`]:l.uuid}}),{uuid:Ee.generateUUID(),type:"toon",nodeType:"Toon",specular:s.uuid,shininess:o.uuid,shadingAlpha:a.uuid,shadingBlend:l.uuid}}function KM(r,e,t){var u,h,d;let n=e.uniforms,i=e.id,s=mt((u=r.roughness)!=null?u:.3),o=mt((h=r.metalness)!=null?h:0),a=mt((d=r.reflectivity)!=null?d:.5),l=mt(n[`f${i}_alpha`].value),c=an(n[`f${i}_mode`].value);return[s,o,a,l,c].forEach(f=>t[f.uuid]=f),Object.assign(e,{uniforms:{[`f${i}_alpha`]:l.uuid,[`f${i}_mode`]:c.uuid}}),{uuid:Ee.generateUUID(),type:"standard",nodeType:"Standard",roughness:s.uuid,metalness:o.uuid,reflectivity:a.uuid,shadingAlpha:l.uuid,shadingBlend:c.uuid}}var QM=new me,_F=["RectangleGeometry","TriangleGeometry","PolygonGeometry","StarGeometry"];function ZM(r){let e={};NF(r.materials,e),EF(r.interactionStates,e),TF(r.geometries,r.object),Object.keys(e).length&&(r.nodes=IF(e))}function $M(r,e){let t=r.geometry;if(t&&t===e)return r;let n=r.children;if(n)for(let i=0,s=n.length;i0){i.width+=s*2,i.height+=s*2,i.extrudeDepth+=s*2;let o=$M(e,n.uuid);if(o!==void 0){let a=new Ke;QM.fromArray(o.matrix),a.applyMatrix4(QM),a.position.z-=s,a.updateMatrix(),o.matrix=a.matrix.toArray()}}}}}function EF(r,e){if(r!==void 0){for(let t of r)if(t.material)if(Array.isArray(t.material))for(let n of t.material)for(let i of n.layersList)pu(i,e);else for(let n of t.material.layersList)pu(n,e)}}function NF(r,e){if(r!==void 0)for(let t of r){let{beforeLayers:n,lightingLayer:i,afterLayers:s}=CF(t.userData.layers);if(!i){console.error("Material upgrade: could not find a ligthing layer");continue}let o=LF(t,i,e);if(e[o.uuid]=o,n.length>0){let a=pu(n[0],e);e[a.uuid]=a;for(let l=1,c=n.length;l0){let a;for(let l of s){let c=pu(l,e),u=pg(a,c);e[u.uuid]=u,e[c.uuid]=c,a=u}o.afterColor=a==null?void 0:a.uuid}Object.assign(t,{type:"ShaderMaterial",wireframeLinecap:"",wireframeLinejoin:"",vertex:o==null?void 0:o.uuid,fragment:o==null?void 0:o.uuid}),delete t.color,delete t.emissive,delete t.specular,delete t.shininess,delete t.roughness,delete t.metalness}}function CF(r){let e=[],t=[],n,i=r.head;for(;i;){if(i.type==="light"){n=i,i=i.next;break}e.push(i),i=i.next}for(;i;)t.unshift(i),i=i.next;return{beforeLayers:e,lightingLayer:n,afterLayers:t}}function LF(r,e,t){let n,i;switch(r.userData.type){case"BasicMaterial":n=gg(r,e,t),i="BasicNodeMaterial";break;case"PhongMaterial":n=XM(r,e,t),i="PhongNodeMaterial";break;case"LambertMaterial":n=qM(r,e,t),i="LambertNodeMaterial";break;case"ToonMaterial":n=YM(r,e,t),i="ToonNodeMaterial";break;case"PhysicalMaterial":n=KM(r,e,t),i="StandardNodeMaterial";break;default:console.warn(`Material upgrade: could not find a properly material node to ${r.userData.type}`),n=gg(r,e,t),i="BasicNodeMaterial"}return Object.assign(r.userData,{nodeType:i}),n}function pu(r,e){switch(r.type){case"light":return UM(r,e);case"color":return mg(r,e);case"depth":return VM(r,e);case"fresnel":return HM(r,e);case"gradient":return jM(r,e);case"noise":return JM(r,e);case"normal":return kM(r,e);case"texture":return WM(r,e);default:return console.warn(`Material upgrade: could not find a properly "layer" node to ${r.type}`),mg(r,e)}}function IF(r){let e=[];for(let t in r)e.push(r[t]);return e}function yg(r){let e=r.metadata;return console.info(`File format version ${e==null?void 0:e.version}`),(e==null?void 0:e.version)===void 0?(console.warn("Unknow file version"),!1):((e.version<=1.1||e.version===4.5)&&(CM(r),e.version=1.2,console.warn("File upgraded from v1.1 or inferior to v1.2")),e.version===1.2&&(IM(r),e.version=1.3,console.warn("File upgraded from v1.2 to v1.3")),e.version===1.3&&(DM(r),e.version=1.4,console.warn("File upgraded from v1.3 to v1.4")),e.version===1.4&&(ZM(r),e.version=1.5,console.warn("File upgraded from v1.4 to v1.5")),!0)}var nA=Cg(tA()),iA=new me,PF=new me,DF=new me,RF=new me,Nl=class extends Vn{constructor(e=Qn.create({}),t=new Ci){super(e,t);this.objectType="SubdivObject";this.resized=!1;this.newlyPasted=!1;this.matrixWorldRigid=new me;this.scaleMatrix=new me;this.hiddenMatrixOld=new me;this.isNegativeDeterminant=!1;this.isUniformScaling=!0;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1,this.subdivPointer=Qn.activeSubdivPtr}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}updateGeometry(e){let t=this.geometry,n=Uc[t.userData.type],i=this.objectType==="SubdivObject"?Object.assign({},t.userData,{geometry:t,subdivPointer:this.subdivPointer,smoothShading:this.smoothShading}):t.userData,s=n.build(n.normalizeInputs(e,i));this.geometry.dispose(),this.geometry=s}clone(e){var a,l;if(this.resized){this.resized=!1;let c;this.geometry.userData.parameters.subdivisions>0?c=this.geometry.originalGeometry:c=this.geometry,Qn.allocate(c),this.subdivPointer=Qn.activeSubdivPtr}let t=this.material.clone(),n=Qn.clone(Ue({},this.geometry.userData.parameters),this.subdivPointer,this.smoothShading),i=(a=this.geometry.originalGeometry)!=null?a:this.geometry,s=(l=n.originalGeometry)!=null?l:n;s.boundingSphere=i.boundingSphere.clone();let o=new Nl(n,t).copy(this,e);return o.subdivPointer=Qn.activeSubdivPtr,o}raycast(e,t){let n=this.geometry.originalGeometry;if(n){let i=this.geometry;this.geometry=n,Vn.prototype.raycast.call(this,e,t),this.geometry=i}else Vn.prototype.raycast.call(this,e,t)}applySVDScaling(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:n,v:i,q:s}=(0,nA.SVD)(t);this.isNegativeDeterminant=this.matrixWorld.determinant()<0,this.isUniformScaling=s.every(h=>Math.abs(s[0]-h)<.01);let o,a,l=iA.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=PF.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),u=DF.copy(c).transpose();if(o=RF.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),a=l.multiply(u),!this.isUniformScaling){this.geometry.applyMatrix4(o);let h=this.geometry.originalGeometry;h?(h.applyMatrix4(o),h.getAttribute("positionWASM").applyMatrix4(o)):this.geometry.getAttribute("positionWASM").applyMatrix4(o),this.resized=!0}return{scaleMatrix:o,matrixWorldRigid:a}}revertSVDScaling(e){let t=this.geometry.originalGeometry;t?Qn.getTopologicalMesh(t):Qn.getTopologicalMesh(this.geometry);let n=e.elements,i=[n[0],n[5],n[10]];if(!i.every(o=>Math.abs(i[0]-o)<.01)){let o=iA.copy(this.scaleMatrix).invert();this.geometry.applyMatrix4(o),t?(t.applyMatrix4(o),t.getAttribute("positionWASM").applyMatrix4(o)):this.geometry.getAttribute("positionWASM").applyMatrix4(o),this.resized=!0}}};var vg=class{constructor(){this._buffers=[]}parse(e){var n;let t=new we;if(this._vertexData=e.vertexData,this._loadBuffers(this._vertexData.buffers),t.uuid=e.uuid,this._vertexData.accessors)for(let i=0,s=this._vertexData.accessors.length;i{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let c=t.attributeTypes[l];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=c.name)}let n=JSON.stringify(t);if(xg.has(e)){let l=xg.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,u)=>{i._callbacks[s]={resolve:c,reject:u},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),xg.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new we;e.index&&t.setIndex(new Re(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=FF.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{let h=u.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=t(h,d,f,c),m=p.attributes.map(v=>v.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function t(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let v in u){let g=self[h[v]],y,x;if(c.useUniqueIDs)x=u[v],y=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[u[v]]),x===-1)continue;y=a.GetAttribute(d,x)}m.attributes.push(i(o,a,d,v,g,y))}return p===o.TRIANGULAR_MESH&&(m.index=n(o,a,d)),o.destroy(d),m}function n(o,a,l){let u=l.num_faces()*3,h=u*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,u).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,u,h){let d=h.num_components(),p=l.num_points()*d,m=p*u.BYTES_PER_ELEMENT,v=s(o,u),g=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,v,m,g);let y=new u(o.HEAPF32.buffer,g,p).slice();return o._free(g),{name:c,array:y,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function Cl(r){let e;return r instanceof Array?(e={},r.forEach(t=>{e[t.uuid]=t})):e=r,e}function rA(r,e){return r[e]===void 0&&console.warn("ObjectLoader > getGeometry: undefined geometry",e),r[e]}function sA(r,e){if(e!==void 0){if(e instanceof Array){let t=[];for(let n=0,i=e.length;n getMaterial: undefined material",s),t.push(r[s])}return t}return r[e]===void 0&&console.warn("ObjectLoader > getMaterial: undefined material",e),r[e]}}var wg=class extends gx(Ap){constructor(){super(...arguments);this.path="";this.resourcePath=""}async loadFromFile(e){var s;let t=await LS(e,this.manager,Ds.TEXT),{object:n,materials:i}=this.parse(JSON.parse(t));return n.name=(s=e.name.split(".").shift())!=null?s:e.name,this.manager.itemEnd(e.name),{scene:n,materials:i}}load(e,t,n,i){let s=this.path===""?Ei.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;let o=new Xn(this.manager);o.setPath(this.path),o.load(e,a=>{let l=null;try{l=JSON.parse(a)}catch(u){i!==void 0&&i(u),console.warn(`ObjectLoader > load: can't parse ${e}.`),console.error(u);return}let c=l.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry"){console.error("ObjectLoader: Can't load "+e);return}this.parse(l,t)},n,i)}parse(e,t){var d;if(yg(e)===!1)return console.error("File can not be parser"),{object:new zs,materials:{}};let n={},i=this.parseGeometries(e.geometries),s=this.loader.parseImages(e.images,()=>{t!==void 0&&t(u)}),o=this.parseTextures(e.textures,s),a=new Jd;a.init(Cl((d=e.nodes)!=null?d:[]),Cl(o));let l=Cl(this.loader.parseMaterials(e.materials,o)),c=this.customParseMaterials(l,e.materials,a),u=this.parseObject(e.object,i,c,n);this.upgradeNoise(u);let h=this.parseInteractionStates(e.interactionStates,a);return this.parseInteractions(e.object,n,h),(e.images===void 0||e.images.length===0)&&t!==void 0&&t(u),{object:u,materials:c}}upgradeNoise(e){e.traverseEntity(t=>{var n;if(t.type==="Mesh"){let i=t,s=i.material;if(!s.userData)return;let o=(n=s.userData.layers)==null?void 0:n.head;for(;o;){if(o.type===lt.NOISE&&o.uniforms[`f${o.id}_size`].value.equals(new M(-1,-1,-1))&&(i.geometry.boundingBox||i.geometry.computeBoundingBox(),i.geometry.boundingBox)){let a=o.uniforms[`f${o.id}_scale`].value,{x:l,y:c,z:u}=i.geometry.boundingBox.max,h=Math.max(l,Math.max(c,u))/(a*a);o.uniforms[`f${o.id}_size`].value.x=h,o.uniforms[`f${o.id}_size`].value.y=h,o.uniforms[`f${o.id}_size`].value.z=h}o=o.next}}})}parseGeometries(e){var n,i;let t={};if(e!==void 0)for(let s=0,o=e.length;s parseGeometries: error parsing geometry of type .",(i=a.userData)==null?void 0:i.type),console.error(c)}}return t}async parseAsync(e){var h;if(yg(e)===!1)return console.error("File can not be parser"),new zs;let t=new Jd,n={},i=await this.parseGeometriesAsync(e.geometries),s=this.loader.parseImages(e.images,()=>{}),o=this.parseTextures(e.textures,s);t.init(Cl((h=e.nodes)!=null?h:[]),Cl(o));let a=Cl(this.loader.parseMaterials(e.materials,o)),l=this.customParseMaterials(a,e.materials,t),c=await this.parseObjectAsync(e.object,i,l,n),u=this.parseInteractionStates(e.interactionStates,t);return this.parseInteractions(e.object,n,u),c}async parseGeometriesAsync(e){var n,i;let t={};if(e!==void 0)for(let s=0,o=e.length;s{this.gltfLoader.parse(JSON.stringify(a.gltf),"",d)}),h=[];u.scene.traverse(d=>{let f=d;f.isMesh&&h.push(f.geometry)}),h.length===1?l=h[0]:(h=Jm(h,d=>d.userData.groupIndex),l=tl.mergeBufferGeometries(h,!0),l.groups.forEach((d,f)=>{d.materialIndex=h[f].userData.materialIndex}))}else l=this.loader.parseGeometries([a])[a.uuid];l.userData={};let c=Object.assign({},a.userData,{geometry:l});l=Lo.create(c);break;default:l=kc(a.userData)}l.uuid=a.uuid,a.name!==void 0&&(l.name=a.name),t[a.uuid]=l}catch(c){console.warn("ObjectLoader > parseGeometries: error parsing geometry of type .",(i=a.userData)==null?void 0:i.type),console.error(c)}}return t}parseTextures(e,t){let n=this.loader.parseTextures(e,t);return Object.keys(n).forEach(i=>{let s=new bi().copy(n[i]);s.uuid=i,n[i]=s}),n}customParseMaterials(e,t,n){let i={};if(t!==void 0)for(let s=0,o=t.length;s{}).catch(()=>{});break;case"VectorObject":s=new Ps(o,a).fromJSON(e);break;case"SubdivObject":s=new Nl(o,a).fromJSON(e),s.subdivPointer=o.subdivPointer;break;default:console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}a||(s.name+=" (Recovered)")}else s=new Pi().fromJSON(e),s.name+=" (Recovered)",console.warn("An empty object is created instead")}else switch(e.objectType){case"Scene":s=new zs().fromJSON(e);break;case"CombinedCamera":s=new Sr().fromJSON(e);break;case"LightDirectional":s=new Rd().fromJSON(e);break;case"LightPoint":s=new Bd().fromJSON(e);break;case"LightSpot":s=new Od().fromJSON(e);break;case"EmptyObject":s=new Pi().fromJSON(e);break;default:if(e.type==="HemisphereLight"||e.type==="DirectionalLight")s=this.loader.parseObject(e,t,n);else{console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}}if(ei(s)&&(i[e.uuid]=s),e.children!==void 0)for(let o of e.children){let a=this.parseObject(o,t,n,i);a!==void 0&&s.add(a)}return s instanceof zs&&s.initFromObjectLoader(e),s}async parseObjectAsync(e,t,n,i){let s;if(e.geometry!==void 0){let o=rA(t,e.geometry),a=sA(n,e.material);if(o){switch(e.objectType){case"Mesh2D":s=new Ml(o,a).fromJSON(e);break;case"Mesh3D":s=new Al(o,a).fromJSON(e);break;case"NonParametric":s=new Fd(o,a).fromJSON(e);break;case"TextFrame":s=new Os(o,a);try{await s.fromJSONasync(e)}catch(l){console.log(l)}break;case"VectorObject":s=new Ps(o,a).fromJSON(e);break;case"SubdivObject":s=new Nl(o,a).fromJSON(e),s.subdivPointer=o.subdivPointer;break;default:console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}a||(s.name+=" (Recovered)")}else s=new Pi().fromJSON(e),s.name+=" (Recovered)",console.warn("An empty object is created instead")}else switch(e.objectType){case"Scene":s=new zs().fromJSON(e);break;case"CombinedCamera":s=new Sr().fromJSON(e);break;case"LightDirectional":s=new Rd().fromJSON(e);break;case"LightPoint":s=new Bd().fromJSON(e);break;case"LightSpot":s=new Od().fromJSON(e);break;case"EmptyObject":s=new Pi().fromJSON(e);break;default:if(e.type==="HemisphereLight"||e.type==="DirectionalLight")s=this.loader.parseObject(e,t,n);else{console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);return}}if(ei(s)&&(i[e.uuid]=s),e.children!==void 0)for(let o of e.children){let a=await this.parseObjectAsync(o,t,n,i);a!==void 0&&s.add(a)}return s instanceof zs&&s.initFromObjectLoader(e),s}parseInteractionStates(e,t){let n={};if(e!==void 0)for(let i=0,s=e.length;i{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseDownEvent()};this._onMouseUp=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseUpEvent()};this._onMouseMove=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent()};this._onTouchStart=e=>{e.touches.length===1&&(e.preventDefault(),this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseDownEvent(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onTouchEnd=()=>{this._handleMouseUpEvent(),this._handleMouseHoverEvent(!0)};this._onTouchMove=e=>{e.touches.length===1&&(e.preventDefault(),e.stopPropagation(),this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())};this._onKeyDown=e=>{this._handleKeyDownEvent(e.key)};this._onKeyUp=e=>{this._handleKeyUpEvent(e.key)};this._domElement=e,this._scene=t,this._camera=n,this._app=i}activate(){this.isEnable=!0,this._scene.traverseEntity(e=>{if(e.interaction!==void 0){e.interaction.start();for(let t of e.interaction.events){let n=t.type;this._enableEvent[n]=!0,(n===Ze.KEY_DOWN||n===Ze.KEY_UP||n===Ze.START||n===Ze.LOOK_AT||n===Ze.FOLLOW)&&(this._map[n]===void 0&&(this._map[n]=[]),this._map[n].push(e))}}}),this._enableEvent[Ze.START]!==void 0&&this._handleStartEvent(),this._enableEvent[Ze.MOUSE_DOWN]!==void 0&&(this._domElement.addEventListener("pointerdown",this._onMouseDown,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1)),this._enableEvent[Ze.MOUSE_UP]!==void 0&&(this._domElement.addEventListener("pointerup",this._onMouseUp,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1)),(this._enableEvent[Ze.MOUSE_HOVER]!==void 0||this._enableEvent[Ze.LOOK_AT]!==void 0||this._enableEvent[Ze.FOLLOW]!==void 0)&&(this._domElement.addEventListener("pointermove",this._onMouseMove,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1),this._domElement.addEventListener("touchmove",this._onTouchMove,!1)),this._enableEvent[Ze.KEY_DOWN]!==void 0&&document.addEventListener("keydown",this._onKeyDown,!1),this._enableEvent[Ze.KEY_UP]!==void 0&&document.addEventListener("keyup",this._onKeyUp,!1)}deactivate(){this._scene.traverseEntity(e=>{e.interaction!==void 0&&e.interaction.end(),e.interaction.cache=void 0}),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._enableEvent={},this._map={},this.isEnable=!1}reset(){this._scene.traverseEntity(e=>{e.interaction.start()}),this._handleStartEvent()}_getPointer(e,t){let n=this._domElement.getBoundingClientRect();return{x:(e-n.left)/n.width*2-1,y:-((t-n.top)/n.height)*2+1}}_handleStartEvent(){var e;(e=this._map[Ze.START])==null||e.forEach(t=>{var n;(n=t.interactionCache.start)==null||n.dispatch()})}_handleMouseDownEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let n=0,i=e.length;n{var a;o instanceof Pi&&((a=o.interactionCache.mouseDown)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseUpEvent(){var t;let e=this._raycastMesh(this._raycaster);for(let n=0,i=e.length;n{var a;o instanceof Pi&&((a=o.interactionCache.mouseUp)==null||a.dispatch())}),!s.interactionCache.follow)break}}_handleMouseHoverEvent(e=!1){var t,n;if(this._enableEvent[Ze.MOUSE_HOVER]!==void 0){let i;if(!e){let o=this._raycastMesh(this._raycaster).find(a=>!a.object.interactionCache.follow);i=o?o.object:void 0}if(this._prevObject!==i){this._prevObject!==void 0&&((t=this._prevObject.interactionCache.mouseHover)==null||t.dispatchReverse()),i!==void 0&&((n=i.interactionCache.mouseHover)==null||n.dispatch());let s=[];i==null||i.traverseAncestors(l=>{l instanceof Pi&&l.interactionCache.mouseHover&&s.push(l)}),this._prevAncestors.filter(l=>{var c;return s.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatchReverse(),!0)});let o=s.filter(l=>{var c;return this._prevAncestors.includes(l)?!1:((c=l.interactionCache.mouseHover)==null||c.dispatch(),!0)}),a=this._prevAncestors.filter(l=>s.includes(l));this._prevAncestors=[...a,...o]}this._prevObject=i}}_handleLookAtEvent(){var e;(e=this._map[Ze.LOOK_AT])==null||e.forEach(t=>{var i;let n=(i=t.interactionCache.lookAt)==null?void 0:i.distance;n!==void 0&&(this._plane.set(this._normal,-n),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.lookAt(this._intersection))}),this._app.skipRender=!1}_handleFollowEvent(){var e;(e=this._map[Ze.FOLLOW])==null||e.forEach(t=>{this._plane.setFromNormalAndCoplanarPoint(this._normal,t.getWorldPosition(this._position)),this._raycaster.ray.intersectPlane(this._plane,this._intersection),t.interaction.follow(this._intersection)}),this._app.skipRender=!1}_handleKeyDownEvent(e){var t;(t=this._map[Ze.KEY_DOWN])==null||t.forEach(n=>{var s;let i=(s=n.interactionCache.keyDown)==null?void 0:s.find(o=>o.key===e);i==null||i.dispatch()})}_handleKeyUpEvent(e){var t;(t=this._map[Ze.KEY_UP])==null||t.forEach(n=>{var s;let i=(s=n.interactionCache.keyUp)==null?void 0:s.find(o=>o.key===e);i==null||i.dispatch()})}_raycastMesh(e){let t=[],n=i=>{for(let s of i.children)ei(s)&&!s.raycastLock&&s.visible&&(wS(s)&&e.intersectObject(s,!1,t),n(s))};return n(this._scene),t}};var Mg=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new O().copy(n),this._editorSize=new O().copy(i),this._aspect=t.aspect,this._fov=s!=null?s:t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;et){let i=zF(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function zF(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var ko;(function(t){t[t.FULLSCREEN=1]="FULLSCREEN",t[t.CUSTOM=2]="CUSTOM"})(ko||(ko={}));var GF=class{constructor(){this._needsTransmission=!0;this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this.skipRender=!0;this.render=()=>{var t;requestAnimationFrame(this.render);let e=Ls.isAllAnimationsEnded;if(!(this.skipRender&&(e===void 0||e))){if(!this._renderer){console.error("Application::render >>> tried to renderer without a renderer");return}this._controls&&(this._controls.enableDamping||this._controls.autoRotate)?this.skipRender=!this._controls.update():this.skipRender=!0,this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&(this._renderer.autoClear=!1,this._needsTransmission&&this.renderTransmissionTarget(),((t=this._scene.postprocessing)==null?void 0:t.enabled)?(this._renderer.autoClear=!1,this._scene.postprocessing.render()):(this._renderer.autoClear=!0,this._renderer.render(this._scene,this._camera)))}};this.resize=()=>{var e,t,n,i;this.skipRender=!1,!!this._renderer&&(this._viewportMode===1&&(this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._frameView&&(this._frameView.frameSize=new O(this._viewportWidth,this._viewportHeight))),(e=this._frameView)==null||e.updateRenderer(),((t=this._scene)==null?void 0:t.postprocessing)&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._viewportMode!==1&&((n=this._frameView)==null||n.updateViewport()),this._camera&&((i=this._frameView)==null||i.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&this._viewportMode===1&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()))};window.addEventListener("resize",Wm(this.resize,200))}async load(e){let n=await(await fetch(e,{credentials:"include",mode:"no-cors"})).json();await this.start(n)}async start(e){this._editorData=e.editor,this._needsTransmission=e.needsTransmission!==void 0?e.needsTransmission:!0;let n=await new wg().parseAsync(e);this._scene=n,this._camera=this._scene.activeCamera,this.init(),this.resize(),this.render()}renderTransmissionTarget(){!this._renderer||!this._transmissionRenderTarget||!this._scene||!this._camera||(this._renderer.setRenderTarget(this._transmissionRenderTarget),this._renderer.clear(),this._camera.layers.enable(0),this._camera.layers.disable(3),this._renderer.render(this._scene,this._camera),this._renderer.setRenderTarget(null),this._camera.layers.enable(3))}init(){var n,i,s,o;let e=document.getElementById("canvas3d");if(!this._scene||!this._camera)return;((n=this._scene.postprocessing)==null?void 0:n.enabled)?(this._renderer=new wt({canvas:e,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene})):this._renderer=new wt({canvas:e,antialias:!0,alpha:!0,stencil:!0,depth:!0,powerPreference:"high-performance"}),this._needsTransmission&&(this._transmissionRenderTarget=new bt(2048,2048,{generateMipmaps:!0,minFilter:Ai,magFilter:$e,wrapS:Zt,wrapT:Zt}),this._transmissionRenderTarget.depthTexture=new so(2048,2048),this._scene.traverseEntity(a=>{if(!(!(a instanceof Vn)||!this._transmissionRenderTarget)&&!Array.isArray(a.material)){let l=a.material.userData.layers.getLayersOfType(lt.TRANSMISSION);for(let c of l)c.uniforms[`f${c.id}_transmissionSamplerMap`].value=this._transmissionRenderTarget.texture,c.uniforms[`f${c.id}_transmissionDepthMap`].value=this._transmissionRenderTarget.depthTexture}})),this._viewportMode=(i=this._scene.canvas.mode)!=null?i:1,this._viewportWidth=(s=this._scene.canvas.size.width)!=null?s:window.innerWidth,this._viewportHeight=(o=this._scene.canvas.size.height)!=null?o:window.innerHeight,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight),this._scene.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=qd,this._renderer.setClearColor(this._scene.color,this._scene.alpha),this._frameView=new Mg(this._renderer,this._camera,new O(this._viewportWidth,this._viewportHeight),new O(this._scene.canvas.editorSize.width,this._scene.canvas.editorSize.height)),!0&&(this._controls=new Gp(this._camera,this._renderer.domElement),this._editorData&&(this._controls.fromJSON(this._editorData.orbitControls),this._controls.useKeyEvents=!1),this._controls.addEventListener("change",()=>this.skipRender=!1),this._controls.addEventListener("start",()=>this.skipRender=!1)),this._playmode=new Sg(this._renderer.domElement,this._scene,this._camera,this)}};ui.FONTS_PATH="_assets/_fonts/";export{GF as Application};