@vctrl/hooks 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3841 +0,0 @@
1
- "use strict";/**
2
- * @license
3
- * Copyright 2010-2024 Three.js Authors
4
- * SPDX-License-Identifier: MIT
5
- */const Qi="167";const cs="attached",Xa="detached";const $t="",Dt="srgb",Jt="srgb-linear",er="display-p3",di="display-p3-linear",Ki="linear",je="srgb",$i="rec709",Zi="p3";const hs="300 es";class Xn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const pt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let us=1234567;const oi=Math.PI/180,Hn=180/Math.PI;function Ut(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(pt[i&255]+pt[i>>8&255]+pt[i>>16&255]+pt[i>>24&255]+"-"+pt[e&255]+pt[e>>8&255]+"-"+pt[e>>16&15|64]+pt[e>>24&255]+"-"+pt[t&63|128]+pt[t>>8&255]+"-"+pt[t>>16&255]+pt[t>>24&255]+pt[n&255]+pt[n>>8&255]+pt[n>>16&255]+pt[n>>24&255]).toLowerCase()}function _t(i,e,t){return Math.max(e,Math.min(t,i))}function zr(i,e){return(i%e+e)%e}function qa(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function Ya(i,e,t){return i!==e?(t-i)/(e-i):0}function li(i,e,t){return(1-t)*i+t*e}function Ka(i,e,t,n){return li(i,e,1-Math.exp(-t*n))}function $a(i,e=1){return e-Math.abs(zr(i,e*2)-e)}function Za(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function ja(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Ja(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Qa(i,e){return i+Math.random()*(e-i)}function eo(i){return i*(.5-Math.random())}function to(i){i!==void 0&&(us=i);let e=us+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function no(i){return i*oi}function io(i){return i*Hn}function ro(i){return(i&i-1)===0&&i!==0}function so(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function ao(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function oo(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),f=s((e-n)/2),u=a((e-n)/2),m=s((n-e)/2),_=a((n-e)/2);switch(r){case"XYX":i.set(o*h,l*f,l*u,o*c);break;case"YZY":i.set(l*u,o*h,l*f,o*c);break;case"ZXZ":i.set(l*f,l*u,o*h,o*c);break;case"XZX":i.set(o*h,l*_,l*m,o*c);break;case"YXY":i.set(l*m,o*h,l*_,o*c);break;case"ZYZ":i.set(l*_,l*m,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function It(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function qe(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const lo={DEG2RAD:oi,RAD2DEG:Hn,generateUUID:Ut,clamp:_t,euclideanModulo:zr,mapLinear:qa,inverseLerp:Ya,lerp:li,damp:Ka,pingpong:$a,smoothstep:Za,smootherstep:ja,randInt:Ja,randFloat:Qa,randFloatSpread:eo,seededRandom:to,degToRad:no,radToDeg:io,isPowerOfTwo:ro,ceilPowerOfTwo:so,floorPowerOfTwo:ao,setQuaternionFromProperEuler:oo,normalize:qe,denormalize:It};class Fe{constructor(e=0,t=0){Fe.prototype.isVector2=!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){return 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){return 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){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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){const 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=Math.trunc(this.x),this.y=Math.trunc(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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(_t(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Pe{constructor(e,t,n,r,s,a,o,l,c){Pe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],f=n[7],u=n[2],m=n[5],_=n[8],v=r[0],p=r[3],d=r[6],T=r[1],S=r[4],A=r[7],B=r[2],R=r[5],w=r[8];return s[0]=a*v+o*T+l*B,s[3]=a*p+o*S+l*R,s[6]=a*d+o*A+l*w,s[1]=c*v+h*T+f*B,s[4]=c*p+h*S+f*R,s[7]=c*d+h*A+f*w,s[2]=u*v+m*T+_*B,s[5]=u*p+m*S+_*R,s[8]=u*d+m*A+_*w,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],f=h*a-o*c,u=o*l-h*s,m=c*s-a*l,_=t*f+n*u+r*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/_;return e[0]=f*v,e[1]=(r*c-h*n)*v,e[2]=(o*n-r*a)*v,e[3]=u*v,e[4]=(h*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=m*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*s)*v,this}transpose(){let e;const 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){const 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,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(or.makeScale(e,t)),this}rotate(e){return this.premultiply(or.makeRotation(-e)),this}translate(e,t){return this.premultiply(or.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])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){const 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)}}const or=new Pe;function xa(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ci(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function co(){const i=ci("canvas");return i.style.display="block",i}const ds={};function Vn(i){i in ds||(ds[i]=!0,console.warn(i))}function ho(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const fs=new Pe().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ps=new Pe().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Zn={[Jt]:{transfer:Ki,primaries:$i,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Dt]:{transfer:je,primaries:$i,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[di]:{transfer:Ki,primaries:Zi,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(ps),fromReference:i=>i.applyMatrix3(fs)},[er]:{transfer:je,primaries:Zi,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(ps),fromReference:i=>i.applyMatrix3(fs).convertLinearToSRGB()}},uo=new Set([Jt,di]),ze={enabled:!0,_workingColorSpace:Jt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!uo.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;const n=Zn[e].toReference,r=Zn[t].fromReference;return r(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this._workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this._workingColorSpace)},getPrimaries:function(i){return Zn[i].primaries},getTransfer:function(i){return i===$t?Ki:Zn[i].transfer},getLuminanceCoefficients:function(i,e=this._workingColorSpace){return i.fromArray(Zn[e].luminanceCoefficients)}};function kn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function lr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let En;class fo{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{En===void 0&&(En=ci("canvas")),En.width=e.width,En.height=e.height;const n=En.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=En}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")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ci("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=kn(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(kn(t[n]/255)*255):t[n]=kn(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let po=0;class Vr{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:po++}),this.uuid=Ut(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(cr(r[a].image)):s.push(cr(r[a]))}else s=cr(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function cr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?fo.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let mo=0;class lt extends Xn{constructor(e=lt.DEFAULT_IMAGE,t=lt.DEFAULT_MAPPING,n=1001,r=1001,s=1006,a=1008,o=1023,l=1009,c=lt.DEFAULT_ANISOTROPY,h=$t){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mo++}),this.uuid=Ut(),this.name="",this.source=new Vr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}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.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,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.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002: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 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002: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++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}lt.DEFAULT_IMAGE=null;lt.DEFAULT_MAPPING=300;lt.DEFAULT_ANISOTROPY=1;class Ze{constructor(e=0,t=0,n=0,r=1){Ze.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,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){return 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){return 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){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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,r,s;const l=e.elements,c=l[0],h=l[4],f=l[8],u=l[1],m=l[5],_=l[9],v=l[2],p=l[6],d=l[10];if(Math.abs(h-u)<.01&&Math.abs(f-v)<.01&&Math.abs(_-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(f+v)<.1&&Math.abs(_+p)<.1&&Math.abs(c+m+d-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const S=(c+1)/2,A=(m+1)/2,B=(d+1)/2,R=(h+u)/4,w=(f+v)/4,F=(_+p)/4;return S>A&&S>B?S<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(S),r=R/n,s=w/n):A>B?A<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(A),n=R/r,s=F/r):B<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(B),n=w/s,r=F/s),this.set(n,r,s,t),this}let T=Math.sqrt((p-_)*(p-_)+(f-v)*(f-v)+(u-h)*(u-h));return Math.abs(T)<.001&&(T=1),this.x=(p-_)/T,this.y=(f-v)/T,this.z=(u-h)/T,this.w=Math.acos((c+m+d-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}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.w=Math.min(this.w,e.w),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.w=Math.max(this.w,e.w),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.w=Math.max(e.w,Math.min(t.w,this.w)),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.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const 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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(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.w+=(e.w-this.w)*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.w=e.w+(t.w-e.w)*n,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class _o extends Xn{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ze(0,0,e,t),this.scissorTest=!1,this.viewport=new Ze(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new lt(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Vr(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Mn extends _o{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Ma extends lt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Sa extends lt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Sn{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],f=n[r+3];const u=s[a+0],m=s[a+1],_=s[a+2],v=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f;return}if(o===1){e[t+0]=u,e[t+1]=m,e[t+2]=_,e[t+3]=v;return}if(f!==v||l!==u||c!==m||h!==_){let p=1-o;const d=l*u+c*m+h*_+f*v,T=d>=0?1:-1,S=1-d*d;if(S>Number.EPSILON){const B=Math.sqrt(S),R=Math.atan2(B,d*T);p=Math.sin(p*R)/B,o=Math.sin(o*R)/B}const A=o*T;if(l=l*p+u*A,c=c*p+m*A,h=h*p+_*A,f=f*p+v*A,p===1-o){const B=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=B,c*=B,h*=B,f*=B}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],f=s[a],u=s[a+1],m=s[a+2],_=s[a+3];return e[t]=o*_+h*f+l*m-c*u,e[t+1]=l*_+h*u+c*f-o*m,e[t+2]=c*_+h*m+o*u-l*f,e[t+3]=h*_-o*f-l*u-c*m,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,r){return this._x=e,this._y=t,this._z=n,this._w=r,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=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),f=o(s/2),u=l(n/2),m=l(r/2),_=l(s/2);switch(a){case"XYZ":this._x=u*h*f+c*m*_,this._y=c*m*f-u*h*_,this._z=c*h*_+u*m*f,this._w=c*h*f-u*m*_;break;case"YXZ":this._x=u*h*f+c*m*_,this._y=c*m*f-u*h*_,this._z=c*h*_-u*m*f,this._w=c*h*f+u*m*_;break;case"ZXY":this._x=u*h*f-c*m*_,this._y=c*m*f+u*h*_,this._z=c*h*_+u*m*f,this._w=c*h*f-u*m*_;break;case"ZYX":this._x=u*h*f-c*m*_,this._y=c*m*f+u*h*_,this._z=c*h*_-u*m*f,this._w=c*h*f+u*m*_;break;case"YZX":this._x=u*h*f+c*m*_,this._y=c*m*f+u*h*_,this._z=c*h*_-u*m*f,this._w=c*h*f-u*m*_;break;case"XZY":this._x=u*h*f-c*m*_,this._y=c*m*f-u*h*_,this._z=c*h*_+u*m*f,this._w=c*h*f+u*m*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],f=t[10],u=n+o+f;if(u>0){const m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-l)*m,this._y=(s-c)*m,this._z=(a-r)*m}else if(n>o&&n>f){const m=2*Math.sqrt(1+n-o-f);this._w=(h-l)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+c)/m}else if(o>f){const m=2*Math.sqrt(1+o-n-f);this._w=(s-c)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+f-n-o);this._w=(a-r)/m,this._x=(s+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.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(_t(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),f=Math.sin((1-t)*h)/c,u=Math.sin(t*h)/c;return this._w=a*f+this._w*u,this._x=n*f+this._x*u,this._y=r*f+this._y*u,this._z=s*f+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}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._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(e=0,t=0,n=0){D.prototype.isVector3=!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){return 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){return 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){return 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 this.applyQuaternion(ms.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ms.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),f=2*(s*n-a*t);return this.x=t+l*c+a*f-o*h,this.y=n+l*h+o*c-s*f,this.z=r+l*f+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,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){const 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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return hr.copy(this).projectOnVector(e),this.sub(hr)}reflect(e){return this.sub(hr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(_t(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}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){return 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}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const hr=new D,ms=new Sn;class Qt{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ct.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ct.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ct.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ct):Ct.fromBufferAttribute(s,a),Ct.applyMatrix4(e.matrixWorld),this.expandByPoint(Ct);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),xi.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),xi.copy(n.boundingBox)),xi.applyMatrix4(e.matrixWorld),this.union(xi)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.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.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ct),Ct.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(jn),Mi.subVectors(this.max,jn),Tn.subVectors(e.a,jn),An.subVectors(e.b,jn),bn.subVectors(e.c,jn),tn.subVectors(An,Tn),nn.subVectors(bn,An),un.subVectors(Tn,bn);let t=[0,-tn.z,tn.y,0,-nn.z,nn.y,0,-un.z,un.y,tn.z,0,-tn.x,nn.z,0,-nn.x,un.z,0,-un.x,-tn.y,tn.x,0,-nn.y,nn.x,0,-un.y,un.x,0];return!ur(t,Tn,An,bn,Mi)||(t=[1,0,0,0,1,0,0,0,1],!ur(t,Tn,An,bn,Mi))?!1:(Si.crossVectors(tn,nn),t=[Si.x,Si.y,Si.z],ur(t,Tn,An,bn,Mi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ct).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ct).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:(Ht[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ht[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ht[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ht[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ht[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ht[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ht[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ht[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ht),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)}}const Ht=[new D,new D,new D,new D,new D,new D,new D,new D],Ct=new D,xi=new Qt,Tn=new D,An=new D,bn=new D,tn=new D,nn=new D,un=new D,jn=new D,Mi=new D,Si=new D,dn=new D;function ur(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){dn.fromArray(i,s);const o=r.x*Math.abs(dn.x)+r.y*Math.abs(dn.y)+r.z*Math.abs(dn.z),l=e.dot(dn),c=t.dot(dn),h=n.dot(dn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const go=new Qt,Jn=new D,dr=new D;class Gt{constructor(e=new D,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):go.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.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){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Jn.subVectors(e,this.center);const t=Jn.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Jn,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(dr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Jn.copy(e.center).add(dr)),this.expandByPoint(Jn.copy(e.center).sub(dr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Wt=new D,fr=new D,yi=new D,rn=new D,pr=new D,Ei=new D,mr=new D;class tr{constructor(e=new D,t=new D(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.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Wt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wt.copy(this.origin).addScaledVector(this.direction,t),Wt.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){fr.copy(e).add(t).multiplyScalar(.5),yi.copy(t).sub(e).normalize(),rn.copy(this.origin).sub(fr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(yi),o=rn.dot(this.direction),l=-rn.dot(yi),c=rn.lengthSq(),h=Math.abs(1-a*a);let f,u,m,_;if(h>0)if(f=a*l-o,u=a*o-l,_=s*h,f>=0)if(u>=-_)if(u<=_){const v=1/h;f*=v,u*=v,m=f*(f+a*u+2*o)+u*(a*f+u+2*l)+c}else u=s,f=Math.max(0,-(a*u+o)),m=-f*f+u*(u+2*l)+c;else u=-s,f=Math.max(0,-(a*u+o)),m=-f*f+u*(u+2*l)+c;else u<=-_?(f=Math.max(0,-(-a*s+o)),u=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+u*(u+2*l)+c):u<=_?(f=0,u=Math.min(Math.max(-s,-l),s),m=u*(u+2*l)+c):(f=Math.max(0,-(a*s+o)),u=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+u*(u+2*l)+c);else u=a>0?-s:s,f=Math.max(0,-(a*u+o)),m=-f*f+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(fr).addScaledVector(yi,u),m}intersectSphere(e,t){Wt.subVectors(e.center,this.origin);const n=Wt.dot(this.direction),r=Wt.dot(Wt)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,r=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,r=(e.min.x-u.x)*c),h>=0?(s=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(s=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),f>=0?(o=(e.min.z-u.z)*f,l=(e.max.z-u.z)*f):(o=(e.max.z-u.z)*f,l=(e.min.z-u.z)*f),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Wt)!==null}intersectTriangle(e,t,n,r,s){pr.subVectors(t,e),Ei.subVectors(n,e),mr.crossVectors(pr,Ei);let a=this.direction.dot(mr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;rn.subVectors(this.origin,e);const l=o*this.direction.dot(Ei.crossVectors(rn,Ei));if(l<0)return null;const c=o*this.direction.dot(pr.cross(rn));if(c<0||l+c>a)return null;const h=-o*rn.dot(mr);return h<0?null:this.at(h/a,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)}}class Ue{constructor(e,t,n,r,s,a,o,l,c,h,f,u,m,_,v,p){Ue.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,h,f,u,m,_,v,p)}set(e,t,n,r,s,a,o,l,c,h,f,u,m,_,v,p){const d=this.elements;return d[0]=e,d[4]=t,d[8]=n,d[12]=r,d[1]=s,d[5]=a,d[9]=o,d[13]=l,d[2]=c,d[6]=h,d[10]=f,d[14]=u,d[3]=m,d[7]=_,d[11]=v,d[15]=p,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 Ue().fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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){const t=this.elements,n=e.elements,r=1/Rn.setFromMatrixColumn(e,0).length(),s=1/Rn.setFromMatrixColumn(e,1).length(),a=1/Rn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,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]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const u=a*h,m=a*f,_=o*h,v=o*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=m+_*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=_+m*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,m=l*f,_=c*h,v=c*f;t[0]=u+v*o,t[4]=_*o-m,t[8]=a*c,t[1]=a*f,t[5]=a*h,t[9]=-o,t[2]=m*o-_,t[6]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,m=l*f,_=c*h,v=c*f;t[0]=u-v*o,t[4]=-a*f,t[8]=_+m*o,t[1]=m+_*o,t[5]=a*h,t[9]=v-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,m=a*f,_=o*h,v=o*f;t[0]=l*h,t[4]=_*c-m,t[8]=u*c+v,t[1]=l*f,t[5]=v*c+u,t[9]=m*c-_,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,m=a*c,_=o*l,v=o*c;t[0]=l*h,t[4]=v-u*f,t[8]=_*f+m,t[1]=f,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*f+_,t[10]=u-v*f}else if(e.order==="XZY"){const u=a*l,m=a*c,_=o*l,v=o*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=u*f+v,t[5]=a*h,t[9]=m*f-_,t[2]=_*f-m,t[6]=o*h,t[10]=v*f+u}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(vo,e,xo)}lookAt(e,t,n){const r=this.elements;return yt.subVectors(e,t),yt.lengthSq()===0&&(yt.z=1),yt.normalize(),sn.crossVectors(n,yt),sn.lengthSq()===0&&(Math.abs(n.z)===1?yt.x+=1e-4:yt.z+=1e-4,yt.normalize(),sn.crossVectors(n,yt)),sn.normalize(),Ti.crossVectors(yt,sn),r[0]=sn.x,r[4]=Ti.x,r[8]=yt.x,r[1]=sn.y,r[5]=Ti.y,r[9]=yt.y,r[2]=sn.z,r[6]=Ti.z,r[10]=yt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],f=n[5],u=n[9],m=n[13],_=n[2],v=n[6],p=n[10],d=n[14],T=n[3],S=n[7],A=n[11],B=n[15],R=r[0],w=r[4],F=r[8],y=r[12],M=r[1],P=r[5],W=r[9],G=r[13],H=r[2],K=r[6],V=r[10],j=r[14],z=r[3],ae=r[7],he=r[11],me=r[15];return s[0]=a*R+o*M+l*H+c*z,s[4]=a*w+o*P+l*K+c*ae,s[8]=a*F+o*W+l*V+c*he,s[12]=a*y+o*G+l*j+c*me,s[1]=h*R+f*M+u*H+m*z,s[5]=h*w+f*P+u*K+m*ae,s[9]=h*F+f*W+u*V+m*he,s[13]=h*y+f*G+u*j+m*me,s[2]=_*R+v*M+p*H+d*z,s[6]=_*w+v*P+p*K+d*ae,s[10]=_*F+v*W+p*V+d*he,s[14]=_*y+v*G+p*j+d*me,s[3]=T*R+S*M+A*H+B*z,s[7]=T*w+S*P+A*K+B*ae,s[11]=T*F+S*W+A*V+B*he,s[15]=T*y+S*G+A*j+B*me,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],f=e[6],u=e[10],m=e[14],_=e[3],v=e[7],p=e[11],d=e[15];return _*(+s*l*f-r*c*f-s*o*u+n*c*u+r*o*m-n*l*m)+v*(+t*l*m-t*c*u+s*a*u-r*a*m+r*c*h-s*l*h)+p*(+t*c*f-t*o*m-s*a*f+n*a*m+s*o*h-n*c*h)+d*(-r*o*h-t*l*f+t*o*u+r*a*f-n*a*u+n*l*h)}transpose(){const e=this.elements;let 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){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],f=e[9],u=e[10],m=e[11],_=e[12],v=e[13],p=e[14],d=e[15],T=f*p*c-v*u*c+v*l*m-o*p*m-f*l*d+o*u*d,S=_*u*c-h*p*c-_*l*m+a*p*m+h*l*d-a*u*d,A=h*v*c-_*f*c+_*o*m-a*v*m-h*o*d+a*f*d,B=_*f*l-h*v*l-_*o*u+a*v*u+h*o*p-a*f*p,R=t*T+n*S+r*A+s*B;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/R;return e[0]=T*w,e[1]=(v*u*s-f*p*s-v*r*m+n*p*m+f*r*d-n*u*d)*w,e[2]=(o*p*s-v*l*s+v*r*c-n*p*c-o*r*d+n*l*d)*w,e[3]=(f*l*s-o*u*s-f*r*c+n*u*c+o*r*m-n*l*m)*w,e[4]=S*w,e[5]=(h*p*s-_*u*s+_*r*m-t*p*m-h*r*d+t*u*d)*w,e[6]=(_*l*s-a*p*s-_*r*c+t*p*c+a*r*d-t*l*d)*w,e[7]=(a*u*s-h*l*s+h*r*c-t*u*c-a*r*m+t*l*m)*w,e[8]=A*w,e[9]=(_*f*s-h*v*s-_*n*m+t*v*m+h*n*d-t*f*d)*w,e[10]=(a*v*s-_*o*s+_*n*c-t*v*c-a*n*d+t*o*d)*w,e[11]=(h*o*s-a*f*s-h*n*c+t*f*c+a*n*m-t*o*m)*w,e[12]=B*w,e[13]=(h*v*r-_*f*r+_*n*u-t*v*u-h*n*p+t*f*p)*w,e[14]=(_*o*r-a*v*r-_*n*l+t*v*l+a*n*p-t*o*p)*w,e[15]=(a*f*r-h*o*r+h*n*l-t*f*l-a*n*u+t*o*u)*w,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const 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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const 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){const 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){const 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){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,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,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,f=o+o,u=s*c,m=s*h,_=s*f,v=a*h,p=a*f,d=o*f,T=l*c,S=l*h,A=l*f,B=n.x,R=n.y,w=n.z;return r[0]=(1-(v+d))*B,r[1]=(m+A)*B,r[2]=(_-S)*B,r[3]=0,r[4]=(m-A)*R,r[5]=(1-(u+d))*R,r[6]=(p+T)*R,r[7]=0,r[8]=(_+S)*w,r[9]=(p-T)*w,r[10]=(1-(u+v))*w,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=Rn.set(r[0],r[1],r[2]).length();const a=Rn.set(r[4],r[5],r[6]).length(),o=Rn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Pt.copy(this);const c=1/s,h=1/a,f=1/o;return Pt.elements[0]*=c,Pt.elements[1]*=c,Pt.elements[2]*=c,Pt.elements[4]*=h,Pt.elements[5]*=h,Pt.elements[6]*=h,Pt.elements[8]*=f,Pt.elements[9]*=f,Pt.elements[10]*=f,t.setFromRotationMatrix(Pt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=2e3){const l=this.elements,c=2*s/(t-e),h=2*s/(n-r),f=(t+e)/(t-e),u=(n+r)/(n-r);let m,_;if(o===2e3)m=-(a+s)/(a-s),_=-2*a*s/(a-s);else if(o===2001)m=-a/(a-s),_=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=h,l[9]=u,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=2e3){const l=this.elements,c=1/(t-e),h=1/(n-r),f=1/(a-s),u=(t+e)*c,m=(n+r)*h;let _,v;if(o===2e3)_=(a+s)*f,v=-2*f;else if(o===2001)_=s*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-u,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=v,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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){const 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}}const Rn=new D,Pt=new Ue,vo=new D(0,0,0),xo=new D(1,1,1),sn=new D,Ti=new D,yt=new D,_s=new Ue,gs=new Sn;class Ot{constructor(e=0,t=0,n=0,r=Ot.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],f=r[2],u=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(_t(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-_t(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(_t(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-_t(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(u,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(_t(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-_t(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,m),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 _s.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_s,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gs.setFromEuler(this),this.setFromQuaternion(gs,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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ot.DEFAULT_ORDER="XYZ";class ya{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Mo=0;const vs=new D,wn=new Sn,Xt=new Ue,Ai=new D,Qn=new D,So=new D,yo=new Sn,xs=new D(1,0,0),Ms=new D(0,1,0),Ss=new D(0,0,1),ys={type:"added"},Eo={type:"removed"},Cn={type:"childadded",child:null},_r={type:"childremoved",child:null};class nt extends Xn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Mo++}),this.uuid=Ut(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=nt.DEFAULT_UP.clone();const e=new D,t=new Ot,n=new Sn,r=new D(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ue},normalMatrix:{value:new Pe}}),this.matrix=new Ue,this.matrixWorld=new Ue,this.matrixAutoUpdate=nt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=nt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ya,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return wn.setFromAxisAngle(e,t),this.quaternion.multiply(wn),this}rotateOnWorldAxis(e,t){return wn.setFromAxisAngle(e,t),this.quaternion.premultiply(wn),this}rotateX(e){return this.rotateOnAxis(xs,e)}rotateY(e){return this.rotateOnAxis(Ms,e)}rotateZ(e){return this.rotateOnAxis(Ss,e)}translateOnAxis(e,t){return vs.copy(e).applyQuaternion(this.quaternion),this.position.add(vs.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xs,e)}translateY(e){return this.translateOnAxis(Ms,e)}translateZ(e){return this.translateOnAxis(Ss,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Xt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ai.copy(e):Ai.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Qn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xt.lookAt(Qn,Ai,this.up):Xt.lookAt(Ai,Qn,this.up),this.quaternion.setFromRotationMatrix(Xt),r&&(Xt.extractRotation(r.matrixWorld),wn.setFromRotationMatrix(Xt),this.quaternion.premultiply(wn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ys),Cn.child=e,this.dispatchEvent(Cn),Cn.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Eo),_r.child=e,this.dispatchEvent(_r),_r.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Xt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Xt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Xt),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ys),Cn.child=e,this.dispatchEvent(Cn),Cn.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qn,e,So),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qn,yo,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(e.shapes,f)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),f=a(e.shapes),u=a(e.skeletons),m=a(e.animations),_=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),f.length>0&&(n.shapes=f),u.length>0&&(n.skeletons=u),m.length>0&&(n.animations=m),_.length>0&&(n.nodes=_)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}nt.DEFAULT_UP=new D(0,1,0);nt.DEFAULT_MATRIX_AUTO_UPDATE=!0;nt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Lt=new D,qt=new D,gr=new D,Yt=new D,Pn=new D,Ln=new D,Es=new D,vr=new D,xr=new D,Mr=new D;class Bt{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Lt.subVectors(e,t),r.cross(Lt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Lt.subVectors(r,t),qt.subVectors(n,t),gr.subVectors(e,t);const a=Lt.dot(Lt),o=Lt.dot(qt),l=Lt.dot(gr),c=qt.dot(qt),h=qt.dot(gr),f=a*c-o*o;if(f===0)return s.set(0,0,0),null;const u=1/f,m=(c*l-o*h)*u,_=(a*h-o*l)*u;return s.set(1-m-_,_,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Yt)===null?!1:Yt.x>=0&&Yt.y>=0&&Yt.x+Yt.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,Yt)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Yt.x),l.addScaledVector(a,Yt.y),l.addScaledVector(o,Yt.z),l)}static isFrontFacing(e,t,n,r){return Lt.subVectors(n,t),qt.subVectors(e,t),Lt.cross(qt).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 Lt.subVectors(this.c,this.b),qt.subVectors(this.a,this.b),Lt.cross(qt).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Bt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Bt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Bt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Bt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Bt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;Pn.subVectors(r,n),Ln.subVectors(s,n),vr.subVectors(e,n);const l=Pn.dot(vr),c=Ln.dot(vr);if(l<=0&&c<=0)return t.copy(n);xr.subVectors(e,r);const h=Pn.dot(xr),f=Ln.dot(xr);if(h>=0&&f<=h)return t.copy(r);const u=l*f-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Pn,a);Mr.subVectors(e,s);const m=Pn.dot(Mr),_=Ln.dot(Mr);if(_>=0&&m<=_)return t.copy(s);const v=m*c-l*_;if(v<=0&&c>=0&&_<=0)return o=c/(c-_),t.copy(n).addScaledVector(Ln,o);const p=h*_-m*f;if(p<=0&&f-h>=0&&m-_>=0)return Es.subVectors(s,r),o=(f-h)/(f-h+(m-_)),t.copy(r).addScaledVector(Es,o);const d=1/(p+v+u);return a=v*d,o=u*d,t.copy(n).addScaledVector(Pn,a).addScaledVector(Ln,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Ea={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},an={h:0,s:0,l:0},bi={h:0,s:0,l:0};function Sr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Ie{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Dt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ze.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,ze.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=ze.workingColorSpace){if(e=zr(e,1),t=_t(t,0,1),n=_t(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Sr(a,s,e+1/3),this.g=Sr(a,s,e),this.b=Sr(a,s,e-1/3)}return ze.toWorkingColorSpace(this,r),this}setStyle(e,t=Dt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Dt){const n=Ea[e.toLowerCase()];return n!==void 0?this.setHex(n,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}copySRGBToLinear(e){return this.r=kn(e.r),this.g=kn(e.g),this.b=kn(e.b),this}copyLinearToSRGB(e){return this.r=lr(e.r),this.g=lr(e.g),this.b=lr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Dt){return ze.fromWorkingColorSpace(mt.copy(this),e),Math.round(_t(mt.r*255,0,255))*65536+Math.round(_t(mt.g*255,0,255))*256+Math.round(_t(mt.b*255,0,255))}getHexString(e=Dt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ze.workingColorSpace){ze.fromWorkingColorSpace(mt.copy(this),t);const n=mt.r,r=mt.g,s=mt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const f=a-o;switch(c=h<=.5?f/(a+o):f/(2-a-o),a){case n:l=(r-s)/f+(r<s?6:0);break;case r:l=(s-n)/f+2;break;case s:l=(n-r)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=ze.workingColorSpace){return ze.fromWorkingColorSpace(mt.copy(this),t),e.r=mt.r,e.g=mt.g,e.b=mt.b,e}getStyle(e=Dt){ze.fromWorkingColorSpace(mt.copy(this),e);const t=mt.r,n=mt.g,r=mt.b;return e!==Dt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(an),this.setHSL(an.h+e,an.s+t,an.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(an),e.getHSL(bi);const n=li(an.h,bi.h,t),r=li(an.s,bi.s,t),s=li(an.l,bi.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const mt=new Ie;Ie.NAMES=Ea;let To=0;class cn extends Xn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:To++}),this.uuid=Ut(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ie(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(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.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),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.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(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&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++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.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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++}onBuild(){console.warn("Material: onBuild() has been removed.")}onBeforeRender(){console.warn("Material: onBeforeRender() has been removed.")}}class kr extends cn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ot,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ot=new D,Ri=new Fe;class At{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Vn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix3(e),this.setXY(t,Ri.x,Ri.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.applyMatrix3(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.applyMatrix4(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.applyNormalMatrix(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ot.fromBufferAttribute(this,t),ot.transformDirection(e),this.setXYZ(t,ot.x,ot.y,ot.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=It(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=qe(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=It(t,this.array)),t}setX(e,t){return this.normalized&&(t=qe(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=It(t,this.array)),t}setY(e,t){return this.normalized&&(t=qe(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=It(t,this.array)),t}setZ(e,t){return this.normalized&&(t=qe(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=It(t,this.array)),t}setW(e,t){return this.normalized&&(t=qe(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=qe(t,this.array),n=qe(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=qe(t,this.array),n=qe(n,this.array),r=qe(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=qe(t,this.array),n=qe(n,this.array),r=qe(r,this.array),s=qe(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}}class Ta extends At{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Aa extends At{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Zt extends At{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Ao=0;const Rt=new Ue,yr=new nt,Dn=new D,Et=new Qt,ei=new Qt,ut=new D;class zt extends Xn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ao++}),this.uuid=Ut(),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(xa(e)?Aa:Ta)(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){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Pe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Rt.makeRotationFromQuaternion(e),this.applyMatrix4(Rt),this}rotateX(e){return Rt.makeRotationX(e),this.applyMatrix4(Rt),this}rotateY(e){return Rt.makeRotationY(e),this.applyMatrix4(Rt),this}rotateZ(e){return Rt.makeRotationZ(e),this.applyMatrix4(Rt),this}translate(e,t,n){return Rt.makeTranslation(e,t,n),this.applyMatrix4(Rt),this}scale(e,t,n){return Rt.makeScale(e,t,n),this.applyMatrix4(Rt),this}lookAt(e){return yr.lookAt(e),yr.updateMatrix(),this.applyMatrix4(yr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Dn).negate(),this.translate(Dn.x,Dn.y,Dn.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Zt(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Et.setFromBufferAttribute(s),this.morphTargetsRelative?(ut.addVectors(this.boundingBox.min,Et.min),this.boundingBox.expandByPoint(ut),ut.addVectors(this.boundingBox.max,Et.max),this.boundingBox.expandByPoint(ut)):(this.boundingBox.expandByPoint(Et.min),this.boundingBox.expandByPoint(Et.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Gt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){const n=this.boundingSphere.center;if(Et.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];ei.setFromBufferAttribute(o),this.morphTargetsRelative?(ut.addVectors(Et.min,ei.min),Et.expandByPoint(ut),ut.addVectors(Et.max,ei.max),Et.expandByPoint(ut)):(Et.expandByPoint(ei.min),Et.expandByPoint(ei.max))}Et.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)ut.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(ut));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ut.fromBufferAttribute(o,c),l&&(Dn.fromBufferAttribute(e,c),ut.add(Dn)),r=Math.max(r,n.distanceToSquared(ut))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new At(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let F=0;F<n.count;F++)o[F]=new D,l[F]=new D;const c=new D,h=new D,f=new D,u=new Fe,m=new Fe,_=new Fe,v=new D,p=new D;function d(F,y,M){c.fromBufferAttribute(n,F),h.fromBufferAttribute(n,y),f.fromBufferAttribute(n,M),u.fromBufferAttribute(s,F),m.fromBufferAttribute(s,y),_.fromBufferAttribute(s,M),h.sub(c),f.sub(c),m.sub(u),_.sub(u);const P=1/(m.x*_.y-_.x*m.y);isFinite(P)&&(v.copy(h).multiplyScalar(_.y).addScaledVector(f,-m.y).multiplyScalar(P),p.copy(f).multiplyScalar(m.x).addScaledVector(h,-_.x).multiplyScalar(P),o[F].add(v),o[y].add(v),o[M].add(v),l[F].add(p),l[y].add(p),l[M].add(p))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let F=0,y=T.length;F<y;++F){const M=T[F],P=M.start,W=M.count;for(let G=P,H=P+W;G<H;G+=3)d(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const S=new D,A=new D,B=new D,R=new D;function w(F){B.fromBufferAttribute(r,F),R.copy(B);const y=o[F];S.copy(y),S.sub(B.multiplyScalar(B.dot(y))).normalize(),A.crossVectors(R,y);const P=A.dot(l[F])<0?-1:1;a.setXYZW(F,S.x,S.y,S.z,P)}for(let F=0,y=T.length;F<y;++F){const M=T[F],P=M.start,W=M.count;for(let G=P,H=P+W;G<H;G+=3)w(e.getX(G+0)),w(e.getX(G+1)),w(e.getX(G+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new At(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,m=n.count;u<m;u++)n.setXYZ(u,0,0,0);const r=new D,s=new D,a=new D,o=new D,l=new D,c=new D,h=new D,f=new D;if(e)for(let u=0,m=e.count;u<m;u+=3){const _=e.getX(u+0),v=e.getX(u+1),p=e.getX(u+2);r.fromBufferAttribute(t,_),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,p),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,p),o.add(h),l.add(h),c.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let u=0,m=t.count;u<m;u+=3)r.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ut.fromBufferAttribute(e,t),ut.normalize(),e.setXYZ(t,ut.x,ut.y,ut.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,f=o.normalized,u=new c.constructor(l.length*h);let m=0,_=0;for(let v=0,p=l.length;v<p;v++){o.isInterleavedBufferAttribute?m=l[v]*o.data.stride+o.offset:m=l[v]*h;for(let d=0;d<h;d++)u[_++]=c[m++]}return new At(u,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new zt,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,f=c.length;h<f;h++){const u=c[h],m=e(u,n);l.push(m)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,u=c.length;f<u;f++){const m=c[f];h.push(m.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],f=s[c];for(let u=0,m=f.length;u<m;u++)h.push(f[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const f=a[c];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ts=new Ue,fn=new tr,wi=new Gt,As=new D,In=new D,Un=new D,Nn=new D,Er=new D,Ci=new D,Pi=new Fe,Li=new Fe,Di=new Fe,bs=new D,Rs=new D,ws=new D,Ii=new D,Ui=new D;class Tt extends nt{constructor(e=new zt,t=new kr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Ci.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],f=s[l];h!==0&&(Er.fromBufferAttribute(f,e),a?Ci.addScaledVector(Er,h):Ci.addScaledVector(Er.sub(t),h))}t.add(Ci)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),wi.copy(n.boundingSphere),wi.applyMatrix4(s),fn.copy(e.ray).recast(e.near),!(wi.containsPoint(fn.origin)===!1&&(fn.intersectSphere(wi,As)===null||fn.origin.distanceToSquared(As)>(e.far-e.near)**2))&&(Ts.copy(s).invert(),fn.copy(e.ray).applyMatrix4(Ts),!(n.boundingBox!==null&&fn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,fn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,u=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,v=u.length;_<v;_++){const p=u[_],d=a[p.materialIndex],T=Math.max(p.start,m.start),S=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let A=T,B=S;A<B;A+=3){const R=o.getX(A),w=o.getX(A+1),F=o.getX(A+2);r=Ni(this,d,e,n,c,h,f,R,w,F),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const _=Math.max(0,m.start),v=Math.min(o.count,m.start+m.count);for(let p=_,d=v;p<d;p+=3){const T=o.getX(p),S=o.getX(p+1),A=o.getX(p+2);r=Ni(this,a,e,n,c,h,f,T,S,A),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,v=u.length;_<v;_++){const p=u[_],d=a[p.materialIndex],T=Math.max(p.start,m.start),S=Math.min(l.count,Math.min(p.start+p.count,m.start+m.count));for(let A=T,B=S;A<B;A+=3){const R=A,w=A+1,F=A+2;r=Ni(this,d,e,n,c,h,f,R,w,F),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const _=Math.max(0,m.start),v=Math.min(l.count,m.start+m.count);for(let p=_,d=v;p<d;p+=3){const T=p,S=p+1,A=p+2;r=Ni(this,a,e,n,c,h,f,T,S,A),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}}}function bo(i,e,t,n,r,s,a,o){let l;if(e.side===1?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===0,o),l===null)return null;Ui.copy(o),Ui.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(Ui);return c<t.near||c>t.far?null:{distance:c,point:Ui.clone(),object:i}}function Ni(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,In),i.getVertexPosition(l,Un),i.getVertexPosition(c,Nn);const h=bo(i,e,t,n,In,Un,Nn,Ii);if(h){r&&(Pi.fromBufferAttribute(r,o),Li.fromBufferAttribute(r,l),Di.fromBufferAttribute(r,c),h.uv=Bt.getInterpolation(Ii,In,Un,Nn,Pi,Li,Di,new Fe)),s&&(Pi.fromBufferAttribute(s,o),Li.fromBufferAttribute(s,l),Di.fromBufferAttribute(s,c),h.uv1=Bt.getInterpolation(Ii,In,Un,Nn,Pi,Li,Di,new Fe)),a&&(bs.fromBufferAttribute(a,o),Rs.fromBufferAttribute(a,l),ws.fromBufferAttribute(a,c),h.normal=Bt.getInterpolation(Ii,In,Un,Nn,bs,Rs,ws,new D),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const f={a:o,b:l,c,normal:new D,materialIndex:0};Bt.getNormal(In,Un,Nn,f.normal),h.face=f}return h}class fi extends zt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],f=[];let u=0,m=0;_("z","y","x",-1,-1,n,t,e,a,s,0),_("z","y","x",1,-1,n,t,-e,a,s,1),_("x","z","y",1,1,e,n,t,r,a,2),_("x","z","y",1,-1,e,n,-t,r,a,3),_("x","y","z",1,-1,e,t,n,r,s,4),_("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Zt(c,3)),this.setAttribute("normal",new Zt(h,3)),this.setAttribute("uv",new Zt(f,2));function _(v,p,d,T,S,A,B,R,w,F,y){const M=A/w,P=B/F,W=A/2,G=B/2,H=R/2,K=w+1,V=F+1;let j=0,z=0;const ae=new D;for(let he=0;he<V;he++){const me=he*P-G;for(let Be=0;Be<K;Be++){const Ke=Be*M-W;ae[v]=Ke*T,ae[p]=me*S,ae[d]=H,c.push(ae.x,ae.y,ae.z),ae[v]=0,ae[p]=0,ae[d]=R>0?1:-1,h.push(ae.x,ae.y,ae.z),f.push(Be/w),f.push(1-he/F),j+=1}}for(let he=0;he<F;he++)for(let me=0;me<w;me++){const Be=u+me+K*he,Ke=u+me+K*(he+1),k=u+(me+1)+K*(he+1),J=u+(me+1)+K*he;l.push(Be,Ke,J),l.push(Ke,k,J),z+=6}o.addGroup(m,z,y),m+=z,u+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Wn(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function vt(i){const e={};for(let t=0;t<i.length;t++){const n=Wn(i[t]);for(const r in n)e[r]=n[r]}return e}function Ro(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function ba(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ze.workingColorSpace}const wo={clone:Wn,merge:vt};var Co=`void main() {
6
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
- }`,Po=`void main() {
8
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
- }`;class jt extends cn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Co,this.fragmentShader=Po,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Wn(e.uniforms),this.uniformsGroups=Ro(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ra extends nt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ue,this.projectionMatrix=new Ue,this.projectionMatrixInverse=new Ue,this.coordinateSystem=2e3}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}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)}}const on=new D,Cs=new Fe,Ps=new Fe;class xt extends Ra{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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){const t=.5*this.getFilmHeight()/e;this.fov=Hn*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(oi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Hn*2*Math.atan(Math.tan(oi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){on.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(on.x,on.y).multiplyScalar(-e/on.z),on.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(on.x,on.y).multiplyScalar(-e/on.z)}getViewSize(e,t){return this.getViewBounds(e,Cs,Ps),t.subVectors(Ps,Cs)}setViewOffset(e,t,n,r,s,a){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=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(oi*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}const Fn=-90,Bn=1;class Lo extends nt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new xt(Fn,Bn,e,t);r.layers=this.layers,this.add(r);const s=new xt(Fn,Bn,e,t);s.layers=this.layers,this.add(s);const a=new xt(Fn,Bn,e,t);a.layers=this.layers,this.add(a);const o=new xt(Fn,Bn,e,t);o.layers=this.layers,this.add(o);const l=new xt(Fn,Bn,e,t);l.layers=this.layers,this.add(l);const c=new xt(Fn,Bn,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,f=e.getRenderTarget(),u=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,l),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,r),e.render(t,h),e.setRenderTarget(f,u,m),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class wa extends lt{constructor(e,t,n,r,s,a,o,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:301,super(e,t,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Do extends Mn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new wa(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:1006}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
-
11
- varying vec3 vWorldDirection;
12
-
13
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
14
-
15
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
16
-
17
- }
18
-
19
- void main() {
20
-
21
- vWorldDirection = transformDirection( position, modelMatrix );
22
-
23
- #include <begin_vertex>
24
- #include <project_vertex>
25
-
26
- }
27
- `,fragmentShader:`
28
-
29
- uniform sampler2D tEquirect;
30
-
31
- varying vec3 vWorldDirection;
32
-
33
- #include <common>
34
-
35
- void main() {
36
-
37
- vec3 direction = normalize( vWorldDirection );
38
-
39
- vec2 sampleUV = equirectUv( direction );
40
-
41
- gl_FragColor = texture2D( tEquirect, sampleUV );
42
-
43
- }
44
- `},r=new fi(5,5,5),s=new jt({name:"CubemapFromEquirect",uniforms:Wn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});s.uniforms.tEquirect.value=t;const a=new Tt(r,s),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=1006),new Lo(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}const Tr=new D,Io=new D,Uo=new Pe;class gn{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Tr.subVectors(n,t).cross(Io.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Tr),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const 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){const n=t||Uo.getNormalMatrix(e),r=this.coplanarPoint(Tr).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.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)}}const pn=new Gt,Fi=new D;class Hr{constructor(e=new gn,t=new gn,n=new gn,r=new gn,s=new gn,a=new gn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],h=r[5],f=r[6],u=r[7],m=r[8],_=r[9],v=r[10],p=r[11],d=r[12],T=r[13],S=r[14],A=r[15];if(n[0].setComponents(l-s,u-c,p-m,A-d).normalize(),n[1].setComponents(l+s,u+c,p+m,A+d).normalize(),n[2].setComponents(l+a,u+h,p+_,A+T).normalize(),n[3].setComponents(l-a,u-h,p-_,A-T).normalize(),n[4].setComponents(l-o,u-f,p-v,A-S).normalize(),t===2e3)n[5].setComponents(l+o,u+f,p+v,A+S).normalize();else if(t===2001)n[5].setComponents(o,f,v,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),pn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),pn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(pn)}intersectsSprite(e){return pn.center.set(0,0,0),pn.radius=.7071067811865476,pn.applyMatrix4(e.matrixWorld),this.intersectsSphere(pn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Fi.x=r.normal.x>0?e.max.x:e.min.x,Fi.y=r.normal.y>0?e.max.y:e.min.y,Fi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Fi)<0)return!1}return!0}containsPoint(e){const 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 Ca(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function No(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,f=c.byteLength,u=i.createBuffer();i.bindBuffer(l,u),i.bufferData(l,c,h),o.onUploadCallback();let m;if(c instanceof Float32Array)m=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=i.SHORT;else if(c instanceof Uint32Array)m=i.UNSIGNED_INT;else if(c instanceof Int32Array)m=i.INT;else if(c instanceof Int8Array)m=i.BYTE;else if(c instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:f}}function n(o,l,c){const h=l.array,f=l._updateRange,u=l.updateRanges;if(i.bindBuffer(c,o),f.count===-1&&u.length===0&&i.bufferSubData(c,0,h),u.length!==0){for(let m=0,_=u.length;m<_;m++){const v=u[m];i.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}f.count!==-1&&(i.bufferSubData(c,f.offset*h.BYTES_PER_ELEMENT,h,f.offset,f.count),f.count=-1),l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}class pi extends zt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,f=e/o,u=t/l,m=[],_=[],v=[],p=[];for(let d=0;d<h;d++){const T=d*u-a;for(let S=0;S<c;S++){const A=S*f-s;_.push(A,-T,0),v.push(0,0,1),p.push(S/o),p.push(1-d/l)}}for(let d=0;d<l;d++)for(let T=0;T<o;T++){const S=T+c*d,A=T+c*(d+1),B=T+1+c*(d+1),R=T+1+c*d;m.push(S,A,R),m.push(A,B,R)}this.setIndex(m),this.setAttribute("position",new Zt(_,3)),this.setAttribute("normal",new Zt(v,3)),this.setAttribute("uv",new Zt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pi(e.width,e.height,e.widthSegments,e.heightSegments)}}var Fo=`#ifdef USE_ALPHAHASH
45
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
- #endif`,Bo=`#ifdef USE_ALPHAHASH
47
- const float ALPHA_HASH_SCALE = 0.05;
48
- float hash2D( vec2 value ) {
49
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
50
- }
51
- float hash3D( vec3 value ) {
52
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
53
- }
54
- float getAlphaHashThreshold( vec3 position ) {
55
- float maxDeriv = max(
56
- length( dFdx( position.xyz ) ),
57
- length( dFdy( position.xyz ) )
58
- );
59
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
60
- vec2 pixScales = vec2(
61
- exp2( floor( log2( pixScale ) ) ),
62
- exp2( ceil( log2( pixScale ) ) )
63
- );
64
- vec2 alpha = vec2(
65
- hash3D( floor( pixScales.x * position.xyz ) ),
66
- hash3D( floor( pixScales.y * position.xyz ) )
67
- );
68
- float lerpFactor = fract( log2( pixScale ) );
69
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
70
- float a = min( lerpFactor, 1.0 - lerpFactor );
71
- vec3 cases = vec3(
72
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
73
- ( x - 0.5 * a ) / ( 1.0 - a ),
74
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
75
- );
76
- float threshold = ( x < ( 1.0 - a ) )
77
- ? ( ( x < a ) ? cases.x : cases.y )
78
- : cases.z;
79
- return clamp( threshold , 1.0e-6, 1.0 );
80
- }
81
- #endif`,Oo=`#ifdef USE_ALPHAMAP
82
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
83
- #endif`,Go=`#ifdef USE_ALPHAMAP
84
- uniform sampler2D alphaMap;
85
- #endif`,zo=`#ifdef USE_ALPHATEST
86
- #ifdef ALPHA_TO_COVERAGE
87
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
88
- if ( diffuseColor.a == 0.0 ) discard;
89
- #else
90
- if ( diffuseColor.a < alphaTest ) discard;
91
- #endif
92
- #endif`,Vo=`#ifdef USE_ALPHATEST
93
- uniform float alphaTest;
94
- #endif`,ko=`#ifdef USE_AOMAP
95
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
96
- reflectedLight.indirectDiffuse *= ambientOcclusion;
97
- #if defined( USE_CLEARCOAT )
98
- clearcoatSpecularIndirect *= ambientOcclusion;
99
- #endif
100
- #if defined( USE_SHEEN )
101
- sheenSpecularIndirect *= ambientOcclusion;
102
- #endif
103
- #if defined( USE_ENVMAP ) && defined( STANDARD )
104
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
105
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
106
- #endif
107
- #endif`,Ho=`#ifdef USE_AOMAP
108
- uniform sampler2D aoMap;
109
- uniform float aoMapIntensity;
110
- #endif`,Wo=`#ifdef USE_BATCHING
111
- #if ! defined( GL_ANGLE_multi_draw )
112
- #define gl_DrawID _gl_DrawID
113
- uniform int _gl_DrawID;
114
- #endif
115
- uniform highp sampler2D batchingTexture;
116
- uniform highp usampler2D batchingIdTexture;
117
- mat4 getBatchingMatrix( const in float i ) {
118
- int size = textureSize( batchingTexture, 0 ).x;
119
- int j = int( i ) * 4;
120
- int x = j % size;
121
- int y = j / size;
122
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
123
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
124
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
125
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
126
- return mat4( v1, v2, v3, v4 );
127
- }
128
- float getIndirectIndex( const in int i ) {
129
- int size = textureSize( batchingIdTexture, 0 ).x;
130
- int x = i % size;
131
- int y = i / size;
132
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
133
- }
134
- #endif
135
- #ifdef USE_BATCHING_COLOR
136
- uniform sampler2D batchingColorTexture;
137
- vec3 getBatchingColor( const in float i ) {
138
- int size = textureSize( batchingColorTexture, 0 ).x;
139
- int j = int( i );
140
- int x = j % size;
141
- int y = j / size;
142
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
143
- }
144
- #endif`,Xo=`#ifdef USE_BATCHING
145
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
146
- #endif`,qo=`vec3 transformed = vec3( position );
147
- #ifdef USE_ALPHAHASH
148
- vPosition = vec3( position );
149
- #endif`,Yo=`vec3 objectNormal = vec3( normal );
150
- #ifdef USE_TANGENT
151
- vec3 objectTangent = vec3( tangent.xyz );
152
- #endif`,Ko=`float G_BlinnPhong_Implicit( ) {
153
- return 0.25;
154
- }
155
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
156
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
157
- }
158
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
159
- vec3 halfDir = normalize( lightDir + viewDir );
160
- float dotNH = saturate( dot( normal, halfDir ) );
161
- float dotVH = saturate( dot( viewDir, halfDir ) );
162
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
163
- float G = G_BlinnPhong_Implicit( );
164
- float D = D_BlinnPhong( shininess, dotNH );
165
- return F * ( G * D );
166
- } // validated`,$o=`#ifdef USE_IRIDESCENCE
167
- const mat3 XYZ_TO_REC709 = mat3(
168
- 3.2404542, -0.9692660, 0.0556434,
169
- -1.5371385, 1.8760108, -0.2040259,
170
- -0.4985314, 0.0415560, 1.0572252
171
- );
172
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
173
- vec3 sqrtF0 = sqrt( fresnel0 );
174
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
175
- }
176
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
177
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
178
- }
179
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
180
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
181
- }
182
- vec3 evalSensitivity( float OPD, vec3 shift ) {
183
- float phase = 2.0 * PI * OPD * 1.0e-9;
184
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
185
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
186
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
187
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
188
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
189
- xyz /= 1.0685e-7;
190
- vec3 rgb = XYZ_TO_REC709 * xyz;
191
- return rgb;
192
- }
193
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
194
- vec3 I;
195
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
196
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
197
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
198
- if ( cosTheta2Sq < 0.0 ) {
199
- return vec3( 1.0 );
200
- }
201
- float cosTheta2 = sqrt( cosTheta2Sq );
202
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
203
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
204
- float T121 = 1.0 - R12;
205
- float phi12 = 0.0;
206
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
207
- float phi21 = PI - phi12;
208
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
209
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
210
- vec3 phi23 = vec3( 0.0 );
211
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
212
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
213
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
214
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
215
- vec3 phi = vec3( phi21 ) + phi23;
216
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
217
- vec3 r123 = sqrt( R123 );
218
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
219
- vec3 C0 = R12 + Rs;
220
- I = C0;
221
- vec3 Cm = Rs - T121;
222
- for ( int m = 1; m <= 2; ++ m ) {
223
- Cm *= r123;
224
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
225
- I += Cm * Sm;
226
- }
227
- return max( I, vec3( 0.0 ) );
228
- }
229
- #endif`,Zo=`#ifdef USE_BUMPMAP
230
- uniform sampler2D bumpMap;
231
- uniform float bumpScale;
232
- vec2 dHdxy_fwd() {
233
- vec2 dSTdx = dFdx( vBumpMapUv );
234
- vec2 dSTdy = dFdy( vBumpMapUv );
235
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
236
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
237
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
238
- return vec2( dBx, dBy );
239
- }
240
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
241
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
242
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
243
- vec3 vN = surf_norm;
244
- vec3 R1 = cross( vSigmaY, vN );
245
- vec3 R2 = cross( vN, vSigmaX );
246
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
247
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
248
- return normalize( abs( fDet ) * surf_norm - vGrad );
249
- }
250
- #endif`,jo=`#if NUM_CLIPPING_PLANES > 0
251
- vec4 plane;
252
- #ifdef ALPHA_TO_COVERAGE
253
- float distanceToPlane, distanceGradient;
254
- float clipOpacity = 1.0;
255
- #pragma unroll_loop_start
256
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
257
- plane = clippingPlanes[ i ];
258
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
259
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
260
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
261
- if ( clipOpacity == 0.0 ) discard;
262
- }
263
- #pragma unroll_loop_end
264
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
265
- float unionClipOpacity = 1.0;
266
- #pragma unroll_loop_start
267
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
268
- plane = clippingPlanes[ i ];
269
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
270
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
271
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
272
- }
273
- #pragma unroll_loop_end
274
- clipOpacity *= 1.0 - unionClipOpacity;
275
- #endif
276
- diffuseColor.a *= clipOpacity;
277
- if ( diffuseColor.a == 0.0 ) discard;
278
- #else
279
- #pragma unroll_loop_start
280
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
281
- plane = clippingPlanes[ i ];
282
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
283
- }
284
- #pragma unroll_loop_end
285
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
286
- bool clipped = true;
287
- #pragma unroll_loop_start
288
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
289
- plane = clippingPlanes[ i ];
290
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
291
- }
292
- #pragma unroll_loop_end
293
- if ( clipped ) discard;
294
- #endif
295
- #endif
296
- #endif`,Jo=`#if NUM_CLIPPING_PLANES > 0
297
- varying vec3 vClipPosition;
298
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
299
- #endif`,Qo=`#if NUM_CLIPPING_PLANES > 0
300
- varying vec3 vClipPosition;
301
- #endif`,el=`#if NUM_CLIPPING_PLANES > 0
302
- vClipPosition = - mvPosition.xyz;
303
- #endif`,tl=`#if defined( USE_COLOR_ALPHA )
304
- diffuseColor *= vColor;
305
- #elif defined( USE_COLOR )
306
- diffuseColor.rgb *= vColor;
307
- #endif`,nl=`#if defined( USE_COLOR_ALPHA )
308
- varying vec4 vColor;
309
- #elif defined( USE_COLOR )
310
- varying vec3 vColor;
311
- #endif`,il=`#if defined( USE_COLOR_ALPHA )
312
- varying vec4 vColor;
313
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
- varying vec3 vColor;
315
- #endif`,rl=`#if defined( USE_COLOR_ALPHA )
316
- vColor = vec4( 1.0 );
317
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
318
- vColor = vec3( 1.0 );
319
- #endif
320
- #ifdef USE_COLOR
321
- vColor *= color;
322
- #endif
323
- #ifdef USE_INSTANCING_COLOR
324
- vColor.xyz *= instanceColor.xyz;
325
- #endif
326
- #ifdef USE_BATCHING_COLOR
327
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
328
- vColor.xyz *= batchingColor.xyz;
329
- #endif`,sl=`#define PI 3.141592653589793
330
- #define PI2 6.283185307179586
331
- #define PI_HALF 1.5707963267948966
332
- #define RECIPROCAL_PI 0.3183098861837907
333
- #define RECIPROCAL_PI2 0.15915494309189535
334
- #define EPSILON 1e-6
335
- #ifndef saturate
336
- #define saturate( a ) clamp( a, 0.0, 1.0 )
337
- #endif
338
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
339
- float pow2( const in float x ) { return x*x; }
340
- vec3 pow2( const in vec3 x ) { return x*x; }
341
- float pow3( const in float x ) { return x*x*x; }
342
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
343
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
344
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
345
- highp float rand( const in vec2 uv ) {
346
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
347
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
348
- return fract( sin( sn ) * c );
349
- }
350
- #ifdef HIGH_PRECISION
351
- float precisionSafeLength( vec3 v ) { return length( v ); }
352
- #else
353
- float precisionSafeLength( vec3 v ) {
354
- float maxComponent = max3( abs( v ) );
355
- return length( v / maxComponent ) * maxComponent;
356
- }
357
- #endif
358
- struct IncidentLight {
359
- vec3 color;
360
- vec3 direction;
361
- bool visible;
362
- };
363
- struct ReflectedLight {
364
- vec3 directDiffuse;
365
- vec3 directSpecular;
366
- vec3 indirectDiffuse;
367
- vec3 indirectSpecular;
368
- };
369
- #ifdef USE_ALPHAHASH
370
- varying vec3 vPosition;
371
- #endif
372
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
373
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
374
- }
375
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
376
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
377
- }
378
- mat3 transposeMat3( const in mat3 m ) {
379
- mat3 tmp;
380
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
381
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
382
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
383
- return tmp;
384
- }
385
- bool isPerspectiveMatrix( mat4 m ) {
386
- return m[ 2 ][ 3 ] == - 1.0;
387
- }
388
- vec2 equirectUv( in vec3 dir ) {
389
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
390
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
391
- return vec2( u, v );
392
- }
393
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
394
- return RECIPROCAL_PI * diffuseColor;
395
- }
396
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
397
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
- }
400
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
401
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
402
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
403
- } // validated`,al=`#ifdef ENVMAP_TYPE_CUBE_UV
404
- #define cubeUV_minMipLevel 4.0
405
- #define cubeUV_minTileSize 16.0
406
- float getFace( vec3 direction ) {
407
- vec3 absDirection = abs( direction );
408
- float face = - 1.0;
409
- if ( absDirection.x > absDirection.z ) {
410
- if ( absDirection.x > absDirection.y )
411
- face = direction.x > 0.0 ? 0.0 : 3.0;
412
- else
413
- face = direction.y > 0.0 ? 1.0 : 4.0;
414
- } else {
415
- if ( absDirection.z > absDirection.y )
416
- face = direction.z > 0.0 ? 2.0 : 5.0;
417
- else
418
- face = direction.y > 0.0 ? 1.0 : 4.0;
419
- }
420
- return face;
421
- }
422
- vec2 getUV( vec3 direction, float face ) {
423
- vec2 uv;
424
- if ( face == 0.0 ) {
425
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
426
- } else if ( face == 1.0 ) {
427
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
428
- } else if ( face == 2.0 ) {
429
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
430
- } else if ( face == 3.0 ) {
431
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
432
- } else if ( face == 4.0 ) {
433
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
434
- } else {
435
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
436
- }
437
- return 0.5 * ( uv + 1.0 );
438
- }
439
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
440
- float face = getFace( direction );
441
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
442
- mipInt = max( mipInt, cubeUV_minMipLevel );
443
- float faceSize = exp2( mipInt );
444
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
445
- if ( face > 2.0 ) {
446
- uv.y += faceSize;
447
- face -= 3.0;
448
- }
449
- uv.x += face * faceSize;
450
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
451
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
452
- uv.x *= CUBEUV_TEXEL_WIDTH;
453
- uv.y *= CUBEUV_TEXEL_HEIGHT;
454
- #ifdef texture2DGradEXT
455
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
456
- #else
457
- return texture2D( envMap, uv ).rgb;
458
- #endif
459
- }
460
- #define cubeUV_r0 1.0
461
- #define cubeUV_m0 - 2.0
462
- #define cubeUV_r1 0.8
463
- #define cubeUV_m1 - 1.0
464
- #define cubeUV_r4 0.4
465
- #define cubeUV_m4 2.0
466
- #define cubeUV_r5 0.305
467
- #define cubeUV_m5 3.0
468
- #define cubeUV_r6 0.21
469
- #define cubeUV_m6 4.0
470
- float roughnessToMip( float roughness ) {
471
- float mip = 0.0;
472
- if ( roughness >= cubeUV_r1 ) {
473
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
474
- } else if ( roughness >= cubeUV_r4 ) {
475
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
476
- } else if ( roughness >= cubeUV_r5 ) {
477
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
478
- } else if ( roughness >= cubeUV_r6 ) {
479
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
480
- } else {
481
- mip = - 2.0 * log2( 1.16 * roughness ); }
482
- return mip;
483
- }
484
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
485
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
486
- float mipF = fract( mip );
487
- float mipInt = floor( mip );
488
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
489
- if ( mipF == 0.0 ) {
490
- return vec4( color0, 1.0 );
491
- } else {
492
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
493
- return vec4( mix( color0, color1, mipF ), 1.0 );
494
- }
495
- }
496
- #endif`,ol=`vec3 transformedNormal = objectNormal;
497
- #ifdef USE_TANGENT
498
- vec3 transformedTangent = objectTangent;
499
- #endif
500
- #ifdef USE_BATCHING
501
- mat3 bm = mat3( batchingMatrix );
502
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
503
- transformedNormal = bm * transformedNormal;
504
- #ifdef USE_TANGENT
505
- transformedTangent = bm * transformedTangent;
506
- #endif
507
- #endif
508
- #ifdef USE_INSTANCING
509
- mat3 im = mat3( instanceMatrix );
510
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
511
- transformedNormal = im * transformedNormal;
512
- #ifdef USE_TANGENT
513
- transformedTangent = im * transformedTangent;
514
- #endif
515
- #endif
516
- transformedNormal = normalMatrix * transformedNormal;
517
- #ifdef FLIP_SIDED
518
- transformedNormal = - transformedNormal;
519
- #endif
520
- #ifdef USE_TANGENT
521
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
522
- #ifdef FLIP_SIDED
523
- transformedTangent = - transformedTangent;
524
- #endif
525
- #endif`,ll=`#ifdef USE_DISPLACEMENTMAP
526
- uniform sampler2D displacementMap;
527
- uniform float displacementScale;
528
- uniform float displacementBias;
529
- #endif`,cl=`#ifdef USE_DISPLACEMENTMAP
530
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
531
- #endif`,hl=`#ifdef USE_EMISSIVEMAP
532
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
533
- totalEmissiveRadiance *= emissiveColor.rgb;
534
- #endif`,ul=`#ifdef USE_EMISSIVEMAP
535
- uniform sampler2D emissiveMap;
536
- #endif`,dl="gl_FragColor = linearToOutputTexel( gl_FragColor );",fl=`
537
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
538
- vec3( 0.8224621, 0.177538, 0.0 ),
539
- vec3( 0.0331941, 0.9668058, 0.0 ),
540
- vec3( 0.0170827, 0.0723974, 0.9105199 )
541
- );
542
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
543
- vec3( 1.2249401, - 0.2249404, 0.0 ),
544
- vec3( - 0.0420569, 1.0420571, 0.0 ),
545
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
546
- );
547
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
548
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
549
- }
550
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
551
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
552
- }
553
- vec4 LinearTransferOETF( in vec4 value ) {
554
- return value;
555
- }
556
- vec4 sRGBTransferOETF( in vec4 value ) {
557
- 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 );
558
- }`,pl=`#ifdef USE_ENVMAP
559
- #ifdef ENV_WORLDPOS
560
- vec3 cameraToFrag;
561
- if ( isOrthographic ) {
562
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
563
- } else {
564
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
565
- }
566
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
567
- #ifdef ENVMAP_MODE_REFLECTION
568
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
569
- #else
570
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
571
- #endif
572
- #else
573
- vec3 reflectVec = vReflect;
574
- #endif
575
- #ifdef ENVMAP_TYPE_CUBE
576
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
577
- #else
578
- vec4 envColor = vec4( 0.0 );
579
- #endif
580
- #ifdef ENVMAP_BLENDING_MULTIPLY
581
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
582
- #elif defined( ENVMAP_BLENDING_MIX )
583
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
584
- #elif defined( ENVMAP_BLENDING_ADD )
585
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
586
- #endif
587
- #endif`,ml=`#ifdef USE_ENVMAP
588
- uniform float envMapIntensity;
589
- uniform float flipEnvMap;
590
- uniform mat3 envMapRotation;
591
- #ifdef ENVMAP_TYPE_CUBE
592
- uniform samplerCube envMap;
593
- #else
594
- uniform sampler2D envMap;
595
- #endif
596
-
597
- #endif`,_l=`#ifdef USE_ENVMAP
598
- uniform float reflectivity;
599
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
600
- #define ENV_WORLDPOS
601
- #endif
602
- #ifdef ENV_WORLDPOS
603
- varying vec3 vWorldPosition;
604
- uniform float refractionRatio;
605
- #else
606
- varying vec3 vReflect;
607
- #endif
608
- #endif`,gl=`#ifdef USE_ENVMAP
609
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
610
- #define ENV_WORLDPOS
611
- #endif
612
- #ifdef ENV_WORLDPOS
613
-
614
- varying vec3 vWorldPosition;
615
- #else
616
- varying vec3 vReflect;
617
- uniform float refractionRatio;
618
- #endif
619
- #endif`,vl=`#ifdef USE_ENVMAP
620
- #ifdef ENV_WORLDPOS
621
- vWorldPosition = worldPosition.xyz;
622
- #else
623
- vec3 cameraToVertex;
624
- if ( isOrthographic ) {
625
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
626
- } else {
627
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
628
- }
629
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
630
- #ifdef ENVMAP_MODE_REFLECTION
631
- vReflect = reflect( cameraToVertex, worldNormal );
632
- #else
633
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
634
- #endif
635
- #endif
636
- #endif`,xl=`#ifdef USE_FOG
637
- vFogDepth = - mvPosition.z;
638
- #endif`,Ml=`#ifdef USE_FOG
639
- varying float vFogDepth;
640
- #endif`,Sl=`#ifdef USE_FOG
641
- #ifdef FOG_EXP2
642
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
643
- #else
644
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
645
- #endif
646
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
647
- #endif`,yl=`#ifdef USE_FOG
648
- uniform vec3 fogColor;
649
- varying float vFogDepth;
650
- #ifdef FOG_EXP2
651
- uniform float fogDensity;
652
- #else
653
- uniform float fogNear;
654
- uniform float fogFar;
655
- #endif
656
- #endif`,El=`#ifdef USE_GRADIENTMAP
657
- uniform sampler2D gradientMap;
658
- #endif
659
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
660
- float dotNL = dot( normal, lightDirection );
661
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
662
- #ifdef USE_GRADIENTMAP
663
- return vec3( texture2D( gradientMap, coord ).r );
664
- #else
665
- vec2 fw = fwidth( coord ) * 0.5;
666
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
667
- #endif
668
- }`,Tl=`#ifdef USE_LIGHTMAP
669
- uniform sampler2D lightMap;
670
- uniform float lightMapIntensity;
671
- #endif`,Al=`LambertMaterial material;
672
- material.diffuseColor = diffuseColor.rgb;
673
- material.specularStrength = specularStrength;`,bl=`varying vec3 vViewPosition;
674
- struct LambertMaterial {
675
- vec3 diffuseColor;
676
- float specularStrength;
677
- };
678
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
679
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
680
- vec3 irradiance = dotNL * directLight.color;
681
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
682
- }
683
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
684
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
685
- }
686
- #define RE_Direct RE_Direct_Lambert
687
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Rl=`uniform bool receiveShadow;
688
- uniform vec3 ambientLightColor;
689
- #if defined( USE_LIGHT_PROBES )
690
- uniform vec3 lightProbe[ 9 ];
691
- #endif
692
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
693
- float x = normal.x, y = normal.y, z = normal.z;
694
- vec3 result = shCoefficients[ 0 ] * 0.886227;
695
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
696
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
697
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
698
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
699
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
700
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
701
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
702
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
703
- return result;
704
- }
705
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
706
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
707
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
708
- return irradiance;
709
- }
710
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
711
- vec3 irradiance = ambientLightColor;
712
- return irradiance;
713
- }
714
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
715
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
716
- if ( cutoffDistance > 0.0 ) {
717
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
718
- }
719
- return distanceFalloff;
720
- }
721
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
722
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
723
- }
724
- #if NUM_DIR_LIGHTS > 0
725
- struct DirectionalLight {
726
- vec3 direction;
727
- vec3 color;
728
- };
729
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
730
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
731
- light.color = directionalLight.color;
732
- light.direction = directionalLight.direction;
733
- light.visible = true;
734
- }
735
- #endif
736
- #if NUM_POINT_LIGHTS > 0
737
- struct PointLight {
738
- vec3 position;
739
- vec3 color;
740
- float distance;
741
- float decay;
742
- };
743
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
744
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
745
- vec3 lVector = pointLight.position - geometryPosition;
746
- light.direction = normalize( lVector );
747
- float lightDistance = length( lVector );
748
- light.color = pointLight.color;
749
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
750
- light.visible = ( light.color != vec3( 0.0 ) );
751
- }
752
- #endif
753
- #if NUM_SPOT_LIGHTS > 0
754
- struct SpotLight {
755
- vec3 position;
756
- vec3 direction;
757
- vec3 color;
758
- float distance;
759
- float decay;
760
- float coneCos;
761
- float penumbraCos;
762
- };
763
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
764
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
765
- vec3 lVector = spotLight.position - geometryPosition;
766
- light.direction = normalize( lVector );
767
- float angleCos = dot( light.direction, spotLight.direction );
768
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
769
- if ( spotAttenuation > 0.0 ) {
770
- float lightDistance = length( lVector );
771
- light.color = spotLight.color * spotAttenuation;
772
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
773
- light.visible = ( light.color != vec3( 0.0 ) );
774
- } else {
775
- light.color = vec3( 0.0 );
776
- light.visible = false;
777
- }
778
- }
779
- #endif
780
- #if NUM_RECT_AREA_LIGHTS > 0
781
- struct RectAreaLight {
782
- vec3 color;
783
- vec3 position;
784
- vec3 halfWidth;
785
- vec3 halfHeight;
786
- };
787
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
788
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
789
- #endif
790
- #if NUM_HEMI_LIGHTS > 0
791
- struct HemisphereLight {
792
- vec3 direction;
793
- vec3 skyColor;
794
- vec3 groundColor;
795
- };
796
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
797
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
798
- float dotNL = dot( normal, hemiLight.direction );
799
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
800
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
801
- return irradiance;
802
- }
803
- #endif`,wl=`#ifdef USE_ENVMAP
804
- vec3 getIBLIrradiance( const in vec3 normal ) {
805
- #ifdef ENVMAP_TYPE_CUBE_UV
806
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
807
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
808
- return PI * envMapColor.rgb * envMapIntensity;
809
- #else
810
- return vec3( 0.0 );
811
- #endif
812
- }
813
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
814
- #ifdef ENVMAP_TYPE_CUBE_UV
815
- vec3 reflectVec = reflect( - viewDir, normal );
816
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
817
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
818
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
819
- return envMapColor.rgb * envMapIntensity;
820
- #else
821
- return vec3( 0.0 );
822
- #endif
823
- }
824
- #ifdef USE_ANISOTROPY
825
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
826
- #ifdef ENVMAP_TYPE_CUBE_UV
827
- vec3 bentNormal = cross( bitangent, viewDir );
828
- bentNormal = normalize( cross( bentNormal, bitangent ) );
829
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
830
- return getIBLRadiance( viewDir, bentNormal, roughness );
831
- #else
832
- return vec3( 0.0 );
833
- #endif
834
- }
835
- #endif
836
- #endif`,Cl=`ToonMaterial material;
837
- material.diffuseColor = diffuseColor.rgb;`,Pl=`varying vec3 vViewPosition;
838
- struct ToonMaterial {
839
- vec3 diffuseColor;
840
- };
841
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
842
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
843
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
844
- }
845
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
846
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
847
- }
848
- #define RE_Direct RE_Direct_Toon
849
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ll=`BlinnPhongMaterial material;
850
- material.diffuseColor = diffuseColor.rgb;
851
- material.specularColor = specular;
852
- material.specularShininess = shininess;
853
- material.specularStrength = specularStrength;`,Dl=`varying vec3 vViewPosition;
854
- struct BlinnPhongMaterial {
855
- vec3 diffuseColor;
856
- vec3 specularColor;
857
- float specularShininess;
858
- float specularStrength;
859
- };
860
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
861
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
862
- vec3 irradiance = dotNL * directLight.color;
863
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
864
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
865
- }
866
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
867
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
868
- }
869
- #define RE_Direct RE_Direct_BlinnPhong
870
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Il=`PhysicalMaterial material;
871
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
872
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
873
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
874
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
875
- material.roughness = min( material.roughness, 1.0 );
876
- #ifdef IOR
877
- material.ior = ior;
878
- #ifdef USE_SPECULAR
879
- float specularIntensityFactor = specularIntensity;
880
- vec3 specularColorFactor = specularColor;
881
- #ifdef USE_SPECULAR_COLORMAP
882
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
883
- #endif
884
- #ifdef USE_SPECULAR_INTENSITYMAP
885
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
886
- #endif
887
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
888
- #else
889
- float specularIntensityFactor = 1.0;
890
- vec3 specularColorFactor = vec3( 1.0 );
891
- material.specularF90 = 1.0;
892
- #endif
893
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
894
- #else
895
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
896
- material.specularF90 = 1.0;
897
- #endif
898
- #ifdef USE_CLEARCOAT
899
- material.clearcoat = clearcoat;
900
- material.clearcoatRoughness = clearcoatRoughness;
901
- material.clearcoatF0 = vec3( 0.04 );
902
- material.clearcoatF90 = 1.0;
903
- #ifdef USE_CLEARCOATMAP
904
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
905
- #endif
906
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
907
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
908
- #endif
909
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
910
- material.clearcoatRoughness += geometryRoughness;
911
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
912
- #endif
913
- #ifdef USE_DISPERSION
914
- material.dispersion = dispersion;
915
- #endif
916
- #ifdef USE_IRIDESCENCE
917
- material.iridescence = iridescence;
918
- material.iridescenceIOR = iridescenceIOR;
919
- #ifdef USE_IRIDESCENCEMAP
920
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
921
- #endif
922
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
923
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
924
- #else
925
- material.iridescenceThickness = iridescenceThicknessMaximum;
926
- #endif
927
- #endif
928
- #ifdef USE_SHEEN
929
- material.sheenColor = sheenColor;
930
- #ifdef USE_SHEEN_COLORMAP
931
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
932
- #endif
933
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
934
- #ifdef USE_SHEEN_ROUGHNESSMAP
935
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
936
- #endif
937
- #endif
938
- #ifdef USE_ANISOTROPY
939
- #ifdef USE_ANISOTROPYMAP
940
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
941
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
942
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
943
- #else
944
- vec2 anisotropyV = anisotropyVector;
945
- #endif
946
- material.anisotropy = length( anisotropyV );
947
- if( material.anisotropy == 0.0 ) {
948
- anisotropyV = vec2( 1.0, 0.0 );
949
- } else {
950
- anisotropyV /= material.anisotropy;
951
- material.anisotropy = saturate( material.anisotropy );
952
- }
953
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
954
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
955
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
956
- #endif`,Ul=`struct PhysicalMaterial {
957
- vec3 diffuseColor;
958
- float roughness;
959
- vec3 specularColor;
960
- float specularF90;
961
- float dispersion;
962
- #ifdef USE_CLEARCOAT
963
- float clearcoat;
964
- float clearcoatRoughness;
965
- vec3 clearcoatF0;
966
- float clearcoatF90;
967
- #endif
968
- #ifdef USE_IRIDESCENCE
969
- float iridescence;
970
- float iridescenceIOR;
971
- float iridescenceThickness;
972
- vec3 iridescenceFresnel;
973
- vec3 iridescenceF0;
974
- #endif
975
- #ifdef USE_SHEEN
976
- vec3 sheenColor;
977
- float sheenRoughness;
978
- #endif
979
- #ifdef IOR
980
- float ior;
981
- #endif
982
- #ifdef USE_TRANSMISSION
983
- float transmission;
984
- float transmissionAlpha;
985
- float thickness;
986
- float attenuationDistance;
987
- vec3 attenuationColor;
988
- #endif
989
- #ifdef USE_ANISOTROPY
990
- float anisotropy;
991
- float alphaT;
992
- vec3 anisotropyT;
993
- vec3 anisotropyB;
994
- #endif
995
- };
996
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
997
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
998
- vec3 sheenSpecularDirect = vec3( 0.0 );
999
- vec3 sheenSpecularIndirect = vec3(0.0 );
1000
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
1001
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
1002
- float x2 = x * x;
1003
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
1004
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
1005
- }
1006
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
1007
- float a2 = pow2( alpha );
1008
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
1009
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
1010
- return 0.5 / max( gv + gl, EPSILON );
1011
- }
1012
- float D_GGX( const in float alpha, const in float dotNH ) {
1013
- float a2 = pow2( alpha );
1014
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1015
- return RECIPROCAL_PI * a2 / pow2( denom );
1016
- }
1017
- #ifdef USE_ANISOTROPY
1018
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
1019
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1020
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1021
- float v = 0.5 / ( gv + gl );
1022
- return saturate(v);
1023
- }
1024
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1025
- float a2 = alphaT * alphaB;
1026
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1027
- highp float v2 = dot( v, v );
1028
- float w2 = a2 / v2;
1029
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
1030
- }
1031
- #endif
1032
- #ifdef USE_CLEARCOAT
1033
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1034
- vec3 f0 = material.clearcoatF0;
1035
- float f90 = material.clearcoatF90;
1036
- float roughness = material.clearcoatRoughness;
1037
- float alpha = pow2( roughness );
1038
- vec3 halfDir = normalize( lightDir + viewDir );
1039
- float dotNL = saturate( dot( normal, lightDir ) );
1040
- float dotNV = saturate( dot( normal, viewDir ) );
1041
- float dotNH = saturate( dot( normal, halfDir ) );
1042
- float dotVH = saturate( dot( viewDir, halfDir ) );
1043
- vec3 F = F_Schlick( f0, f90, dotVH );
1044
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1045
- float D = D_GGX( alpha, dotNH );
1046
- return F * ( V * D );
1047
- }
1048
- #endif
1049
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1050
- vec3 f0 = material.specularColor;
1051
- float f90 = material.specularF90;
1052
- float roughness = material.roughness;
1053
- float alpha = pow2( roughness );
1054
- vec3 halfDir = normalize( lightDir + viewDir );
1055
- float dotNL = saturate( dot( normal, lightDir ) );
1056
- float dotNV = saturate( dot( normal, viewDir ) );
1057
- float dotNH = saturate( dot( normal, halfDir ) );
1058
- float dotVH = saturate( dot( viewDir, halfDir ) );
1059
- vec3 F = F_Schlick( f0, f90, dotVH );
1060
- #ifdef USE_IRIDESCENCE
1061
- F = mix( F, material.iridescenceFresnel, material.iridescence );
1062
- #endif
1063
- #ifdef USE_ANISOTROPY
1064
- float dotTL = dot( material.anisotropyT, lightDir );
1065
- float dotTV = dot( material.anisotropyT, viewDir );
1066
- float dotTH = dot( material.anisotropyT, halfDir );
1067
- float dotBL = dot( material.anisotropyB, lightDir );
1068
- float dotBV = dot( material.anisotropyB, viewDir );
1069
- float dotBH = dot( material.anisotropyB, halfDir );
1070
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1071
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1072
- #else
1073
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1074
- float D = D_GGX( alpha, dotNH );
1075
- #endif
1076
- return F * ( V * D );
1077
- }
1078
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1079
- const float LUT_SIZE = 64.0;
1080
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1081
- const float LUT_BIAS = 0.5 / LUT_SIZE;
1082
- float dotNV = saturate( dot( N, V ) );
1083
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1084
- uv = uv * LUT_SCALE + LUT_BIAS;
1085
- return uv;
1086
- }
1087
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1088
- float l = length( f );
1089
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1090
- }
1091
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1092
- float x = dot( v1, v2 );
1093
- float y = abs( x );
1094
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1095
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
1096
- float v = a / b;
1097
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1098
- return cross( v1, v2 ) * theta_sintheta;
1099
- }
1100
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1101
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1102
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1103
- vec3 lightNormal = cross( v1, v2 );
1104
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1105
- vec3 T1, T2;
1106
- T1 = normalize( V - N * dot( V, N ) );
1107
- T2 = - cross( N, T1 );
1108
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1109
- vec3 coords[ 4 ];
1110
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1111
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1112
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1113
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1114
- coords[ 0 ] = normalize( coords[ 0 ] );
1115
- coords[ 1 ] = normalize( coords[ 1 ] );
1116
- coords[ 2 ] = normalize( coords[ 2 ] );
1117
- coords[ 3 ] = normalize( coords[ 3 ] );
1118
- vec3 vectorFormFactor = vec3( 0.0 );
1119
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1120
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1121
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1122
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1123
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1124
- return vec3( result );
1125
- }
1126
- #if defined( USE_SHEEN )
1127
- float D_Charlie( float roughness, float dotNH ) {
1128
- float alpha = pow2( roughness );
1129
- float invAlpha = 1.0 / alpha;
1130
- float cos2h = dotNH * dotNH;
1131
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
1132
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1133
- }
1134
- float V_Neubelt( float dotNV, float dotNL ) {
1135
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1136
- }
1137
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1138
- vec3 halfDir = normalize( lightDir + viewDir );
1139
- float dotNL = saturate( dot( normal, lightDir ) );
1140
- float dotNV = saturate( dot( normal, viewDir ) );
1141
- float dotNH = saturate( dot( normal, halfDir ) );
1142
- float D = D_Charlie( sheenRoughness, dotNH );
1143
- float V = V_Neubelt( dotNV, dotNL );
1144
- return sheenColor * ( D * V );
1145
- }
1146
- #endif
1147
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1148
- float dotNV = saturate( dot( normal, viewDir ) );
1149
- float r2 = roughness * roughness;
1150
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1151
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1152
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1153
- return saturate( DG * RECIPROCAL_PI );
1154
- }
1155
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1156
- float dotNV = saturate( dot( normal, viewDir ) );
1157
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1158
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1159
- vec4 r = roughness * c0 + c1;
1160
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1161
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1162
- return fab;
1163
- }
1164
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1165
- vec2 fab = DFGApprox( normal, viewDir, roughness );
1166
- return specularColor * fab.x + specularF90 * fab.y;
1167
- }
1168
- #ifdef USE_IRIDESCENCE
1169
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1170
- #else
1171
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1172
- #endif
1173
- vec2 fab = DFGApprox( normal, viewDir, roughness );
1174
- #ifdef USE_IRIDESCENCE
1175
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1176
- #else
1177
- vec3 Fr = specularColor;
1178
- #endif
1179
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1180
- float Ess = fab.x + fab.y;
1181
- float Ems = 1.0 - Ess;
1182
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1183
- singleScatter += FssEss;
1184
- multiScatter += Fms * Ems;
1185
- }
1186
- #if NUM_RECT_AREA_LIGHTS > 0
1187
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1188
- vec3 normal = geometryNormal;
1189
- vec3 viewDir = geometryViewDir;
1190
- vec3 position = geometryPosition;
1191
- vec3 lightPos = rectAreaLight.position;
1192
- vec3 halfWidth = rectAreaLight.halfWidth;
1193
- vec3 halfHeight = rectAreaLight.halfHeight;
1194
- vec3 lightColor = rectAreaLight.color;
1195
- float roughness = material.roughness;
1196
- vec3 rectCoords[ 4 ];
1197
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1198
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1199
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1200
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
1201
- vec4 t1 = texture2D( ltc_1, uv );
1202
- vec4 t2 = texture2D( ltc_2, uv );
1203
- mat3 mInv = mat3(
1204
- vec3( t1.x, 0, t1.y ),
1205
- vec3( 0, 1, 0 ),
1206
- vec3( t1.z, 0, t1.w )
1207
- );
1208
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1209
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1210
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1211
- }
1212
- #endif
1213
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1214
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1215
- vec3 irradiance = dotNL * directLight.color;
1216
- #ifdef USE_CLEARCOAT
1217
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1218
- vec3 ccIrradiance = dotNLcc * directLight.color;
1219
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1220
- #endif
1221
- #ifdef USE_SHEEN
1222
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1223
- #endif
1224
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1225
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1226
- }
1227
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1228
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1229
- }
1230
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
1231
- #ifdef USE_CLEARCOAT
1232
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1233
- #endif
1234
- #ifdef USE_SHEEN
1235
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1236
- #endif
1237
- vec3 singleScattering = vec3( 0.0 );
1238
- vec3 multiScattering = vec3( 0.0 );
1239
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1240
- #ifdef USE_IRIDESCENCE
1241
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1242
- #else
1243
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1244
- #endif
1245
- vec3 totalScattering = singleScattering + multiScattering;
1246
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1247
- reflectedLight.indirectSpecular += radiance * singleScattering;
1248
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1249
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1250
- }
1251
- #define RE_Direct RE_Direct_Physical
1252
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1253
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1254
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1255
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1256
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1257
- }`,Nl=`
1258
- vec3 geometryPosition = - vViewPosition;
1259
- vec3 geometryNormal = normal;
1260
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1261
- vec3 geometryClearcoatNormal = vec3( 0.0 );
1262
- #ifdef USE_CLEARCOAT
1263
- geometryClearcoatNormal = clearcoatNormal;
1264
- #endif
1265
- #ifdef USE_IRIDESCENCE
1266
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
1267
- if ( material.iridescenceThickness == 0.0 ) {
1268
- material.iridescence = 0.0;
1269
- } else {
1270
- material.iridescence = saturate( material.iridescence );
1271
- }
1272
- if ( material.iridescence > 0.0 ) {
1273
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1274
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1275
- }
1276
- #endif
1277
- IncidentLight directLight;
1278
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1279
- PointLight pointLight;
1280
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1281
- PointLightShadow pointLightShadow;
1282
- #endif
1283
- #pragma unroll_loop_start
1284
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1285
- pointLight = pointLights[ i ];
1286
- getPointLightInfo( pointLight, geometryPosition, directLight );
1287
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1288
- pointLightShadow = pointLightShadows[ i ];
1289
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1290
- #endif
1291
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1292
- }
1293
- #pragma unroll_loop_end
1294
- #endif
1295
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1296
- SpotLight spotLight;
1297
- vec4 spotColor;
1298
- vec3 spotLightCoord;
1299
- bool inSpotLightMap;
1300
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1301
- SpotLightShadow spotLightShadow;
1302
- #endif
1303
- #pragma unroll_loop_start
1304
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1305
- spotLight = spotLights[ i ];
1306
- getSpotLightInfo( spotLight, geometryPosition, directLight );
1307
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1308
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1309
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1310
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1311
- #else
1312
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1313
- #endif
1314
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1315
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1316
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1317
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1318
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1319
- #endif
1320
- #undef SPOT_LIGHT_MAP_INDEX
1321
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1322
- spotLightShadow = spotLightShadows[ i ];
1323
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1324
- #endif
1325
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1326
- }
1327
- #pragma unroll_loop_end
1328
- #endif
1329
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1330
- DirectionalLight directionalLight;
1331
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1332
- DirectionalLightShadow directionalLightShadow;
1333
- #endif
1334
- #pragma unroll_loop_start
1335
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1336
- directionalLight = directionalLights[ i ];
1337
- getDirectionalLightInfo( directionalLight, directLight );
1338
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1339
- directionalLightShadow = directionalLightShadows[ i ];
1340
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1341
- #endif
1342
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1343
- }
1344
- #pragma unroll_loop_end
1345
- #endif
1346
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1347
- RectAreaLight rectAreaLight;
1348
- #pragma unroll_loop_start
1349
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1350
- rectAreaLight = rectAreaLights[ i ];
1351
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1352
- }
1353
- #pragma unroll_loop_end
1354
- #endif
1355
- #if defined( RE_IndirectDiffuse )
1356
- vec3 iblIrradiance = vec3( 0.0 );
1357
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1358
- #if defined( USE_LIGHT_PROBES )
1359
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1360
- #endif
1361
- #if ( NUM_HEMI_LIGHTS > 0 )
1362
- #pragma unroll_loop_start
1363
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1364
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1365
- }
1366
- #pragma unroll_loop_end
1367
- #endif
1368
- #endif
1369
- #if defined( RE_IndirectSpecular )
1370
- vec3 radiance = vec3( 0.0 );
1371
- vec3 clearcoatRadiance = vec3( 0.0 );
1372
- #endif`,Fl=`#if defined( RE_IndirectDiffuse )
1373
- #ifdef USE_LIGHTMAP
1374
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1375
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1376
- irradiance += lightMapIrradiance;
1377
- #endif
1378
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1379
- iblIrradiance += getIBLIrradiance( geometryNormal );
1380
- #endif
1381
- #endif
1382
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1383
- #ifdef USE_ANISOTROPY
1384
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1385
- #else
1386
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1387
- #endif
1388
- #ifdef USE_CLEARCOAT
1389
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1390
- #endif
1391
- #endif`,Bl=`#if defined( RE_IndirectDiffuse )
1392
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1393
- #endif
1394
- #if defined( RE_IndirectSpecular )
1395
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1396
- #endif`,Ol=`#if defined( USE_LOGDEPTHBUF )
1397
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1398
- #endif`,Gl=`#if defined( USE_LOGDEPTHBUF )
1399
- uniform float logDepthBufFC;
1400
- varying float vFragDepth;
1401
- varying float vIsPerspective;
1402
- #endif`,zl=`#ifdef USE_LOGDEPTHBUF
1403
- varying float vFragDepth;
1404
- varying float vIsPerspective;
1405
- #endif`,Vl=`#ifdef USE_LOGDEPTHBUF
1406
- vFragDepth = 1.0 + gl_Position.w;
1407
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1408
- #endif`,kl=`#ifdef USE_MAP
1409
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1410
- #ifdef DECODE_VIDEO_TEXTURE
1411
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
1412
-
1413
- #endif
1414
- diffuseColor *= sampledDiffuseColor;
1415
- #endif`,Hl=`#ifdef USE_MAP
1416
- uniform sampler2D map;
1417
- #endif`,Wl=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1418
- #if defined( USE_POINTS_UV )
1419
- vec2 uv = vUv;
1420
- #else
1421
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1422
- #endif
1423
- #endif
1424
- #ifdef USE_MAP
1425
- diffuseColor *= texture2D( map, uv );
1426
- #endif
1427
- #ifdef USE_ALPHAMAP
1428
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
1429
- #endif`,Xl=`#if defined( USE_POINTS_UV )
1430
- varying vec2 vUv;
1431
- #else
1432
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1433
- uniform mat3 uvTransform;
1434
- #endif
1435
- #endif
1436
- #ifdef USE_MAP
1437
- uniform sampler2D map;
1438
- #endif
1439
- #ifdef USE_ALPHAMAP
1440
- uniform sampler2D alphaMap;
1441
- #endif`,ql=`float metalnessFactor = metalness;
1442
- #ifdef USE_METALNESSMAP
1443
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1444
- metalnessFactor *= texelMetalness.b;
1445
- #endif`,Yl=`#ifdef USE_METALNESSMAP
1446
- uniform sampler2D metalnessMap;
1447
- #endif`,Kl=`#ifdef USE_INSTANCING_MORPH
1448
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1449
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1450
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1451
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1452
- }
1453
- #endif`,$l=`#if defined( USE_MORPHCOLORS )
1454
- vColor *= morphTargetBaseInfluence;
1455
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
- #if defined( USE_COLOR_ALPHA )
1457
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1458
- #elif defined( USE_COLOR )
1459
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1460
- #endif
1461
- }
1462
- #endif`,Zl=`#ifdef USE_MORPHNORMALS
1463
- objectNormal *= morphTargetBaseInfluence;
1464
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1465
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1466
- }
1467
- #endif`,jl=`#ifdef USE_MORPHTARGETS
1468
- #ifndef USE_INSTANCING_MORPH
1469
- uniform float morphTargetBaseInfluence;
1470
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1471
- #endif
1472
- uniform sampler2DArray morphTargetsTexture;
1473
- uniform ivec2 morphTargetsTextureSize;
1474
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1475
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1476
- int y = texelIndex / morphTargetsTextureSize.x;
1477
- int x = texelIndex - y * morphTargetsTextureSize.x;
1478
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1479
- return texelFetch( morphTargetsTexture, morphUV, 0 );
1480
- }
1481
- #endif`,Jl=`#ifdef USE_MORPHTARGETS
1482
- transformed *= morphTargetBaseInfluence;
1483
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1484
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1485
- }
1486
- #endif`,Ql=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1487
- #ifdef FLAT_SHADED
1488
- vec3 fdx = dFdx( vViewPosition );
1489
- vec3 fdy = dFdy( vViewPosition );
1490
- vec3 normal = normalize( cross( fdx, fdy ) );
1491
- #else
1492
- vec3 normal = normalize( vNormal );
1493
- #ifdef DOUBLE_SIDED
1494
- normal *= faceDirection;
1495
- #endif
1496
- #endif
1497
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1498
- #ifdef USE_TANGENT
1499
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1500
- #else
1501
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
1502
- #if defined( USE_NORMALMAP )
1503
- vNormalMapUv
1504
- #elif defined( USE_CLEARCOAT_NORMALMAP )
1505
- vClearcoatNormalMapUv
1506
- #else
1507
- vUv
1508
- #endif
1509
- );
1510
- #endif
1511
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1512
- tbn[0] *= faceDirection;
1513
- tbn[1] *= faceDirection;
1514
- #endif
1515
- #endif
1516
- #ifdef USE_CLEARCOAT_NORMALMAP
1517
- #ifdef USE_TANGENT
1518
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1519
- #else
1520
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1521
- #endif
1522
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1523
- tbn2[0] *= faceDirection;
1524
- tbn2[1] *= faceDirection;
1525
- #endif
1526
- #endif
1527
- vec3 nonPerturbedNormal = normal;`,ec=`#ifdef USE_NORMALMAP_OBJECTSPACE
1528
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1529
- #ifdef FLIP_SIDED
1530
- normal = - normal;
1531
- #endif
1532
- #ifdef DOUBLE_SIDED
1533
- normal = normal * faceDirection;
1534
- #endif
1535
- normal = normalize( normalMatrix * normal );
1536
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
1537
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1538
- mapN.xy *= normalScale;
1539
- normal = normalize( tbn * mapN );
1540
- #elif defined( USE_BUMPMAP )
1541
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1542
- #endif`,tc=`#ifndef FLAT_SHADED
1543
- varying vec3 vNormal;
1544
- #ifdef USE_TANGENT
1545
- varying vec3 vTangent;
1546
- varying vec3 vBitangent;
1547
- #endif
1548
- #endif`,nc=`#ifndef FLAT_SHADED
1549
- varying vec3 vNormal;
1550
- #ifdef USE_TANGENT
1551
- varying vec3 vTangent;
1552
- varying vec3 vBitangent;
1553
- #endif
1554
- #endif`,ic=`#ifndef FLAT_SHADED
1555
- vNormal = normalize( transformedNormal );
1556
- #ifdef USE_TANGENT
1557
- vTangent = normalize( transformedTangent );
1558
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1559
- #endif
1560
- #endif`,rc=`#ifdef USE_NORMALMAP
1561
- uniform sampler2D normalMap;
1562
- uniform vec2 normalScale;
1563
- #endif
1564
- #ifdef USE_NORMALMAP_OBJECTSPACE
1565
- uniform mat3 normalMatrix;
1566
- #endif
1567
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1568
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1569
- vec3 q0 = dFdx( eye_pos.xyz );
1570
- vec3 q1 = dFdy( eye_pos.xyz );
1571
- vec2 st0 = dFdx( uv.st );
1572
- vec2 st1 = dFdy( uv.st );
1573
- vec3 N = surf_norm;
1574
- vec3 q1perp = cross( q1, N );
1575
- vec3 q0perp = cross( N, q0 );
1576
- vec3 T = q1perp * st0.x + q0perp * st1.x;
1577
- vec3 B = q1perp * st0.y + q0perp * st1.y;
1578
- float det = max( dot( T, T ), dot( B, B ) );
1579
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1580
- return mat3( T * scale, B * scale, N );
1581
- }
1582
- #endif`,sc=`#ifdef USE_CLEARCOAT
1583
- vec3 clearcoatNormal = nonPerturbedNormal;
1584
- #endif`,ac=`#ifdef USE_CLEARCOAT_NORMALMAP
1585
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1586
- clearcoatMapN.xy *= clearcoatNormalScale;
1587
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1588
- #endif`,oc=`#ifdef USE_CLEARCOATMAP
1589
- uniform sampler2D clearcoatMap;
1590
- #endif
1591
- #ifdef USE_CLEARCOAT_NORMALMAP
1592
- uniform sampler2D clearcoatNormalMap;
1593
- uniform vec2 clearcoatNormalScale;
1594
- #endif
1595
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1596
- uniform sampler2D clearcoatRoughnessMap;
1597
- #endif`,lc=`#ifdef USE_IRIDESCENCEMAP
1598
- uniform sampler2D iridescenceMap;
1599
- #endif
1600
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
1601
- uniform sampler2D iridescenceThicknessMap;
1602
- #endif`,cc=`#ifdef OPAQUE
1603
- diffuseColor.a = 1.0;
1604
- #endif
1605
- #ifdef USE_TRANSMISSION
1606
- diffuseColor.a *= material.transmissionAlpha;
1607
- #endif
1608
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,hc=`vec3 packNormalToRGB( const in vec3 normal ) {
1609
- return normalize( normal ) * 0.5 + 0.5;
1610
- }
1611
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
1612
- return 2.0 * rgb.xyz - 1.0;
1613
- }
1614
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1615
- const float Inv255 = 1. / 255.;
1616
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1617
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1618
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1619
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1620
- vec4 packDepthToRGBA( const in float v ) {
1621
- if( v <= 0.0 )
1622
- return vec4( 0., 0., 0., 0. );
1623
- if( v >= 1.0 )
1624
- return vec4( 1., 1., 1., 1. );
1625
- float vuf;
1626
- float af = modf( v * PackFactors.a, vuf );
1627
- float bf = modf( vuf * ShiftRight8, vuf );
1628
- float gf = modf( vuf * ShiftRight8, vuf );
1629
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1630
- }
1631
- vec3 packDepthToRGB( const in float v ) {
1632
- if( v <= 0.0 )
1633
- return vec3( 0., 0., 0. );
1634
- if( v >= 1.0 )
1635
- return vec3( 1., 1., 1. );
1636
- float vuf;
1637
- float bf = modf( v * PackFactors.b, vuf );
1638
- float gf = modf( vuf * ShiftRight8, vuf );
1639
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
1640
- }
1641
- vec2 packDepthToRG( const in float v ) {
1642
- if( v <= 0.0 )
1643
- return vec2( 0., 0. );
1644
- if( v >= 1.0 )
1645
- return vec2( 1., 1. );
1646
- float vuf;
1647
- float gf = modf( v * 256., vuf );
1648
- return vec2( vuf * Inv255, gf );
1649
- }
1650
- float unpackRGBAToDepth( const in vec4 v ) {
1651
- return dot( v, UnpackFactors4 );
1652
- }
1653
- float unpackRGBToDepth( const in vec3 v ) {
1654
- return dot( v, UnpackFactors3 );
1655
- }
1656
- float unpackRGToDepth( const in vec2 v ) {
1657
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1658
- }
1659
- vec4 pack2HalfToRGBA( const in vec2 v ) {
1660
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1661
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1662
- }
1663
- vec2 unpackRGBATo2Half( const in vec4 v ) {
1664
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1665
- }
1666
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1667
- return ( viewZ + near ) / ( near - far );
1668
- }
1669
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1670
- return depth * ( near - far ) - near;
1671
- }
1672
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1673
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1674
- }
1675
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1676
- return ( near * far ) / ( ( far - near ) * depth - far );
1677
- }`,uc=`#ifdef PREMULTIPLIED_ALPHA
1678
- gl_FragColor.rgb *= gl_FragColor.a;
1679
- #endif`,dc=`vec4 mvPosition = vec4( transformed, 1.0 );
1680
- #ifdef USE_BATCHING
1681
- mvPosition = batchingMatrix * mvPosition;
1682
- #endif
1683
- #ifdef USE_INSTANCING
1684
- mvPosition = instanceMatrix * mvPosition;
1685
- #endif
1686
- mvPosition = modelViewMatrix * mvPosition;
1687
- gl_Position = projectionMatrix * mvPosition;`,fc=`#ifdef DITHERING
1688
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1689
- #endif`,pc=`#ifdef DITHERING
1690
- vec3 dithering( vec3 color ) {
1691
- float grid_position = rand( gl_FragCoord.xy );
1692
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1693
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1694
- return color + dither_shift_RGB;
1695
- }
1696
- #endif`,mc=`float roughnessFactor = roughness;
1697
- #ifdef USE_ROUGHNESSMAP
1698
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1699
- roughnessFactor *= texelRoughness.g;
1700
- #endif`,_c=`#ifdef USE_ROUGHNESSMAP
1701
- uniform sampler2D roughnessMap;
1702
- #endif`,gc=`#if NUM_SPOT_LIGHT_COORDS > 0
1703
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1704
- #endif
1705
- #if NUM_SPOT_LIGHT_MAPS > 0
1706
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1707
- #endif
1708
- #ifdef USE_SHADOWMAP
1709
- #if NUM_DIR_LIGHT_SHADOWS > 0
1710
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1711
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1712
- struct DirectionalLightShadow {
1713
- float shadowIntensity;
1714
- float shadowBias;
1715
- float shadowNormalBias;
1716
- float shadowRadius;
1717
- vec2 shadowMapSize;
1718
- };
1719
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1720
- #endif
1721
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1722
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1723
- struct SpotLightShadow {
1724
- float shadowIntensity;
1725
- float shadowBias;
1726
- float shadowNormalBias;
1727
- float shadowRadius;
1728
- vec2 shadowMapSize;
1729
- };
1730
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1731
- #endif
1732
- #if NUM_POINT_LIGHT_SHADOWS > 0
1733
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1734
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1735
- struct PointLightShadow {
1736
- float shadowIntensity;
1737
- float shadowBias;
1738
- float shadowNormalBias;
1739
- float shadowRadius;
1740
- vec2 shadowMapSize;
1741
- float shadowCameraNear;
1742
- float shadowCameraFar;
1743
- };
1744
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1745
- #endif
1746
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1747
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1748
- }
1749
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1750
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
1751
- }
1752
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1753
- float occlusion = 1.0;
1754
- vec2 distribution = texture2DDistribution( shadow, uv );
1755
- float hard_shadow = step( compare , distribution.x );
1756
- if (hard_shadow != 1.0 ) {
1757
- float distance = compare - distribution.x ;
1758
- float variance = max( 0.00000, distribution.y * distribution.y );
1759
- 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 );
1760
- }
1761
- return occlusion;
1762
- }
1763
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1764
- float shadow = 1.0;
1765
- shadowCoord.xyz /= shadowCoord.w;
1766
- shadowCoord.z += shadowBias;
1767
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1768
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1769
- if ( frustumTest ) {
1770
- #if defined( SHADOWMAP_TYPE_PCF )
1771
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1772
- float dx0 = - texelSize.x * shadowRadius;
1773
- float dy0 = - texelSize.y * shadowRadius;
1774
- float dx1 = + texelSize.x * shadowRadius;
1775
- float dy1 = + texelSize.y * shadowRadius;
1776
- float dx2 = dx0 / 2.0;
1777
- float dy2 = dy0 / 2.0;
1778
- float dx3 = dx1 / 2.0;
1779
- float dy3 = dy1 / 2.0;
1780
- shadow = (
1781
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1782
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1783
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1784
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1785
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1786
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1787
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1788
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1789
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1790
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1791
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1792
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1793
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1794
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1795
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1796
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1797
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1798
- ) * ( 1.0 / 17.0 );
1799
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1800
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1801
- float dx = texelSize.x;
1802
- float dy = texelSize.y;
1803
- vec2 uv = shadowCoord.xy;
1804
- vec2 f = fract( uv * shadowMapSize + 0.5 );
1805
- uv -= f * texelSize;
1806
- shadow = (
1807
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1808
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1809
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1810
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1811
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1812
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1813
- f.x ) +
1814
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1815
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1816
- f.x ) +
1817
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1818
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1819
- f.y ) +
1820
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1821
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1822
- f.y ) +
1823
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1824
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1825
- f.x ),
1826
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1827
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1828
- f.x ),
1829
- f.y )
1830
- ) * ( 1.0 / 9.0 );
1831
- #elif defined( SHADOWMAP_TYPE_VSM )
1832
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1833
- #else
1834
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1835
- #endif
1836
- }
1837
- return mix( 1.0, shadow, shadowIntensity );
1838
- }
1839
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
1840
- vec3 absV = abs( v );
1841
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1842
- absV *= scaleToCube;
1843
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1844
- vec2 planar = v.xy;
1845
- float almostATexel = 1.5 * texelSizeY;
1846
- float almostOne = 1.0 - almostATexel;
1847
- if ( absV.z >= almostOne ) {
1848
- if ( v.z > 0.0 )
1849
- planar.x = 4.0 - v.x;
1850
- } else if ( absV.x >= almostOne ) {
1851
- float signX = sign( v.x );
1852
- planar.x = v.z * signX + 2.0 * signX;
1853
- } else if ( absV.y >= almostOne ) {
1854
- float signY = sign( v.y );
1855
- planar.x = v.x + 2.0 * signY + 2.0;
1856
- planar.y = v.z * signY - 2.0;
1857
- }
1858
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1859
- }
1860
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1861
- float shadow = 1.0;
1862
- vec3 lightToPosition = shadowCoord.xyz;
1863
-
1864
- float lightToPositionLength = length( lightToPosition );
1865
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1866
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1867
- vec3 bd3D = normalize( lightToPosition );
1868
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1869
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1870
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1871
- shadow = (
1872
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1873
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1874
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1875
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1876
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1877
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1878
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1879
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1880
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1881
- ) * ( 1.0 / 9.0 );
1882
- #else
1883
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1884
- #endif
1885
- }
1886
- return mix( 1.0, shadow, shadowIntensity );
1887
- }
1888
- #endif`,vc=`#if NUM_SPOT_LIGHT_COORDS > 0
1889
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1890
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1891
- #endif
1892
- #ifdef USE_SHADOWMAP
1893
- #if NUM_DIR_LIGHT_SHADOWS > 0
1894
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1895
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1896
- struct DirectionalLightShadow {
1897
- float shadowIntensity;
1898
- float shadowBias;
1899
- float shadowNormalBias;
1900
- float shadowRadius;
1901
- vec2 shadowMapSize;
1902
- };
1903
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1904
- #endif
1905
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1906
- struct SpotLightShadow {
1907
- float shadowIntensity;
1908
- float shadowBias;
1909
- float shadowNormalBias;
1910
- float shadowRadius;
1911
- vec2 shadowMapSize;
1912
- };
1913
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1914
- #endif
1915
- #if NUM_POINT_LIGHT_SHADOWS > 0
1916
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1917
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1918
- struct PointLightShadow {
1919
- float shadowIntensity;
1920
- float shadowBias;
1921
- float shadowNormalBias;
1922
- float shadowRadius;
1923
- vec2 shadowMapSize;
1924
- float shadowCameraNear;
1925
- float shadowCameraFar;
1926
- };
1927
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1928
- #endif
1929
- #endif`,xc=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1930
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1931
- vec4 shadowWorldPosition;
1932
- #endif
1933
- #if defined( USE_SHADOWMAP )
1934
- #if NUM_DIR_LIGHT_SHADOWS > 0
1935
- #pragma unroll_loop_start
1936
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1937
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1938
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1939
- }
1940
- #pragma unroll_loop_end
1941
- #endif
1942
- #if NUM_POINT_LIGHT_SHADOWS > 0
1943
- #pragma unroll_loop_start
1944
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1945
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1946
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1947
- }
1948
- #pragma unroll_loop_end
1949
- #endif
1950
- #endif
1951
- #if NUM_SPOT_LIGHT_COORDS > 0
1952
- #pragma unroll_loop_start
1953
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1954
- shadowWorldPosition = worldPosition;
1955
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1956
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1957
- #endif
1958
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1959
- }
1960
- #pragma unroll_loop_end
1961
- #endif`,Mc=`float getShadowMask() {
1962
- float shadow = 1.0;
1963
- #ifdef USE_SHADOWMAP
1964
- #if NUM_DIR_LIGHT_SHADOWS > 0
1965
- DirectionalLightShadow directionalLight;
1966
- #pragma unroll_loop_start
1967
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1968
- directionalLight = directionalLightShadows[ i ];
1969
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1970
- }
1971
- #pragma unroll_loop_end
1972
- #endif
1973
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1974
- SpotLightShadow spotLight;
1975
- #pragma unroll_loop_start
1976
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1977
- spotLight = spotLightShadows[ i ];
1978
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1979
- }
1980
- #pragma unroll_loop_end
1981
- #endif
1982
- #if NUM_POINT_LIGHT_SHADOWS > 0
1983
- PointLightShadow pointLight;
1984
- #pragma unroll_loop_start
1985
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1986
- pointLight = pointLightShadows[ i ];
1987
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1988
- }
1989
- #pragma unroll_loop_end
1990
- #endif
1991
- #endif
1992
- return shadow;
1993
- }`,Sc=`#ifdef USE_SKINNING
1994
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
1995
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
1996
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1997
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
1998
- #endif`,yc=`#ifdef USE_SKINNING
1999
- uniform mat4 bindMatrix;
2000
- uniform mat4 bindMatrixInverse;
2001
- uniform highp sampler2D boneTexture;
2002
- mat4 getBoneMatrix( const in float i ) {
2003
- int size = textureSize( boneTexture, 0 ).x;
2004
- int j = int( i ) * 4;
2005
- int x = j % size;
2006
- int y = j / size;
2007
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2008
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2009
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2010
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2011
- return mat4( v1, v2, v3, v4 );
2012
- }
2013
- #endif`,Ec=`#ifdef USE_SKINNING
2014
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2015
- vec4 skinned = vec4( 0.0 );
2016
- skinned += boneMatX * skinVertex * skinWeight.x;
2017
- skinned += boneMatY * skinVertex * skinWeight.y;
2018
- skinned += boneMatZ * skinVertex * skinWeight.z;
2019
- skinned += boneMatW * skinVertex * skinWeight.w;
2020
- transformed = ( bindMatrixInverse * skinned ).xyz;
2021
- #endif`,Tc=`#ifdef USE_SKINNING
2022
- mat4 skinMatrix = mat4( 0.0 );
2023
- skinMatrix += skinWeight.x * boneMatX;
2024
- skinMatrix += skinWeight.y * boneMatY;
2025
- skinMatrix += skinWeight.z * boneMatZ;
2026
- skinMatrix += skinWeight.w * boneMatW;
2027
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2028
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2029
- #ifdef USE_TANGENT
2030
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2031
- #endif
2032
- #endif`,Ac=`float specularStrength;
2033
- #ifdef USE_SPECULARMAP
2034
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2035
- specularStrength = texelSpecular.r;
2036
- #else
2037
- specularStrength = 1.0;
2038
- #endif`,bc=`#ifdef USE_SPECULARMAP
2039
- uniform sampler2D specularMap;
2040
- #endif`,Rc=`#if defined( TONE_MAPPING )
2041
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2042
- #endif`,wc=`#ifndef saturate
2043
- #define saturate( a ) clamp( a, 0.0, 1.0 )
2044
- #endif
2045
- uniform float toneMappingExposure;
2046
- vec3 LinearToneMapping( vec3 color ) {
2047
- return saturate( toneMappingExposure * color );
2048
- }
2049
- vec3 ReinhardToneMapping( vec3 color ) {
2050
- color *= toneMappingExposure;
2051
- return saturate( color / ( vec3( 1.0 ) + color ) );
2052
- }
2053
- vec3 OptimizedCineonToneMapping( vec3 color ) {
2054
- color *= toneMappingExposure;
2055
- color = max( vec3( 0.0 ), color - 0.004 );
2056
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2057
- }
2058
- vec3 RRTAndODTFit( vec3 v ) {
2059
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2060
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2061
- return a / b;
2062
- }
2063
- vec3 ACESFilmicToneMapping( vec3 color ) {
2064
- const mat3 ACESInputMat = mat3(
2065
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2066
- vec3( 0.04823, 0.01566, 0.83777 )
2067
- );
2068
- const mat3 ACESOutputMat = mat3(
2069
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2070
- vec3( -0.07367, -0.00605, 1.07602 )
2071
- );
2072
- color *= toneMappingExposure / 0.6;
2073
- color = ACESInputMat * color;
2074
- color = RRTAndODTFit( color );
2075
- color = ACESOutputMat * color;
2076
- return saturate( color );
2077
- }
2078
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2079
- vec3( 1.6605, - 0.1246, - 0.0182 ),
2080
- vec3( - 0.5876, 1.1329, - 0.1006 ),
2081
- vec3( - 0.0728, - 0.0083, 1.1187 )
2082
- );
2083
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2084
- vec3( 0.6274, 0.0691, 0.0164 ),
2085
- vec3( 0.3293, 0.9195, 0.0880 ),
2086
- vec3( 0.0433, 0.0113, 0.8956 )
2087
- );
2088
- vec3 agxDefaultContrastApprox( vec3 x ) {
2089
- vec3 x2 = x * x;
2090
- vec3 x4 = x2 * x2;
2091
- return + 15.5 * x4 * x2
2092
- - 40.14 * x4 * x
2093
- + 31.96 * x4
2094
- - 6.868 * x2 * x
2095
- + 0.4298 * x2
2096
- + 0.1191 * x
2097
- - 0.00232;
2098
- }
2099
- vec3 AgXToneMapping( vec3 color ) {
2100
- const mat3 AgXInsetMatrix = mat3(
2101
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2102
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2103
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2104
- );
2105
- const mat3 AgXOutsetMatrix = mat3(
2106
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2107
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2108
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2109
- );
2110
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2111
- color *= toneMappingExposure;
2112
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2113
- color = AgXInsetMatrix * color;
2114
- color = max( color, 1e-10 ); color = log2( color );
2115
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2116
- color = clamp( color, 0.0, 1.0 );
2117
- color = agxDefaultContrastApprox( color );
2118
- color = AgXOutsetMatrix * color;
2119
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2120
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2121
- color = clamp( color, 0.0, 1.0 );
2122
- return color;
2123
- }
2124
- vec3 NeutralToneMapping( vec3 color ) {
2125
- const float StartCompression = 0.8 - 0.04;
2126
- const float Desaturation = 0.15;
2127
- color *= toneMappingExposure;
2128
- float x = min( color.r, min( color.g, color.b ) );
2129
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2130
- color -= offset;
2131
- float peak = max( color.r, max( color.g, color.b ) );
2132
- if ( peak < StartCompression ) return color;
2133
- float d = 1. - StartCompression;
2134
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
2135
- color *= newPeak / peak;
2136
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2137
- return mix( color, vec3( newPeak ), g );
2138
- }
2139
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Cc=`#ifdef USE_TRANSMISSION
2140
- material.transmission = transmission;
2141
- material.transmissionAlpha = 1.0;
2142
- material.thickness = thickness;
2143
- material.attenuationDistance = attenuationDistance;
2144
- material.attenuationColor = attenuationColor;
2145
- #ifdef USE_TRANSMISSIONMAP
2146
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2147
- #endif
2148
- #ifdef USE_THICKNESSMAP
2149
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2150
- #endif
2151
- vec3 pos = vWorldPosition;
2152
- vec3 v = normalize( cameraPosition - pos );
2153
- vec3 n = inverseTransformDirection( normal, viewMatrix );
2154
- vec4 transmitted = getIBLVolumeRefraction(
2155
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2156
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2157
- material.attenuationColor, material.attenuationDistance );
2158
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2159
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2160
- #endif`,Pc=`#ifdef USE_TRANSMISSION
2161
- uniform float transmission;
2162
- uniform float thickness;
2163
- uniform float attenuationDistance;
2164
- uniform vec3 attenuationColor;
2165
- #ifdef USE_TRANSMISSIONMAP
2166
- uniform sampler2D transmissionMap;
2167
- #endif
2168
- #ifdef USE_THICKNESSMAP
2169
- uniform sampler2D thicknessMap;
2170
- #endif
2171
- uniform vec2 transmissionSamplerSize;
2172
- uniform sampler2D transmissionSamplerMap;
2173
- uniform mat4 modelMatrix;
2174
- uniform mat4 projectionMatrix;
2175
- varying vec3 vWorldPosition;
2176
- float w0( float a ) {
2177
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2178
- }
2179
- float w1( float a ) {
2180
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2181
- }
2182
- float w2( float a ){
2183
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2184
- }
2185
- float w3( float a ) {
2186
- return ( 1.0 / 6.0 ) * ( a * a * a );
2187
- }
2188
- float g0( float a ) {
2189
- return w0( a ) + w1( a );
2190
- }
2191
- float g1( float a ) {
2192
- return w2( a ) + w3( a );
2193
- }
2194
- float h0( float a ) {
2195
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2196
- }
2197
- float h1( float a ) {
2198
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2199
- }
2200
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2201
- uv = uv * texelSize.zw + 0.5;
2202
- vec2 iuv = floor( uv );
2203
- vec2 fuv = fract( uv );
2204
- float g0x = g0( fuv.x );
2205
- float g1x = g1( fuv.x );
2206
- float h0x = h0( fuv.x );
2207
- float h1x = h1( fuv.x );
2208
- float h0y = h0( fuv.y );
2209
- float h1y = h1( fuv.y );
2210
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2211
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2212
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2213
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2214
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2215
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2216
- }
2217
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2218
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2219
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2220
- vec2 fLodSizeInv = 1.0 / fLodSize;
2221
- vec2 cLodSizeInv = 1.0 / cLodSize;
2222
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2223
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2224
- return mix( fSample, cSample, fract( lod ) );
2225
- }
2226
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2227
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2228
- vec3 modelScale;
2229
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2230
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2231
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2232
- return normalize( refractionVector ) * thickness * modelScale;
2233
- }
2234
- float applyIorToRoughness( const in float roughness, const in float ior ) {
2235
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2236
- }
2237
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2238
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2239
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2240
- }
2241
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2242
- if ( isinf( attenuationDistance ) ) {
2243
- return vec3( 1.0 );
2244
- } else {
2245
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2246
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2247
- }
2248
- }
2249
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2250
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2251
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2252
- const in vec3 attenuationColor, const in float attenuationDistance ) {
2253
- vec4 transmittedLight;
2254
- vec3 transmittance;
2255
- #ifdef USE_DISPERSION
2256
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2257
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2258
- for ( int i = 0; i < 3; i ++ ) {
2259
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2260
- vec3 refractedRayExit = position + transmissionRay;
2261
-
2262
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2263
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2264
- refractionCoords += 1.0;
2265
- refractionCoords /= 2.0;
2266
-
2267
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2268
- transmittedLight[ i ] = transmissionSample[ i ];
2269
- transmittedLight.a += transmissionSample.a;
2270
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2271
- }
2272
- transmittedLight.a /= 3.0;
2273
-
2274
- #else
2275
-
2276
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2277
- vec3 refractedRayExit = position + transmissionRay;
2278
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2279
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2280
- refractionCoords += 1.0;
2281
- refractionCoords /= 2.0;
2282
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2283
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2284
-
2285
- #endif
2286
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2287
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2288
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2289
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2290
- }
2291
- #endif`,Lc=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2292
- varying vec2 vUv;
2293
- #endif
2294
- #ifdef USE_MAP
2295
- varying vec2 vMapUv;
2296
- #endif
2297
- #ifdef USE_ALPHAMAP
2298
- varying vec2 vAlphaMapUv;
2299
- #endif
2300
- #ifdef USE_LIGHTMAP
2301
- varying vec2 vLightMapUv;
2302
- #endif
2303
- #ifdef USE_AOMAP
2304
- varying vec2 vAoMapUv;
2305
- #endif
2306
- #ifdef USE_BUMPMAP
2307
- varying vec2 vBumpMapUv;
2308
- #endif
2309
- #ifdef USE_NORMALMAP
2310
- varying vec2 vNormalMapUv;
2311
- #endif
2312
- #ifdef USE_EMISSIVEMAP
2313
- varying vec2 vEmissiveMapUv;
2314
- #endif
2315
- #ifdef USE_METALNESSMAP
2316
- varying vec2 vMetalnessMapUv;
2317
- #endif
2318
- #ifdef USE_ROUGHNESSMAP
2319
- varying vec2 vRoughnessMapUv;
2320
- #endif
2321
- #ifdef USE_ANISOTROPYMAP
2322
- varying vec2 vAnisotropyMapUv;
2323
- #endif
2324
- #ifdef USE_CLEARCOATMAP
2325
- varying vec2 vClearcoatMapUv;
2326
- #endif
2327
- #ifdef USE_CLEARCOAT_NORMALMAP
2328
- varying vec2 vClearcoatNormalMapUv;
2329
- #endif
2330
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2331
- varying vec2 vClearcoatRoughnessMapUv;
2332
- #endif
2333
- #ifdef USE_IRIDESCENCEMAP
2334
- varying vec2 vIridescenceMapUv;
2335
- #endif
2336
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2337
- varying vec2 vIridescenceThicknessMapUv;
2338
- #endif
2339
- #ifdef USE_SHEEN_COLORMAP
2340
- varying vec2 vSheenColorMapUv;
2341
- #endif
2342
- #ifdef USE_SHEEN_ROUGHNESSMAP
2343
- varying vec2 vSheenRoughnessMapUv;
2344
- #endif
2345
- #ifdef USE_SPECULARMAP
2346
- varying vec2 vSpecularMapUv;
2347
- #endif
2348
- #ifdef USE_SPECULAR_COLORMAP
2349
- varying vec2 vSpecularColorMapUv;
2350
- #endif
2351
- #ifdef USE_SPECULAR_INTENSITYMAP
2352
- varying vec2 vSpecularIntensityMapUv;
2353
- #endif
2354
- #ifdef USE_TRANSMISSIONMAP
2355
- uniform mat3 transmissionMapTransform;
2356
- varying vec2 vTransmissionMapUv;
2357
- #endif
2358
- #ifdef USE_THICKNESSMAP
2359
- uniform mat3 thicknessMapTransform;
2360
- varying vec2 vThicknessMapUv;
2361
- #endif`,Dc=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2362
- varying vec2 vUv;
2363
- #endif
2364
- #ifdef USE_MAP
2365
- uniform mat3 mapTransform;
2366
- varying vec2 vMapUv;
2367
- #endif
2368
- #ifdef USE_ALPHAMAP
2369
- uniform mat3 alphaMapTransform;
2370
- varying vec2 vAlphaMapUv;
2371
- #endif
2372
- #ifdef USE_LIGHTMAP
2373
- uniform mat3 lightMapTransform;
2374
- varying vec2 vLightMapUv;
2375
- #endif
2376
- #ifdef USE_AOMAP
2377
- uniform mat3 aoMapTransform;
2378
- varying vec2 vAoMapUv;
2379
- #endif
2380
- #ifdef USE_BUMPMAP
2381
- uniform mat3 bumpMapTransform;
2382
- varying vec2 vBumpMapUv;
2383
- #endif
2384
- #ifdef USE_NORMALMAP
2385
- uniform mat3 normalMapTransform;
2386
- varying vec2 vNormalMapUv;
2387
- #endif
2388
- #ifdef USE_DISPLACEMENTMAP
2389
- uniform mat3 displacementMapTransform;
2390
- varying vec2 vDisplacementMapUv;
2391
- #endif
2392
- #ifdef USE_EMISSIVEMAP
2393
- uniform mat3 emissiveMapTransform;
2394
- varying vec2 vEmissiveMapUv;
2395
- #endif
2396
- #ifdef USE_METALNESSMAP
2397
- uniform mat3 metalnessMapTransform;
2398
- varying vec2 vMetalnessMapUv;
2399
- #endif
2400
- #ifdef USE_ROUGHNESSMAP
2401
- uniform mat3 roughnessMapTransform;
2402
- varying vec2 vRoughnessMapUv;
2403
- #endif
2404
- #ifdef USE_ANISOTROPYMAP
2405
- uniform mat3 anisotropyMapTransform;
2406
- varying vec2 vAnisotropyMapUv;
2407
- #endif
2408
- #ifdef USE_CLEARCOATMAP
2409
- uniform mat3 clearcoatMapTransform;
2410
- varying vec2 vClearcoatMapUv;
2411
- #endif
2412
- #ifdef USE_CLEARCOAT_NORMALMAP
2413
- uniform mat3 clearcoatNormalMapTransform;
2414
- varying vec2 vClearcoatNormalMapUv;
2415
- #endif
2416
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2417
- uniform mat3 clearcoatRoughnessMapTransform;
2418
- varying vec2 vClearcoatRoughnessMapUv;
2419
- #endif
2420
- #ifdef USE_SHEEN_COLORMAP
2421
- uniform mat3 sheenColorMapTransform;
2422
- varying vec2 vSheenColorMapUv;
2423
- #endif
2424
- #ifdef USE_SHEEN_ROUGHNESSMAP
2425
- uniform mat3 sheenRoughnessMapTransform;
2426
- varying vec2 vSheenRoughnessMapUv;
2427
- #endif
2428
- #ifdef USE_IRIDESCENCEMAP
2429
- uniform mat3 iridescenceMapTransform;
2430
- varying vec2 vIridescenceMapUv;
2431
- #endif
2432
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2433
- uniform mat3 iridescenceThicknessMapTransform;
2434
- varying vec2 vIridescenceThicknessMapUv;
2435
- #endif
2436
- #ifdef USE_SPECULARMAP
2437
- uniform mat3 specularMapTransform;
2438
- varying vec2 vSpecularMapUv;
2439
- #endif
2440
- #ifdef USE_SPECULAR_COLORMAP
2441
- uniform mat3 specularColorMapTransform;
2442
- varying vec2 vSpecularColorMapUv;
2443
- #endif
2444
- #ifdef USE_SPECULAR_INTENSITYMAP
2445
- uniform mat3 specularIntensityMapTransform;
2446
- varying vec2 vSpecularIntensityMapUv;
2447
- #endif
2448
- #ifdef USE_TRANSMISSIONMAP
2449
- uniform mat3 transmissionMapTransform;
2450
- varying vec2 vTransmissionMapUv;
2451
- #endif
2452
- #ifdef USE_THICKNESSMAP
2453
- uniform mat3 thicknessMapTransform;
2454
- varying vec2 vThicknessMapUv;
2455
- #endif`,Ic=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2456
- vUv = vec3( uv, 1 ).xy;
2457
- #endif
2458
- #ifdef USE_MAP
2459
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2460
- #endif
2461
- #ifdef USE_ALPHAMAP
2462
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2463
- #endif
2464
- #ifdef USE_LIGHTMAP
2465
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2466
- #endif
2467
- #ifdef USE_AOMAP
2468
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2469
- #endif
2470
- #ifdef USE_BUMPMAP
2471
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2472
- #endif
2473
- #ifdef USE_NORMALMAP
2474
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2475
- #endif
2476
- #ifdef USE_DISPLACEMENTMAP
2477
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2478
- #endif
2479
- #ifdef USE_EMISSIVEMAP
2480
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2481
- #endif
2482
- #ifdef USE_METALNESSMAP
2483
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2484
- #endif
2485
- #ifdef USE_ROUGHNESSMAP
2486
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2487
- #endif
2488
- #ifdef USE_ANISOTROPYMAP
2489
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2490
- #endif
2491
- #ifdef USE_CLEARCOATMAP
2492
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2493
- #endif
2494
- #ifdef USE_CLEARCOAT_NORMALMAP
2495
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2496
- #endif
2497
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2498
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2499
- #endif
2500
- #ifdef USE_IRIDESCENCEMAP
2501
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2502
- #endif
2503
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2504
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2505
- #endif
2506
- #ifdef USE_SHEEN_COLORMAP
2507
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2508
- #endif
2509
- #ifdef USE_SHEEN_ROUGHNESSMAP
2510
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2511
- #endif
2512
- #ifdef USE_SPECULARMAP
2513
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2514
- #endif
2515
- #ifdef USE_SPECULAR_COLORMAP
2516
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2517
- #endif
2518
- #ifdef USE_SPECULAR_INTENSITYMAP
2519
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2520
- #endif
2521
- #ifdef USE_TRANSMISSIONMAP
2522
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2523
- #endif
2524
- #ifdef USE_THICKNESSMAP
2525
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2526
- #endif`,Uc=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2527
- vec4 worldPosition = vec4( transformed, 1.0 );
2528
- #ifdef USE_BATCHING
2529
- worldPosition = batchingMatrix * worldPosition;
2530
- #endif
2531
- #ifdef USE_INSTANCING
2532
- worldPosition = instanceMatrix * worldPosition;
2533
- #endif
2534
- worldPosition = modelMatrix * worldPosition;
2535
- #endif`;const Nc=`varying vec2 vUv;
2536
- uniform mat3 uvTransform;
2537
- void main() {
2538
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2539
- gl_Position = vec4( position.xy, 1.0, 1.0 );
2540
- }`,Fc=`uniform sampler2D t2D;
2541
- uniform float backgroundIntensity;
2542
- varying vec2 vUv;
2543
- void main() {
2544
- vec4 texColor = texture2D( t2D, vUv );
2545
- #ifdef DECODE_VIDEO_TEXTURE
2546
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
2547
- #endif
2548
- texColor.rgb *= backgroundIntensity;
2549
- gl_FragColor = texColor;
2550
- #include <tonemapping_fragment>
2551
- #include <colorspace_fragment>
2552
- }`,Bc=`varying vec3 vWorldDirection;
2553
- #include <common>
2554
- void main() {
2555
- vWorldDirection = transformDirection( position, modelMatrix );
2556
- #include <begin_vertex>
2557
- #include <project_vertex>
2558
- gl_Position.z = gl_Position.w;
2559
- }`,Oc=`#ifdef ENVMAP_TYPE_CUBE
2560
- uniform samplerCube envMap;
2561
- #elif defined( ENVMAP_TYPE_CUBE_UV )
2562
- uniform sampler2D envMap;
2563
- #endif
2564
- uniform float flipEnvMap;
2565
- uniform float backgroundBlurriness;
2566
- uniform float backgroundIntensity;
2567
- uniform mat3 backgroundRotation;
2568
- varying vec3 vWorldDirection;
2569
- #include <cube_uv_reflection_fragment>
2570
- void main() {
2571
- #ifdef ENVMAP_TYPE_CUBE
2572
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2573
- #elif defined( ENVMAP_TYPE_CUBE_UV )
2574
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2575
- #else
2576
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2577
- #endif
2578
- texColor.rgb *= backgroundIntensity;
2579
- gl_FragColor = texColor;
2580
- #include <tonemapping_fragment>
2581
- #include <colorspace_fragment>
2582
- }`,Gc=`varying vec3 vWorldDirection;
2583
- #include <common>
2584
- void main() {
2585
- vWorldDirection = transformDirection( position, modelMatrix );
2586
- #include <begin_vertex>
2587
- #include <project_vertex>
2588
- gl_Position.z = gl_Position.w;
2589
- }`,zc=`uniform samplerCube tCube;
2590
- uniform float tFlip;
2591
- uniform float opacity;
2592
- varying vec3 vWorldDirection;
2593
- void main() {
2594
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2595
- gl_FragColor = texColor;
2596
- gl_FragColor.a *= opacity;
2597
- #include <tonemapping_fragment>
2598
- #include <colorspace_fragment>
2599
- }`,Vc=`#include <common>
2600
- #include <batching_pars_vertex>
2601
- #include <uv_pars_vertex>
2602
- #include <displacementmap_pars_vertex>
2603
- #include <morphtarget_pars_vertex>
2604
- #include <skinning_pars_vertex>
2605
- #include <logdepthbuf_pars_vertex>
2606
- #include <clipping_planes_pars_vertex>
2607
- varying vec2 vHighPrecisionZW;
2608
- void main() {
2609
- #include <uv_vertex>
2610
- #include <batching_vertex>
2611
- #include <skinbase_vertex>
2612
- #include <morphinstance_vertex>
2613
- #ifdef USE_DISPLACEMENTMAP
2614
- #include <beginnormal_vertex>
2615
- #include <morphnormal_vertex>
2616
- #include <skinnormal_vertex>
2617
- #endif
2618
- #include <begin_vertex>
2619
- #include <morphtarget_vertex>
2620
- #include <skinning_vertex>
2621
- #include <displacementmap_vertex>
2622
- #include <project_vertex>
2623
- #include <logdepthbuf_vertex>
2624
- #include <clipping_planes_vertex>
2625
- vHighPrecisionZW = gl_Position.zw;
2626
- }`,kc=`#if DEPTH_PACKING == 3200
2627
- uniform float opacity;
2628
- #endif
2629
- #include <common>
2630
- #include <packing>
2631
- #include <uv_pars_fragment>
2632
- #include <map_pars_fragment>
2633
- #include <alphamap_pars_fragment>
2634
- #include <alphatest_pars_fragment>
2635
- #include <alphahash_pars_fragment>
2636
- #include <logdepthbuf_pars_fragment>
2637
- #include <clipping_planes_pars_fragment>
2638
- varying vec2 vHighPrecisionZW;
2639
- void main() {
2640
- vec4 diffuseColor = vec4( 1.0 );
2641
- #include <clipping_planes_fragment>
2642
- #if DEPTH_PACKING == 3200
2643
- diffuseColor.a = opacity;
2644
- #endif
2645
- #include <map_fragment>
2646
- #include <alphamap_fragment>
2647
- #include <alphatest_fragment>
2648
- #include <alphahash_fragment>
2649
- #include <logdepthbuf_fragment>
2650
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2651
- #if DEPTH_PACKING == 3200
2652
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2653
- #elif DEPTH_PACKING == 3201
2654
- gl_FragColor = packDepthToRGBA( fragCoordZ );
2655
- #elif DEPTH_PACKING == 3202
2656
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2657
- #elif DEPTH_PACKING == 3203
2658
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2659
- #endif
2660
- }`,Hc=`#define DISTANCE
2661
- varying vec3 vWorldPosition;
2662
- #include <common>
2663
- #include <batching_pars_vertex>
2664
- #include <uv_pars_vertex>
2665
- #include <displacementmap_pars_vertex>
2666
- #include <morphtarget_pars_vertex>
2667
- #include <skinning_pars_vertex>
2668
- #include <clipping_planes_pars_vertex>
2669
- void main() {
2670
- #include <uv_vertex>
2671
- #include <batching_vertex>
2672
- #include <skinbase_vertex>
2673
- #include <morphinstance_vertex>
2674
- #ifdef USE_DISPLACEMENTMAP
2675
- #include <beginnormal_vertex>
2676
- #include <morphnormal_vertex>
2677
- #include <skinnormal_vertex>
2678
- #endif
2679
- #include <begin_vertex>
2680
- #include <morphtarget_vertex>
2681
- #include <skinning_vertex>
2682
- #include <displacementmap_vertex>
2683
- #include <project_vertex>
2684
- #include <worldpos_vertex>
2685
- #include <clipping_planes_vertex>
2686
- vWorldPosition = worldPosition.xyz;
2687
- }`,Wc=`#define DISTANCE
2688
- uniform vec3 referencePosition;
2689
- uniform float nearDistance;
2690
- uniform float farDistance;
2691
- varying vec3 vWorldPosition;
2692
- #include <common>
2693
- #include <packing>
2694
- #include <uv_pars_fragment>
2695
- #include <map_pars_fragment>
2696
- #include <alphamap_pars_fragment>
2697
- #include <alphatest_pars_fragment>
2698
- #include <alphahash_pars_fragment>
2699
- #include <clipping_planes_pars_fragment>
2700
- void main () {
2701
- vec4 diffuseColor = vec4( 1.0 );
2702
- #include <clipping_planes_fragment>
2703
- #include <map_fragment>
2704
- #include <alphamap_fragment>
2705
- #include <alphatest_fragment>
2706
- #include <alphahash_fragment>
2707
- float dist = length( vWorldPosition - referencePosition );
2708
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2709
- dist = saturate( dist );
2710
- gl_FragColor = packDepthToRGBA( dist );
2711
- }`,Xc=`varying vec3 vWorldDirection;
2712
- #include <common>
2713
- void main() {
2714
- vWorldDirection = transformDirection( position, modelMatrix );
2715
- #include <begin_vertex>
2716
- #include <project_vertex>
2717
- }`,qc=`uniform sampler2D tEquirect;
2718
- varying vec3 vWorldDirection;
2719
- #include <common>
2720
- void main() {
2721
- vec3 direction = normalize( vWorldDirection );
2722
- vec2 sampleUV = equirectUv( direction );
2723
- gl_FragColor = texture2D( tEquirect, sampleUV );
2724
- #include <tonemapping_fragment>
2725
- #include <colorspace_fragment>
2726
- }`,Yc=`uniform float scale;
2727
- attribute float lineDistance;
2728
- varying float vLineDistance;
2729
- #include <common>
2730
- #include <uv_pars_vertex>
2731
- #include <color_pars_vertex>
2732
- #include <fog_pars_vertex>
2733
- #include <morphtarget_pars_vertex>
2734
- #include <logdepthbuf_pars_vertex>
2735
- #include <clipping_planes_pars_vertex>
2736
- void main() {
2737
- vLineDistance = scale * lineDistance;
2738
- #include <uv_vertex>
2739
- #include <color_vertex>
2740
- #include <morphinstance_vertex>
2741
- #include <morphcolor_vertex>
2742
- #include <begin_vertex>
2743
- #include <morphtarget_vertex>
2744
- #include <project_vertex>
2745
- #include <logdepthbuf_vertex>
2746
- #include <clipping_planes_vertex>
2747
- #include <fog_vertex>
2748
- }`,Kc=`uniform vec3 diffuse;
2749
- uniform float opacity;
2750
- uniform float dashSize;
2751
- uniform float totalSize;
2752
- varying float vLineDistance;
2753
- #include <common>
2754
- #include <color_pars_fragment>
2755
- #include <uv_pars_fragment>
2756
- #include <map_pars_fragment>
2757
- #include <fog_pars_fragment>
2758
- #include <logdepthbuf_pars_fragment>
2759
- #include <clipping_planes_pars_fragment>
2760
- void main() {
2761
- vec4 diffuseColor = vec4( diffuse, opacity );
2762
- #include <clipping_planes_fragment>
2763
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
2764
- discard;
2765
- }
2766
- vec3 outgoingLight = vec3( 0.0 );
2767
- #include <logdepthbuf_fragment>
2768
- #include <map_fragment>
2769
- #include <color_fragment>
2770
- outgoingLight = diffuseColor.rgb;
2771
- #include <opaque_fragment>
2772
- #include <tonemapping_fragment>
2773
- #include <colorspace_fragment>
2774
- #include <fog_fragment>
2775
- #include <premultiplied_alpha_fragment>
2776
- }`,$c=`#include <common>
2777
- #include <batching_pars_vertex>
2778
- #include <uv_pars_vertex>
2779
- #include <envmap_pars_vertex>
2780
- #include <color_pars_vertex>
2781
- #include <fog_pars_vertex>
2782
- #include <morphtarget_pars_vertex>
2783
- #include <skinning_pars_vertex>
2784
- #include <logdepthbuf_pars_vertex>
2785
- #include <clipping_planes_pars_vertex>
2786
- void main() {
2787
- #include <uv_vertex>
2788
- #include <color_vertex>
2789
- #include <morphinstance_vertex>
2790
- #include <morphcolor_vertex>
2791
- #include <batching_vertex>
2792
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2793
- #include <beginnormal_vertex>
2794
- #include <morphnormal_vertex>
2795
- #include <skinbase_vertex>
2796
- #include <skinnormal_vertex>
2797
- #include <defaultnormal_vertex>
2798
- #endif
2799
- #include <begin_vertex>
2800
- #include <morphtarget_vertex>
2801
- #include <skinning_vertex>
2802
- #include <project_vertex>
2803
- #include <logdepthbuf_vertex>
2804
- #include <clipping_planes_vertex>
2805
- #include <worldpos_vertex>
2806
- #include <envmap_vertex>
2807
- #include <fog_vertex>
2808
- }`,Zc=`uniform vec3 diffuse;
2809
- uniform float opacity;
2810
- #ifndef FLAT_SHADED
2811
- varying vec3 vNormal;
2812
- #endif
2813
- #include <common>
2814
- #include <dithering_pars_fragment>
2815
- #include <color_pars_fragment>
2816
- #include <uv_pars_fragment>
2817
- #include <map_pars_fragment>
2818
- #include <alphamap_pars_fragment>
2819
- #include <alphatest_pars_fragment>
2820
- #include <alphahash_pars_fragment>
2821
- #include <aomap_pars_fragment>
2822
- #include <lightmap_pars_fragment>
2823
- #include <envmap_common_pars_fragment>
2824
- #include <envmap_pars_fragment>
2825
- #include <fog_pars_fragment>
2826
- #include <specularmap_pars_fragment>
2827
- #include <logdepthbuf_pars_fragment>
2828
- #include <clipping_planes_pars_fragment>
2829
- void main() {
2830
- vec4 diffuseColor = vec4( diffuse, opacity );
2831
- #include <clipping_planes_fragment>
2832
- #include <logdepthbuf_fragment>
2833
- #include <map_fragment>
2834
- #include <color_fragment>
2835
- #include <alphamap_fragment>
2836
- #include <alphatest_fragment>
2837
- #include <alphahash_fragment>
2838
- #include <specularmap_fragment>
2839
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2840
- #ifdef USE_LIGHTMAP
2841
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2842
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2843
- #else
2844
- reflectedLight.indirectDiffuse += vec3( 1.0 );
2845
- #endif
2846
- #include <aomap_fragment>
2847
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2848
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
2849
- #include <envmap_fragment>
2850
- #include <opaque_fragment>
2851
- #include <tonemapping_fragment>
2852
- #include <colorspace_fragment>
2853
- #include <fog_fragment>
2854
- #include <premultiplied_alpha_fragment>
2855
- #include <dithering_fragment>
2856
- }`,jc=`#define LAMBERT
2857
- varying vec3 vViewPosition;
2858
- #include <common>
2859
- #include <batching_pars_vertex>
2860
- #include <uv_pars_vertex>
2861
- #include <displacementmap_pars_vertex>
2862
- #include <envmap_pars_vertex>
2863
- #include <color_pars_vertex>
2864
- #include <fog_pars_vertex>
2865
- #include <normal_pars_vertex>
2866
- #include <morphtarget_pars_vertex>
2867
- #include <skinning_pars_vertex>
2868
- #include <shadowmap_pars_vertex>
2869
- #include <logdepthbuf_pars_vertex>
2870
- #include <clipping_planes_pars_vertex>
2871
- void main() {
2872
- #include <uv_vertex>
2873
- #include <color_vertex>
2874
- #include <morphinstance_vertex>
2875
- #include <morphcolor_vertex>
2876
- #include <batching_vertex>
2877
- #include <beginnormal_vertex>
2878
- #include <morphnormal_vertex>
2879
- #include <skinbase_vertex>
2880
- #include <skinnormal_vertex>
2881
- #include <defaultnormal_vertex>
2882
- #include <normal_vertex>
2883
- #include <begin_vertex>
2884
- #include <morphtarget_vertex>
2885
- #include <skinning_vertex>
2886
- #include <displacementmap_vertex>
2887
- #include <project_vertex>
2888
- #include <logdepthbuf_vertex>
2889
- #include <clipping_planes_vertex>
2890
- vViewPosition = - mvPosition.xyz;
2891
- #include <worldpos_vertex>
2892
- #include <envmap_vertex>
2893
- #include <shadowmap_vertex>
2894
- #include <fog_vertex>
2895
- }`,Jc=`#define LAMBERT
2896
- uniform vec3 diffuse;
2897
- uniform vec3 emissive;
2898
- uniform float opacity;
2899
- #include <common>
2900
- #include <packing>
2901
- #include <dithering_pars_fragment>
2902
- #include <color_pars_fragment>
2903
- #include <uv_pars_fragment>
2904
- #include <map_pars_fragment>
2905
- #include <alphamap_pars_fragment>
2906
- #include <alphatest_pars_fragment>
2907
- #include <alphahash_pars_fragment>
2908
- #include <aomap_pars_fragment>
2909
- #include <lightmap_pars_fragment>
2910
- #include <emissivemap_pars_fragment>
2911
- #include <envmap_common_pars_fragment>
2912
- #include <envmap_pars_fragment>
2913
- #include <fog_pars_fragment>
2914
- #include <bsdfs>
2915
- #include <lights_pars_begin>
2916
- #include <normal_pars_fragment>
2917
- #include <lights_lambert_pars_fragment>
2918
- #include <shadowmap_pars_fragment>
2919
- #include <bumpmap_pars_fragment>
2920
- #include <normalmap_pars_fragment>
2921
- #include <specularmap_pars_fragment>
2922
- #include <logdepthbuf_pars_fragment>
2923
- #include <clipping_planes_pars_fragment>
2924
- void main() {
2925
- vec4 diffuseColor = vec4( diffuse, opacity );
2926
- #include <clipping_planes_fragment>
2927
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2928
- vec3 totalEmissiveRadiance = emissive;
2929
- #include <logdepthbuf_fragment>
2930
- #include <map_fragment>
2931
- #include <color_fragment>
2932
- #include <alphamap_fragment>
2933
- #include <alphatest_fragment>
2934
- #include <alphahash_fragment>
2935
- #include <specularmap_fragment>
2936
- #include <normal_fragment_begin>
2937
- #include <normal_fragment_maps>
2938
- #include <emissivemap_fragment>
2939
- #include <lights_lambert_fragment>
2940
- #include <lights_fragment_begin>
2941
- #include <lights_fragment_maps>
2942
- #include <lights_fragment_end>
2943
- #include <aomap_fragment>
2944
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2945
- #include <envmap_fragment>
2946
- #include <opaque_fragment>
2947
- #include <tonemapping_fragment>
2948
- #include <colorspace_fragment>
2949
- #include <fog_fragment>
2950
- #include <premultiplied_alpha_fragment>
2951
- #include <dithering_fragment>
2952
- }`,Qc=`#define MATCAP
2953
- varying vec3 vViewPosition;
2954
- #include <common>
2955
- #include <batching_pars_vertex>
2956
- #include <uv_pars_vertex>
2957
- #include <color_pars_vertex>
2958
- #include <displacementmap_pars_vertex>
2959
- #include <fog_pars_vertex>
2960
- #include <normal_pars_vertex>
2961
- #include <morphtarget_pars_vertex>
2962
- #include <skinning_pars_vertex>
2963
- #include <logdepthbuf_pars_vertex>
2964
- #include <clipping_planes_pars_vertex>
2965
- void main() {
2966
- #include <uv_vertex>
2967
- #include <color_vertex>
2968
- #include <morphinstance_vertex>
2969
- #include <morphcolor_vertex>
2970
- #include <batching_vertex>
2971
- #include <beginnormal_vertex>
2972
- #include <morphnormal_vertex>
2973
- #include <skinbase_vertex>
2974
- #include <skinnormal_vertex>
2975
- #include <defaultnormal_vertex>
2976
- #include <normal_vertex>
2977
- #include <begin_vertex>
2978
- #include <morphtarget_vertex>
2979
- #include <skinning_vertex>
2980
- #include <displacementmap_vertex>
2981
- #include <project_vertex>
2982
- #include <logdepthbuf_vertex>
2983
- #include <clipping_planes_vertex>
2984
- #include <fog_vertex>
2985
- vViewPosition = - mvPosition.xyz;
2986
- }`,eh=`#define MATCAP
2987
- uniform vec3 diffuse;
2988
- uniform float opacity;
2989
- uniform sampler2D matcap;
2990
- varying vec3 vViewPosition;
2991
- #include <common>
2992
- #include <dithering_pars_fragment>
2993
- #include <color_pars_fragment>
2994
- #include <uv_pars_fragment>
2995
- #include <map_pars_fragment>
2996
- #include <alphamap_pars_fragment>
2997
- #include <alphatest_pars_fragment>
2998
- #include <alphahash_pars_fragment>
2999
- #include <fog_pars_fragment>
3000
- #include <normal_pars_fragment>
3001
- #include <bumpmap_pars_fragment>
3002
- #include <normalmap_pars_fragment>
3003
- #include <logdepthbuf_pars_fragment>
3004
- #include <clipping_planes_pars_fragment>
3005
- void main() {
3006
- vec4 diffuseColor = vec4( diffuse, opacity );
3007
- #include <clipping_planes_fragment>
3008
- #include <logdepthbuf_fragment>
3009
- #include <map_fragment>
3010
- #include <color_fragment>
3011
- #include <alphamap_fragment>
3012
- #include <alphatest_fragment>
3013
- #include <alphahash_fragment>
3014
- #include <normal_fragment_begin>
3015
- #include <normal_fragment_maps>
3016
- vec3 viewDir = normalize( vViewPosition );
3017
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3018
- vec3 y = cross( viewDir, x );
3019
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3020
- #ifdef USE_MATCAP
3021
- vec4 matcapColor = texture2D( matcap, uv );
3022
- #else
3023
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3024
- #endif
3025
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3026
- #include <opaque_fragment>
3027
- #include <tonemapping_fragment>
3028
- #include <colorspace_fragment>
3029
- #include <fog_fragment>
3030
- #include <premultiplied_alpha_fragment>
3031
- #include <dithering_fragment>
3032
- }`,th=`#define NORMAL
3033
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3034
- varying vec3 vViewPosition;
3035
- #endif
3036
- #include <common>
3037
- #include <batching_pars_vertex>
3038
- #include <uv_pars_vertex>
3039
- #include <displacementmap_pars_vertex>
3040
- #include <normal_pars_vertex>
3041
- #include <morphtarget_pars_vertex>
3042
- #include <skinning_pars_vertex>
3043
- #include <logdepthbuf_pars_vertex>
3044
- #include <clipping_planes_pars_vertex>
3045
- void main() {
3046
- #include <uv_vertex>
3047
- #include <batching_vertex>
3048
- #include <beginnormal_vertex>
3049
- #include <morphinstance_vertex>
3050
- #include <morphnormal_vertex>
3051
- #include <skinbase_vertex>
3052
- #include <skinnormal_vertex>
3053
- #include <defaultnormal_vertex>
3054
- #include <normal_vertex>
3055
- #include <begin_vertex>
3056
- #include <morphtarget_vertex>
3057
- #include <skinning_vertex>
3058
- #include <displacementmap_vertex>
3059
- #include <project_vertex>
3060
- #include <logdepthbuf_vertex>
3061
- #include <clipping_planes_vertex>
3062
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3063
- vViewPosition = - mvPosition.xyz;
3064
- #endif
3065
- }`,nh=`#define NORMAL
3066
- uniform float opacity;
3067
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3068
- varying vec3 vViewPosition;
3069
- #endif
3070
- #include <packing>
3071
- #include <uv_pars_fragment>
3072
- #include <normal_pars_fragment>
3073
- #include <bumpmap_pars_fragment>
3074
- #include <normalmap_pars_fragment>
3075
- #include <logdepthbuf_pars_fragment>
3076
- #include <clipping_planes_pars_fragment>
3077
- void main() {
3078
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3079
- #include <clipping_planes_fragment>
3080
- #include <logdepthbuf_fragment>
3081
- #include <normal_fragment_begin>
3082
- #include <normal_fragment_maps>
3083
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3084
- #ifdef OPAQUE
3085
- gl_FragColor.a = 1.0;
3086
- #endif
3087
- }`,ih=`#define PHONG
3088
- varying vec3 vViewPosition;
3089
- #include <common>
3090
- #include <batching_pars_vertex>
3091
- #include <uv_pars_vertex>
3092
- #include <displacementmap_pars_vertex>
3093
- #include <envmap_pars_vertex>
3094
- #include <color_pars_vertex>
3095
- #include <fog_pars_vertex>
3096
- #include <normal_pars_vertex>
3097
- #include <morphtarget_pars_vertex>
3098
- #include <skinning_pars_vertex>
3099
- #include <shadowmap_pars_vertex>
3100
- #include <logdepthbuf_pars_vertex>
3101
- #include <clipping_planes_pars_vertex>
3102
- void main() {
3103
- #include <uv_vertex>
3104
- #include <color_vertex>
3105
- #include <morphcolor_vertex>
3106
- #include <batching_vertex>
3107
- #include <beginnormal_vertex>
3108
- #include <morphinstance_vertex>
3109
- #include <morphnormal_vertex>
3110
- #include <skinbase_vertex>
3111
- #include <skinnormal_vertex>
3112
- #include <defaultnormal_vertex>
3113
- #include <normal_vertex>
3114
- #include <begin_vertex>
3115
- #include <morphtarget_vertex>
3116
- #include <skinning_vertex>
3117
- #include <displacementmap_vertex>
3118
- #include <project_vertex>
3119
- #include <logdepthbuf_vertex>
3120
- #include <clipping_planes_vertex>
3121
- vViewPosition = - mvPosition.xyz;
3122
- #include <worldpos_vertex>
3123
- #include <envmap_vertex>
3124
- #include <shadowmap_vertex>
3125
- #include <fog_vertex>
3126
- }`,rh=`#define PHONG
3127
- uniform vec3 diffuse;
3128
- uniform vec3 emissive;
3129
- uniform vec3 specular;
3130
- uniform float shininess;
3131
- uniform float opacity;
3132
- #include <common>
3133
- #include <packing>
3134
- #include <dithering_pars_fragment>
3135
- #include <color_pars_fragment>
3136
- #include <uv_pars_fragment>
3137
- #include <map_pars_fragment>
3138
- #include <alphamap_pars_fragment>
3139
- #include <alphatest_pars_fragment>
3140
- #include <alphahash_pars_fragment>
3141
- #include <aomap_pars_fragment>
3142
- #include <lightmap_pars_fragment>
3143
- #include <emissivemap_pars_fragment>
3144
- #include <envmap_common_pars_fragment>
3145
- #include <envmap_pars_fragment>
3146
- #include <fog_pars_fragment>
3147
- #include <bsdfs>
3148
- #include <lights_pars_begin>
3149
- #include <normal_pars_fragment>
3150
- #include <lights_phong_pars_fragment>
3151
- #include <shadowmap_pars_fragment>
3152
- #include <bumpmap_pars_fragment>
3153
- #include <normalmap_pars_fragment>
3154
- #include <specularmap_pars_fragment>
3155
- #include <logdepthbuf_pars_fragment>
3156
- #include <clipping_planes_pars_fragment>
3157
- void main() {
3158
- vec4 diffuseColor = vec4( diffuse, opacity );
3159
- #include <clipping_planes_fragment>
3160
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3161
- vec3 totalEmissiveRadiance = emissive;
3162
- #include <logdepthbuf_fragment>
3163
- #include <map_fragment>
3164
- #include <color_fragment>
3165
- #include <alphamap_fragment>
3166
- #include <alphatest_fragment>
3167
- #include <alphahash_fragment>
3168
- #include <specularmap_fragment>
3169
- #include <normal_fragment_begin>
3170
- #include <normal_fragment_maps>
3171
- #include <emissivemap_fragment>
3172
- #include <lights_phong_fragment>
3173
- #include <lights_fragment_begin>
3174
- #include <lights_fragment_maps>
3175
- #include <lights_fragment_end>
3176
- #include <aomap_fragment>
3177
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3178
- #include <envmap_fragment>
3179
- #include <opaque_fragment>
3180
- #include <tonemapping_fragment>
3181
- #include <colorspace_fragment>
3182
- #include <fog_fragment>
3183
- #include <premultiplied_alpha_fragment>
3184
- #include <dithering_fragment>
3185
- }`,sh=`#define STANDARD
3186
- varying vec3 vViewPosition;
3187
- #ifdef USE_TRANSMISSION
3188
- varying vec3 vWorldPosition;
3189
- #endif
3190
- #include <common>
3191
- #include <batching_pars_vertex>
3192
- #include <uv_pars_vertex>
3193
- #include <displacementmap_pars_vertex>
3194
- #include <color_pars_vertex>
3195
- #include <fog_pars_vertex>
3196
- #include <normal_pars_vertex>
3197
- #include <morphtarget_pars_vertex>
3198
- #include <skinning_pars_vertex>
3199
- #include <shadowmap_pars_vertex>
3200
- #include <logdepthbuf_pars_vertex>
3201
- #include <clipping_planes_pars_vertex>
3202
- void main() {
3203
- #include <uv_vertex>
3204
- #include <color_vertex>
3205
- #include <morphinstance_vertex>
3206
- #include <morphcolor_vertex>
3207
- #include <batching_vertex>
3208
- #include <beginnormal_vertex>
3209
- #include <morphnormal_vertex>
3210
- #include <skinbase_vertex>
3211
- #include <skinnormal_vertex>
3212
- #include <defaultnormal_vertex>
3213
- #include <normal_vertex>
3214
- #include <begin_vertex>
3215
- #include <morphtarget_vertex>
3216
- #include <skinning_vertex>
3217
- #include <displacementmap_vertex>
3218
- #include <project_vertex>
3219
- #include <logdepthbuf_vertex>
3220
- #include <clipping_planes_vertex>
3221
- vViewPosition = - mvPosition.xyz;
3222
- #include <worldpos_vertex>
3223
- #include <shadowmap_vertex>
3224
- #include <fog_vertex>
3225
- #ifdef USE_TRANSMISSION
3226
- vWorldPosition = worldPosition.xyz;
3227
- #endif
3228
- }`,ah=`#define STANDARD
3229
- #ifdef PHYSICAL
3230
- #define IOR
3231
- #define USE_SPECULAR
3232
- #endif
3233
- uniform vec3 diffuse;
3234
- uniform vec3 emissive;
3235
- uniform float roughness;
3236
- uniform float metalness;
3237
- uniform float opacity;
3238
- #ifdef IOR
3239
- uniform float ior;
3240
- #endif
3241
- #ifdef USE_SPECULAR
3242
- uniform float specularIntensity;
3243
- uniform vec3 specularColor;
3244
- #ifdef USE_SPECULAR_COLORMAP
3245
- uniform sampler2D specularColorMap;
3246
- #endif
3247
- #ifdef USE_SPECULAR_INTENSITYMAP
3248
- uniform sampler2D specularIntensityMap;
3249
- #endif
3250
- #endif
3251
- #ifdef USE_CLEARCOAT
3252
- uniform float clearcoat;
3253
- uniform float clearcoatRoughness;
3254
- #endif
3255
- #ifdef USE_DISPERSION
3256
- uniform float dispersion;
3257
- #endif
3258
- #ifdef USE_IRIDESCENCE
3259
- uniform float iridescence;
3260
- uniform float iridescenceIOR;
3261
- uniform float iridescenceThicknessMinimum;
3262
- uniform float iridescenceThicknessMaximum;
3263
- #endif
3264
- #ifdef USE_SHEEN
3265
- uniform vec3 sheenColor;
3266
- uniform float sheenRoughness;
3267
- #ifdef USE_SHEEN_COLORMAP
3268
- uniform sampler2D sheenColorMap;
3269
- #endif
3270
- #ifdef USE_SHEEN_ROUGHNESSMAP
3271
- uniform sampler2D sheenRoughnessMap;
3272
- #endif
3273
- #endif
3274
- #ifdef USE_ANISOTROPY
3275
- uniform vec2 anisotropyVector;
3276
- #ifdef USE_ANISOTROPYMAP
3277
- uniform sampler2D anisotropyMap;
3278
- #endif
3279
- #endif
3280
- varying vec3 vViewPosition;
3281
- #include <common>
3282
- #include <packing>
3283
- #include <dithering_pars_fragment>
3284
- #include <color_pars_fragment>
3285
- #include <uv_pars_fragment>
3286
- #include <map_pars_fragment>
3287
- #include <alphamap_pars_fragment>
3288
- #include <alphatest_pars_fragment>
3289
- #include <alphahash_pars_fragment>
3290
- #include <aomap_pars_fragment>
3291
- #include <lightmap_pars_fragment>
3292
- #include <emissivemap_pars_fragment>
3293
- #include <iridescence_fragment>
3294
- #include <cube_uv_reflection_fragment>
3295
- #include <envmap_common_pars_fragment>
3296
- #include <envmap_physical_pars_fragment>
3297
- #include <fog_pars_fragment>
3298
- #include <lights_pars_begin>
3299
- #include <normal_pars_fragment>
3300
- #include <lights_physical_pars_fragment>
3301
- #include <transmission_pars_fragment>
3302
- #include <shadowmap_pars_fragment>
3303
- #include <bumpmap_pars_fragment>
3304
- #include <normalmap_pars_fragment>
3305
- #include <clearcoat_pars_fragment>
3306
- #include <iridescence_pars_fragment>
3307
- #include <roughnessmap_pars_fragment>
3308
- #include <metalnessmap_pars_fragment>
3309
- #include <logdepthbuf_pars_fragment>
3310
- #include <clipping_planes_pars_fragment>
3311
- void main() {
3312
- vec4 diffuseColor = vec4( diffuse, opacity );
3313
- #include <clipping_planes_fragment>
3314
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3315
- vec3 totalEmissiveRadiance = emissive;
3316
- #include <logdepthbuf_fragment>
3317
- #include <map_fragment>
3318
- #include <color_fragment>
3319
- #include <alphamap_fragment>
3320
- #include <alphatest_fragment>
3321
- #include <alphahash_fragment>
3322
- #include <roughnessmap_fragment>
3323
- #include <metalnessmap_fragment>
3324
- #include <normal_fragment_begin>
3325
- #include <normal_fragment_maps>
3326
- #include <clearcoat_normal_fragment_begin>
3327
- #include <clearcoat_normal_fragment_maps>
3328
- #include <emissivemap_fragment>
3329
- #include <lights_physical_fragment>
3330
- #include <lights_fragment_begin>
3331
- #include <lights_fragment_maps>
3332
- #include <lights_fragment_end>
3333
- #include <aomap_fragment>
3334
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3335
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3336
- #include <transmission_fragment>
3337
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3338
- #ifdef USE_SHEEN
3339
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3340
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3341
- #endif
3342
- #ifdef USE_CLEARCOAT
3343
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3344
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3345
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3346
- #endif
3347
- #include <opaque_fragment>
3348
- #include <tonemapping_fragment>
3349
- #include <colorspace_fragment>
3350
- #include <fog_fragment>
3351
- #include <premultiplied_alpha_fragment>
3352
- #include <dithering_fragment>
3353
- }`,oh=`#define TOON
3354
- varying vec3 vViewPosition;
3355
- #include <common>
3356
- #include <batching_pars_vertex>
3357
- #include <uv_pars_vertex>
3358
- #include <displacementmap_pars_vertex>
3359
- #include <color_pars_vertex>
3360
- #include <fog_pars_vertex>
3361
- #include <normal_pars_vertex>
3362
- #include <morphtarget_pars_vertex>
3363
- #include <skinning_pars_vertex>
3364
- #include <shadowmap_pars_vertex>
3365
- #include <logdepthbuf_pars_vertex>
3366
- #include <clipping_planes_pars_vertex>
3367
- void main() {
3368
- #include <uv_vertex>
3369
- #include <color_vertex>
3370
- #include <morphinstance_vertex>
3371
- #include <morphcolor_vertex>
3372
- #include <batching_vertex>
3373
- #include <beginnormal_vertex>
3374
- #include <morphnormal_vertex>
3375
- #include <skinbase_vertex>
3376
- #include <skinnormal_vertex>
3377
- #include <defaultnormal_vertex>
3378
- #include <normal_vertex>
3379
- #include <begin_vertex>
3380
- #include <morphtarget_vertex>
3381
- #include <skinning_vertex>
3382
- #include <displacementmap_vertex>
3383
- #include <project_vertex>
3384
- #include <logdepthbuf_vertex>
3385
- #include <clipping_planes_vertex>
3386
- vViewPosition = - mvPosition.xyz;
3387
- #include <worldpos_vertex>
3388
- #include <shadowmap_vertex>
3389
- #include <fog_vertex>
3390
- }`,lh=`#define TOON
3391
- uniform vec3 diffuse;
3392
- uniform vec3 emissive;
3393
- uniform float opacity;
3394
- #include <common>
3395
- #include <packing>
3396
- #include <dithering_pars_fragment>
3397
- #include <color_pars_fragment>
3398
- #include <uv_pars_fragment>
3399
- #include <map_pars_fragment>
3400
- #include <alphamap_pars_fragment>
3401
- #include <alphatest_pars_fragment>
3402
- #include <alphahash_pars_fragment>
3403
- #include <aomap_pars_fragment>
3404
- #include <lightmap_pars_fragment>
3405
- #include <emissivemap_pars_fragment>
3406
- #include <gradientmap_pars_fragment>
3407
- #include <fog_pars_fragment>
3408
- #include <bsdfs>
3409
- #include <lights_pars_begin>
3410
- #include <normal_pars_fragment>
3411
- #include <lights_toon_pars_fragment>
3412
- #include <shadowmap_pars_fragment>
3413
- #include <bumpmap_pars_fragment>
3414
- #include <normalmap_pars_fragment>
3415
- #include <logdepthbuf_pars_fragment>
3416
- #include <clipping_planes_pars_fragment>
3417
- void main() {
3418
- vec4 diffuseColor = vec4( diffuse, opacity );
3419
- #include <clipping_planes_fragment>
3420
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3421
- vec3 totalEmissiveRadiance = emissive;
3422
- #include <logdepthbuf_fragment>
3423
- #include <map_fragment>
3424
- #include <color_fragment>
3425
- #include <alphamap_fragment>
3426
- #include <alphatest_fragment>
3427
- #include <alphahash_fragment>
3428
- #include <normal_fragment_begin>
3429
- #include <normal_fragment_maps>
3430
- #include <emissivemap_fragment>
3431
- #include <lights_toon_fragment>
3432
- #include <lights_fragment_begin>
3433
- #include <lights_fragment_maps>
3434
- #include <lights_fragment_end>
3435
- #include <aomap_fragment>
3436
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3437
- #include <opaque_fragment>
3438
- #include <tonemapping_fragment>
3439
- #include <colorspace_fragment>
3440
- #include <fog_fragment>
3441
- #include <premultiplied_alpha_fragment>
3442
- #include <dithering_fragment>
3443
- }`,ch=`uniform float size;
3444
- uniform float scale;
3445
- #include <common>
3446
- #include <color_pars_vertex>
3447
- #include <fog_pars_vertex>
3448
- #include <morphtarget_pars_vertex>
3449
- #include <logdepthbuf_pars_vertex>
3450
- #include <clipping_planes_pars_vertex>
3451
- #ifdef USE_POINTS_UV
3452
- varying vec2 vUv;
3453
- uniform mat3 uvTransform;
3454
- #endif
3455
- void main() {
3456
- #ifdef USE_POINTS_UV
3457
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3458
- #endif
3459
- #include <color_vertex>
3460
- #include <morphinstance_vertex>
3461
- #include <morphcolor_vertex>
3462
- #include <begin_vertex>
3463
- #include <morphtarget_vertex>
3464
- #include <project_vertex>
3465
- gl_PointSize = size;
3466
- #ifdef USE_SIZEATTENUATION
3467
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3468
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3469
- #endif
3470
- #include <logdepthbuf_vertex>
3471
- #include <clipping_planes_vertex>
3472
- #include <worldpos_vertex>
3473
- #include <fog_vertex>
3474
- }`,hh=`uniform vec3 diffuse;
3475
- uniform float opacity;
3476
- #include <common>
3477
- #include <color_pars_fragment>
3478
- #include <map_particle_pars_fragment>
3479
- #include <alphatest_pars_fragment>
3480
- #include <alphahash_pars_fragment>
3481
- #include <fog_pars_fragment>
3482
- #include <logdepthbuf_pars_fragment>
3483
- #include <clipping_planes_pars_fragment>
3484
- void main() {
3485
- vec4 diffuseColor = vec4( diffuse, opacity );
3486
- #include <clipping_planes_fragment>
3487
- vec3 outgoingLight = vec3( 0.0 );
3488
- #include <logdepthbuf_fragment>
3489
- #include <map_particle_fragment>
3490
- #include <color_fragment>
3491
- #include <alphatest_fragment>
3492
- #include <alphahash_fragment>
3493
- outgoingLight = diffuseColor.rgb;
3494
- #include <opaque_fragment>
3495
- #include <tonemapping_fragment>
3496
- #include <colorspace_fragment>
3497
- #include <fog_fragment>
3498
- #include <premultiplied_alpha_fragment>
3499
- }`,uh=`#include <common>
3500
- #include <batching_pars_vertex>
3501
- #include <fog_pars_vertex>
3502
- #include <morphtarget_pars_vertex>
3503
- #include <skinning_pars_vertex>
3504
- #include <logdepthbuf_pars_vertex>
3505
- #include <shadowmap_pars_vertex>
3506
- void main() {
3507
- #include <batching_vertex>
3508
- #include <beginnormal_vertex>
3509
- #include <morphinstance_vertex>
3510
- #include <morphnormal_vertex>
3511
- #include <skinbase_vertex>
3512
- #include <skinnormal_vertex>
3513
- #include <defaultnormal_vertex>
3514
- #include <begin_vertex>
3515
- #include <morphtarget_vertex>
3516
- #include <skinning_vertex>
3517
- #include <project_vertex>
3518
- #include <logdepthbuf_vertex>
3519
- #include <worldpos_vertex>
3520
- #include <shadowmap_vertex>
3521
- #include <fog_vertex>
3522
- }`,dh=`uniform vec3 color;
3523
- uniform float opacity;
3524
- #include <common>
3525
- #include <packing>
3526
- #include <fog_pars_fragment>
3527
- #include <bsdfs>
3528
- #include <lights_pars_begin>
3529
- #include <logdepthbuf_pars_fragment>
3530
- #include <shadowmap_pars_fragment>
3531
- #include <shadowmask_pars_fragment>
3532
- void main() {
3533
- #include <logdepthbuf_fragment>
3534
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3535
- #include <tonemapping_fragment>
3536
- #include <colorspace_fragment>
3537
- #include <fog_fragment>
3538
- }`,fh=`uniform float rotation;
3539
- uniform vec2 center;
3540
- #include <common>
3541
- #include <uv_pars_vertex>
3542
- #include <fog_pars_vertex>
3543
- #include <logdepthbuf_pars_vertex>
3544
- #include <clipping_planes_pars_vertex>
3545
- void main() {
3546
- #include <uv_vertex>
3547
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3548
- vec2 scale;
3549
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
3550
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
3551
- #ifndef USE_SIZEATTENUATION
3552
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3553
- if ( isPerspective ) scale *= - mvPosition.z;
3554
- #endif
3555
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3556
- vec2 rotatedPosition;
3557
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3558
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3559
- mvPosition.xy += rotatedPosition;
3560
- gl_Position = projectionMatrix * mvPosition;
3561
- #include <logdepthbuf_vertex>
3562
- #include <clipping_planes_vertex>
3563
- #include <fog_vertex>
3564
- }`,ph=`uniform vec3 diffuse;
3565
- uniform float opacity;
3566
- #include <common>
3567
- #include <uv_pars_fragment>
3568
- #include <map_pars_fragment>
3569
- #include <alphamap_pars_fragment>
3570
- #include <alphatest_pars_fragment>
3571
- #include <alphahash_pars_fragment>
3572
- #include <fog_pars_fragment>
3573
- #include <logdepthbuf_pars_fragment>
3574
- #include <clipping_planes_pars_fragment>
3575
- void main() {
3576
- vec4 diffuseColor = vec4( diffuse, opacity );
3577
- #include <clipping_planes_fragment>
3578
- vec3 outgoingLight = vec3( 0.0 );
3579
- #include <logdepthbuf_fragment>
3580
- #include <map_fragment>
3581
- #include <alphamap_fragment>
3582
- #include <alphatest_fragment>
3583
- #include <alphahash_fragment>
3584
- outgoingLight = diffuseColor.rgb;
3585
- #include <opaque_fragment>
3586
- #include <tonemapping_fragment>
3587
- #include <colorspace_fragment>
3588
- #include <fog_fragment>
3589
- }`,Ce={alphahash_fragment:Fo,alphahash_pars_fragment:Bo,alphamap_fragment:Oo,alphamap_pars_fragment:Go,alphatest_fragment:zo,alphatest_pars_fragment:Vo,aomap_fragment:ko,aomap_pars_fragment:Ho,batching_pars_vertex:Wo,batching_vertex:Xo,begin_vertex:qo,beginnormal_vertex:Yo,bsdfs:Ko,iridescence_fragment:$o,bumpmap_pars_fragment:Zo,clipping_planes_fragment:jo,clipping_planes_pars_fragment:Jo,clipping_planes_pars_vertex:Qo,clipping_planes_vertex:el,color_fragment:tl,color_pars_fragment:nl,color_pars_vertex:il,color_vertex:rl,common:sl,cube_uv_reflection_fragment:al,defaultnormal_vertex:ol,displacementmap_pars_vertex:ll,displacementmap_vertex:cl,emissivemap_fragment:hl,emissivemap_pars_fragment:ul,colorspace_fragment:dl,colorspace_pars_fragment:fl,envmap_fragment:pl,envmap_common_pars_fragment:ml,envmap_pars_fragment:_l,envmap_pars_vertex:gl,envmap_physical_pars_fragment:wl,envmap_vertex:vl,fog_vertex:xl,fog_pars_vertex:Ml,fog_fragment:Sl,fog_pars_fragment:yl,gradientmap_pars_fragment:El,lightmap_pars_fragment:Tl,lights_lambert_fragment:Al,lights_lambert_pars_fragment:bl,lights_pars_begin:Rl,lights_toon_fragment:Cl,lights_toon_pars_fragment:Pl,lights_phong_fragment:Ll,lights_phong_pars_fragment:Dl,lights_physical_fragment:Il,lights_physical_pars_fragment:Ul,lights_fragment_begin:Nl,lights_fragment_maps:Fl,lights_fragment_end:Bl,logdepthbuf_fragment:Ol,logdepthbuf_pars_fragment:Gl,logdepthbuf_pars_vertex:zl,logdepthbuf_vertex:Vl,map_fragment:kl,map_pars_fragment:Hl,map_particle_fragment:Wl,map_particle_pars_fragment:Xl,metalnessmap_fragment:ql,metalnessmap_pars_fragment:Yl,morphinstance_vertex:Kl,morphcolor_vertex:$l,morphnormal_vertex:Zl,morphtarget_pars_vertex:jl,morphtarget_vertex:Jl,normal_fragment_begin:Ql,normal_fragment_maps:ec,normal_pars_fragment:tc,normal_pars_vertex:nc,normal_vertex:ic,normalmap_pars_fragment:rc,clearcoat_normal_fragment_begin:sc,clearcoat_normal_fragment_maps:ac,clearcoat_pars_fragment:oc,iridescence_pars_fragment:lc,opaque_fragment:cc,packing:hc,premultiplied_alpha_fragment:uc,project_vertex:dc,dithering_fragment:fc,dithering_pars_fragment:pc,roughnessmap_fragment:mc,roughnessmap_pars_fragment:_c,shadowmap_pars_fragment:gc,shadowmap_pars_vertex:vc,shadowmap_vertex:xc,shadowmask_pars_fragment:Mc,skinbase_vertex:Sc,skinning_pars_vertex:yc,skinning_vertex:Ec,skinnormal_vertex:Tc,specularmap_fragment:Ac,specularmap_pars_fragment:bc,tonemapping_fragment:Rc,tonemapping_pars_fragment:wc,transmission_fragment:Cc,transmission_pars_fragment:Pc,uv_pars_fragment:Lc,uv_pars_vertex:Dc,uv_vertex:Ic,worldpos_vertex:Uc,background_vert:Nc,background_frag:Fc,backgroundCube_vert:Bc,backgroundCube_frag:Oc,cube_vert:Gc,cube_frag:zc,depth_vert:Vc,depth_frag:kc,distanceRGBA_vert:Hc,distanceRGBA_frag:Wc,equirect_vert:Xc,equirect_frag:qc,linedashed_vert:Yc,linedashed_frag:Kc,meshbasic_vert:$c,meshbasic_frag:Zc,meshlambert_vert:jc,meshlambert_frag:Jc,meshmatcap_vert:Qc,meshmatcap_frag:eh,meshnormal_vert:th,meshnormal_frag:nh,meshphong_vert:ih,meshphong_frag:rh,meshphysical_vert:sh,meshphysical_frag:ah,meshtoon_vert:oh,meshtoon_frag:lh,points_vert:ch,points_frag:hh,shadow_vert:uh,shadow_frag:dh,sprite_vert:fh,sprite_frag:ph},ie={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pe},alphaMap:{value:null},alphaMapTransform:{value:new Pe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pe}},envmap:{envMap:{value:null},envMapRotation:{value:new Pe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Pe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pe},normalScale:{value:new Fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pe},alphaTest:{value:0},uvTransform:{value:new Pe}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new Fe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pe},alphaMap:{value:null},alphaMapTransform:{value:new Pe},alphaTest:{value:0}}},Ft={basic:{uniforms:vt([ie.common,ie.specularmap,ie.envmap,ie.aomap,ie.lightmap,ie.fog]),vertexShader:Ce.meshbasic_vert,fragmentShader:Ce.meshbasic_frag},lambert:{uniforms:vt([ie.common,ie.specularmap,ie.envmap,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.fog,ie.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Ce.meshlambert_vert,fragmentShader:Ce.meshlambert_frag},phong:{uniforms:vt([ie.common,ie.specularmap,ie.envmap,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.fog,ie.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30}}]),vertexShader:Ce.meshphong_vert,fragmentShader:Ce.meshphong_frag},standard:{uniforms:vt([ie.common,ie.envmap,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.roughnessmap,ie.metalnessmap,ie.fog,ie.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ce.meshphysical_vert,fragmentShader:Ce.meshphysical_frag},toon:{uniforms:vt([ie.common,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.gradientmap,ie.fog,ie.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Ce.meshtoon_vert,fragmentShader:Ce.meshtoon_frag},matcap:{uniforms:vt([ie.common,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.fog,{matcap:{value:null}}]),vertexShader:Ce.meshmatcap_vert,fragmentShader:Ce.meshmatcap_frag},points:{uniforms:vt([ie.points,ie.fog]),vertexShader:Ce.points_vert,fragmentShader:Ce.points_frag},dashed:{uniforms:vt([ie.common,ie.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ce.linedashed_vert,fragmentShader:Ce.linedashed_frag},depth:{uniforms:vt([ie.common,ie.displacementmap]),vertexShader:Ce.depth_vert,fragmentShader:Ce.depth_frag},normal:{uniforms:vt([ie.common,ie.bumpmap,ie.normalmap,ie.displacementmap,{opacity:{value:1}}]),vertexShader:Ce.meshnormal_vert,fragmentShader:Ce.meshnormal_frag},sprite:{uniforms:vt([ie.sprite,ie.fog]),vertexShader:Ce.sprite_vert,fragmentShader:Ce.sprite_frag},background:{uniforms:{uvTransform:{value:new Pe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ce.background_vert,fragmentShader:Ce.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pe}},vertexShader:Ce.backgroundCube_vert,fragmentShader:Ce.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ce.cube_vert,fragmentShader:Ce.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ce.equirect_vert,fragmentShader:Ce.equirect_frag},distanceRGBA:{uniforms:vt([ie.common,ie.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ce.distanceRGBA_vert,fragmentShader:Ce.distanceRGBA_frag},shadow:{uniforms:vt([ie.lights,ie.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:Ce.shadow_vert,fragmentShader:Ce.shadow_frag}};Ft.physical={uniforms:vt([Ft.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pe},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pe},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pe},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pe},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pe},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pe}}]),vertexShader:Ce.meshphysical_vert,fragmentShader:Ce.meshphysical_frag};const Bi={r:0,b:0,g:0},mn=new Ot,mh=new Ue;function _h(i,e,t,n,r,s,a){const o=new Ie(0);let l=s===!0?0:1,c,h,f=null,u=0,m=null;function _(T){let S=T.isScene===!0?T.background:null;return S&&S.isTexture&&(S=(T.backgroundBlurriness>0?t:e).get(S)),S}function v(T){let S=!1;const A=_(T);A===null?d(o,l):A&&A.isColor&&(d(A,1),S=!0);const B=i.xr.getEnvironmentBlendMode();B==="additive"?n.buffers.color.setClear(0,0,0,1,a):B==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(T,S){const A=_(S);A&&(A.isCubeTexture||A.mapping===306)?(h===void 0&&(h=new Tt(new fi(1,1,1),new jt({name:"BackgroundCubeMaterial",uniforms:Wn(Ft.backgroundCube.uniforms),vertexShader:Ft.backgroundCube.vertexShader,fragmentShader:Ft.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(B,R,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),mn.copy(S.backgroundRotation),mn.x*=-1,mn.y*=-1,mn.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(mn.y*=-1,mn.z*=-1),h.material.uniforms.envMap.value=A,h.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(mh.makeRotationFromEuler(mn)),h.material.toneMapped=ze.getTransfer(A.colorSpace)!==je,(f!==A||u!==A.version||m!==i.toneMapping)&&(h.material.needsUpdate=!0,f=A,u=A.version,m=i.toneMapping),h.layers.enableAll(),T.unshift(h,h.geometry,h.material,0,0,null)):A&&A.isTexture&&(c===void 0&&(c=new Tt(new pi(2,2),new jt({name:"BackgroundMaterial",uniforms:Wn(Ft.background.uniforms),vertexShader:Ft.background.vertexShader,fragmentShader:Ft.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=A,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=ze.getTransfer(A.colorSpace)!==je,A.matrixAutoUpdate===!0&&A.updateMatrix(),c.material.uniforms.uvTransform.value.copy(A.matrix),(f!==A||u!==A.version||m!==i.toneMapping)&&(c.material.needsUpdate=!0,f=A,u=A.version,m=i.toneMapping),c.layers.enableAll(),T.unshift(c,c.geometry,c.material,0,0,null))}function d(T,S){T.getRGB(Bi,ba(i)),n.buffers.color.setClear(Bi.r,Bi.g,Bi.b,S,a)}return{getClearColor:function(){return o},setClearColor:function(T,S=1){o.set(T),l=S,d(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(T){l=T,d(o,l)},render:v,addToRenderList:p}}function gh(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=u(null);let s=r,a=!1;function o(M,P,W,G,H){let K=!1;const V=f(G,W,P);s!==V&&(s=V,c(s.object)),K=m(M,G,W,H),K&&_(M,G,W,H),H!==null&&e.update(H,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,A(M,P,W,G),H!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return i.createVertexArray()}function c(M){return i.bindVertexArray(M)}function h(M){return i.deleteVertexArray(M)}function f(M,P,W){const G=W.wireframe===!0;let H=n[M.id];H===void 0&&(H={},n[M.id]=H);let K=H[P.id];K===void 0&&(K={},H[P.id]=K);let V=K[G];return V===void 0&&(V=u(l()),K[G]=V),V}function u(M){const P=[],W=[],G=[];for(let H=0;H<t;H++)P[H]=0,W[H]=0,G[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:W,attributeDivisors:G,object:M,attributes:{},index:null}}function m(M,P,W,G){const H=s.attributes,K=P.attributes;let V=0;const j=W.getAttributes();for(const z in j)if(j[z].location>=0){const he=H[z];let me=K[z];if(me===void 0&&(z==="instanceMatrix"&&M.instanceMatrix&&(me=M.instanceMatrix),z==="instanceColor"&&M.instanceColor&&(me=M.instanceColor)),he===void 0||he.attribute!==me||me&&he.data!==me.data)return!0;V++}return s.attributesNum!==V||s.index!==G}function _(M,P,W,G){const H={},K=P.attributes;let V=0;const j=W.getAttributes();for(const z in j)if(j[z].location>=0){let he=K[z];he===void 0&&(z==="instanceMatrix"&&M.instanceMatrix&&(he=M.instanceMatrix),z==="instanceColor"&&M.instanceColor&&(he=M.instanceColor));const me={};me.attribute=he,he&&he.data&&(me.data=he.data),H[z]=me,V++}s.attributes=H,s.attributesNum=V,s.index=G}function v(){const M=s.newAttributes;for(let P=0,W=M.length;P<W;P++)M[P]=0}function p(M){d(M,0)}function d(M,P){const W=s.newAttributes,G=s.enabledAttributes,H=s.attributeDivisors;W[M]=1,G[M]===0&&(i.enableVertexAttribArray(M),G[M]=1),H[M]!==P&&(i.vertexAttribDivisor(M,P),H[M]=P)}function T(){const M=s.newAttributes,P=s.enabledAttributes;for(let W=0,G=P.length;W<G;W++)P[W]!==M[W]&&(i.disableVertexAttribArray(W),P[W]=0)}function S(M,P,W,G,H,K,V){V===!0?i.vertexAttribIPointer(M,P,W,H,K):i.vertexAttribPointer(M,P,W,G,H,K)}function A(M,P,W,G){v();const H=G.attributes,K=W.getAttributes(),V=P.defaultAttributeValues;for(const j in K){const z=K[j];if(z.location>=0){let ae=H[j];if(ae===void 0&&(j==="instanceMatrix"&&M.instanceMatrix&&(ae=M.instanceMatrix),j==="instanceColor"&&M.instanceColor&&(ae=M.instanceColor)),ae!==void 0){const he=ae.normalized,me=ae.itemSize,Be=e.get(ae);if(Be===void 0)continue;const Ke=Be.buffer,k=Be.type,J=Be.bytesPerElement,de=k===i.INT||k===i.UNSIGNED_INT||ae.gpuType===1013;if(ae.isInterleavedBufferAttribute){const le=ae.data,be=le.stride,Le=ae.offset;if(le.isInstancedInterleavedBuffer){for(let Ne=0;Ne<z.locationSize;Ne++)d(z.location+Ne,le.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let Ne=0;Ne<z.locationSize;Ne++)p(z.location+Ne);i.bindBuffer(i.ARRAY_BUFFER,Ke);for(let Ne=0;Ne<z.locationSize;Ne++)S(z.location+Ne,me/z.locationSize,k,he,be*J,(Le+me/z.locationSize*Ne)*J,de)}else{if(ae.isInstancedBufferAttribute){for(let le=0;le<z.locationSize;le++)d(z.location+le,ae.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let le=0;le<z.locationSize;le++)p(z.location+le);i.bindBuffer(i.ARRAY_BUFFER,Ke);for(let le=0;le<z.locationSize;le++)S(z.location+le,me/z.locationSize,k,he,me*J,me/z.locationSize*le*J,de)}}else if(V!==void 0){const he=V[j];if(he!==void 0)switch(he.length){case 2:i.vertexAttrib2fv(z.location,he);break;case 3:i.vertexAttrib3fv(z.location,he);break;case 4:i.vertexAttrib4fv(z.location,he);break;default:i.vertexAttrib1fv(z.location,he)}}}}T()}function B(){F();for(const M in n){const P=n[M];for(const W in P){const G=P[W];for(const H in G)h(G[H].object),delete G[H];delete P[W]}delete n[M]}}function R(M){if(n[M.id]===void 0)return;const P=n[M.id];for(const W in P){const G=P[W];for(const H in G)h(G[H].object),delete G[H];delete P[W]}delete n[M.id]}function w(M){for(const P in n){const W=n[P];if(W[M.id]===void 0)continue;const G=W[M.id];for(const H in G)h(G[H].object),delete G[H];delete W[M.id]}}function F(){y(),a=!0,s!==r&&(s=r,c(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:F,resetDefaultState:y,dispose:B,releaseStatesOfGeometry:R,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:p,disableUnusedAttributes:T}}function vh(i,e,t){let n;function r(c){n=c}function s(c,h){i.drawArrays(n,c,h),t.update(h,n,1)}function a(c,h,f){f!==0&&(i.drawArraysInstanced(n,c,h,f),t.update(h,n,f))}function o(c,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,f);let m=0;for(let _=0;_<f;_++)m+=h[_];t.update(m,n,1)}function l(c,h,f,u){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let _=0;_<c.length;_++)a(c[_],h[_],u[_]);else{m.multiDrawArraysInstancedWEBGL(n,c,0,h,0,u,0,f);let _=0;for(let v=0;v<f;v++)_+=h[v];for(let v=0;v<u.length;v++)t.update(_,n,u[v])}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function xh(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(R){return!(R!==1023&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const w=R===1016&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==1009&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==1015&&!w)}function l(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,u=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),v=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),d=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),A=m>0,B=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:f,maxTextures:u,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:v,maxAttributes:p,maxVertexUniforms:d,maxVaryings:T,maxFragmentUniforms:S,vertexTextures:A,maxSamples:B}}function Mh(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new gn,o=new Pe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,u){const m=f.length!==0||u||n!==0||r;return r=u,n=f.length,m},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,u){t=h(f,u,0)},this.setState=function(f,u,m){const _=f.clippingPlanes,v=f.clipIntersection,p=f.clipShadows,d=i.get(f);if(!r||_===null||_.length===0||s&&!p)s?h(null):c();else{const T=s?0:n,S=T*4;let A=d.clippingState||null;l.value=A,A=h(_,u,S,m);for(let B=0;B!==S;++B)A[B]=t[B];d.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=T}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(f,u,m,_){const v=f!==null?f.length:0;let p=null;if(v!==0){if(p=l.value,_!==!0||p===null){const d=m+v*4,T=u.matrixWorldInverse;o.getNormalMatrix(T),(p===null||p.length<d)&&(p=new Float32Array(d));for(let S=0,A=m;S!==v;++S,A+=4)a.copy(f[S]).applyMatrix4(T,o),a.normal.toArray(p,A),p[A+3]=a.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,p}}function Sh(i){let e=new WeakMap;function t(a,o){return o===303?a.mapping=301:o===304&&(a.mapping=302),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===303||o===304)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Do(l.height);return c.fromEquirectangularTexture(i,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Wr extends Ra{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,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,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}const zn=4,Ls=[.125,.215,.35,.446,.526,.582],xn=20,Ar=new Wr,Ds=new Ie;let br=null,Rr=0,wr=0,Cr=!1;const vn=(1+Math.sqrt(5))/2,On=1/vn,Is=[new D(-vn,On,0),new D(vn,On,0),new D(-On,0,vn),new D(On,0,vn),new D(0,vn,-On),new D(0,vn,On),new D(-1,1,-1),new D(1,1,-1),new D(-1,1,1),new D(1,1,1)];class Us{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){br=this._renderer.getRenderTarget(),Rr=this._renderer.getActiveCubeFace(),wr=this._renderer.getActiveMipmapLevel(),Cr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Bs(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fs(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(br,Rr,wr),this._renderer.xr.enabled=Cr,e.scissorTest=!1,Oi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),br=this._renderer.getRenderTarget(),Rr=this._renderer.getActiveCubeFace(),wr=this._renderer.getActiveMipmapLevel(),Cr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:1006,minFilter:1006,generateMipmaps:!1,type:1016,format:1023,colorSpace:Jt,depthBuffer:!1},r=Ns(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ns(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=yh(s)),this._blurMaterial=Eh(s,e,t)}return r}_compileMaterial(e){const t=new Tt(this._lodPlanes[0],e);this._renderer.compile(t,Ar)}_sceneToCubeUV(e,t,n,r){const o=new xt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,u=h.toneMapping;h.getClearColor(Ds),h.toneMapping=0,h.autoClear=!1;const m=new kr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),_=new Tt(new fi,m);let v=!1;const p=e.background;p?p.isColor&&(m.color.copy(p),e.background=null,v=!0):(m.color.copy(Ds),v=!0);for(let d=0;d<6;d++){const T=d%3;T===0?(o.up.set(0,l[d],0),o.lookAt(c[d],0,0)):T===1?(o.up.set(0,0,l[d]),o.lookAt(0,c[d],0)):(o.up.set(0,l[d],0),o.lookAt(0,0,c[d]));const S=this._cubeSize;Oi(r,T*S,d>2?S:0,S,S),h.setRenderTarget(r),v&&h.render(_,o),h.render(e,o)}_.geometry.dispose(),_.material.dispose(),h.toneMapping=u,h.autoClear=f,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Bs()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fs());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Tt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Oi(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Ar)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Is[(r-s-1)%Is.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,f=new Tt(this._lodPlanes[r],c),u=c.uniforms,m=this._sizeLods[n]-1,_=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*xn-1),v=s/_,p=isFinite(s)?1+Math.floor(h*v):xn;p>xn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${xn}`);const d=[];let T=0;for(let w=0;w<xn;++w){const F=w/v,y=Math.exp(-F*F/2);d.push(y),w===0?T+=y:w<p&&(T+=2*y)}for(let w=0;w<d.length;w++)d[w]=d[w]/T;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=d,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:S}=this;u.dTheta.value=_,u.mipInt.value=S-n;const A=this._sizeLods[r],B=3*A*(r>S-zn?r-S+zn:0),R=4*(this._cubeSize-A);Oi(t,B,R,3*A,2*A),l.setRenderTarget(t),l.render(f,Ar)}}function yh(i){const e=[],t=[],n=[];let r=i;const s=i-zn+1+Ls.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>i-zn?l=Ls[a-i+zn-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,f=1+c,u=[h,h,f,h,f,f,h,h,f,f,h,f],m=6,_=6,v=3,p=2,d=1,T=new Float32Array(v*_*m),S=new Float32Array(p*_*m),A=new Float32Array(d*_*m);for(let R=0;R<m;R++){const w=R%3*2/3-1,F=R>2?0:-1,y=[w,F,0,w+2/3,F,0,w+2/3,F+1,0,w,F,0,w+2/3,F+1,0,w,F+1,0];T.set(y,v*_*R),S.set(u,p*_*R);const M=[R,R,R,R,R,R];A.set(M,d*_*R)}const B=new zt;B.setAttribute("position",new At(T,v)),B.setAttribute("uv",new At(S,p)),B.setAttribute("faceIndex",new At(A,d)),e.push(B),r>zn&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Ns(i,e,t){const n=new Mn(i,e,t);return n.texture.mapping=306,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Oi(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Eh(i,e,t){const n=new Float32Array(xn),r=new D(0,1,0);return new jt({name:"SphericalGaussianBlur",defines:{n:xn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Xr(),fragmentShader:`
3590
-
3591
- precision mediump float;
3592
- precision mediump int;
3593
-
3594
- varying vec3 vOutputDirection;
3595
-
3596
- uniform sampler2D envMap;
3597
- uniform int samples;
3598
- uniform float weights[ n ];
3599
- uniform bool latitudinal;
3600
- uniform float dTheta;
3601
- uniform float mipInt;
3602
- uniform vec3 poleAxis;
3603
-
3604
- #define ENVMAP_TYPE_CUBE_UV
3605
- #include <cube_uv_reflection_fragment>
3606
-
3607
- vec3 getSample( float theta, vec3 axis ) {
3608
-
3609
- float cosTheta = cos( theta );
3610
- // Rodrigues' axis-angle rotation
3611
- vec3 sampleDirection = vOutputDirection * cosTheta
3612
- + cross( axis, vOutputDirection ) * sin( theta )
3613
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3614
-
3615
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
3616
-
3617
- }
3618
-
3619
- void main() {
3620
-
3621
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3622
-
3623
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3624
-
3625
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3626
-
3627
- }
3628
-
3629
- axis = normalize( axis );
3630
-
3631
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3632
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3633
-
3634
- for ( int i = 1; i < n; i++ ) {
3635
-
3636
- if ( i >= samples ) {
3637
-
3638
- break;
3639
-
3640
- }
3641
-
3642
- float theta = dTheta * float( i );
3643
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3644
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3645
-
3646
- }
3647
-
3648
- }
3649
- `,blending:0,depthTest:!1,depthWrite:!1})}function Fs(){return new jt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Xr(),fragmentShader:`
3650
-
3651
- precision mediump float;
3652
- precision mediump int;
3653
-
3654
- varying vec3 vOutputDirection;
3655
-
3656
- uniform sampler2D envMap;
3657
-
3658
- #include <common>
3659
-
3660
- void main() {
3661
-
3662
- vec3 outputDirection = normalize( vOutputDirection );
3663
- vec2 uv = equirectUv( outputDirection );
3664
-
3665
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3666
-
3667
- }
3668
- `,blending:0,depthTest:!1,depthWrite:!1})}function Bs(){return new jt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Xr(),fragmentShader:`
3669
-
3670
- precision mediump float;
3671
- precision mediump int;
3672
-
3673
- uniform float flipEnvMap;
3674
-
3675
- varying vec3 vOutputDirection;
3676
-
3677
- uniform samplerCube envMap;
3678
-
3679
- void main() {
3680
-
3681
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3682
-
3683
- }
3684
- `,blending:0,depthTest:!1,depthWrite:!1})}function Xr(){return`
3685
-
3686
- precision mediump float;
3687
- precision mediump int;
3688
-
3689
- attribute float faceIndex;
3690
-
3691
- varying vec3 vOutputDirection;
3692
-
3693
- // RH coordinate system; PMREM face-indexing convention
3694
- vec3 getDirection( vec2 uv, float face ) {
3695
-
3696
- uv = 2.0 * uv - 1.0;
3697
-
3698
- vec3 direction = vec3( uv, 1.0 );
3699
-
3700
- if ( face == 0.0 ) {
3701
-
3702
- direction = direction.zyx; // ( 1, v, u ) pos x
3703
-
3704
- } else if ( face == 1.0 ) {
3705
-
3706
- direction = direction.xzy;
3707
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3708
-
3709
- } else if ( face == 2.0 ) {
3710
-
3711
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
3712
-
3713
- } else if ( face == 3.0 ) {
3714
-
3715
- direction = direction.zyx;
3716
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
3717
-
3718
- } else if ( face == 4.0 ) {
3719
-
3720
- direction = direction.xzy;
3721
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
3722
-
3723
- } else if ( face == 5.0 ) {
3724
-
3725
- direction.z *= -1.0; // ( u, v, -1 ) neg z
3726
-
3727
- }
3728
-
3729
- return direction;
3730
-
3731
- }
3732
-
3733
- void main() {
3734
-
3735
- vOutputDirection = getDirection( uv, faceIndex );
3736
- gl_Position = vec4( position, 1.0 );
3737
-
3738
- }
3739
- `}function Th(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===303||l===304,h=l===301||l===302;if(c||h){let f=e.get(o);const u=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==u)return t===null&&(t=new Us(i)),f=c?t.fromEquirectangular(o,f):t.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return c&&m&&m.height>0||h&&m&&r(m)?(t===null&&(t=new Us(i)),f=c?t.fromEquirectangular(o):t.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",s),f.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Ah(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&Vn("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function bh(i,e,t,n){const r={},s=new WeakMap;function a(f){const u=f.target;u.index!==null&&e.remove(u.index);for(const _ in u.attributes)e.remove(u.attributes[_]);for(const _ in u.morphAttributes){const v=u.morphAttributes[_];for(let p=0,d=v.length;p<d;p++)e.remove(v[p])}u.removeEventListener("dispose",a),delete r[u.id];const m=s.get(u);m&&(e.remove(m),s.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(f,u){return r[u.id]===!0||(u.addEventListener("dispose",a),r[u.id]=!0,t.memory.geometries++),u}function l(f){const u=f.attributes;for(const _ in u)e.update(u[_],i.ARRAY_BUFFER);const m=f.morphAttributes;for(const _ in m){const v=m[_];for(let p=0,d=v.length;p<d;p++)e.update(v[p],i.ARRAY_BUFFER)}}function c(f){const u=[],m=f.index,_=f.attributes.position;let v=0;if(m!==null){const T=m.array;v=m.version;for(let S=0,A=T.length;S<A;S+=3){const B=T[S+0],R=T[S+1],w=T[S+2];u.push(B,R,R,w,w,B)}}else if(_!==void 0){const T=_.array;v=_.version;for(let S=0,A=T.length/3-1;S<A;S+=3){const B=S+0,R=S+1,w=S+2;u.push(B,R,R,w,w,B)}}else return;const p=new(xa(u)?Aa:Ta)(u,1);p.version=v;const d=s.get(f);d&&e.remove(d),s.set(f,p)}function h(f){const u=s.get(f);if(u){const m=f.index;m!==null&&u.version<m.version&&c(f)}else c(f);return s.get(f)}return{get:o,update:l,getWireframeAttribute:h}}function Rh(i,e,t){let n;function r(u){n=u}let s,a;function o(u){s=u.type,a=u.bytesPerElement}function l(u,m){i.drawElements(n,m,s,u*a),t.update(m,n,1)}function c(u,m,_){_!==0&&(i.drawElementsInstanced(n,m,s,u*a,_),t.update(m,n,_))}function h(u,m,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,u,0,_);let p=0;for(let d=0;d<_;d++)p+=m[d];t.update(p,n,1)}function f(u,m,_,v){if(_===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let d=0;d<u.length;d++)c(u[d]/a,m[d],v[d]);else{p.multiDrawElementsInstancedWEBGL(n,m,0,s,u,0,v,0,_);let d=0;for(let T=0;T<_;T++)d+=m[T];for(let T=0;T<v.length;T++)t.update(d,n,v[T])}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function wh(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function Ch(i,e,t){const n=new WeakMap,r=new Ze;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=h!==void 0?h.length:0;let u=n.get(o);if(u===void 0||u.count!==f){let y=function(){w.dispose(),n.delete(o),o.removeEventListener("dispose",y)};u!==void 0&&u.texture.dispose();const m=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],d=o.morphAttributes.normal||[],T=o.morphAttributes.color||[];let S=0;m===!0&&(S=1),_===!0&&(S=2),v===!0&&(S=3);let A=o.attributes.position.count*S,B=1;A>e.maxTextureSize&&(B=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const R=new Float32Array(A*B*4*f),w=new Ma(R,A,B,f);w.type=1015,w.needsUpdate=!0;const F=S*4;for(let M=0;M<f;M++){const P=p[M],W=d[M],G=T[M],H=A*B*4*M;for(let K=0;K<P.count;K++){const V=K*F;m===!0&&(r.fromBufferAttribute(P,K),R[H+V+0]=r.x,R[H+V+1]=r.y,R[H+V+2]=r.z,R[H+V+3]=0),_===!0&&(r.fromBufferAttribute(W,K),R[H+V+4]=r.x,R[H+V+5]=r.y,R[H+V+6]=r.z,R[H+V+7]=0),v===!0&&(r.fromBufferAttribute(G,K),R[H+V+8]=r.x,R[H+V+9]=r.y,R[H+V+10]=r.z,R[H+V+11]=G.itemSize===4?r.w:1)}}u={count:f,texture:w,size:new Fe(A,B)},n.set(o,u),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let m=0;for(let v=0;v<c.length;v++)m+=c[v];const _=o.morphTargetsRelative?1:1-m;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:s}}function Ph(i,e,t,n){let r=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,f=e.get(l,h);if(r.get(f)!==c&&(e.update(f),r.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const u=l.skeleton;r.get(u)!==c&&(u.update(),r.set(u,c))}return f}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}class Pa extends lt{constructor(e,t,n,r,s,a,o,l,c,h=1026){if(h!==1026&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===1026&&(n=1014),n===void 0&&h===1027&&(n=1020),super(null,r,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:1003,this.minFilter=l!==void 0?l:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const La=new lt,Os=new Pa(1,1),Da=new Ma,Ia=new Sa,Ua=new wa,Gs=[],zs=[],Vs=new Float32Array(16),ks=new Float32Array(9),Hs=new Float32Array(4);function qn(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=Gs[r];if(s===void 0&&(s=new Float32Array(r),Gs[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function ct(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function ht(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function nr(i,e){let t=zs[e];t===void 0&&(t=new Int32Array(e),zs[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Lh(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Dh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ct(t,e))return;i.uniform2fv(this.addr,e),ht(t,e)}}function Ih(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ct(t,e))return;i.uniform3fv(this.addr,e),ht(t,e)}}function Uh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ct(t,e))return;i.uniform4fv(this.addr,e),ht(t,e)}}function Nh(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ct(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),ht(t,e)}else{if(ct(t,n))return;Hs.set(n),i.uniformMatrix2fv(this.addr,!1,Hs),ht(t,n)}}function Fh(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ct(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),ht(t,e)}else{if(ct(t,n))return;ks.set(n),i.uniformMatrix3fv(this.addr,!1,ks),ht(t,n)}}function Bh(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(ct(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),ht(t,e)}else{if(ct(t,n))return;Vs.set(n),i.uniformMatrix4fv(this.addr,!1,Vs),ht(t,n)}}function Oh(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Gh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ct(t,e))return;i.uniform2iv(this.addr,e),ht(t,e)}}function zh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ct(t,e))return;i.uniform3iv(this.addr,e),ht(t,e)}}function Vh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ct(t,e))return;i.uniform4iv(this.addr,e),ht(t,e)}}function kh(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Hh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ct(t,e))return;i.uniform2uiv(this.addr,e),ht(t,e)}}function Wh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ct(t,e))return;i.uniform3uiv(this.addr,e),ht(t,e)}}function Xh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ct(t,e))return;i.uniform4uiv(this.addr,e),ht(t,e)}}function qh(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Os.compareFunction=515,s=Os):s=La,t.setTexture2D(e||s,r)}function Yh(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Ia,r)}function Kh(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Ua,r)}function $h(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Da,r)}function Zh(i){switch(i){case 5126:return Lh;case 35664:return Dh;case 35665:return Ih;case 35666:return Uh;case 35674:return Nh;case 35675:return Fh;case 35676:return Bh;case 5124:case 35670:return Oh;case 35667:case 35671:return Gh;case 35668:case 35672:return zh;case 35669:case 35673:return Vh;case 5125:return kh;case 36294:return Hh;case 36295:return Wh;case 36296:return Xh;case 35678:case 36198:case 36298:case 36306:case 35682:return qh;case 35679:case 36299:case 36307:return Yh;case 35680:case 36300:case 36308:case 36293:return Kh;case 36289:case 36303:case 36311:case 36292:return $h}}function jh(i,e){i.uniform1fv(this.addr,e)}function Jh(i,e){const t=qn(e,this.size,2);i.uniform2fv(this.addr,t)}function Qh(i,e){const t=qn(e,this.size,3);i.uniform3fv(this.addr,t)}function eu(i,e){const t=qn(e,this.size,4);i.uniform4fv(this.addr,t)}function tu(i,e){const t=qn(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function nu(i,e){const t=qn(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function iu(i,e){const t=qn(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function ru(i,e){i.uniform1iv(this.addr,e)}function su(i,e){i.uniform2iv(this.addr,e)}function au(i,e){i.uniform3iv(this.addr,e)}function ou(i,e){i.uniform4iv(this.addr,e)}function lu(i,e){i.uniform1uiv(this.addr,e)}function cu(i,e){i.uniform2uiv(this.addr,e)}function hu(i,e){i.uniform3uiv(this.addr,e)}function uu(i,e){i.uniform4uiv(this.addr,e)}function du(i,e,t){const n=this.cache,r=e.length,s=nr(t,r);ct(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||La,s[a])}function fu(i,e,t){const n=this.cache,r=e.length,s=nr(t,r);ct(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Ia,s[a])}function pu(i,e,t){const n=this.cache,r=e.length,s=nr(t,r);ct(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Ua,s[a])}function mu(i,e,t){const n=this.cache,r=e.length,s=nr(t,r);ct(n,s)||(i.uniform1iv(this.addr,s),ht(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Da,s[a])}function _u(i){switch(i){case 5126:return jh;case 35664:return Jh;case 35665:return Qh;case 35666:return eu;case 35674:return tu;case 35675:return nu;case 35676:return iu;case 5124:case 35670:return ru;case 35667:case 35671:return su;case 35668:case 35672:return au;case 35669:case 35673:return ou;case 5125:return lu;case 36294:return cu;case 36295:return hu;case 36296:return uu;case 35678:case 36198:case 36298:case 36306:case 35682:return du;case 35679:case 36299:case 36307:return fu;case 35680:case 36300:case 36308:case 36293:return pu;case 36289:case 36303:case 36311:case 36292:return mu}}class gu{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Zh(t.type)}}class vu{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=_u(t.type)}}class xu{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Pr=/(\w+)(\])?(\[|\.)?/g;function Ws(i,e){i.seq.push(e),i.map[e.id]=e}function Mu(i,e,t){const n=i.name,r=n.length;for(Pr.lastIndex=0;;){const s=Pr.exec(n),a=Pr.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Ws(t,c===void 0?new gu(o,i,e):new vu(o,i,e));break}else{let f=t.map[o];f===void 0&&(f=new xu(o),Ws(t,f)),t=f}}}class Yi{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);Mu(s,a,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function Xs(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Su=37297;let yu=0;function Eu(i,e){const t=i.split(`
3740
- `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3741
- `)}function Tu(i){const e=ze.getPrimaries(ze.workingColorSpace),t=ze.getPrimaries(i);let n;switch(e===t?n="":e===Zi&&t===$i?n="LinearDisplayP3ToLinearSRGB":e===$i&&t===Zi&&(n="LinearSRGBToLinearDisplayP3"),i){case Jt:case di:return[n,"LinearTransferOETF"];case Dt:case er:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function qs(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
3742
-
3743
- `+r+`
3744
-
3745
- `+Eu(i.getShaderSource(e),a)}else return r}function Au(i,e){const t=Tu(e);return`vec4 ${i}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function bu(i,e){let t;switch(e){case 1:t="Linear";break;case 2:t="Reinhard";break;case 3:t="OptimizedCineon";break;case 4:t="ACESFilmic";break;case 6:t="AgX";break;case 7:t="Neutral";break;case 5:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Gi=new D;function Ru(){ze.getLuminanceCoefficients(Gi);const i=Gi.x.toFixed(4),e=Gi.y.toFixed(4),t=Gi.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3746
- `)}function wu(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(si).join(`
3747
- `)}function Cu(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3748
- `)}function Pu(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function si(i){return i!==""}function Ys(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ks(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Lu=/^[ \t]*#include +<([\w\d./]+)>/gm;function Br(i){return i.replace(Lu,Iu)}const Du=new Map;function Iu(i,e){let t=Ce[e];if(t===void 0){const n=Du.get(e);if(n!==void 0)t=Ce[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Br(t)}const Uu=/#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 $s(i){return i.replace(Uu,Nu)}function Nu(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Zs(i){let e=`precision ${i.precision} float;
3749
- precision ${i.precision} int;
3750
- precision ${i.precision} sampler2D;
3751
- precision ${i.precision} samplerCube;
3752
- precision ${i.precision} sampler3D;
3753
- precision ${i.precision} sampler2DArray;
3754
- precision ${i.precision} sampler2DShadow;
3755
- precision ${i.precision} samplerCubeShadow;
3756
- precision ${i.precision} sampler2DArrayShadow;
3757
- precision ${i.precision} isampler2D;
3758
- precision ${i.precision} isampler3D;
3759
- precision ${i.precision} isamplerCube;
3760
- precision ${i.precision} isampler2DArray;
3761
- precision ${i.precision} usampler2D;
3762
- precision ${i.precision} usampler3D;
3763
- precision ${i.precision} usamplerCube;
3764
- precision ${i.precision} usampler2DArray;
3765
- `;return i.precision==="highp"?e+=`
3766
- #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3767
- #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3768
- #define LOW_PRECISION`),e}function Fu(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===1?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===2?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===3&&(e="SHADOWMAP_TYPE_VSM"),e}function Bu(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case 301:case 302:e="ENVMAP_TYPE_CUBE";break;case 306:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Ou(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case 302:e="ENVMAP_MODE_REFRACTION";break}return e}function Gu(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD";break}return e}function zu(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function Vu(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=Fu(t),c=Bu(t),h=Ou(t),f=Gu(t),u=zu(t),m=wu(t),_=Cu(s),v=r.createProgram();let p,d,T=t.glslVersion?"#version "+t.glslVersion+`
3769
- `:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(si).join(`
3770
- `),p.length>0&&(p+=`
3771
- `),d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(si).join(`
3772
- `),d.length>0&&(d+=`
3773
- `)):(p=[Zs(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",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 "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",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.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3774
- `].filter(si).join(`
3775
- `),d=[Zs(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",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.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==0?"#define TONE_MAPPING":"",t.toneMapping!==0?Ce.tonemapping_pars_fragment:"",t.toneMapping!==0?bu("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ce.colorspace_pars_fragment,Au("linearToOutputTexel",t.outputColorSpace),Ru(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3776
- `].filter(si).join(`
3777
- `)),a=Br(a),a=Ys(a,t),a=Ks(a,t),o=Br(o),o=Ys(o,t),o=Ks(o,t),a=$s(a),o=$s(o),t.isRawShaderMaterial!==!0&&(T=`#version 300 es
3778
- `,p=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3779
- `)+`
3780
- `+p,d=["#define varying in",t.glslVersion===hs?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===hs?"":"#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(`
3781
- `)+`
3782
- `+d);const S=T+p+a,A=T+d+o,B=Xs(r,r.VERTEX_SHADER,S),R=Xs(r,r.FRAGMENT_SHADER,A);r.attachShader(v,B),r.attachShader(v,R),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function w(P){if(i.debug.checkShaderErrors){const W=r.getProgramInfoLog(v).trim(),G=r.getShaderInfoLog(B).trim(),H=r.getShaderInfoLog(R).trim();let K=!0,V=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(K=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,v,B,R);else{const j=qs(r,B,"vertex"),z=qs(r,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3783
-
3784
- Material Name: `+P.name+`
3785
- Material Type: `+P.type+`
3786
-
3787
- Program Info Log: `+W+`
3788
- `+j+`
3789
- `+z)}else W!==""?console.warn("THREE.WebGLProgram: Program Info Log:",W):(G===""||H==="")&&(V=!1);V&&(P.diagnostics={runnable:K,programLog:W,vertexShader:{log:G,prefix:p},fragmentShader:{log:H,prefix:d}})}r.deleteShader(B),r.deleteShader(R),F=new Yi(r,v),y=Pu(r,v)}let F;this.getUniforms=function(){return F===void 0&&w(this),F};let y;this.getAttributes=function(){return y===void 0&&w(this),y};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,Su)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=yu++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=B,this.fragmentShader=R,this}let ku=0;class Hu{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Wu(e),t.set(e,n)),n}}class Wu{constructor(e){this.id=ku++,this.code=e,this.usedTimes=0}}function Xu(i,e,t,n,r,s,a){const o=new ya,l=new Hu,c=new Set,h=[],f=r.logarithmicDepthBuffer,u=r.vertexTextures;let m=r.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(y){return c.add(y),y===0?"uv":`uv${y}`}function p(y,M,P,W,G){const H=W.fog,K=G.geometry,V=y.isMeshStandardMaterial?W.environment:null,j=(y.isMeshStandardMaterial?t:e).get(y.envMap||V),z=j&&j.mapping===306?j.image.height:null,ae=_[y.type];y.precision!==null&&(m=r.getMaxPrecision(y.precision),m!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",m,"instead."));const he=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,me=he!==void 0?he.length:0;let Be=0;K.morphAttributes.position!==void 0&&(Be=1),K.morphAttributes.normal!==void 0&&(Be=2),K.morphAttributes.color!==void 0&&(Be=3);let Ke,k,J,de;if(ae){const Ve=Ft[ae];Ke=Ve.vertexShader,k=Ve.fragmentShader}else Ke=y.vertexShader,k=y.fragmentShader,l.update(y),J=l.getVertexShaderID(y),de=l.getFragmentShaderID(y);const le=i.getRenderTarget(),be=G.isInstancedMesh===!0,Le=G.isBatchedMesh===!0,Ne=!!y.map,Qe=!!y.matcap,b=!!j,it=!!y.aoMap,Xe=!!y.lightMap,$e=!!y.bumpMap,ge=!!y.normalMap,rt=!!y.displacementMap,Te=!!y.emissiveMap,Re=!!y.metalnessMap,E=!!y.roughnessMap,g=y.anisotropy>0,O=y.clearcoat>0,$=y.dispersion>0,Z=y.iridescence>0,Y=y.sheen>0,ve=y.transmission>0,re=g&&!!y.anisotropyMap,ce=O&&!!y.clearcoatMap,we=O&&!!y.clearcoatNormalMap,Q=O&&!!y.clearcoatRoughnessMap,oe=Z&&!!y.iridescenceMap,Oe=Z&&!!y.iridescenceThicknessMap,Ee=Y&&!!y.sheenColorMap,ue=Y&&!!y.sheenRoughnessMap,Ae=!!y.specularMap,De=!!y.specularColorMap,Je=!!y.specularIntensityMap,C=ve&&!!y.transmissionMap,ee=ve&&!!y.thicknessMap,X=!!y.gradientMap,q=!!y.alphaMap,ne=y.alphaTest>0,Me=!!y.alphaHash,Ge=!!y.extensions;let st=0;y.toneMapped&&(le===null||le.isXRRenderTarget===!0)&&(st=i.toneMapping);const dt={shaderID:ae,shaderType:y.type,shaderName:y.name,vertexShader:Ke,fragmentShader:k,defines:y.defines,customVertexShaderID:J,customFragmentShaderID:de,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:m,batching:Le,batchingColor:Le&&G._colorsTexture!==null,instancing:be,instancingColor:be&&G.instanceColor!==null,instancingMorph:be&&G.morphTexture!==null,supportsVertexTextures:u,outputColorSpace:le===null?i.outputColorSpace:le.isXRRenderTarget===!0?le.texture.colorSpace:Jt,alphaToCoverage:!!y.alphaToCoverage,map:Ne,matcap:Qe,envMap:b,envMapMode:b&&j.mapping,envMapCubeUVHeight:z,aoMap:it,lightMap:Xe,bumpMap:$e,normalMap:ge,displacementMap:u&&rt,emissiveMap:Te,normalMapObjectSpace:ge&&y.normalMapType===1,normalMapTangentSpace:ge&&y.normalMapType===0,metalnessMap:Re,roughnessMap:E,anisotropy:g,anisotropyMap:re,clearcoat:O,clearcoatMap:ce,clearcoatNormalMap:we,clearcoatRoughnessMap:Q,dispersion:$,iridescence:Z,iridescenceMap:oe,iridescenceThicknessMap:Oe,sheen:Y,sheenColorMap:Ee,sheenRoughnessMap:ue,specularMap:Ae,specularColorMap:De,specularIntensityMap:Je,transmission:ve,transmissionMap:C,thicknessMap:ee,gradientMap:X,opaque:y.transparent===!1&&y.blending===1&&y.alphaToCoverage===!1,alphaMap:q,alphaTest:ne,alphaHash:Me,combine:y.combine,mapUv:Ne&&v(y.map.channel),aoMapUv:it&&v(y.aoMap.channel),lightMapUv:Xe&&v(y.lightMap.channel),bumpMapUv:$e&&v(y.bumpMap.channel),normalMapUv:ge&&v(y.normalMap.channel),displacementMapUv:rt&&v(y.displacementMap.channel),emissiveMapUv:Te&&v(y.emissiveMap.channel),metalnessMapUv:Re&&v(y.metalnessMap.channel),roughnessMapUv:E&&v(y.roughnessMap.channel),anisotropyMapUv:re&&v(y.anisotropyMap.channel),clearcoatMapUv:ce&&v(y.clearcoatMap.channel),clearcoatNormalMapUv:we&&v(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&v(y.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&v(y.iridescenceMap.channel),iridescenceThicknessMapUv:Oe&&v(y.iridescenceThicknessMap.channel),sheenColorMapUv:Ee&&v(y.sheenColorMap.channel),sheenRoughnessMapUv:ue&&v(y.sheenRoughnessMap.channel),specularMapUv:Ae&&v(y.specularMap.channel),specularColorMapUv:De&&v(y.specularColorMap.channel),specularIntensityMapUv:Je&&v(y.specularIntensityMap.channel),transmissionMapUv:C&&v(y.transmissionMap.channel),thicknessMapUv:ee&&v(y.thicknessMap.channel),alphaMapUv:q&&v(y.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(ge||g),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!K.attributes.uv&&(Ne||q),fog:!!H,useFog:y.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:G.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:Be,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:st,decodeVideoTexture:Ne&&y.map.isVideoTexture===!0&&ze.getTransfer(y.map.colorSpace)===je,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===2,flipSided:y.side===1,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:Ge&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ge&&y.extensions.multiDraw===!0||Le)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return dt.vertexUv1s=c.has(1),dt.vertexUv2s=c.has(2),dt.vertexUv3s=c.has(3),c.clear(),dt}function d(y){const M=[];if(y.shaderID?M.push(y.shaderID):(M.push(y.customVertexShaderID),M.push(y.customFragmentShaderID)),y.defines!==void 0)for(const P in y.defines)M.push(P),M.push(y.defines[P]);return y.isRawShaderMaterial===!1&&(T(M,y),S(M,y),M.push(i.outputColorSpace)),M.push(y.customProgramCacheKey),M.join()}function T(y,M){y.push(M.precision),y.push(M.outputColorSpace),y.push(M.envMapMode),y.push(M.envMapCubeUVHeight),y.push(M.mapUv),y.push(M.alphaMapUv),y.push(M.lightMapUv),y.push(M.aoMapUv),y.push(M.bumpMapUv),y.push(M.normalMapUv),y.push(M.displacementMapUv),y.push(M.emissiveMapUv),y.push(M.metalnessMapUv),y.push(M.roughnessMapUv),y.push(M.anisotropyMapUv),y.push(M.clearcoatMapUv),y.push(M.clearcoatNormalMapUv),y.push(M.clearcoatRoughnessMapUv),y.push(M.iridescenceMapUv),y.push(M.iridescenceThicknessMapUv),y.push(M.sheenColorMapUv),y.push(M.sheenRoughnessMapUv),y.push(M.specularMapUv),y.push(M.specularColorMapUv),y.push(M.specularIntensityMapUv),y.push(M.transmissionMapUv),y.push(M.thicknessMapUv),y.push(M.combine),y.push(M.fogExp2),y.push(M.sizeAttenuation),y.push(M.morphTargetsCount),y.push(M.morphAttributeCount),y.push(M.numDirLights),y.push(M.numPointLights),y.push(M.numSpotLights),y.push(M.numSpotLightMaps),y.push(M.numHemiLights),y.push(M.numRectAreaLights),y.push(M.numDirLightShadows),y.push(M.numPointLightShadows),y.push(M.numSpotLightShadows),y.push(M.numSpotLightShadowsWithMaps),y.push(M.numLightProbes),y.push(M.shadowMapType),y.push(M.toneMapping),y.push(M.numClippingPlanes),y.push(M.numClipIntersection),y.push(M.depthPacking)}function S(y,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),y.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.skinning&&o.enable(4),M.morphTargets&&o.enable(5),M.morphNormals&&o.enable(6),M.morphColors&&o.enable(7),M.premultipliedAlpha&&o.enable(8),M.shadowMapEnabled&&o.enable(9),M.doubleSided&&o.enable(10),M.flipSided&&o.enable(11),M.useDepthPacking&&o.enable(12),M.dithering&&o.enable(13),M.transmission&&o.enable(14),M.sheen&&o.enable(15),M.opaque&&o.enable(16),M.pointsUvs&&o.enable(17),M.decodeVideoTexture&&o.enable(18),M.alphaToCoverage&&o.enable(19),y.push(o.mask)}function A(y){const M=_[y.type];let P;if(M){const W=Ft[M];P=wo.clone(W.uniforms)}else P=y.uniforms;return P}function B(y,M){let P;for(let W=0,G=h.length;W<G;W++){const H=h[W];if(H.cacheKey===M){P=H,++P.usedTimes;break}}return P===void 0&&(P=new Vu(i,M,y,s),h.push(P)),P}function R(y){if(--y.usedTimes===0){const M=h.indexOf(y);h[M]=h[h.length-1],h.pop(),y.destroy()}}function w(y){l.remove(y)}function F(){l.dispose()}return{getParameters:p,getProgramCacheKey:d,getUniforms:A,acquireProgram:B,releaseProgram:R,releaseShaderCache:w,programs:h,dispose:F}}function qu(){let i=new WeakMap;function e(s){let a=i.get(s);return a===void 0&&(a={},i.set(s,a)),a}function t(s){i.delete(s)}function n(s,a,o){i.get(s)[a]=o}function r(){i=new WeakMap}return{get:e,remove:t,update:n,dispose:r}}function Yu(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function js(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Js(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(f,u,m,_,v,p){let d=i[e];return d===void 0?(d={id:f.id,object:f,geometry:u,material:m,groupOrder:_,renderOrder:f.renderOrder,z:v,group:p},i[e]=d):(d.id=f.id,d.object=f,d.geometry=u,d.material=m,d.groupOrder=_,d.renderOrder=f.renderOrder,d.z=v,d.group=p),e++,d}function o(f,u,m,_,v,p){const d=a(f,u,m,_,v,p);m.transmission>0?n.push(d):m.transparent===!0?r.push(d):t.push(d)}function l(f,u,m,_,v,p){const d=a(f,u,m,_,v,p);m.transmission>0?n.unshift(d):m.transparent===!0?r.unshift(d):t.unshift(d)}function c(f,u){t.length>1&&t.sort(f||Yu),n.length>1&&n.sort(u||js),r.length>1&&r.sort(u||js)}function h(){for(let f=e,u=i.length;f<u;f++){const m=i[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function Ku(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new Js,i.set(n,[a])):r>=s.length?(a=new Js,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function $u(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new Ie};break;case"SpotLight":t={position:new D,direction:new D,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function Zu(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let ju=0;function Ju(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Qu(i){const e=new $u,t=Zu(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new D);const r=new D,s=new Ue,a=new Ue;function o(c){let h=0,f=0,u=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let m=0,_=0,v=0,p=0,d=0,T=0,S=0,A=0,B=0,R=0,w=0;c.sort(Ju);for(let y=0,M=c.length;y<M;y++){const P=c[y],W=P.color,G=P.intensity,H=P.distance,K=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)h+=W.r*G,f+=W.g*G,u+=W.b*G;else if(P.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(P.sh.coefficients[V],G);w++}else if(P.isDirectionalLight){const V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const j=P.shadow,z=t.get(P);z.shadowIntensity=j.intensity,z.shadowBias=j.bias,z.shadowNormalBias=j.normalBias,z.shadowRadius=j.radius,z.shadowMapSize=j.mapSize,n.directionalShadow[m]=z,n.directionalShadowMap[m]=K,n.directionalShadowMatrix[m]=P.shadow.matrix,T++}n.directional[m]=V,m++}else if(P.isSpotLight){const V=e.get(P);V.position.setFromMatrixPosition(P.matrixWorld),V.color.copy(W).multiplyScalar(G),V.distance=H,V.coneCos=Math.cos(P.angle),V.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),V.decay=P.decay,n.spot[v]=V;const j=P.shadow;if(P.map&&(n.spotLightMap[B]=P.map,B++,j.updateMatrices(P),P.castShadow&&R++),n.spotLightMatrix[v]=j.matrix,P.castShadow){const z=t.get(P);z.shadowIntensity=j.intensity,z.shadowBias=j.bias,z.shadowNormalBias=j.normalBias,z.shadowRadius=j.radius,z.shadowMapSize=j.mapSize,n.spotShadow[v]=z,n.spotShadowMap[v]=K,A++}v++}else if(P.isRectAreaLight){const V=e.get(P);V.color.copy(W).multiplyScalar(G),V.halfWidth.set(P.width*.5,0,0),V.halfHeight.set(0,P.height*.5,0),n.rectArea[p]=V,p++}else if(P.isPointLight){const V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),V.distance=P.distance,V.decay=P.decay,P.castShadow){const j=P.shadow,z=t.get(P);z.shadowIntensity=j.intensity,z.shadowBias=j.bias,z.shadowNormalBias=j.normalBias,z.shadowRadius=j.radius,z.shadowMapSize=j.mapSize,z.shadowCameraNear=j.camera.near,z.shadowCameraFar=j.camera.far,n.pointShadow[_]=z,n.pointShadowMap[_]=K,n.pointShadowMatrix[_]=P.shadow.matrix,S++}n.point[_]=V,_++}else if(P.isHemisphereLight){const V=e.get(P);V.skyColor.copy(P.color).multiplyScalar(G),V.groundColor.copy(P.groundColor).multiplyScalar(G),n.hemi[d]=V,d++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ie.LTC_FLOAT_1,n.rectAreaLTC2=ie.LTC_FLOAT_2):(n.rectAreaLTC1=ie.LTC_HALF_1,n.rectAreaLTC2=ie.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=f,n.ambient[2]=u;const F=n.hash;(F.directionalLength!==m||F.pointLength!==_||F.spotLength!==v||F.rectAreaLength!==p||F.hemiLength!==d||F.numDirectionalShadows!==T||F.numPointShadows!==S||F.numSpotShadows!==A||F.numSpotMaps!==B||F.numLightProbes!==w)&&(n.directional.length=m,n.spot.length=v,n.rectArea.length=p,n.point.length=_,n.hemi.length=d,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=A+B-R,n.spotLightMap.length=B,n.numSpotLightShadowsWithMaps=R,n.numLightProbes=w,F.directionalLength=m,F.pointLength=_,F.spotLength=v,F.rectAreaLength=p,F.hemiLength=d,F.numDirectionalShadows=T,F.numPointShadows=S,F.numSpotShadows=A,F.numSpotMaps=B,F.numLightProbes=w,n.version=ju++)}function l(c,h){let f=0,u=0,m=0,_=0,v=0;const p=h.matrixWorldInverse;for(let d=0,T=c.length;d<T;d++){const S=c[d];if(S.isDirectionalLight){const A=n.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(p),f++}else if(S.isSpotLight){const A=n.spot[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(p),A.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(p),m++}else if(S.isRectAreaLight){const A=n.rectArea[_];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(p),a.identity(),s.copy(S.matrixWorld),s.premultiply(p),a.extractRotation(s),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),_++}else if(S.isPointLight){const A=n.point[u];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(p),u++}else if(S.isHemisphereLight){const A=n.hemi[v];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(p),v++}}}return{setup:o,setupView:l,state:n}}function Qs(i){const e=new Qu(i),t=[],n=[];function r(h){c.camera=h,t.length=0,n.length=0}function s(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function ed(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new Qs(i),e.set(r,[o])):s>=a.length?(o=new Qs(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}class td extends cn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(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}}class nd extends cn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const id=`void main() {
3790
- gl_Position = vec4( position, 1.0 );
3791
- }`,rd=`uniform sampler2D shadow_pass;
3792
- uniform vec2 resolution;
3793
- uniform float radius;
3794
- #include <packing>
3795
- void main() {
3796
- const float samples = float( VSM_SAMPLES );
3797
- float mean = 0.0;
3798
- float squared_mean = 0.0;
3799
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3800
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3801
- for ( float i = 0.0; i < samples; i ++ ) {
3802
- float uvOffset = uvStart + i * uvStride;
3803
- #ifdef HORIZONTAL_PASS
3804
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3805
- mean += distribution.x;
3806
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3807
- #else
3808
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3809
- mean += depth;
3810
- squared_mean += depth * depth;
3811
- #endif
3812
- }
3813
- mean = mean / samples;
3814
- squared_mean = squared_mean / samples;
3815
- float std_dev = sqrt( squared_mean - mean * mean );
3816
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3817
- }`;function sd(i,e,t){let n=new Hr;const r=new Fe,s=new Fe,a=new Ze,o=new td({depthPacking:3201}),l=new nd,c={},h=t.maxTextureSize,f={0:1,1:0,2:2},u=new jt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:id,fragmentShader:rd}),m=u.clone();m.defines.HORIZONTAL_PASS=1;const _=new zt;_.setAttribute("position",new At(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Tt(_,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let d=this.type;this.render=function(R,w,F){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||R.length===0)return;const y=i.getRenderTarget(),M=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),W=i.state;W.setBlending(0),W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);const G=d!==3&&this.type===3,H=d===3&&this.type!==3;for(let K=0,V=R.length;K<V;K++){const j=R[K],z=j.shadow;if(z===void 0){console.warn("THREE.WebGLShadowMap:",j,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);const ae=z.getFrameExtents();if(r.multiply(ae),s.copy(z.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/ae.x),r.x=s.x*ae.x,z.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/ae.y),r.y=s.y*ae.y,z.mapSize.y=s.y)),z.map===null||G===!0||H===!0){const me=this.type!==3?{minFilter:1003,magFilter:1003}:{};z.map!==null&&z.map.dispose(),z.map=new Mn(r.x,r.y,me),z.map.texture.name=j.name+".shadowMap",z.camera.updateProjectionMatrix()}i.setRenderTarget(z.map),i.clear();const he=z.getViewportCount();for(let me=0;me<he;me++){const Be=z.getViewport(me);a.set(s.x*Be.x,s.y*Be.y,s.x*Be.z,s.y*Be.w),W.viewport(a),z.updateMatrices(j,me),n=z.getFrustum(),A(w,F,z.camera,j,this.type)}z.isPointLightShadow!==!0&&this.type===3&&T(z,F),z.needsUpdate=!1}d=this.type,p.needsUpdate=!1,i.setRenderTarget(y,M,P)};function T(R,w){const F=e.update(v);u.defines.VSM_SAMPLES!==R.blurSamples&&(u.defines.VSM_SAMPLES=R.blurSamples,m.defines.VSM_SAMPLES=R.blurSamples,u.needsUpdate=!0,m.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new Mn(r.x,r.y)),u.uniforms.shadow_pass.value=R.map.texture,u.uniforms.resolution.value=R.mapSize,u.uniforms.radius.value=R.radius,i.setRenderTarget(R.mapPass),i.clear(),i.renderBufferDirect(w,null,F,u,v,null),m.uniforms.shadow_pass.value=R.mapPass.texture,m.uniforms.resolution.value=R.mapSize,m.uniforms.radius.value=R.radius,i.setRenderTarget(R.map),i.clear(),i.renderBufferDirect(w,null,F,m,v,null)}function S(R,w,F,y){let M=null;const P=F.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(P!==void 0)M=P;else if(M=F.isPointLight===!0?l:o,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const W=M.uuid,G=w.uuid;let H=c[W];H===void 0&&(H={},c[W]=H);let K=H[G];K===void 0&&(K=M.clone(),H[G]=K,w.addEventListener("dispose",B)),M=K}if(M.visible=w.visible,M.wireframe=w.wireframe,y===3?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:f[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,F.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const W=i.properties.get(M);W.light=F}return M}function A(R,w,F,y,M){if(R.visible===!1)return;if(R.layers.test(w.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&M===3)&&(!R.frustumCulled||n.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,R.matrixWorld);const G=e.update(R),H=R.material;if(Array.isArray(H)){const K=G.groups;for(let V=0,j=K.length;V<j;V++){const z=K[V],ae=H[z.materialIndex];if(ae&&ae.visible){const he=S(R,ae,y,M);R.onBeforeShadow(i,R,w,F,G,he,z),i.renderBufferDirect(F,null,G,he,R,z),R.onAfterShadow(i,R,w,F,G,he,z)}}}else if(H.visible){const K=S(R,H,y,M);R.onBeforeShadow(i,R,w,F,G,K,null),i.renderBufferDirect(F,null,G,K,R,null),R.onAfterShadow(i,R,w,F,G,K,null)}}const W=R.children;for(let G=0,H=W.length;G<H;G++)A(W[G],w,F,y,M)}function B(R){R.target.removeEventListener("dispose",B);for(const F in c){const y=c[F],M=R.target.uuid;M in y&&(y[M].dispose(),delete y[M])}}}function ad(i){function e(){let C=!1;const ee=new Ze;let X=null;const q=new Ze(0,0,0,0);return{setMask:function(ne){X!==ne&&!C&&(i.colorMask(ne,ne,ne,ne),X=ne)},setLocked:function(ne){C=ne},setClear:function(ne,Me,Ge,st,dt){dt===!0&&(ne*=st,Me*=st,Ge*=st),ee.set(ne,Me,Ge,st),q.equals(ee)===!1&&(i.clearColor(ne,Me,Ge,st),q.copy(ee))},reset:function(){C=!1,X=null,q.set(-1,0,0,0)}}}function t(){let C=!1,ee=null,X=null,q=null;return{setTest:function(ne){ne?de(i.DEPTH_TEST):le(i.DEPTH_TEST)},setMask:function(ne){ee!==ne&&!C&&(i.depthMask(ne),ee=ne)},setFunc:function(ne){if(X!==ne){switch(ne){case 0:i.depthFunc(i.NEVER);break;case 1:i.depthFunc(i.ALWAYS);break;case 2:i.depthFunc(i.LESS);break;case 3:i.depthFunc(i.LEQUAL);break;case 4:i.depthFunc(i.EQUAL);break;case 5:i.depthFunc(i.GEQUAL);break;case 6:i.depthFunc(i.GREATER);break;case 7:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}X=ne}},setLocked:function(ne){C=ne},setClear:function(ne){q!==ne&&(i.clearDepth(ne),q=ne)},reset:function(){C=!1,ee=null,X=null,q=null}}}function n(){let C=!1,ee=null,X=null,q=null,ne=null,Me=null,Ge=null,st=null,dt=null;return{setTest:function(Ve){C||(Ve?de(i.STENCIL_TEST):le(i.STENCIL_TEST))},setMask:function(Ve){ee!==Ve&&!C&&(i.stencilMask(Ve),ee=Ve)},setFunc:function(Ve,kt,Nt){(X!==Ve||q!==kt||ne!==Nt)&&(i.stencilFunc(Ve,kt,Nt),X=Ve,q=kt,ne=Nt)},setOp:function(Ve,kt,Nt){(Me!==Ve||Ge!==kt||st!==Nt)&&(i.stencilOp(Ve,kt,Nt),Me=Ve,Ge=kt,st=Nt)},setLocked:function(Ve){C=Ve},setClear:function(Ve){dt!==Ve&&(i.clearStencil(Ve),dt=Ve)},reset:function(){C=!1,ee=null,X=null,q=null,ne=null,Me=null,Ge=null,st=null,dt=null}}}const r=new e,s=new t,a=new n,o=new WeakMap,l=new WeakMap;let c={},h={},f=new WeakMap,u=[],m=null,_=!1,v=null,p=null,d=null,T=null,S=null,A=null,B=null,R=new Ie(0,0,0),w=0,F=!1,y=null,M=null,P=null,W=null,G=null;const H=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const j=i.getParameter(i.VERSION);j.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(j)[1]),K=V>=1):j.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),K=V>=2);let z=null,ae={};const he=i.getParameter(i.SCISSOR_BOX),me=i.getParameter(i.VIEWPORT),Be=new Ze().fromArray(he),Ke=new Ze().fromArray(me);function k(C,ee,X,q){const ne=new Uint8Array(4),Me=i.createTexture();i.bindTexture(C,Me),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ge=0;Ge<X;Ge++)C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY?i.texImage3D(ee,0,i.RGBA,1,1,q,0,i.RGBA,i.UNSIGNED_BYTE,ne):i.texImage2D(ee+Ge,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ne);return Me}const J={};J[i.TEXTURE_2D]=k(i.TEXTURE_2D,i.TEXTURE_2D,1),J[i.TEXTURE_CUBE_MAP]=k(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),J[i.TEXTURE_2D_ARRAY]=k(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),J[i.TEXTURE_3D]=k(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),de(i.DEPTH_TEST),s.setFunc(3),$e(!1),ge(1),de(i.CULL_FACE),it(0);function de(C){c[C]!==!0&&(i.enable(C),c[C]=!0)}function le(C){c[C]!==!1&&(i.disable(C),c[C]=!1)}function be(C,ee){return h[C]!==ee?(i.bindFramebuffer(C,ee),h[C]=ee,C===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=ee),C===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=ee),!0):!1}function Le(C,ee){let X=u,q=!1;if(C){X=f.get(ee),X===void 0&&(X=[],f.set(ee,X));const ne=C.textures;if(X.length!==ne.length||X[0]!==i.COLOR_ATTACHMENT0){for(let Me=0,Ge=ne.length;Me<Ge;Me++)X[Me]=i.COLOR_ATTACHMENT0+Me;X.length=ne.length,q=!0}}else X[0]!==i.BACK&&(X[0]=i.BACK,q=!0);q&&i.drawBuffers(X)}function Ne(C){return m!==C?(i.useProgram(C),m=C,!0):!1}const Qe={100:i.FUNC_ADD,101:i.FUNC_SUBTRACT,102:i.FUNC_REVERSE_SUBTRACT};Qe[103]=i.MIN,Qe[104]=i.MAX;const b={200:i.ZERO,201:i.ONE,202:i.SRC_COLOR,204:i.SRC_ALPHA,210:i.SRC_ALPHA_SATURATE,208:i.DST_COLOR,206:i.DST_ALPHA,203:i.ONE_MINUS_SRC_COLOR,205:i.ONE_MINUS_SRC_ALPHA,209:i.ONE_MINUS_DST_COLOR,207:i.ONE_MINUS_DST_ALPHA,211:i.CONSTANT_COLOR,212:i.ONE_MINUS_CONSTANT_COLOR,213:i.CONSTANT_ALPHA,214:i.ONE_MINUS_CONSTANT_ALPHA};function it(C,ee,X,q,ne,Me,Ge,st,dt,Ve){if(C===0){_===!0&&(le(i.BLEND),_=!1);return}if(_===!1&&(de(i.BLEND),_=!0),C!==5){if(C!==v||Ve!==F){if((p!==100||S!==100)&&(i.blendEquation(i.FUNC_ADD),p=100,S=100),Ve)switch(C){case 1:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case 2:i.blendFunc(i.ONE,i.ONE);break;case 3:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case 4:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}else switch(C){case 1:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case 2:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case 3:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case 4:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}d=null,T=null,A=null,B=null,R.set(0,0,0),w=0,v=C,F=Ve}return}ne=ne||ee,Me=Me||X,Ge=Ge||q,(ee!==p||ne!==S)&&(i.blendEquationSeparate(Qe[ee],Qe[ne]),p=ee,S=ne),(X!==d||q!==T||Me!==A||Ge!==B)&&(i.blendFuncSeparate(b[X],b[q],b[Me],b[Ge]),d=X,T=q,A=Me,B=Ge),(st.equals(R)===!1||dt!==w)&&(i.blendColor(st.r,st.g,st.b,dt),R.copy(st),w=dt),v=C,F=!1}function Xe(C,ee){C.side===2?le(i.CULL_FACE):de(i.CULL_FACE);let X=C.side===1;ee&&(X=!X),$e(X),C.blending===1&&C.transparent===!1?it(0):it(C.blending,C.blendEquation,C.blendSrc,C.blendDst,C.blendEquationAlpha,C.blendSrcAlpha,C.blendDstAlpha,C.blendColor,C.blendAlpha,C.premultipliedAlpha),s.setFunc(C.depthFunc),s.setTest(C.depthTest),s.setMask(C.depthWrite),r.setMask(C.colorWrite);const q=C.stencilWrite;a.setTest(q),q&&(a.setMask(C.stencilWriteMask),a.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),a.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),Te(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?de(i.SAMPLE_ALPHA_TO_COVERAGE):le(i.SAMPLE_ALPHA_TO_COVERAGE)}function $e(C){y!==C&&(C?i.frontFace(i.CW):i.frontFace(i.CCW),y=C)}function ge(C){C!==0?(de(i.CULL_FACE),C!==M&&(C===1?i.cullFace(i.BACK):C===2?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):le(i.CULL_FACE),M=C}function rt(C){C!==P&&(K&&i.lineWidth(C),P=C)}function Te(C,ee,X){C?(de(i.POLYGON_OFFSET_FILL),(W!==ee||G!==X)&&(i.polygonOffset(ee,X),W=ee,G=X)):le(i.POLYGON_OFFSET_FILL)}function Re(C){C?de(i.SCISSOR_TEST):le(i.SCISSOR_TEST)}function E(C){C===void 0&&(C=i.TEXTURE0+H-1),z!==C&&(i.activeTexture(C),z=C)}function g(C,ee,X){X===void 0&&(z===null?X=i.TEXTURE0+H-1:X=z);let q=ae[X];q===void 0&&(q={type:void 0,texture:void 0},ae[X]=q),(q.type!==C||q.texture!==ee)&&(z!==X&&(i.activeTexture(X),z=X),i.bindTexture(C,ee||J[C]),q.type=C,q.texture=ee)}function O(){const C=ae[z];C!==void 0&&C.type!==void 0&&(i.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function $(){try{i.compressedTexImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Z(){try{i.compressedTexImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Y(){try{i.texSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ve(){try{i.texSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function re(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ce(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function we(){try{i.texStorage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Q(){try{i.texStorage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function oe(){try{i.texImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Oe(){try{i.texImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Ee(C){Be.equals(C)===!1&&(i.scissor(C.x,C.y,C.z,C.w),Be.copy(C))}function ue(C){Ke.equals(C)===!1&&(i.viewport(C.x,C.y,C.z,C.w),Ke.copy(C))}function Ae(C,ee){let X=l.get(ee);X===void 0&&(X=new WeakMap,l.set(ee,X));let q=X.get(C);q===void 0&&(q=i.getUniformBlockIndex(ee,C.name),X.set(C,q))}function De(C,ee){const q=l.get(ee).get(C);o.get(ee)!==q&&(i.uniformBlockBinding(ee,q,C.__bindingPointIndex),o.set(ee,q))}function Je(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},z=null,ae={},h={},f=new WeakMap,u=[],m=null,_=!1,v=null,p=null,d=null,T=null,S=null,A=null,B=null,R=new Ie(0,0,0),w=0,F=!1,y=null,M=null,P=null,W=null,G=null,Be.set(0,0,i.canvas.width,i.canvas.height),Ke.set(0,0,i.canvas.width,i.canvas.height),r.reset(),s.reset(),a.reset()}return{buffers:{color:r,depth:s,stencil:a},enable:de,disable:le,bindFramebuffer:be,drawBuffers:Le,useProgram:Ne,setBlending:it,setMaterial:Xe,setFlipSided:$e,setCullFace:ge,setLineWidth:rt,setPolygonOffset:Te,setScissorTest:Re,activeTexture:E,bindTexture:g,unbindTexture:O,compressedTexImage2D:$,compressedTexImage3D:Z,texImage2D:oe,texImage3D:Oe,updateUBOMapping:Ae,uniformBlockBinding:De,texStorage2D:we,texStorage3D:Q,texSubImage2D:Y,texSubImage3D:ve,compressedTexSubImage2D:re,compressedTexSubImage3D:ce,scissor:Ee,viewport:ue,reset:Je}}function ea(i,e,t,n){const r=od(n);switch(t){case 1021:return i*e;case 1024:return i*e;case 1025:return i*e*2;case 1028:return i*e/r.components*r.byteLength;case 1029:return i*e/r.components*r.byteLength;case 1030:return i*e*2/r.components*r.byteLength;case 1031:return i*e*2/r.components*r.byteLength;case 1022:return i*e*3/r.components*r.byteLength;case 1023:return i*e*4/r.components*r.byteLength;case 1033:return i*e*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case 33778:case 33779:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case 35841:case 35843:return Math.max(i,16)*Math.max(e,8)/4;case 35840:case 35842:return Math.max(i,8)*Math.max(e,8)/2;case 36196:case 37492:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case 37496:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case 37808:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case 37809:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case 37810:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case 37811:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case 37812:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case 37813:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case 37814:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case 37815:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case 37816:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case 37817:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case 37818:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case 37819:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case 37820:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case 37821:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(i/4)*Math.ceil(e/4)*16;case 36283:case 36284:return Math.ceil(i/4)*Math.ceil(e/4)*8;case 36285:case 36286:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function od(i){switch(i){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function ld(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Fe,h=new WeakMap;let f;const u=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(E,g){return m?new OffscreenCanvas(E,g):ci("canvas")}function v(E,g,O){let $=1;const Z=Re(E);if((Z.width>O||Z.height>O)&&($=O/Math.max(Z.width,Z.height)),$<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const Y=Math.floor($*Z.width),ve=Math.floor($*Z.height);f===void 0&&(f=_(Y,ve));const re=g?_(Y,ve):f;return re.width=Y,re.height=ve,re.getContext("2d").drawImage(E,0,0,Y,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+Y+"x"+ve+")."),re}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),E;return E}function p(E){return E.generateMipmaps&&E.minFilter!==1003&&E.minFilter!==1006}function d(E){i.generateMipmap(E)}function T(E,g,O,$,Z=!1){if(E!==null){if(i[E]!==void 0)return i[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let Y=g;if(g===i.RED&&(O===i.FLOAT&&(Y=i.R32F),O===i.HALF_FLOAT&&(Y=i.R16F),O===i.UNSIGNED_BYTE&&(Y=i.R8)),g===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.R8UI),O===i.UNSIGNED_SHORT&&(Y=i.R16UI),O===i.UNSIGNED_INT&&(Y=i.R32UI),O===i.BYTE&&(Y=i.R8I),O===i.SHORT&&(Y=i.R16I),O===i.INT&&(Y=i.R32I)),g===i.RG&&(O===i.FLOAT&&(Y=i.RG32F),O===i.HALF_FLOAT&&(Y=i.RG16F),O===i.UNSIGNED_BYTE&&(Y=i.RG8)),g===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RG8UI),O===i.UNSIGNED_SHORT&&(Y=i.RG16UI),O===i.UNSIGNED_INT&&(Y=i.RG32UI),O===i.BYTE&&(Y=i.RG8I),O===i.SHORT&&(Y=i.RG16I),O===i.INT&&(Y=i.RG32I)),g===i.RGB&&O===i.UNSIGNED_INT_5_9_9_9_REV&&(Y=i.RGB9_E5),g===i.RGBA){const ve=Z?Ki:ze.getTransfer($);O===i.FLOAT&&(Y=i.RGBA32F),O===i.HALF_FLOAT&&(Y=i.RGBA16F),O===i.UNSIGNED_BYTE&&(Y=ve===je?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT_4_4_4_4&&(Y=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(Y=i.RGB5_A1)}return(Y===i.R16F||Y===i.R32F||Y===i.RG16F||Y===i.RG32F||Y===i.RGBA16F||Y===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function S(E,g){let O;return E?g===null||g===1014||g===1020?O=i.DEPTH24_STENCIL8:g===1015?O=i.DEPTH32F_STENCIL8:g===1012&&(O=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===1014||g===1020?O=i.DEPTH_COMPONENT24:g===1015?O=i.DEPTH_COMPONENT32F:g===1012&&(O=i.DEPTH_COMPONENT16),O}function A(E,g){return p(E)===!0||E.isFramebufferTexture&&E.minFilter!==1003&&E.minFilter!==1006?Math.log2(Math.max(g.width,g.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?g.mipmaps.length:1}function B(E){const g=E.target;g.removeEventListener("dispose",B),w(g),g.isVideoTexture&&h.delete(g)}function R(E){const g=E.target;g.removeEventListener("dispose",R),y(g)}function w(E){const g=n.get(E);if(g.__webglInit===void 0)return;const O=E.source,$=u.get(O);if($){const Z=$[g.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&F(E),Object.keys($).length===0&&u.delete(O)}n.remove(E)}function F(E){const g=n.get(E);i.deleteTexture(g.__webglTexture);const O=E.source,$=u.get(O);delete $[g.__cacheKey],a.memory.textures--}function y(E){const g=n.get(E);if(E.depthTexture&&E.depthTexture.dispose(),E.isWebGLCubeRenderTarget)for(let $=0;$<6;$++){if(Array.isArray(g.__webglFramebuffer[$]))for(let Z=0;Z<g.__webglFramebuffer[$].length;Z++)i.deleteFramebuffer(g.__webglFramebuffer[$][Z]);else i.deleteFramebuffer(g.__webglFramebuffer[$]);g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer[$])}else{if(Array.isArray(g.__webglFramebuffer))for(let $=0;$<g.__webglFramebuffer.length;$++)i.deleteFramebuffer(g.__webglFramebuffer[$]);else i.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&i.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let $=0;$<g.__webglColorRenderbuffer.length;$++)g.__webglColorRenderbuffer[$]&&i.deleteRenderbuffer(g.__webglColorRenderbuffer[$]);g.__webglDepthRenderbuffer&&i.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const O=E.textures;for(let $=0,Z=O.length;$<Z;$++){const Y=n.get(O[$]);Y.__webglTexture&&(i.deleteTexture(Y.__webglTexture),a.memory.textures--),n.remove(O[$])}n.remove(E)}let M=0;function P(){M=0}function W(){const E=M;return E>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),M+=1,E}function G(E){const g=[];return g.push(E.wrapS),g.push(E.wrapT),g.push(E.wrapR||0),g.push(E.magFilter),g.push(E.minFilter),g.push(E.anisotropy),g.push(E.internalFormat),g.push(E.format),g.push(E.type),g.push(E.generateMipmaps),g.push(E.premultiplyAlpha),g.push(E.flipY),g.push(E.unpackAlignment),g.push(E.colorSpace),g.join()}function H(E,g){const O=n.get(E);if(E.isVideoTexture&&rt(E),E.isRenderTargetTexture===!1&&E.version>0&&O.__version!==E.version){const $=E.image;if($===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if($.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ke(O,E,g);return}}t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+g)}function K(E,g){const O=n.get(E);if(E.version>0&&O.__version!==E.version){Ke(O,E,g);return}t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+g)}function V(E,g){const O=n.get(E);if(E.version>0&&O.__version!==E.version){Ke(O,E,g);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+g)}function j(E,g){const O=n.get(E);if(E.version>0&&O.__version!==E.version){k(O,E,g);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+g)}const z={1e3:i.REPEAT,1001:i.CLAMP_TO_EDGE,1002:i.MIRRORED_REPEAT},ae={1003:i.NEAREST,1004:i.NEAREST_MIPMAP_NEAREST,1005:i.NEAREST_MIPMAP_LINEAR,1006:i.LINEAR,1007:i.LINEAR_MIPMAP_NEAREST,1008:i.LINEAR_MIPMAP_LINEAR},he={512:i.NEVER,519:i.ALWAYS,513:i.LESS,515:i.LEQUAL,514:i.EQUAL,518:i.GEQUAL,516:i.GREATER,517:i.NOTEQUAL};function me(E,g){if(g.type===1015&&e.has("OES_texture_float_linear")===!1&&(g.magFilter===1006||g.magFilter===1007||g.magFilter===1005||g.magFilter===1008||g.minFilter===1006||g.minFilter===1007||g.minFilter===1005||g.minFilter===1008)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,z[g.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,z[g.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,z[g.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,ae[g.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,ae[g.minFilter]),g.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,he[g.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===1003||g.minFilter!==1005&&g.minFilter!==1008||g.type===1015&&e.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,r.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function Be(E,g){let O=!1;E.__webglInit===void 0&&(E.__webglInit=!0,g.addEventListener("dispose",B));const $=g.source;let Z=u.get($);Z===void 0&&(Z={},u.set($,Z));const Y=G(g);if(Y!==E.__cacheKey){Z[Y]===void 0&&(Z[Y]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Z[Y].usedTimes++;const ve=Z[E.__cacheKey];ve!==void 0&&(Z[E.__cacheKey].usedTimes--,ve.usedTimes===0&&F(g)),E.__cacheKey=Y,E.__webglTexture=Z[Y].texture}return O}function Ke(E,g,O){let $=i.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&($=i.TEXTURE_2D_ARRAY),g.isData3DTexture&&($=i.TEXTURE_3D);const Z=Be(E,g),Y=g.source;t.bindTexture($,E.__webglTexture,i.TEXTURE0+O);const ve=n.get(Y);if(Y.version!==ve.__version||Z===!0){t.activeTexture(i.TEXTURE0+O);const re=ze.getPrimaries(ze.workingColorSpace),ce=g.colorSpace===$t?null:ze.getPrimaries(g.colorSpace),we=g.colorSpace===$t||re===ce?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,we);let Q=v(g.image,!1,r.maxTextureSize);Q=Te(g,Q);const oe=s.convert(g.format,g.colorSpace),Oe=s.convert(g.type);let Ee=T(g.internalFormat,oe,Oe,g.colorSpace,g.isVideoTexture);me($,g);let ue;const Ae=g.mipmaps,De=g.isVideoTexture!==!0,Je=ve.__version===void 0||Z===!0,C=Y.dataReady,ee=A(g,Q);if(g.isDepthTexture)Ee=S(g.format===1027,g.type),Je&&(De?t.texStorage2D(i.TEXTURE_2D,1,Ee,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,Ee,Q.width,Q.height,0,oe,Oe,null));else if(g.isDataTexture)if(Ae.length>0){De&&Je&&t.texStorage2D(i.TEXTURE_2D,ee,Ee,Ae[0].width,Ae[0].height);for(let X=0,q=Ae.length;X<q;X++)ue=Ae[X],De?C&&t.texSubImage2D(i.TEXTURE_2D,X,0,0,ue.width,ue.height,oe,Oe,ue.data):t.texImage2D(i.TEXTURE_2D,X,Ee,ue.width,ue.height,0,oe,Oe,ue.data);g.generateMipmaps=!1}else De?(Je&&t.texStorage2D(i.TEXTURE_2D,ee,Ee,Q.width,Q.height),C&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Q.width,Q.height,oe,Oe,Q.data)):t.texImage2D(i.TEXTURE_2D,0,Ee,Q.width,Q.height,0,oe,Oe,Q.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){De&&Je&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ee,Ee,Ae[0].width,Ae[0].height,Q.depth);for(let X=0,q=Ae.length;X<q;X++)if(ue=Ae[X],g.format!==1023)if(oe!==null)if(De){if(C)if(g.layerUpdates.size>0){const ne=ea(ue.width,ue.height,g.format,g.type);for(const Me of g.layerUpdates){const Ge=ue.data.subarray(Me*ne/ue.data.BYTES_PER_ELEMENT,(Me+1)*ne/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,X,0,0,Me,ue.width,ue.height,1,oe,Ge,0,0)}g.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,X,0,0,0,ue.width,ue.height,Q.depth,oe,ue.data,0,0)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,X,Ee,ue.width,ue.height,Q.depth,0,ue.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else De?C&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,X,0,0,0,ue.width,ue.height,Q.depth,oe,Oe,ue.data):t.texImage3D(i.TEXTURE_2D_ARRAY,X,Ee,ue.width,ue.height,Q.depth,0,oe,Oe,ue.data)}else{De&&Je&&t.texStorage2D(i.TEXTURE_2D,ee,Ee,Ae[0].width,Ae[0].height);for(let X=0,q=Ae.length;X<q;X++)ue=Ae[X],g.format!==1023?oe!==null?De?C&&t.compressedTexSubImage2D(i.TEXTURE_2D,X,0,0,ue.width,ue.height,oe,ue.data):t.compressedTexImage2D(i.TEXTURE_2D,X,Ee,ue.width,ue.height,0,ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):De?C&&t.texSubImage2D(i.TEXTURE_2D,X,0,0,ue.width,ue.height,oe,Oe,ue.data):t.texImage2D(i.TEXTURE_2D,X,Ee,ue.width,ue.height,0,oe,Oe,ue.data)}else if(g.isDataArrayTexture)if(De){if(Je&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ee,Ee,Q.width,Q.height,Q.depth),C)if(g.layerUpdates.size>0){const X=ea(Q.width,Q.height,g.format,g.type);for(const q of g.layerUpdates){const ne=Q.data.subarray(q*X/Q.data.BYTES_PER_ELEMENT,(q+1)*X/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,q,Q.width,Q.height,1,oe,Oe,ne)}g.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,oe,Oe,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Ee,Q.width,Q.height,Q.depth,0,oe,Oe,Q.data);else if(g.isData3DTexture)De?(Je&&t.texStorage3D(i.TEXTURE_3D,ee,Ee,Q.width,Q.height,Q.depth),C&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,oe,Oe,Q.data)):t.texImage3D(i.TEXTURE_3D,0,Ee,Q.width,Q.height,Q.depth,0,oe,Oe,Q.data);else if(g.isFramebufferTexture){if(Je)if(De)t.texStorage2D(i.TEXTURE_2D,ee,Ee,Q.width,Q.height);else{let X=Q.width,q=Q.height;for(let ne=0;ne<ee;ne++)t.texImage2D(i.TEXTURE_2D,ne,Ee,X,q,0,oe,Oe,null),X>>=1,q>>=1}}else if(Ae.length>0){if(De&&Je){const X=Re(Ae[0]);t.texStorage2D(i.TEXTURE_2D,ee,Ee,X.width,X.height)}for(let X=0,q=Ae.length;X<q;X++)ue=Ae[X],De?C&&t.texSubImage2D(i.TEXTURE_2D,X,0,0,oe,Oe,ue):t.texImage2D(i.TEXTURE_2D,X,Ee,oe,Oe,ue);g.generateMipmaps=!1}else if(De){if(Je){const X=Re(Q);t.texStorage2D(i.TEXTURE_2D,ee,Ee,X.width,X.height)}C&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,oe,Oe,Q)}else t.texImage2D(i.TEXTURE_2D,0,Ee,oe,Oe,Q);p(g)&&d($),ve.__version=Y.version,g.onUpdate&&g.onUpdate(g)}E.__version=g.version}function k(E,g,O){if(g.image.length!==6)return;const $=Be(E,g),Z=g.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+O);const Y=n.get(Z);if(Z.version!==Y.__version||$===!0){t.activeTexture(i.TEXTURE0+O);const ve=ze.getPrimaries(ze.workingColorSpace),re=g.colorSpace===$t?null:ze.getPrimaries(g.colorSpace),ce=g.colorSpace===$t||ve===re?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ce);const we=g.isCompressedTexture||g.image[0].isCompressedTexture,Q=g.image[0]&&g.image[0].isDataTexture,oe=[];for(let q=0;q<6;q++)!we&&!Q?oe[q]=v(g.image[q],!0,r.maxCubemapSize):oe[q]=Q?g.image[q].image:g.image[q],oe[q]=Te(g,oe[q]);const Oe=oe[0],Ee=s.convert(g.format,g.colorSpace),ue=s.convert(g.type),Ae=T(g.internalFormat,Ee,ue,g.colorSpace),De=g.isVideoTexture!==!0,Je=Y.__version===void 0||$===!0,C=Z.dataReady;let ee=A(g,Oe);me(i.TEXTURE_CUBE_MAP,g);let X;if(we){De&&Je&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,Ae,Oe.width,Oe.height);for(let q=0;q<6;q++){X=oe[q].mipmaps;for(let ne=0;ne<X.length;ne++){const Me=X[ne];g.format!==1023?Ee!==null?De?C&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne,0,0,Me.width,Me.height,Ee,Me.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne,Ae,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):De?C&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne,0,0,Me.width,Me.height,Ee,ue,Me.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne,Ae,Me.width,Me.height,0,Ee,ue,Me.data)}}}else{if(X=g.mipmaps,De&&Je){X.length>0&&ee++;const q=Re(oe[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,Ae,q.width,q.height)}for(let q=0;q<6;q++)if(Q){De?C&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,oe[q].width,oe[q].height,Ee,ue,oe[q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Ae,oe[q].width,oe[q].height,0,Ee,ue,oe[q].data);for(let ne=0;ne<X.length;ne++){const Ge=X[ne].image[q].image;De?C&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne+1,0,0,Ge.width,Ge.height,Ee,ue,Ge.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne+1,Ae,Ge.width,Ge.height,0,Ee,ue,Ge.data)}}else{De?C&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,Ee,ue,oe[q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Ae,Ee,ue,oe[q]);for(let ne=0;ne<X.length;ne++){const Me=X[ne];De?C&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne+1,0,0,Ee,ue,Me.image[q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,ne+1,Ae,Ee,ue,Me.image[q])}}}p(g)&&d(i.TEXTURE_CUBE_MAP),Y.__version=Z.version,g.onUpdate&&g.onUpdate(g)}E.__version=g.version}function J(E,g,O,$,Z,Y){const ve=s.convert(O.format,O.colorSpace),re=s.convert(O.type),ce=T(O.internalFormat,ve,re,O.colorSpace);if(!n.get(g).__hasExternalTextures){const Q=Math.max(1,g.width>>Y),oe=Math.max(1,g.height>>Y);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?t.texImage3D(Z,Y,ce,Q,oe,g.depth,0,ve,re,null):t.texImage2D(Z,Y,ce,Q,oe,0,ve,re,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),ge(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,$,Z,n.get(O).__webglTexture,0,$e(g)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,$,Z,n.get(O).__webglTexture,Y),t.bindFramebuffer(i.FRAMEBUFFER,null)}function de(E,g,O){if(i.bindRenderbuffer(i.RENDERBUFFER,E),g.depthBuffer){const $=g.depthTexture,Z=$&&$.isDepthTexture?$.type:null,Y=S(g.stencilBuffer,Z),ve=g.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,re=$e(g);ge(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,re,Y,g.width,g.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,re,Y,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,Y,g.width,g.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ve,i.RENDERBUFFER,E)}else{const $=g.textures;for(let Z=0;Z<$.length;Z++){const Y=$[Z],ve=s.convert(Y.format,Y.colorSpace),re=s.convert(Y.type),ce=T(Y.internalFormat,ve,re,Y.colorSpace),we=$e(g);O&&ge(g)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,we,ce,g.width,g.height):ge(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,we,ce,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,ce,g.width,g.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function le(E,g){if(g&&g.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(g.depthTexture).__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),H(g.depthTexture,0);const $=n.get(g.depthTexture).__webglTexture,Z=$e(g);if(g.depthTexture.format===1026)ge(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0);else if(g.depthTexture.format===1027)ge(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0);else throw new Error("Unknown depthTexture format")}function be(E){const g=n.get(E),O=E.isWebGLCubeRenderTarget===!0;if(E.depthTexture&&!g.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");le(g.__webglFramebuffer,E)}else if(O){g.__webglDepthbuffer=[];for(let $=0;$<6;$++)t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[$]),g.__webglDepthbuffer[$]=i.createRenderbuffer(),de(g.__webglDepthbuffer[$],E,!1)}else t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer=i.createRenderbuffer(),de(g.__webglDepthbuffer,E,!1);t.bindFramebuffer(i.FRAMEBUFFER,null)}function Le(E,g,O){const $=n.get(E);g!==void 0&&J($.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&be(E)}function Ne(E){const g=E.texture,O=n.get(E),$=n.get(g);E.addEventListener("dispose",R);const Z=E.textures,Y=E.isWebGLCubeRenderTarget===!0,ve=Z.length>1;if(ve||($.__webglTexture===void 0&&($.__webglTexture=i.createTexture()),$.__version=g.version,a.memory.textures++),Y){O.__webglFramebuffer=[];for(let re=0;re<6;re++)if(g.mipmaps&&g.mipmaps.length>0){O.__webglFramebuffer[re]=[];for(let ce=0;ce<g.mipmaps.length;ce++)O.__webglFramebuffer[re][ce]=i.createFramebuffer()}else O.__webglFramebuffer[re]=i.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){O.__webglFramebuffer=[];for(let re=0;re<g.mipmaps.length;re++)O.__webglFramebuffer[re]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ve)for(let re=0,ce=Z.length;re<ce;re++){const we=n.get(Z[re]);we.__webglTexture===void 0&&(we.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&ge(E)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let re=0;re<Z.length;re++){const ce=Z[re];O.__webglColorRenderbuffer[re]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[re]);const we=s.convert(ce.format,ce.colorSpace),Q=s.convert(ce.type),oe=T(ce.internalFormat,we,Q,ce.colorSpace,E.isXRRenderTarget===!0),Oe=$e(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,Oe,oe,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+re,i.RENDERBUFFER,O.__webglColorRenderbuffer[re])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),de(O.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Y){t.bindTexture(i.TEXTURE_CUBE_MAP,$.__webglTexture),me(i.TEXTURE_CUBE_MAP,g);for(let re=0;re<6;re++)if(g.mipmaps&&g.mipmaps.length>0)for(let ce=0;ce<g.mipmaps.length;ce++)J(O.__webglFramebuffer[re][ce],E,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ce);else J(O.__webglFramebuffer[re],E,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+re,0);p(g)&&d(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ve){for(let re=0,ce=Z.length;re<ce;re++){const we=Z[re],Q=n.get(we);t.bindTexture(i.TEXTURE_2D,Q.__webglTexture),me(i.TEXTURE_2D,we),J(O.__webglFramebuffer,E,we,i.COLOR_ATTACHMENT0+re,i.TEXTURE_2D,0),p(we)&&d(i.TEXTURE_2D)}t.unbindTexture()}else{let re=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(re=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(re,$.__webglTexture),me(re,g),g.mipmaps&&g.mipmaps.length>0)for(let ce=0;ce<g.mipmaps.length;ce++)J(O.__webglFramebuffer[ce],E,g,i.COLOR_ATTACHMENT0,re,ce);else J(O.__webglFramebuffer,E,g,i.COLOR_ATTACHMENT0,re,0);p(g)&&d(re),t.unbindTexture()}E.depthBuffer&&be(E)}function Qe(E){const g=E.textures;for(let O=0,$=g.length;O<$;O++){const Z=g[O];if(p(Z)){const Y=E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,ve=n.get(Z).__webglTexture;t.bindTexture(Y,ve),d(Y),t.unbindTexture()}}}const b=[],it=[];function Xe(E){if(E.samples>0){if(ge(E)===!1){const g=E.textures,O=E.width,$=E.height;let Z=i.COLOR_BUFFER_BIT;const Y=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ve=n.get(E),re=g.length>1;if(re)for(let ce=0;ce<g.length;ce++)t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let ce=0;ce<g.length;ce++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),re){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ve.__webglColorRenderbuffer[ce]);const we=n.get(g[ce]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,we,0)}i.blitFramebuffer(0,0,O,$,0,0,O,$,Z,i.NEAREST),l===!0&&(b.length=0,it.length=0,b.push(i.COLOR_ATTACHMENT0+ce),E.depthBuffer&&E.resolveDepthBuffer===!1&&(b.push(Y),it.push(Y),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,it)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,b))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),re)for(let ce=0;ce<g.length;ce++){t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,ve.__webglColorRenderbuffer[ce]);const we=n.get(g[ce]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,we,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){const g=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[g])}}}function $e(E){return Math.min(r.maxSamples,E.samples)}function ge(E){const g=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function rt(E){const g=a.render.frame;h.get(E)!==g&&(h.set(E,g),E.update())}function Te(E,g){const O=E.colorSpace,$=E.format,Z=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||O!==Jt&&O!==$t&&(ze.getTransfer(O)===je?($!==1023||Z!==1009)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),g}function Re(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(c.width=E.naturalWidth||E.width,c.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(c.width=E.displayWidth,c.height=E.displayHeight):(c.width=E.width,c.height=E.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=P,this.setTexture2D=H,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=j,this.rebindTextures=Le,this.setupRenderTarget=Ne,this.updateRenderTargetMipmap=Qe,this.updateMultisampleRenderTarget=Xe,this.setupDepthRenderbuffer=be,this.setupFrameBufferTexture=J,this.useMultisampledRTT=ge}function cd(i,e){function t(n,r=$t){let s;const a=ze.getTransfer(r);if(n===1009)return i.UNSIGNED_BYTE;if(n===1017)return i.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return i.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===1010)return i.BYTE;if(n===1011)return i.SHORT;if(n===1012)return i.UNSIGNED_SHORT;if(n===1013)return i.INT;if(n===1014)return i.UNSIGNED_INT;if(n===1015)return i.FLOAT;if(n===1016)return i.HALF_FLOAT;if(n===1021)return i.ALPHA;if(n===1022)return i.RGB;if(n===1023)return i.RGBA;if(n===1024)return i.LUMINANCE;if(n===1025)return i.LUMINANCE_ALPHA;if(n===1026)return i.DEPTH_COMPONENT;if(n===1027)return i.DEPTH_STENCIL;if(n===1028)return i.RED;if(n===1029)return i.RED_INTEGER;if(n===1030)return i.RG;if(n===1031)return i.RG_INTEGER;if(n===1033)return i.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===je)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===33776)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===33776)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===35840)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===36196||n===37492)return a===je?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===37496)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===37808)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===je?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===36492)return a===je?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===36492)return s.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}class hd extends xt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class ai extends nt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ud={type:"move"};class Lr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ai,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ai,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ai,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const p=t.getJointPose(v,n),d=this._getHandJoint(c,v);p!==null&&(d.matrix.fromArray(p.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=p.radius),d.visible=p!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],u=h.position.distanceTo(f.position),m=.02,_=.005;c.inputState.pinching&&u>m+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=m-_&&(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),l.matrixWorldNeedsUpdate=!0,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));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(ud)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ai;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const dd=`
3818
- void main() {
3819
-
3820
- gl_Position = vec4( position, 1.0 );
3821
-
3822
- }`,fd=`
3823
- uniform sampler2DArray depthColor;
3824
- uniform float depthWidth;
3825
- uniform float depthHeight;
3826
-
3827
- void main() {
3828
-
3829
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3830
-
3831
- if ( coord.x >= 1.0 ) {
3832
-
3833
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3834
-
3835
- } else {
3836
-
3837
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3838
-
3839
- }
3840
-
3841
- }`;class pd{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new lt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new jt({vertexShader:dd,fragmentShader:fd,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Tt(new pi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class md extends Xn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,f=null,u=null,m=null,_=null;const v=new pd,p=t.getContextAttributes();let d=null,T=null;const S=[],A=[],B=new Fe;let R=null;const w=new xt;w.layers.enable(1),w.viewport=new Ze;const F=new xt;F.layers.enable(2),F.viewport=new Ze;const y=[w,F],M=new hd;M.layers.enable(1),M.layers.enable(2);let P=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(k){let J=S[k];return J===void 0&&(J=new Lr,S[k]=J),J.getTargetRaySpace()},this.getControllerGrip=function(k){let J=S[k];return J===void 0&&(J=new Lr,S[k]=J),J.getGripSpace()},this.getHand=function(k){let J=S[k];return J===void 0&&(J=new Lr,S[k]=J),J.getHandSpace()};function G(k){const J=A.indexOf(k.inputSource);if(J===-1)return;const de=S[J];de!==void 0&&(de.update(k.inputSource,k.frame,c||a),de.dispatchEvent({type:k.type,data:k.inputSource}))}function H(){r.removeEventListener("select",G),r.removeEventListener("selectstart",G),r.removeEventListener("selectend",G),r.removeEventListener("squeeze",G),r.removeEventListener("squeezestart",G),r.removeEventListener("squeezeend",G),r.removeEventListener("end",H),r.removeEventListener("inputsourceschange",K);for(let k=0;k<S.length;k++){const J=A[k];J!==null&&(A[k]=null,S[k].disconnect(J))}P=null,W=null,v.reset(),e.setRenderTarget(d),m=null,u=null,f=null,r=null,T=null,Ke.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(B.width,B.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(k){s=k,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(k){o=k,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(k){c=k},this.getBaseLayer=function(){return u!==null?u:m},this.getBinding=function(){return f},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(k){if(r=k,r!==null){if(d=e.getRenderTarget(),r.addEventListener("select",G),r.addEventListener("selectstart",G),r.addEventListener("selectend",G),r.addEventListener("squeeze",G),r.addEventListener("squeezestart",G),r.addEventListener("squeezeend",G),r.addEventListener("end",H),r.addEventListener("inputsourceschange",K),p.xrCompatible!==!0&&await t.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(B),r.renderState.layers===void 0){const J={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,J),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new Mn(m.framebufferWidth,m.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil})}else{let J=null,de=null,le=null;p.depth&&(le=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,J=p.stencil?1027:1026,de=p.stencil?1020:1014);const be={colorFormat:t.RGBA8,depthFormat:le,scaleFactor:s};f=new XRWebGLBinding(r,t),u=f.createProjectionLayer(be),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),T=new Mn(u.textureWidth,u.textureHeight,{format:1023,type:1009,depthTexture:new Pa(u.textureWidth,u.textureHeight,de,void 0,void 0,void 0,void 0,void 0,void 0,J),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Ke.setContext(r),Ke.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function K(k){for(let J=0;J<k.removed.length;J++){const de=k.removed[J],le=A.indexOf(de);le>=0&&(A[le]=null,S[le].disconnect(de))}for(let J=0;J<k.added.length;J++){const de=k.added[J];let le=A.indexOf(de);if(le===-1){for(let Le=0;Le<S.length;Le++)if(Le>=A.length){A.push(de),le=Le;break}else if(A[Le]===null){A[Le]=de,le=Le;break}if(le===-1)break}const be=S[le];be&&be.connect(de)}}const V=new D,j=new D;function z(k,J,de){V.setFromMatrixPosition(J.matrixWorld),j.setFromMatrixPosition(de.matrixWorld);const le=V.distanceTo(j),be=J.projectionMatrix.elements,Le=de.projectionMatrix.elements,Ne=be[14]/(be[10]-1),Qe=be[14]/(be[10]+1),b=(be[9]+1)/be[5],it=(be[9]-1)/be[5],Xe=(be[8]-1)/be[0],$e=(Le[8]+1)/Le[0],ge=Ne*Xe,rt=Ne*$e,Te=le/(-Xe+$e),Re=Te*-Xe;J.matrixWorld.decompose(k.position,k.quaternion,k.scale),k.translateX(Re),k.translateZ(Te),k.matrixWorld.compose(k.position,k.quaternion,k.scale),k.matrixWorldInverse.copy(k.matrixWorld).invert();const E=Ne+Te,g=Qe+Te,O=ge-Re,$=rt+(le-Re),Z=b*Qe/g*E,Y=it*Qe/g*E;k.projectionMatrix.makePerspective(O,$,Z,Y,E,g),k.projectionMatrixInverse.copy(k.projectionMatrix).invert()}function ae(k,J){J===null?k.matrixWorld.copy(k.matrix):k.matrixWorld.multiplyMatrices(J.matrixWorld,k.matrix),k.matrixWorldInverse.copy(k.matrixWorld).invert()}this.updateCamera=function(k){if(r===null)return;v.texture!==null&&(k.near=v.depthNear,k.far=v.depthFar),M.near=F.near=w.near=k.near,M.far=F.far=w.far=k.far,(P!==M.near||W!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),P=M.near,W=M.far,w.near=P,w.far=W,F.near=P,F.far=W,w.updateProjectionMatrix(),F.updateProjectionMatrix(),k.updateProjectionMatrix());const J=k.parent,de=M.cameras;ae(M,J);for(let le=0;le<de.length;le++)ae(de[le],J);de.length===2?z(M,w,F):M.projectionMatrix.copy(w.projectionMatrix),he(k,M,J)};function he(k,J,de){de===null?k.matrix.copy(J.matrixWorld):(k.matrix.copy(de.matrixWorld),k.matrix.invert(),k.matrix.multiply(J.matrixWorld)),k.matrix.decompose(k.position,k.quaternion,k.scale),k.updateMatrixWorld(!0),k.projectionMatrix.copy(J.projectionMatrix),k.projectionMatrixInverse.copy(J.projectionMatrixInverse),k.isPerspectiveCamera&&(k.fov=Hn*2*Math.atan(1/k.projectionMatrix.elements[5]),k.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(u===null&&m===null))return l},this.setFoveation=function(k){l=k,u!==null&&(u.fixedFoveation=k),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=k)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let me=null;function Be(k,J){if(h=J.getViewerPose(c||a),_=J,h!==null){const de=h.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let le=!1;de.length!==M.cameras.length&&(M.cameras.length=0,le=!0);for(let Le=0;Le<de.length;Le++){const Ne=de[Le];let Qe=null;if(m!==null)Qe=m.getViewport(Ne);else{const it=f.getViewSubImage(u,Ne);Qe=it.viewport,Le===0&&(e.setRenderTargetTextures(T,it.colorTexture,u.ignoreDepthValues?void 0:it.depthStencilTexture),e.setRenderTarget(T))}let b=y[Le];b===void 0&&(b=new xt,b.layers.enable(Le),b.viewport=new Ze,y[Le]=b),b.matrix.fromArray(Ne.transform.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale),b.projectionMatrix.fromArray(Ne.projectionMatrix),b.projectionMatrixInverse.copy(b.projectionMatrix).invert(),b.viewport.set(Qe.x,Qe.y,Qe.width,Qe.height),Le===0&&(M.matrix.copy(b.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),le===!0&&M.cameras.push(b)}const be=r.enabledFeatures;if(be&&be.includes("depth-sensing")){const Le=f.getDepthInformation(de[0]);Le&&Le.isValid&&Le.texture&&v.init(e,Le,r.renderState)}}for(let de=0;de<S.length;de++){const le=A[de],be=S[de];le!==null&&be!==void 0&&be.update(le,J,c||a)}me&&me(k,J),J.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:J}),_=null}const Ke=new Ca;Ke.setAnimationLoop(Be),this.setAnimationLoop=function(k){me=k},this.dispose=function(){}}}const _n=new Ot,_d=new Ue;function gd(i,e){function t(p,d){p.matrixAutoUpdate===!0&&p.updateMatrix(),d.value.copy(p.matrix)}function n(p,d){d.color.getRGB(p.fogColor.value,ba(i)),d.isFog?(p.fogNear.value=d.near,p.fogFar.value=d.far):d.isFogExp2&&(p.fogDensity.value=d.density)}function r(p,d,T,S,A){d.isMeshBasicMaterial||d.isMeshLambertMaterial?s(p,d):d.isMeshToonMaterial?(s(p,d),f(p,d)):d.isMeshPhongMaterial?(s(p,d),h(p,d)):d.isMeshStandardMaterial?(s(p,d),u(p,d),d.isMeshPhysicalMaterial&&m(p,d,A)):d.isMeshMatcapMaterial?(s(p,d),_(p,d)):d.isMeshDepthMaterial?s(p,d):d.isMeshDistanceMaterial?(s(p,d),v(p,d)):d.isMeshNormalMaterial?s(p,d):d.isLineBasicMaterial?(a(p,d),d.isLineDashedMaterial&&o(p,d)):d.isPointsMaterial?l(p,d,T,S):d.isSpriteMaterial?c(p,d):d.isShadowMaterial?(p.color.value.copy(d.color),p.opacity.value=d.opacity):d.isShaderMaterial&&(d.uniformsNeedUpdate=!1)}function s(p,d){p.opacity.value=d.opacity,d.color&&p.diffuse.value.copy(d.color),d.emissive&&p.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity),d.map&&(p.map.value=d.map,t(d.map,p.mapTransform)),d.alphaMap&&(p.alphaMap.value=d.alphaMap,t(d.alphaMap,p.alphaMapTransform)),d.bumpMap&&(p.bumpMap.value=d.bumpMap,t(d.bumpMap,p.bumpMapTransform),p.bumpScale.value=d.bumpScale,d.side===1&&(p.bumpScale.value*=-1)),d.normalMap&&(p.normalMap.value=d.normalMap,t(d.normalMap,p.normalMapTransform),p.normalScale.value.copy(d.normalScale),d.side===1&&p.normalScale.value.negate()),d.displacementMap&&(p.displacementMap.value=d.displacementMap,t(d.displacementMap,p.displacementMapTransform),p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias),d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap,t(d.emissiveMap,p.emissiveMapTransform)),d.specularMap&&(p.specularMap.value=d.specularMap,t(d.specularMap,p.specularMapTransform)),d.alphaTest>0&&(p.alphaTest.value=d.alphaTest);const T=e.get(d),S=T.envMap,A=T.envMapRotation;S&&(p.envMap.value=S,_n.copy(A),_n.x*=-1,_n.y*=-1,_n.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(_n.y*=-1,_n.z*=-1),p.envMapRotation.value.setFromMatrix4(_d.makeRotationFromEuler(_n)),p.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=d.reflectivity,p.ior.value=d.ior,p.refractionRatio.value=d.refractionRatio),d.lightMap&&(p.lightMap.value=d.lightMap,p.lightMapIntensity.value=d.lightMapIntensity,t(d.lightMap,p.lightMapTransform)),d.aoMap&&(p.aoMap.value=d.aoMap,p.aoMapIntensity.value=d.aoMapIntensity,t(d.aoMap,p.aoMapTransform))}function a(p,d){p.diffuse.value.copy(d.color),p.opacity.value=d.opacity,d.map&&(p.map.value=d.map,t(d.map,p.mapTransform))}function o(p,d){p.dashSize.value=d.dashSize,p.totalSize.value=d.dashSize+d.gapSize,p.scale.value=d.scale}function l(p,d,T,S){p.diffuse.value.copy(d.color),p.opacity.value=d.opacity,p.size.value=d.size*T,p.scale.value=S*.5,d.map&&(p.map.value=d.map,t(d.map,p.uvTransform)),d.alphaMap&&(p.alphaMap.value=d.alphaMap,t(d.alphaMap,p.alphaMapTransform)),d.alphaTest>0&&(p.alphaTest.value=d.alphaTest)}function c(p,d){p.diffuse.value.copy(d.color),p.opacity.value=d.opacity,p.rotation.value=d.rotation,d.map&&(p.map.value=d.map,t(d.map,p.mapTransform)),d.alphaMap&&(p.alphaMap.value=d.alphaMap,t(d.alphaMap,p.alphaMapTransform)),d.alphaTest>0&&(p.alphaTest.value=d.alphaTest)}function h(p,d){p.specular.value.copy(d.specular),p.shininess.value=Math.max(d.shininess,1e-4)}function f(p,d){d.gradientMap&&(p.gradientMap.value=d.gradientMap)}function u(p,d){p.metalness.value=d.metalness,d.metalnessMap&&(p.metalnessMap.value=d.metalnessMap,t(d.metalnessMap,p.metalnessMapTransform)),p.roughness.value=d.roughness,d.roughnessMap&&(p.roughnessMap.value=d.roughnessMap,t(d.roughnessMap,p.roughnessMapTransform)),d.envMap&&(p.envMapIntensity.value=d.envMapIntensity)}function m(p,d,T){p.ior.value=d.ior,d.sheen>0&&(p.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),p.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(p.sheenColorMap.value=d.sheenColorMap,t(d.sheenColorMap,p.sheenColorMapTransform)),d.sheenRoughnessMap&&(p.sheenRoughnessMap.value=d.sheenRoughnessMap,t(d.sheenRoughnessMap,p.sheenRoughnessMapTransform))),d.clearcoat>0&&(p.clearcoat.value=d.clearcoat,p.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(p.clearcoatMap.value=d.clearcoatMap,t(d.clearcoatMap,p.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,t(d.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(p.clearcoatNormalMap.value=d.clearcoatNormalMap,t(d.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===1&&p.clearcoatNormalScale.value.negate())),d.dispersion>0&&(p.dispersion.value=d.dispersion),d.iridescence>0&&(p.iridescence.value=d.iridescence,p.iridescenceIOR.value=d.iridescenceIOR,p.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(p.iridescenceMap.value=d.iridescenceMap,t(d.iridescenceMap,p.iridescenceMapTransform)),d.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=d.iridescenceThicknessMap,t(d.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),d.transmission>0&&(p.transmission.value=d.transmission,p.transmissionSamplerMap.value=T.texture,p.transmissionSamplerSize.value.set(T.width,T.height),d.transmissionMap&&(p.transmissionMap.value=d.transmissionMap,t(d.transmissionMap,p.transmissionMapTransform)),p.thickness.value=d.thickness,d.thicknessMap&&(p.thicknessMap.value=d.thicknessMap,t(d.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=d.attenuationDistance,p.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(p.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(p.anisotropyMap.value=d.anisotropyMap,t(d.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=d.specularIntensity,p.specularColor.value.copy(d.specularColor),d.specularColorMap&&(p.specularColorMap.value=d.specularColorMap,t(d.specularColorMap,p.specularColorMapTransform)),d.specularIntensityMap&&(p.specularIntensityMap.value=d.specularIntensityMap,t(d.specularIntensityMap,p.specularIntensityMapTransform))}function _(p,d){d.matcap&&(p.matcap.value=d.matcap)}function v(p,d){const T=e.get(d).light;p.referencePosition.value.setFromMatrixPosition(T.matrixWorld),p.nearDistance.value=T.shadow.camera.near,p.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function vd(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(T,S){const A=S.program;n.uniformBlockBinding(T,A)}function c(T,S){let A=r[T.id];A===void 0&&(_(T),A=h(T),r[T.id]=A,T.addEventListener("dispose",p));const B=S.program;n.updateUBOMapping(T,B);const R=e.render.frame;s[T.id]!==R&&(u(T),s[T.id]=R)}function h(T){const S=f();T.__bindingPointIndex=S;const A=i.createBuffer(),B=T.__size,R=T.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,B,R),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,A),A}function f(){for(let T=0;T<o;T++)if(a.indexOf(T)===-1)return a.push(T),T;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(T){const S=r[T.id],A=T.uniforms,B=T.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let R=0,w=A.length;R<w;R++){const F=Array.isArray(A[R])?A[R]:[A[R]];for(let y=0,M=F.length;y<M;y++){const P=F[y];if(m(P,R,y,B)===!0){const W=P.__offset,G=Array.isArray(P.value)?P.value:[P.value];let H=0;for(let K=0;K<G.length;K++){const V=G[K],j=v(V);typeof V=="number"||typeof V=="boolean"?(P.__data[0]=V,i.bufferSubData(i.UNIFORM_BUFFER,W+H,P.__data)):V.isMatrix3?(P.__data[0]=V.elements[0],P.__data[1]=V.elements[1],P.__data[2]=V.elements[2],P.__data[3]=0,P.__data[4]=V.elements[3],P.__data[5]=V.elements[4],P.__data[6]=V.elements[5],P.__data[7]=0,P.__data[8]=V.elements[6],P.__data[9]=V.elements[7],P.__data[10]=V.elements[8],P.__data[11]=0):(V.toArray(P.__data,H),H+=j.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,W,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(T,S,A,B){const R=T.value,w=S+"_"+A;if(B[w]===void 0)return typeof R=="number"||typeof R=="boolean"?B[w]=R:B[w]=R.clone(),!0;{const F=B[w];if(typeof R=="number"||typeof R=="boolean"){if(F!==R)return B[w]=R,!0}else if(F.equals(R)===!1)return F.copy(R),!0}return!1}function _(T){const S=T.uniforms;let A=0;const B=16;for(let w=0,F=S.length;w<F;w++){const y=Array.isArray(S[w])?S[w]:[S[w]];for(let M=0,P=y.length;M<P;M++){const W=y[M],G=Array.isArray(W.value)?W.value:[W.value];for(let H=0,K=G.length;H<K;H++){const V=G[H],j=v(V),z=A%B,ae=z%j.boundary,he=z+ae;A+=ae,he!==0&&B-he<j.storage&&(A+=B-he),W.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),W.__offset=A,A+=j.storage}}}const R=A%B;return R>0&&(A+=B-R),T.__size=A,T.__cache={},this}function v(T){const S={boundary:0,storage:0};return typeof T=="number"||typeof T=="boolean"?(S.boundary=4,S.storage=4):T.isVector2?(S.boundary=8,S.storage=8):T.isVector3||T.isColor?(S.boundary=16,S.storage=12):T.isVector4?(S.boundary=16,S.storage=16):T.isMatrix3?(S.boundary=48,S.storage=48):T.isMatrix4?(S.boundary=64,S.storage=64):T.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",T),S}function p(T){const S=T.target;S.removeEventListener("dispose",p);const A=a.indexOf(S.__bindingPointIndex);a.splice(A,1),i.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function d(){for(const T in r)i.deleteBuffer(r[T]);a=[],r={},s={}}return{bind:l,update:c,dispose:d}}class xd{constructor(e={}){const{canvas:t=co(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let u;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=n.getContextAttributes().alpha}else u=a;const m=new Uint32Array(4),_=new Int32Array(4);let v=null,p=null;const d=[],T=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Dt,this.toneMapping=0,this.toneMappingExposure=1;const S=this;let A=!1,B=0,R=0,w=null,F=-1,y=null;const M=new Ze,P=new Ze;let W=null;const G=new Ie(0);let H=0,K=t.width,V=t.height,j=1,z=null,ae=null;const he=new Ze(0,0,K,V),me=new Ze(0,0,K,V);let Be=!1;const Ke=new Hr;let k=!1,J=!1;const de=new Ue,le=new D,be=new Ze,Le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ne=!1;function Qe(){return w===null?j:1}let b=n;function it(x,L){return t.getContext(x,L)}try{const x={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Qi}`),t.addEventListener("webglcontextlost",X,!1),t.addEventListener("webglcontextrestored",q,!1),t.addEventListener("webglcontextcreationerror",ne,!1),b===null){const L="webgl2";if(b=it(L,x),b===null)throw it(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(x){throw console.error("THREE.WebGLRenderer: "+x.message),x}let Xe,$e,ge,rt,Te,Re,E,g,O,$,Z,Y,ve,re,ce,we,Q,oe,Oe,Ee,ue,Ae,De,Je;function C(){Xe=new Ah(b),Xe.init(),Ae=new cd(b,Xe),$e=new xh(b,Xe,e,Ae),ge=new ad(b),rt=new wh(b),Te=new qu,Re=new ld(b,Xe,ge,Te,$e,Ae,rt),E=new Sh(S),g=new Th(S),O=new No(b),De=new gh(b,O),$=new bh(b,O,rt,De),Z=new Ph(b,$,O,rt),Oe=new Ch(b,$e,Re),we=new Mh(Te),Y=new Xu(S,E,g,Xe,$e,De,we),ve=new gd(S,Te),re=new Ku,ce=new ed(Xe),oe=new _h(S,E,g,ge,Z,u,l),Q=new sd(S,Z,$e),Je=new vd(b,rt,$e,ge),Ee=new vh(b,Xe,rt),ue=new Rh(b,Xe,rt),rt.programs=Y.programs,S.capabilities=$e,S.extensions=Xe,S.properties=Te,S.renderLists=re,S.shadowMap=Q,S.state=ge,S.info=rt}C();const ee=new md(S,b);this.xr=ee,this.getContext=function(){return b},this.getContextAttributes=function(){return b.getContextAttributes()},this.forceContextLoss=function(){const x=Xe.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Xe.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(x){x!==void 0&&(j=x,this.setSize(K,V,!1))},this.getSize=function(x){return x.set(K,V)},this.setSize=function(x,L,U=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=x,V=L,t.width=Math.floor(x*j),t.height=Math.floor(L*j),U===!0&&(t.style.width=x+"px",t.style.height=L+"px"),this.setViewport(0,0,x,L)},this.getDrawingBufferSize=function(x){return x.set(K*j,V*j).floor()},this.setDrawingBufferSize=function(x,L,U){K=x,V=L,j=U,t.width=Math.floor(x*U),t.height=Math.floor(L*U),this.setViewport(0,0,x,L)},this.getCurrentViewport=function(x){return x.copy(M)},this.getViewport=function(x){return x.copy(he)},this.setViewport=function(x,L,U,N){x.isVector4?he.set(x.x,x.y,x.z,x.w):he.set(x,L,U,N),ge.viewport(M.copy(he).multiplyScalar(j).round())},this.getScissor=function(x){return x.copy(me)},this.setScissor=function(x,L,U,N){x.isVector4?me.set(x.x,x.y,x.z,x.w):me.set(x,L,U,N),ge.scissor(P.copy(me).multiplyScalar(j).round())},this.getScissorTest=function(){return Be},this.setScissorTest=function(x){ge.setScissorTest(Be=x)},this.setOpaqueSort=function(x){z=x},this.setTransparentSort=function(x){ae=x},this.getClearColor=function(x){return x.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor.apply(oe,arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha.apply(oe,arguments)},this.clear=function(x=!0,L=!0,U=!0){let N=0;if(x){let I=!1;if(w!==null){const te=w.texture.format;I=te===1033||te===1031||te===1029}if(I){const te=w.texture.type,se=te===1009||te===1014||te===1012||te===1020||te===1017||te===1018,fe=oe.getClearColor(),pe=oe.getClearAlpha(),Se=fe.r,ye=fe.g,xe=fe.b;se?(m[0]=Se,m[1]=ye,m[2]=xe,m[3]=pe,b.clearBufferuiv(b.COLOR,0,m)):(_[0]=Se,_[1]=ye,_[2]=xe,_[3]=pe,b.clearBufferiv(b.COLOR,0,_))}else N|=b.COLOR_BUFFER_BIT}L&&(N|=b.DEPTH_BUFFER_BIT),U&&(N|=b.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),b.clear(N)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",X,!1),t.removeEventListener("webglcontextrestored",q,!1),t.removeEventListener("webglcontextcreationerror",ne,!1),re.dispose(),ce.dispose(),Te.dispose(),E.dispose(),g.dispose(),Z.dispose(),De.dispose(),Je.dispose(),Y.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",Nt),ee.removeEventListener("sessionend",ns),hn.stop()};function X(x){x.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function q(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const x=rt.autoReset,L=Q.enabled,U=Q.autoUpdate,N=Q.needsUpdate,I=Q.type;C(),rt.autoReset=x,Q.enabled=L,Q.autoUpdate=U,Q.needsUpdate=N,Q.type=I}function ne(x){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function Me(x){const L=x.target;L.removeEventListener("dispose",Me),Ge(L)}function Ge(x){st(x),Te.remove(x)}function st(x){const L=Te.get(x).programs;L!==void 0&&(L.forEach(function(U){Y.releaseProgram(U)}),x.isShaderMaterial&&Y.releaseShaderCache(x))}this.renderBufferDirect=function(x,L,U,N,I,te){L===null&&(L=Le);const se=I.isMesh&&I.matrixWorld.determinant()<0,fe=Va(x,L,U,N,I);ge.setMaterial(N,se);let pe=U.index,Se=1;if(N.wireframe===!0){if(pe=$.getWireframeAttribute(U),pe===void 0)return;Se=2}const ye=U.drawRange,xe=U.attributes.position;let ke=ye.start*Se,et=(ye.start+ye.count)*Se;te!==null&&(ke=Math.max(ke,te.start*Se),et=Math.min(et,(te.start+te.count)*Se)),pe!==null?(ke=Math.max(ke,0),et=Math.min(et,pe.count)):xe!=null&&(ke=Math.max(ke,0),et=Math.min(et,xe.count));const tt=et-ke;if(tt<0||tt===1/0)return;De.setup(I,N,fe,U,pe);let Mt,He=Ee;if(pe!==null&&(Mt=O.get(pe),He=ue,He.setIndex(Mt)),I.isMesh)N.wireframe===!0?(ge.setLineWidth(N.wireframeLinewidth*Qe()),He.setMode(b.LINES)):He.setMode(b.TRIANGLES);else if(I.isLine){let _e=N.linewidth;_e===void 0&&(_e=1),ge.setLineWidth(_e*Qe()),I.isLineSegments?He.setMode(b.LINES):I.isLineLoop?He.setMode(b.LINE_LOOP):He.setMode(b.LINE_STRIP)}else I.isPoints?He.setMode(b.POINTS):I.isSprite&&He.setMode(b.TRIANGLES);if(I.isBatchedMesh)if(I._multiDrawInstances!==null)He.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances);else if(Xe.get("WEBGL_multi_draw"))He.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else{const _e=I._multiDrawStarts,ft=I._multiDrawCounts,We=I._multiDrawCount,wt=pe?O.get(pe).bytesPerElement:1,yn=Te.get(N).currentProgram.getUniforms();for(let St=0;St<We;St++)yn.setValue(b,"_gl_DrawID",St),He.render(_e[St]/wt,ft[St])}else if(I.isInstancedMesh)He.renderInstances(ke,tt,I.count);else if(U.isInstancedBufferGeometry){const _e=U._maxInstanceCount!==void 0?U._maxInstanceCount:1/0,ft=Math.min(U.instanceCount,_e);He.renderInstances(ke,tt,ft)}else He.render(ke,tt)};function dt(x,L,U){x.transparent===!0&&x.side===2&&x.forceSinglePass===!1?(x.side=1,x.needsUpdate=!0,vi(x,L,U),x.side=0,x.needsUpdate=!0,vi(x,L,U),x.side=2):vi(x,L,U)}this.compile=function(x,L,U=null){U===null&&(U=x),p=ce.get(U),p.init(L),T.push(p),U.traverseVisible(function(I){I.isLight&&I.layers.test(L.layers)&&(p.pushLight(I),I.castShadow&&p.pushShadow(I))}),x!==U&&x.traverseVisible(function(I){I.isLight&&I.layers.test(L.layers)&&(p.pushLight(I),I.castShadow&&p.pushShadow(I))}),p.setupLights();const N=new Set;return x.traverse(function(I){const te=I.material;if(te)if(Array.isArray(te))for(let se=0;se<te.length;se++){const fe=te[se];dt(fe,U,I),N.add(fe)}else dt(te,U,I),N.add(te)}),T.pop(),p=null,N},this.compileAsync=function(x,L,U=null){const N=this.compile(x,L,U);return new Promise(I=>{function te(){if(N.forEach(function(se){Te.get(se).currentProgram.isReady()&&N.delete(se)}),N.size===0){I(x);return}setTimeout(te,10)}Xe.get("KHR_parallel_shader_compile")!==null?te():setTimeout(te,10)})};let Ve=null;function kt(x){Ve&&Ve(x)}function Nt(){hn.stop()}function ns(){hn.start()}const hn=new Ca;hn.setAnimationLoop(kt),typeof self<"u"&&hn.setContext(self),this.setAnimationLoop=function(x){Ve=x,ee.setAnimationLoop(x),x===null?hn.stop():hn.start()},ee.addEventListener("sessionstart",Nt),ee.addEventListener("sessionend",ns),this.render=function(x,L){if(L!==void 0&&L.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(L),L=ee.getCamera()),x.isScene===!0&&x.onBeforeRender(S,x,L,w),p=ce.get(x,T.length),p.init(L),T.push(p),de.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Ke.setFromProjectionMatrix(de),J=this.localClippingEnabled,k=we.init(this.clippingPlanes,J),v=re.get(x,d.length),v.init(),d.push(v),ee.enabled===!0&&ee.isPresenting===!0){const te=S.xr.getDepthSensingMesh();te!==null&&ir(te,L,-1/0,S.sortObjects)}ir(x,L,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(z,ae),Ne=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,Ne&&oe.addToRenderList(v,x),this.info.render.frame++,k===!0&&we.beginShadows();const U=p.state.shadowsArray;Q.render(U,x,L),k===!0&&we.endShadows(),this.info.autoReset===!0&&this.info.reset();const N=v.opaque,I=v.transmissive;if(p.setupLights(),L.isArrayCamera){const te=L.cameras;if(I.length>0)for(let se=0,fe=te.length;se<fe;se++){const pe=te[se];rs(N,I,x,pe)}Ne&&oe.render(x);for(let se=0,fe=te.length;se<fe;se++){const pe=te[se];is(v,x,pe,pe.viewport)}}else I.length>0&&rs(N,I,x,L),Ne&&oe.render(x),is(v,x,L);w!==null&&(Re.updateMultisampleRenderTarget(w),Re.updateRenderTargetMipmap(w)),x.isScene===!0&&x.onAfterRender(S,x,L),De.resetDefaultState(),F=-1,y=null,T.pop(),T.length>0?(p=T[T.length-1],k===!0&&we.setGlobalState(S.clippingPlanes,p.state.camera)):p=null,d.pop(),d.length>0?v=d[d.length-1]:v=null};function ir(x,L,U,N){if(x.visible===!1)return;if(x.layers.test(L.layers)){if(x.isGroup)U=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(L);else if(x.isLight)p.pushLight(x),x.castShadow&&p.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Ke.intersectsSprite(x)){N&&be.setFromMatrixPosition(x.matrixWorld).applyMatrix4(de);const se=Z.update(x),fe=x.material;fe.visible&&v.push(x,se,fe,U,be.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Ke.intersectsObject(x))){const se=Z.update(x),fe=x.material;if(N&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),be.copy(x.boundingSphere.center)):(se.boundingSphere===null&&se.computeBoundingSphere(),be.copy(se.boundingSphere.center)),be.applyMatrix4(x.matrixWorld).applyMatrix4(de)),Array.isArray(fe)){const pe=se.groups;for(let Se=0,ye=pe.length;Se<ye;Se++){const xe=pe[Se],ke=fe[xe.materialIndex];ke&&ke.visible&&v.push(x,se,ke,U,be.z,xe)}}else fe.visible&&v.push(x,se,fe,U,be.z,null)}}const te=x.children;for(let se=0,fe=te.length;se<fe;se++)ir(te[se],L,U,N)}function is(x,L,U,N){const I=x.opaque,te=x.transmissive,se=x.transparent;p.setupLightsView(U),k===!0&&we.setGlobalState(S.clippingPlanes,U),N&&ge.viewport(M.copy(N)),I.length>0&&gi(I,L,U),te.length>0&&gi(te,L,U),se.length>0&&gi(se,L,U),ge.buffers.depth.setTest(!0),ge.buffers.depth.setMask(!0),ge.buffers.color.setMask(!0),ge.setPolygonOffset(!1)}function rs(x,L,U,N){if((U.isScene===!0?U.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[N.id]===void 0&&(p.state.transmissionRenderTarget[N.id]=new Mn(1,1,{generateMipmaps:!0,type:Xe.has("EXT_color_buffer_half_float")||Xe.has("EXT_color_buffer_float")?1016:1009,minFilter:1008,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ze.workingColorSpace}));const te=p.state.transmissionRenderTarget[N.id],se=N.viewport||M;te.setSize(se.z,se.w);const fe=S.getRenderTarget();S.setRenderTarget(te),S.getClearColor(G),H=S.getClearAlpha(),H<1&&S.setClearColor(16777215,.5),S.clear(),Ne&&oe.render(U);const pe=S.toneMapping;S.toneMapping=0;const Se=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),p.setupLightsView(N),k===!0&&we.setGlobalState(S.clippingPlanes,N),gi(x,U,N),Re.updateMultisampleRenderTarget(te),Re.updateRenderTargetMipmap(te),Xe.has("WEBGL_multisampled_render_to_texture")===!1){let ye=!1;for(let xe=0,ke=L.length;xe<ke;xe++){const et=L[xe],tt=et.object,Mt=et.geometry,He=et.material,_e=et.group;if(He.side===2&&tt.layers.test(N.layers)){const ft=He.side;He.side=1,He.needsUpdate=!0,ss(tt,U,N,Mt,He,_e),He.side=ft,He.needsUpdate=!0,ye=!0}}ye===!0&&(Re.updateMultisampleRenderTarget(te),Re.updateRenderTargetMipmap(te))}S.setRenderTarget(fe),S.setClearColor(G,H),Se!==void 0&&(N.viewport=Se),S.toneMapping=pe}function gi(x,L,U){const N=L.isScene===!0?L.overrideMaterial:null;for(let I=0,te=x.length;I<te;I++){const se=x[I],fe=se.object,pe=se.geometry,Se=N===null?se.material:N,ye=se.group;fe.layers.test(U.layers)&&ss(fe,L,U,pe,Se,ye)}}function ss(x,L,U,N,I,te){x.onBeforeRender(S,L,U,N,I,te),x.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),I.transparent===!0&&I.side===2&&I.forceSinglePass===!1?(I.side=1,I.needsUpdate=!0,S.renderBufferDirect(U,L,N,I,x,te),I.side=0,I.needsUpdate=!0,S.renderBufferDirect(U,L,N,I,x,te),I.side=2):S.renderBufferDirect(U,L,N,I,x,te),x.onAfterRender(S,L,U,N,I,te)}function vi(x,L,U){L.isScene!==!0&&(L=Le);const N=Te.get(x),I=p.state.lights,te=p.state.shadowsArray,se=I.state.version,fe=Y.getParameters(x,I.state,te,L,U),pe=Y.getProgramCacheKey(fe);let Se=N.programs;N.environment=x.isMeshStandardMaterial?L.environment:null,N.fog=L.fog,N.envMap=(x.isMeshStandardMaterial?g:E).get(x.envMap||N.environment),N.envMapRotation=N.environment!==null&&x.envMap===null?L.environmentRotation:x.envMapRotation,Se===void 0&&(x.addEventListener("dispose",Me),Se=new Map,N.programs=Se);let ye=Se.get(pe);if(ye!==void 0){if(N.currentProgram===ye&&N.lightsStateVersion===se)return os(x,fe),ye}else fe.uniforms=Y.getUniforms(x),x.onBeforeCompile(fe,S),ye=Y.acquireProgram(fe,pe),Se.set(pe,ye),N.uniforms=fe.uniforms;const xe=N.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(xe.clippingPlanes=we.uniform),os(x,fe),N.needsLights=Ha(x),N.lightsStateVersion=se,N.needsLights&&(xe.ambientLightColor.value=I.state.ambient,xe.lightProbe.value=I.state.probe,xe.directionalLights.value=I.state.directional,xe.directionalLightShadows.value=I.state.directionalShadow,xe.spotLights.value=I.state.spot,xe.spotLightShadows.value=I.state.spotShadow,xe.rectAreaLights.value=I.state.rectArea,xe.ltc_1.value=I.state.rectAreaLTC1,xe.ltc_2.value=I.state.rectAreaLTC2,xe.pointLights.value=I.state.point,xe.pointLightShadows.value=I.state.pointShadow,xe.hemisphereLights.value=I.state.hemi,xe.directionalShadowMap.value=I.state.directionalShadowMap,xe.directionalShadowMatrix.value=I.state.directionalShadowMatrix,xe.spotShadowMap.value=I.state.spotShadowMap,xe.spotLightMatrix.value=I.state.spotLightMatrix,xe.spotLightMap.value=I.state.spotLightMap,xe.pointShadowMap.value=I.state.pointShadowMap,xe.pointShadowMatrix.value=I.state.pointShadowMatrix),N.currentProgram=ye,N.uniformsList=null,ye}function as(x){if(x.uniformsList===null){const L=x.currentProgram.getUniforms();x.uniformsList=Yi.seqWithValue(L.seq,x.uniforms)}return x.uniformsList}function os(x,L){const U=Te.get(x);U.outputColorSpace=L.outputColorSpace,U.batching=L.batching,U.batchingColor=L.batchingColor,U.instancing=L.instancing,U.instancingColor=L.instancingColor,U.instancingMorph=L.instancingMorph,U.skinning=L.skinning,U.morphTargets=L.morphTargets,U.morphNormals=L.morphNormals,U.morphColors=L.morphColors,U.morphTargetsCount=L.morphTargetsCount,U.numClippingPlanes=L.numClippingPlanes,U.numIntersection=L.numClipIntersection,U.vertexAlphas=L.vertexAlphas,U.vertexTangents=L.vertexTangents,U.toneMapping=L.toneMapping}function Va(x,L,U,N,I){L.isScene!==!0&&(L=Le),Re.resetTextureUnits();const te=L.fog,se=N.isMeshStandardMaterial?L.environment:null,fe=w===null?S.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:Jt,pe=(N.isMeshStandardMaterial?g:E).get(N.envMap||se),Se=N.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,ye=!!U.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),xe=!!U.morphAttributes.position,ke=!!U.morphAttributes.normal,et=!!U.morphAttributes.color;let tt=0;N.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(tt=S.toneMapping);const Mt=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,He=Mt!==void 0?Mt.length:0,_e=Te.get(N),ft=p.state.lights;if(k===!0&&(J===!0||x!==y)){const bt=x===y&&N.id===F;we.setState(N,x,bt)}let We=!1;N.version===_e.__version?(_e.needsLights&&_e.lightsStateVersion!==ft.state.version||_e.outputColorSpace!==fe||I.isBatchedMesh&&_e.batching===!1||!I.isBatchedMesh&&_e.batching===!0||I.isBatchedMesh&&_e.batchingColor===!0&&I.colorTexture===null||I.isBatchedMesh&&_e.batchingColor===!1&&I.colorTexture!==null||I.isInstancedMesh&&_e.instancing===!1||!I.isInstancedMesh&&_e.instancing===!0||I.isSkinnedMesh&&_e.skinning===!1||!I.isSkinnedMesh&&_e.skinning===!0||I.isInstancedMesh&&_e.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&_e.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&_e.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&_e.instancingMorph===!1&&I.morphTexture!==null||_e.envMap!==pe||N.fog===!0&&_e.fog!==te||_e.numClippingPlanes!==void 0&&(_e.numClippingPlanes!==we.numPlanes||_e.numIntersection!==we.numIntersection)||_e.vertexAlphas!==Se||_e.vertexTangents!==ye||_e.morphTargets!==xe||_e.morphNormals!==ke||_e.morphColors!==et||_e.toneMapping!==tt||_e.morphTargetsCount!==He)&&(We=!0):(We=!0,_e.__version=N.version);let wt=_e.currentProgram;We===!0&&(wt=vi(N,L,I));let yn=!1,St=!1,rr=!1;const at=wt.getUniforms(),en=_e.uniforms;if(ge.useProgram(wt.program)&&(yn=!0,St=!0,rr=!0),N.id!==F&&(F=N.id,St=!0),yn||y!==x){at.setValue(b,"projectionMatrix",x.projectionMatrix),at.setValue(b,"viewMatrix",x.matrixWorldInverse);const bt=at.map.cameraPosition;bt!==void 0&&bt.setValue(b,le.setFromMatrixPosition(x.matrixWorld)),$e.logarithmicDepthBuffer&&at.setValue(b,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&at.setValue(b,"isOrthographic",x.isOrthographicCamera===!0),y!==x&&(y=x,St=!0,rr=!0)}if(I.isSkinnedMesh){at.setOptional(b,I,"bindMatrix"),at.setOptional(b,I,"bindMatrixInverse");const bt=I.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),at.setValue(b,"boneTexture",bt.boneTexture,Re))}I.isBatchedMesh&&(at.setOptional(b,I,"batchingTexture"),at.setValue(b,"batchingTexture",I._matricesTexture,Re),at.setOptional(b,I,"batchingIdTexture"),at.setValue(b,"batchingIdTexture",I._indirectTexture,Re),at.setOptional(b,I,"batchingColorTexture"),I._colorsTexture!==null&&at.setValue(b,"batchingColorTexture",I._colorsTexture,Re));const sr=U.morphAttributes;if((sr.position!==void 0||sr.normal!==void 0||sr.color!==void 0)&&Oe.update(I,U,wt),(St||_e.receiveShadow!==I.receiveShadow)&&(_e.receiveShadow=I.receiveShadow,at.setValue(b,"receiveShadow",I.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(en.envMap.value=pe,en.flipEnvMap.value=pe.isCubeTexture&&pe.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&L.environment!==null&&(en.envMapIntensity.value=L.environmentIntensity),St&&(at.setValue(b,"toneMappingExposure",S.toneMappingExposure),_e.needsLights&&ka(en,rr),te&&N.fog===!0&&ve.refreshFogUniforms(en,te),ve.refreshMaterialUniforms(en,N,j,V,p.state.transmissionRenderTarget[x.id]),Yi.upload(b,as(_e),en,Re)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(Yi.upload(b,as(_e),en,Re),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&at.setValue(b,"center",I.center),at.setValue(b,"modelViewMatrix",I.modelViewMatrix),at.setValue(b,"normalMatrix",I.normalMatrix),at.setValue(b,"modelMatrix",I.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){const bt=N.uniformsGroups;for(let ar=0,Wa=bt.length;ar<Wa;ar++){const ls=bt[ar];Je.update(ls,wt),Je.bind(ls,wt)}}return wt}function ka(x,L){x.ambientLightColor.needsUpdate=L,x.lightProbe.needsUpdate=L,x.directionalLights.needsUpdate=L,x.directionalLightShadows.needsUpdate=L,x.pointLights.needsUpdate=L,x.pointLightShadows.needsUpdate=L,x.spotLights.needsUpdate=L,x.spotLightShadows.needsUpdate=L,x.rectAreaLights.needsUpdate=L,x.hemisphereLights.needsUpdate=L}function Ha(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(x,L,U){Te.get(x.texture).__webglTexture=L,Te.get(x.depthTexture).__webglTexture=U;const N=Te.get(x);N.__hasExternalTextures=!0,N.__autoAllocateDepthBuffer=U===void 0,N.__autoAllocateDepthBuffer||Xe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),N.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(x,L){const U=Te.get(x);U.__webglFramebuffer=L,U.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(x,L=0,U=0){w=x,B=L,R=U;let N=!0,I=null,te=!1,se=!1;if(x){const pe=Te.get(x);pe.__useDefaultFramebuffer!==void 0?(ge.bindFramebuffer(b.FRAMEBUFFER,null),N=!1):pe.__webglFramebuffer===void 0?Re.setupRenderTarget(x):pe.__hasExternalTextures&&Re.rebindTextures(x,Te.get(x.texture).__webglTexture,Te.get(x.depthTexture).__webglTexture);const Se=x.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(se=!0);const ye=Te.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(ye[L])?I=ye[L][U]:I=ye[L],te=!0):x.samples>0&&Re.useMultisampledRTT(x)===!1?I=Te.get(x).__webglMultisampledFramebuffer:Array.isArray(ye)?I=ye[U]:I=ye,M.copy(x.viewport),P.copy(x.scissor),W=x.scissorTest}else M.copy(he).multiplyScalar(j).floor(),P.copy(me).multiplyScalar(j).floor(),W=Be;if(ge.bindFramebuffer(b.FRAMEBUFFER,I)&&N&&ge.drawBuffers(x,I),ge.viewport(M),ge.scissor(P),ge.setScissorTest(W),te){const pe=Te.get(x.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_CUBE_MAP_POSITIVE_X+L,pe.__webglTexture,U)}else if(se){const pe=Te.get(x.texture),Se=L||0;b.framebufferTextureLayer(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,pe.__webglTexture,U||0,Se)}F=-1},this.readRenderTargetPixels=function(x,L,U,N,I,te,se){if(!(x&&x.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let fe=Te.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&se!==void 0&&(fe=fe[se]),fe){ge.bindFramebuffer(b.FRAMEBUFFER,fe);try{const pe=x.texture,Se=pe.format,ye=pe.type;if(!$e.textureFormatReadable(Se)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!$e.textureTypeReadable(ye)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=x.width-N&&U>=0&&U<=x.height-I&&b.readPixels(L,U,N,I,Ae.convert(Se),Ae.convert(ye),te)}finally{const pe=w!==null?Te.get(w).__webglFramebuffer:null;ge.bindFramebuffer(b.FRAMEBUFFER,pe)}}},this.readRenderTargetPixelsAsync=async function(x,L,U,N,I,te,se){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let fe=Te.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&se!==void 0&&(fe=fe[se]),fe){ge.bindFramebuffer(b.FRAMEBUFFER,fe);try{const pe=x.texture,Se=pe.format,ye=pe.type;if(!$e.textureFormatReadable(Se))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!$e.textureTypeReadable(ye))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(L>=0&&L<=x.width-N&&U>=0&&U<=x.height-I){const xe=b.createBuffer();b.bindBuffer(b.PIXEL_PACK_BUFFER,xe),b.bufferData(b.PIXEL_PACK_BUFFER,te.byteLength,b.STREAM_READ),b.readPixels(L,U,N,I,Ae.convert(Se),Ae.convert(ye),0),b.flush();const ke=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);await ho(b,ke,4);try{b.bindBuffer(b.PIXEL_PACK_BUFFER,xe),b.getBufferSubData(b.PIXEL_PACK_BUFFER,0,te)}finally{b.deleteBuffer(xe),b.deleteSync(ke)}return te}}finally{const pe=w!==null?Te.get(w).__webglFramebuffer:null;ge.bindFramebuffer(b.FRAMEBUFFER,pe)}}},this.copyFramebufferToTexture=function(x,L=null,U=0){x.isTexture!==!0&&(Vn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),L=arguments[0]||null,x=arguments[1]);const N=Math.pow(2,-U),I=Math.floor(x.image.width*N),te=Math.floor(x.image.height*N),se=L!==null?L.x:0,fe=L!==null?L.y:0;Re.setTexture2D(x,0),b.copyTexSubImage2D(b.TEXTURE_2D,U,0,0,se,fe,I,te),ge.unbindTexture()},this.copyTextureToTexture=function(x,L,U=null,N=null,I=0){x.isTexture!==!0&&(Vn("WebGLRenderer: copyTextureToTexture function signature has changed."),N=arguments[0]||null,x=arguments[1],L=arguments[2],I=arguments[3]||0,U=null);let te,se,fe,pe,Se,ye;U!==null?(te=U.max.x-U.min.x,se=U.max.y-U.min.y,fe=U.min.x,pe=U.min.y):(te=x.image.width,se=x.image.height,fe=0,pe=0),N!==null?(Se=N.x,ye=N.y):(Se=0,ye=0);const xe=Ae.convert(L.format),ke=Ae.convert(L.type);Re.setTexture2D(L,0),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,L.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,L.unpackAlignment);const et=b.getParameter(b.UNPACK_ROW_LENGTH),tt=b.getParameter(b.UNPACK_IMAGE_HEIGHT),Mt=b.getParameter(b.UNPACK_SKIP_PIXELS),He=b.getParameter(b.UNPACK_SKIP_ROWS),_e=b.getParameter(b.UNPACK_SKIP_IMAGES),ft=x.isCompressedTexture?x.mipmaps[I]:x.image;b.pixelStorei(b.UNPACK_ROW_LENGTH,ft.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,ft.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,fe),b.pixelStorei(b.UNPACK_SKIP_ROWS,pe),x.isDataTexture?b.texSubImage2D(b.TEXTURE_2D,I,Se,ye,te,se,xe,ke,ft.data):x.isCompressedTexture?b.compressedTexSubImage2D(b.TEXTURE_2D,I,Se,ye,ft.width,ft.height,xe,ft.data):b.texSubImage2D(b.TEXTURE_2D,I,Se,ye,te,se,xe,ke,ft),b.pixelStorei(b.UNPACK_ROW_LENGTH,et),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,tt),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Mt),b.pixelStorei(b.UNPACK_SKIP_ROWS,He),b.pixelStorei(b.UNPACK_SKIP_IMAGES,_e),I===0&&L.generateMipmaps&&b.generateMipmap(b.TEXTURE_2D),ge.unbindTexture()},this.copyTextureToTexture3D=function(x,L,U=null,N=null,I=0){x.isTexture!==!0&&(Vn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),U=arguments[0]||null,N=arguments[1]||null,x=arguments[2],L=arguments[3],I=arguments[4]||0);let te,se,fe,pe,Se,ye,xe,ke,et;const tt=x.isCompressedTexture?x.mipmaps[I]:x.image;U!==null?(te=U.max.x-U.min.x,se=U.max.y-U.min.y,fe=U.max.z-U.min.z,pe=U.min.x,Se=U.min.y,ye=U.min.z):(te=tt.width,se=tt.height,fe=tt.depth,pe=0,Se=0,ye=0),N!==null?(xe=N.x,ke=N.y,et=N.z):(xe=0,ke=0,et=0);const Mt=Ae.convert(L.format),He=Ae.convert(L.type);let _e;if(L.isData3DTexture)Re.setTexture3D(L,0),_e=b.TEXTURE_3D;else if(L.isDataArrayTexture||L.isCompressedArrayTexture)Re.setTexture2DArray(L,0),_e=b.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,L.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,L.unpackAlignment);const ft=b.getParameter(b.UNPACK_ROW_LENGTH),We=b.getParameter(b.UNPACK_IMAGE_HEIGHT),wt=b.getParameter(b.UNPACK_SKIP_PIXELS),yn=b.getParameter(b.UNPACK_SKIP_ROWS),St=b.getParameter(b.UNPACK_SKIP_IMAGES);b.pixelStorei(b.UNPACK_ROW_LENGTH,tt.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,tt.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,pe),b.pixelStorei(b.UNPACK_SKIP_ROWS,Se),b.pixelStorei(b.UNPACK_SKIP_IMAGES,ye),x.isDataTexture||x.isData3DTexture?b.texSubImage3D(_e,I,xe,ke,et,te,se,fe,Mt,He,tt.data):L.isCompressedArrayTexture?b.compressedTexSubImage3D(_e,I,xe,ke,et,te,se,fe,Mt,tt.data):b.texSubImage3D(_e,I,xe,ke,et,te,se,fe,Mt,He,tt),b.pixelStorei(b.UNPACK_ROW_LENGTH,ft),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,We),b.pixelStorei(b.UNPACK_SKIP_PIXELS,wt),b.pixelStorei(b.UNPACK_SKIP_ROWS,yn),b.pixelStorei(b.UNPACK_SKIP_IMAGES,St),I===0&&L.generateMipmaps&&b.generateMipmap(_e),ge.unbindTexture()},this.initRenderTarget=function(x){Te.get(x).__webglFramebuffer===void 0&&Re.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?Re.setTextureCube(x,0):x.isData3DTexture?Re.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?Re.setTexture2DArray(x,0):Re.setTexture2D(x,0),ge.unbindTexture()},this.resetState=function(){B=0,R=0,w=null,ge.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===er?"display-p3":"srgb",t.unpackColorSpace=ze.workingColorSpace===di?"display-p3":"srgb"}}class Md extends nt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ot,this.environmentIntensity=1,this.environmentRotation=new Ot,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__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()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Sd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=35044,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ut()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return Vn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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 r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ut()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ut()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const gt=new D;class qr{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix4(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyNormalMatrix(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.transformDirection(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=It(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=qe(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=qe(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=It(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=It(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=It(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=It(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=qe(t,this.array),n=qe(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=qe(t,this.array),n=qe(n,this.array),r=qe(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=qe(t,this.array),n=qe(n,this.array),r=qe(r,this.array),s=qe(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new At(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new qr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const ta=new D,na=new Ze,ia=new Ze,yd=new D,ra=new Ue,zi=new D,Dr=new Gt,sa=new Ue,Ir=new tr;class Ed extends Tt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=cs,this.bindMatrix=new Ue,this.bindMatrixInverse=new Ue,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Qt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,zi),this.boundingBox.expandByPoint(zi)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Gt),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,zi),this.boundingSphere.expandByPoint(zi)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Dr.copy(this.boundingSphere),Dr.applyMatrix4(r),e.ray.intersectsSphere(Dr)!==!1&&(sa.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(sa),!(this.boundingBox!==null&&Ir.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ir)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ze,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===cs?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Xa?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;na.fromBufferAttribute(r.attributes.skinIndex,e),ia.fromBufferAttribute(r.attributes.skinWeight,e),ta.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=ia.getComponent(s);if(a!==0){const o=na.getComponent(s);ra.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(yd.copy(ta).applyMatrix4(ra),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Na extends nt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Yr extends lt{constructor(e=null,t=1,n=1,r,s,a,o,l,c=1003,h=1003,f,u){super(null,a,o,l,c,h,r,s,f,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const aa=new Ue,Td=new Ue;class Kr{constructor(e=[],t=[]){this.uuid=Ut(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Ue)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ue;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:Td;aa.multiplyMatrices(o,t[s]),aa.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Kr(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Yr(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Na),this.bones.push(a),this.boneInverses.push(new Ue().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class Or extends At{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Gn=new Ue,oa=new Ue,Vi=[],la=new Qt,Ad=new Ue,ti=new Tt,ni=new Gt;class bd extends Tt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Or(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Ad)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Qt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Gn),la.copy(e.boundingBox).applyMatrix4(Gn),this.boundingBox.union(la)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Gt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Gn),ni.copy(e.boundingSphere).applyMatrix4(Gn),this.boundingSphere.union(ni)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(ti.geometry=this.geometry,ti.material=this.material,ti.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ni.copy(this.boundingSphere),ni.applyMatrix4(n),e.ray.intersectsSphere(ni)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Gn),oa.multiplyMatrices(n,Gn),ti.matrixWorld=oa,ti.raycast(e,Vi);for(let a=0,o=Vi.length;a<o;a++){const l=Vi[a];l.instanceId=s,l.object=this,t.push(l)}Vi.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Or(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Yr(new Float32Array(r*this.count),r,this.count,1028,1015));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Fa extends cn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const ji=new D,Ji=new D,ca=new Ue,ii=new tr,ki=new Gt,Ur=new D,ha=new D;class $r extends nt{constructor(e=new zt,t=new Fa){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)ji.fromBufferAttribute(t,r-1),Ji.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=ji.distanceTo(Ji);e.setAttribute("lineDistance",new Zt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ki.copy(n.boundingSphere),ki.applyMatrix4(r),ki.radius+=s,e.ray.intersectsSphere(ki)===!1)return;ca.copy(r).invert(),ii.copy(e.ray).applyMatrix4(ca);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){const m=Math.max(0,a.start),_=Math.min(h.count,a.start+a.count);for(let v=m,p=_-1;v<p;v+=c){const d=h.getX(v),T=h.getX(v+1),S=Hi(this,e,ii,l,d,T);S&&t.push(S)}if(this.isLineLoop){const v=h.getX(_-1),p=h.getX(m),d=Hi(this,e,ii,l,v,p);d&&t.push(d)}}else{const m=Math.max(0,a.start),_=Math.min(u.count,a.start+a.count);for(let v=m,p=_-1;v<p;v+=c){const d=Hi(this,e,ii,l,v,v+1);d&&t.push(d)}if(this.isLineLoop){const v=Hi(this,e,ii,l,_-1,m);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Hi(i,e,t,n,r,s){const a=i.geometry.attributes.position;if(ji.fromBufferAttribute(a,r),Ji.fromBufferAttribute(a,s),t.distanceSqToSegment(ji,Ji,Ur,ha)>n)return;Ur.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Ur);if(!(l<e.near||l>e.far))return{distance:l,point:ha.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,object:i}}const ua=new D,da=new D;class Rd extends $r{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)ua.fromBufferAttribute(t,r),da.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+ua.distanceTo(da);e.setAttribute("lineDistance",new Zt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wd extends $r{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ba extends cn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const fa=new Ue,Gr=new tr,Wi=new Gt,Xi=new D;class Cd extends nt{constructor(e=new zt,t=new Ba){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Wi.copy(n.boundingSphere),Wi.applyMatrix4(r),Wi.radius+=s,e.ray.intersectsSphere(Wi)===!1)return;fa.copy(r).invert(),Gr.copy(e.ray).applyMatrix4(fa);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,f=n.attributes.position;if(c!==null){const u=Math.max(0,a.start),m=Math.min(c.count,a.start+a.count);for(let _=u,v=m;_<v;_++){const p=c.getX(_);Xi.fromBufferAttribute(f,p),pa(Xi,p,l,r,e,t,this)}}else{const u=Math.max(0,a.start),m=Math.min(f.count,a.start+a.count);for(let _=u,v=m;_<v;_++)Xi.fromBufferAttribute(f,_),pa(Xi,_,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function pa(i,e,t,n,r,s,a){const o=Gr.distanceSqToPoint(i);if(o<t){const l=new D;Gr.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}class Zr extends lt{constructor(e,t,n,r,s,a,o,l,c,h,f,u){super(null,a,o,l,c,h,r,s,f,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Pd extends Zr{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ld extends Zr{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Dd extends lt{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Oa extends cn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ot,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Id extends Oa{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Fe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return _t(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ie(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function qi(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Ud(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Nd(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function ma(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function Ga(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}class mi{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];n:{e:{let a;t:{i:if(!(e<r)){for(let o=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=r,r=t[++n],e<r)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=t[--n-1],e>=s)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Fd extends mi{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:s=e,o=2*t-n;break;case 2402:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case 2401:a=e,l=2*n-t;break;case 2402:a=1,l=n+r[1]-r[0];break;default:a=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,f=this._offsetNext,u=this._weightPrev,m=this._weightNext,_=(n-t)/(r-t),v=_*_,p=v*_,d=-u*p+2*u*v-u*_,T=(1+u)*p+(-1.5-2*u)*v+(-.5+u)*_+1,S=(-1-m)*p+(1.5+m)*v+.5*_,A=m*p-m*v;for(let B=0;B!==o;++B)s[B]=d*a[h+B]+T*a[c+B]+S*a[l+B]+A*a[f+B];return s}}class Bd extends mi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(r-t),f=1-h;for(let u=0;u!==o;++u)s[u]=a[c+u]*f+a[l+u]*h;return s}}class Od extends mi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Vt{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=qi(t,this.TimeBufferType),this.values=qi(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:qi(e.times,Array),values:qi(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Od(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Bd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Fd(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Ud(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===2302,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(r)l=!0;else{const f=o*n,u=f-n,m=f+n;for(let _=0;_!==n;++_){const v=t[f+_];if(v!==t[u+_]||v!==t[m+_]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const f=o*n,u=a*n;for(let m=0;m!==n;++m)t[u+m]=t[f+m]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Vt.prototype.TimeBufferType=Float32Array;Vt.prototype.ValueBufferType=Float32Array;Vt.prototype.DefaultInterpolation=2301;class Yn extends Vt{constructor(e,t,n){super(e,t,n)}}Yn.prototype.ValueTypeName="bool";Yn.prototype.ValueBufferType=Array;Yn.prototype.DefaultInterpolation=2300;Yn.prototype.InterpolantFactoryMethodLinear=void 0;Yn.prototype.InterpolantFactoryMethodSmooth=void 0;class za extends Vt{}za.prototype.ValueTypeName="color";class hi extends Vt{}hi.prototype.ValueTypeName="number";class Gd extends mi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t);let c=e*o;for(let h=c+o;c!==h;c+=4)Sn.slerpFlat(s,0,a,c-o,a,c,l);return s}}class _i extends Vt{InterpolantFactoryMethodLinear(e){return new Gd(this.times,this.values,this.getValueSize(),e)}}_i.prototype.ValueTypeName="quaternion";_i.prototype.InterpolantFactoryMethodSmooth=void 0;class Kn extends Vt{constructor(e,t,n){super(e,t,n)}}Kn.prototype.ValueTypeName="string";Kn.prototype.ValueBufferType=Array;Kn.prototype.DefaultInterpolation=2300;Kn.prototype.InterpolantFactoryMethodLinear=void 0;Kn.prototype.InterpolantFactoryMethodSmooth=void 0;class ui extends Vt{}ui.prototype.ValueTypeName="vector";class zd{constructor(e="",t=-1,n=[],r=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Ut(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(kd(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Vt.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=Nd(l);l=ma(l,1,h),c=ma(c,1,h),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new hi(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const f=h[1];let u=r[f];u||(r[f]=u=[]),u.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(f,u,m,_,v){if(m.length!==0){const p=[],d=[];Ga(m,p,d,_),p.length!==0&&v.push(new f(u,p,d))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f<c.length;f++){const u=c[f].keys;if(!(!u||u.length===0))if(u[0].morphTargets){const m={};let _;for(_=0;_<u.length;_++)if(u[_].morphTargets)for(let v=0;v<u[_].morphTargets.length;v++)m[u[_].morphTargets[v]]=-1;for(const v in m){const p=[],d=[];for(let T=0;T!==u[_].morphTargets.length;++T){const S=u[_];p.push(S.time),d.push(S.morphTarget===v?1:0)}r.push(new hi(".morphTargetInfluence["+v+"]",p,d))}l=m.length*a}else{const m=".bones["+t[f].name+"]";n(ui,m+".position",u,"pos",r),n(_i,m+".quaternion",u,"rot",r),n(ui,m+".scale",u,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Vd(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return hi;case"vector":case"vector2":case"vector3":case"vector4":return ui;case"color":return za;case"quaternion":return _i;case"bool":case"boolean":return Yn;case"string":return Kn}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function kd(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Vd(i.type);if(i.times===void 0){const t=[],n=[];Ga(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const ln={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Hd{constructor(e,t,n){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,u=c.length;f<u;f+=2){const m=c[f],_=c[f+1];if(m.global&&(m.lastIndex=0),m.test(h))return _}return null}}}const Wd=new Hd;class $n{constructor(e){this.manager=e!==void 0?e:Wd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}$n.DEFAULT_MATERIAL_NAME="__DEFAULT";const Kt={};class Xd extends Error{constructor(e,t){super(e),this.response=t}}class qd extends $n{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ln.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Kt[e]!==void 0){Kt[e].push({onLoad:t,onProgress:n,onError:r});return}Kt[e]=[],Kt[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Kt[e],f=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),m=u?parseInt(u):0,_=m!==0;let v=0;const p=new ReadableStream({start(d){T();function T(){f.read().then(({done:S,value:A})=>{if(S)d.close();else{v+=A.byteLength;const B=new ProgressEvent("progress",{lengthComputable:_,loaded:v,total:m});for(let R=0,w=h.length;R<w;R++){const F=h[R];F.onProgress&&F.onProgress(B)}d.enqueue(A),T()}},S=>{d.error(S)})}}});return new Response(p)}else throw new Xd(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(o),u=f&&f[1]?f[1].toLowerCase():void 0,m=new TextDecoder(u);return c.arrayBuffer().then(_=>m.decode(_))}}}).then(c=>{ln.add(e,c);const h=Kt[e];delete Kt[e];for(let f=0,u=h.length;f<u;f++){const m=h[f];m.onLoad&&m.onLoad(c)}}).catch(c=>{const h=Kt[e];if(h===void 0)throw this.manager.itemError(e),c;delete Kt[e];for(let f=0,u=h.length;f<u;f++){const m=h[f];m.onError&&m.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Yd extends $n{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ln.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=ci("img");function l(){h(),ln.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){h(),r&&r(f),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class Kd extends $n{constructor(e){super(e)}load(e,t,n,r){const s=new lt,a=new Yd(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class jr extends nt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ie(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const Nr=new Ue,_a=new D,ga=new D;class Jr{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Fe(512,512),this.map=null,this.mapPass=null,this.matrix=new Ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hr,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;_a.setFromMatrixPosition(e.matrixWorld),t.position.copy(_a),ga.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ga),t.updateMatrixWorld(),Nr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nr),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Nr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class $d extends Jr{constructor(){super(new xt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Hn*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Zd extends jr{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.target=new nt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new $d}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),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}}const va=new Ue,ri=new D,Fr=new D;class jd extends Jr{constructor(){super(new xt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Fe(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new D(1,0,0),new D(-1,0,0),new D(0,0,1),new D(0,0,-1),new D(0,1,0),new D(0,-1,0)],this._cubeUps=[new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,0,1),new D(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),ri.setFromMatrixPosition(e.matrixWorld),n.position.copy(ri),Fr.copy(n.position),Fr.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Fr),n.updateMatrixWorld(),r.makeTranslation(-ri.x,-ri.y,-ri.z),va.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(va)}}class Jd extends jr{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new jd}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Qd extends Jr{constructor(){super(new Wr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ef extends jr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.target=new nt,this.shadow=new Qd}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class tf{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class nf extends $n{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ln.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return ln.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),ln.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});ln.add(e,l),s.manager.itemStart(e)}}const Qr="\\[\\]\\.:\\/",rf=new RegExp("["+Qr+"]","g"),es="[^"+Qr+"]",sf="[^"+Qr.replace("\\.","")+"]",af=/((?:WC+[\/:])*)/.source.replace("WC",es),of=/(WCOD+)?/.source.replace("WCOD",sf),lf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",es),cf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",es),hf=new RegExp("^"+af+of+lf+cf+"$"),uf=["material","materials","bones","map"];class df{constructor(e,t,n){const r=n||Ye.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Ye{constructor(e,t,n){this.path=t,this.parsedPath=n||Ye.parseTrackName(t),this.node=Ye.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Ye.Composite(e,t,n):new Ye(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(rf,"")}static parseTrackName(e){const t=hf.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);uf.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),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===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Ye.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Ye.Composite=df;Ye.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ye.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ye.prototype.GetterByBindingType=[Ye.prototype._getValue_direct,Ye.prototype._getValue_array,Ye.prototype._getValue_arrayElement,Ye.prototype._getValue_toArray];Ye.prototype.SetterByBindingTypeAndVersioning=[[Ye.prototype._setValue_direct,Ye.prototype._setValue_direct_setNeedsUpdate,Ye.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ye.prototype._setValue_array,Ye.prototype._setValue_array_setNeedsUpdate,Ye.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ye.prototype._setValue_arrayElement,Ye.prototype._setValue_arrayElement_setNeedsUpdate,Ye.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ye.prototype._setValue_fromArray,Ye.prototype._setValue_fromArray_setNeedsUpdate,Ye.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ts{constructor(e){this.value=e}clone(){return new ts(this.value.clone===void 0?this.value:this.value.clone())}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Qi}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Qi);exports.AnimationClip=zd;exports.Bone=Na;exports.Box3=Qt;exports.BufferAttribute=At;exports.BufferGeometry=zt;exports.CanvasTexture=Dd;exports.ClampToEdgeWrapping=1001;exports.Color=Ie;exports.ColorManagement=ze;exports.CompressedArrayTexture=Pd;exports.CompressedCubeTexture=Ld;exports.CompressedTexture=Zr;exports.Data3DTexture=Sa;exports.DataTexture=Yr;exports.DirectionalLight=ef;exports.DisplayP3ColorSpace=er;exports.DoubleSide=2;exports.FileLoader=qd;exports.FloatType=1015;exports.FrontSide=0;exports.Group=ai;exports.HalfFloatType=1016;exports.ImageBitmapLoader=nf;exports.InstancedBufferAttribute=Or;exports.InstancedMesh=bd;exports.InterleavedBuffer=Sd;exports.InterleavedBufferAttribute=qr;exports.Interpolant=mi;exports.InterpolateDiscrete=2300;exports.InterpolateLinear=2301;exports.Line=$r;exports.LineBasicMaterial=Fa;exports.LineLoop=wd;exports.LineSegments=Rd;exports.LinearDisplayP3ColorSpace=di;exports.LinearFilter=1006;exports.LinearMipmapLinearFilter=1008;exports.LinearMipmapNearestFilter=1007;exports.LinearSRGBColorSpace=Jt;exports.Loader=$n;exports.LoaderUtils=tf;exports.Material=cn;exports.MathUtils=lo;exports.Matrix4=Ue;exports.Mesh=Tt;exports.MeshBasicMaterial=kr;exports.MeshPhysicalMaterial=Id;exports.MeshStandardMaterial=Oa;exports.MirroredRepeatWrapping=1002;exports.NearestFilter=1003;exports.NearestMipmapLinearFilter=1005;exports.NearestMipmapNearestFilter=1004;exports.NoColorSpace=$t;exports.NumberKeyframeTrack=hi;exports.Object3D=nt;exports.OrthographicCamera=Wr;exports.PerspectiveCamera=xt;exports.PlaneGeometry=pi;exports.PointLight=Jd;exports.Points=Cd;exports.PointsMaterial=Ba;exports.PropertyBinding=Ye;exports.Quaternion=Sn;exports.QuaternionKeyframeTrack=_i;exports.REVISION=Qi;exports.RGBAFormat=1023;exports.RGBA_ASTC_4x4_Format=37808;exports.RGBA_ASTC_6x6_Format=37812;exports.RGBA_BPTC_Format=36492;exports.RGBA_ETC2_EAC_Format=37496;exports.RGBA_PVRTC_4BPPV1_Format=35842;exports.RGBA_S3TC_DXT1_Format=33777;exports.RGBA_S3TC_DXT5_Format=33779;exports.RGB_ETC1_Format=36196;exports.RGB_ETC2_Format=37492;exports.RGB_PVRTC_4BPPV1_Format=35840;exports.RGFormat=1030;exports.RedFormat=1028;exports.RepeatWrapping=1e3;exports.SRGBColorSpace=Dt;exports.Scene=Md;exports.ShaderMaterial=jt;exports.Skeleton=Kr;exports.SkinnedMesh=Ed;exports.Source=Vr;exports.Sphere=Gt;exports.SpotLight=Zd;exports.Texture=lt;exports.TextureLoader=Kd;exports.TriangleFanDrawMode=2;exports.TriangleStripDrawMode=1;exports.TrianglesDrawMode=0;exports.Uniform=ts;exports.UnsignedByteType=1009;exports.Vector2=Fe;exports.Vector3=D;exports.VectorKeyframeTrack=ui;exports.WebGLRenderer=xd;