@viamrobotics/motion-tools 1.12.0 → 1.12.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.
@@ -0,0 +1,3580 @@
1
+ // AUTO-GENERATED by scripts/build-workers.js - do not edit
2
+ export const workerCode = `"use strict";(()=>{var Kn=1;var Qn=3,Kt=0;var Qt=1;var jt=100;var en=204,tn=205;var vn=0,yn=1,Mn=2,We=3,Sn=4,bn=5,An=6,Tn=7,jn=0,ei=1,ti=2;var En=1,wn=2,Cn=3,Rn=4,In=5,Pn=6,Ln=7;var Dn=300,ni=301,Un=302;var ii=306,nn=1e3,Ge=1001,sn=1002;var si=1006;var ri=1008;var ai=1009;var oi=1015;var li=1023;var Xe=2300,yt=2301,xt=2302,rn=2400,an=2401,on=2402;var Nn="",G="srgb",ln="srgb-linear",cn="linear",vt="srgb";var Me=7680;var hn=519;var un=35044;var He=2e3,dn=2001;function ci(p){for(let e=p.length-1;e>=0;--e)if(p[e]>=65535)return!0;return!1}function pi(p){return ArrayBuffer.isView(p)&&!(p instanceof DataView)}function fn(p){return document.createElementNS("http://www.w3.org/1999/xhtml",p)}var Bn={},Mt=null;function N(...p){let e="THREE."+p.shift();Mt?Mt("warn",e,...p):console.warn(e,...p)}function L(...p){let e="THREE."+p.shift();Mt?Mt("error",e,...p):console.error(e,...p)}function pn(...p){let e=p.join(" ");e in Bn||(Bn[e]=!0,N(...p))}var Se=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,e);e.target=null}}},V=["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"];var xa=Math.PI/180,mi=180/Math.PI;function Qe(){let p=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(V[p&255]+V[p>>8&255]+V[p>>16&255]+V[p>>24&255]+"-"+V[e&255]+V[e>>8&255]+"-"+V[e>>16&15|64]+V[e>>24&255]+"-"+V[t&63|128]+V[t>>8&255]+"-"+V[t>>16&255]+V[t>>24&255]+V[n&255]+V[n>>8&255]+V[n>>16&255]+V[n>>24&255]).toLowerCase()}function R(p,e,t){return Math.max(e,Math.min(t,p))}function gi(p,e){return(p%e+e)%e}function Bt(p,e,t){return(1-t)*p+t*e}function Oe(p,e){switch(e.constructor){case Float32Array:return p;case Uint32Array:return p/4294967295;case Uint16Array:return p/65535;case Uint8Array:return p/255;case Int32Array:return Math.max(p/2147483647,-1);case Int16Array:return Math.max(p/32767,-1);case Int8Array:return Math.max(p/127,-1);default:throw new Error("Invalid component type.")}}function X(p,e){switch(e.constructor){case Float32Array:return p;case Uint32Array:return Math.round(p*4294967295);case Uint16Array:return Math.round(p*65535);case Uint8Array:return Math.round(p*255);case Int32Array:return Math.round(p*2147483647);case Int16Array:return Math.round(p*32767);case Int8Array:return Math.round(p*127);default:throw new Error("Invalid component type.")}}var H=class p{constructor(e=0,t=0){p.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){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=R(this.x,e.x,t.x),this.y=R(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=R(this.x,e,t),this.y=R(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(R(n,e,t))}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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(R(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ae=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,r,a){let l=n[i+0],o=n[i+1],c=n[i+2],u=n[i+3],f=s[r+0],d=s[r+1],h=s[r+2],m=s[r+3];if(a<=0){e[t+0]=l,e[t+1]=o,e[t+2]=c,e[t+3]=u;return}if(a>=1){e[t+0]=f,e[t+1]=d,e[t+2]=h,e[t+3]=m;return}if(u!==m||l!==f||o!==d||c!==h){let _=l*f+o*d+c*h+u*m;_<0&&(f=-f,d=-d,h=-h,m=-m,_=-_);let g=1-a;if(_<.9995){let y=Math.acos(_),v=Math.sin(y);g=Math.sin(g*y)/v,a=Math.sin(a*y)/v,l=l*g+f*a,o=o*g+d*a,c=c*g+h*a,u=u*g+m*a}else{l=l*g+f*a,o=o*g+d*a,c=c*g+h*a,u=u*g+m*a;let y=1/Math.sqrt(l*l+o*o+c*c+u*u);l*=y,o*=y,c*=y,u*=y}}e[t]=l,e[t+1]=o,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,r){let a=n[i],l=n[i+1],o=n[i+2],c=n[i+3],u=s[r],f=s[r+1],d=s[r+2],h=s[r+3];return e[t]=a*h+c*u+l*d-o*f,e[t+1]=l*h+c*f+o*u-a*d,e[t+2]=o*h+c*d+a*f-l*u,e[t+3]=c*h-a*u-l*f-o*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,i=e._y,s=e._z,r=e._order,a=Math.cos,l=Math.sin,o=a(n/2),c=a(i/2),u=a(s/2),f=l(n/2),d=l(i/2),h=l(s/2);switch(r){case"XYZ":this._x=f*c*u+o*d*h,this._y=o*d*u-f*c*h,this._z=o*c*h+f*d*u,this._w=o*c*u-f*d*h;break;case"YXZ":this._x=f*c*u+o*d*h,this._y=o*d*u-f*c*h,this._z=o*c*h-f*d*u,this._w=o*c*u+f*d*h;break;case"ZXY":this._x=f*c*u-o*d*h,this._y=o*d*u+f*c*h,this._z=o*c*h+f*d*u,this._w=o*c*u-f*d*h;break;case"ZYX":this._x=f*c*u-o*d*h,this._y=o*d*u+f*c*h,this._z=o*c*h-f*d*u,this._w=o*c*u+f*d*h;break;case"YZX":this._x=f*c*u+o*d*h,this._y=o*d*u+f*c*h,this._z=o*c*h-f*d*u,this._w=o*c*u-f*d*h;break;case"XZY":this._x=f*c*u-o*d*h,this._y=o*d*u-f*c*h,this._z=o*c*h+f*d*u,this._w=o*c*u+f*d*h;break;default:N("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],a=t[5],l=t[9],o=t[2],c=t[6],u=t[10],f=n+a+u;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(c-l)*d,this._y=(s-o)*d,this._z=(r-i)*d}else if(n>a&&n>u){let d=2*Math.sqrt(1+n-a-u);this._w=(c-l)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+o)/d}else if(a>u){let d=2*Math.sqrt(1+a-n-u);this._w=(s-o)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(l+c)/d}else{let d=2*Math.sqrt(1+u-n-a);this._w=(r-i)/d,this._x=(s+o)/d,this._y=(l+c)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(R(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,r=e._w,a=t._x,l=t._y,o=t._z,c=t._w;return this._x=n*c+r*a+i*o-s*l,this._y=i*c+r*l+s*a-n*o,this._z=s*c+r*o+n*l-i*a,this._w=r*c-n*a-i*l-s*o,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,i=e._y,s=e._z,r=e._w,a=this.dot(e);a<0&&(n=-n,i=-i,s=-s,r=-r,a=-a);let l=1-t;if(a<.9995){let o=Math.acos(a),c=Math.sin(o);l=Math.sin(l*o)/c,t=Math.sin(t*o)/c,this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+r*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+r*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*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}},x=class p{constructor(e=0,t=0,n=0){p.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(zn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(zn.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,r=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,r=e.y,a=e.z,l=e.w,o=2*(r*i-a*n),c=2*(a*t-s*i),u=2*(s*n-r*t);return this.x=t+l*o+r*u-a*c,this.y=n+l*c+a*o-s*u,this.z=i+l*u+s*c-r*o,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=R(this.x,e.x,t.x),this.y=R(this.y,e.y,t.y),this.z=R(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=R(this.x,e,t),this.y=R(this.y,e,t),this.z=R(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(R(n,e,t))}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){let n=e.x,i=e.y,s=e.z,r=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*r-n*l,this.z=n*a-i*r,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return zt.copy(this).projectOnVector(e),this.sub(zt)}reflect(e){return this.sub(zt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(R(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}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(){let 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}},zt=new x,zn=new ae,w=class p{constructor(e,t,n,i,s,r,a,l,o){p.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,r,a,l,o)}set(e,t,n,i,s,r,a,l,o){let c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=n,c[7]=r,c[8]=o,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[3],l=n[6],o=n[1],c=n[4],u=n[7],f=n[2],d=n[5],h=n[8],m=i[0],_=i[3],g=i[6],y=i[1],v=i[4],b=i[7],S=i[2],E=i[5],T=i[8];return s[0]=r*m+a*y+l*S,s[3]=r*_+a*v+l*E,s[6]=r*g+a*b+l*T,s[1]=o*m+c*y+u*S,s[4]=o*_+c*v+u*E,s[7]=o*g+c*b+u*T,s[2]=f*m+d*y+h*S,s[5]=f*_+d*v+h*E,s[8]=f*g+d*b+h*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],l=e[6],o=e[7],c=e[8];return t*r*c-t*a*o-n*s*c+n*a*l+i*s*o-i*r*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],l=e[6],o=e[7],c=e[8],u=c*r-a*o,f=a*l-c*s,d=o*s-r*l,h=t*u+n*f+i*d;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/h;return e[0]=u*m,e[1]=(i*o-c*n)*m,e[2]=(a*n-i*r)*m,e[3]=f*m,e[4]=(c*t-i*l)*m,e[5]=(i*s-a*t)*m,e[6]=d*m,e[7]=(n*l-o*t)*m,e[8]=(r*t-n*s)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,r,a){let l=Math.cos(s),o=Math.sin(s);return this.set(n*l,n*o,-n*(l*r+o*a)+r+e,-i*o,i*l,-i*(-o*r+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Vt.makeScale(e,t)),this}rotate(e){return this.premultiply(Vt.makeRotation(-e)),this}translate(e,t){return this.premultiply(Vt.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){let 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){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Vt=new w,Vn=new w().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),kn=new w().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function _i(){let p={enabled:!0,workingColorSpace:ln,spaces:{},convert:function(i,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===vt&&(i.r=re(i.r),i.g=re(i.g),i.b=re(i.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===vt&&(i.r=De(i.r),i.g=De(i.g),i.b=De(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Nn?cn:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,r){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return pn("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),p.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return pn("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),p.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return p.define({[ln]:{primaries:e,whitePoint:n,transfer:cn,toXYZ:Vn,fromXYZ:kn,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:G},outputColorSpaceConfig:{drawingBufferColorSpace:G}},[G]:{primaries:e,whitePoint:n,transfer:vt,toXYZ:Vn,fromXYZ:kn,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:G}}}),p}var \$=_i();function re(p){return p<.04045?p*.0773993808:Math.pow(p*.9478672986+.0521327014,2.4)}function De(p){return p<.0031308?p*12.92:1.055*Math.pow(p,.41666)-.055}var Te,St=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Te===void 0&&(Te=fn("canvas")),Te.width=e.width,Te.height=e.height;let i=Te.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Te}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=fn("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=re(s[r]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(re(t[n]/255)*255):t[n]=re(t[n]);return{data:t,width:e.width,height:e.height}}else return N("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},xi=0,bt=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:xi++}),this.uuid=Qe(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,a=i.length;r<a;r++)i[r].isDataTexture?s.push(kt(i[r].image)):s.push(kt(i[r]))}else s=kt(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function kt(p){return typeof HTMLImageElement<"u"&&p instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&p instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&p instanceof ImageBitmap?St.getDataURL(p):p.data?{data:Array.from(p.data),width:p.width,height:p.height,type:p.data.constructor.name}:(N("Texture: Unable to serialize Texture."),{})}var vi=0,Gt=new x,Ue=class p extends Se{constructor(e=p.DEFAULT_IMAGE,t=p.DEFAULT_MAPPING,n=Ge,i=Ge,s=si,r=ri,a=li,l=ai,o=p.DEFAULT_ANISOTROPY,c=Nn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vi++}),this.uuid=Qe(),this.name="",this.source=new bt(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=o,this.format=a,this.internalFormat=null,this.type=l,this.offset=new H(0,0),this.repeat=new H(1,1),this.center=new H(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new w,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Gt).x}get height(){return this.source.getSize(Gt).y}get depth(){return this.source.getSize(Gt).z}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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){N(\`Texture.setValues(): parameter '\${t}' has value of undefined.\`);continue}let i=this[t];if(i===void 0){N(\`Texture.setValues(): property '\${t}' does not exist.\`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,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!==Dn)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nn:e.x=e.x-Math.floor(e.x);break;case Ge:e.x=e.x<0?0:1;break;case sn: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 nn:e.y=e.y-Math.floor(e.y);break;case Ge:e.y=e.y<0?0:1;break;case sn: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++}};Ue.DEFAULT_IMAGE=null;Ue.DEFAULT_MAPPING=Dn;Ue.DEFAULT_ANISOTROPY=1;var me=class{constructor(e=new x(1/0,1/0,1/0),t=new x(-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(K.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(K.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){let n=K.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);let n=e.geometry;if(n!==void 0){let s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let r=0,a=s.count;r<a;r++)e.isMesh===!0?e.getVertexPosition(r,K):K.fromBufferAttribute(s,r),K.applyMatrix4(e.matrixWorld),this.expandByPoint(K);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),at.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),at.copy(n.boundingBox)),at.applyMatrix4(e.matrixWorld),this.union(at)}let i=e.children;for(let s=0,r=i.length;s<r;s++)this.expandByObject(i[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,K),K.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(Be),ot.subVectors(this.max,Be),Ee.subVectors(e.a,Be),we.subVectors(e.b,Be),Ce.subVectors(e.c,Be),he.subVectors(we,Ee),ue.subVectors(Ce,we),ve.subVectors(Ee,Ce);let t=[0,-he.z,he.y,0,-ue.z,ue.y,0,-ve.z,ve.y,he.z,0,-he.x,ue.z,0,-ue.x,ve.z,0,-ve.x,-he.y,he.x,0,-ue.y,ue.x,0,-ve.y,ve.x,0];return!Ht(t,Ee,we,Ce,ot)||(t=[1,0,0,0,1,0,0,0,1],!Ht(t,Ee,we,Ce,ot))?!1:(lt.crossVectors(he,ue),t=[lt.x,lt.y,lt.z],Ht(t,Ee,we,Ce,ot))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,K).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(K).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:(te[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),te[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),te[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),te[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),te[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),te[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),te[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),te[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(te),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},te=[new x,new x,new x,new x,new x,new x,new x,new x],K=new x,at=new me,Ee=new x,we=new x,Ce=new x,he=new x,ue=new x,ve=new x,Be=new x,ot=new x,lt=new x,ye=new x;function Ht(p,e,t,n,i){for(let s=0,r=p.length-3;s<=r;s+=3){ye.fromArray(p,s);let a=i.x*Math.abs(ye.x)+i.y*Math.abs(ye.y)+i.z*Math.abs(ye.z),l=e.dot(ye),o=t.dot(ye),c=n.dot(ye);if(Math.max(-Math.max(l,o,c),Math.min(l,o,c))>a)return!1}return!0}var yi=new me,ze=new x,Wt=new x,qe=class{constructor(e=new x,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){let n=this.center;t!==void 0?n.copy(t):yi.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;s<r;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),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){let 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){let 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;ze.subVectors(e,this.center);let t=ze.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(ze,i/n),this.radius+=i}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):(Wt.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ze.copy(e.center).add(Wt)),this.expandByPoint(ze.copy(e.center).sub(Wt))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},ne=new x,Xt=new x,ct=new x,de=new x,qt=new x,ht=new x,Yt=new x,At=class{constructor(e=new x,t=new x(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,ne)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ne.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ne.copy(this.origin).addScaledVector(this.direction,t),ne.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Xt.copy(e).add(t).multiplyScalar(.5),ct.copy(t).sub(e).normalize(),de.copy(this.origin).sub(Xt);let s=e.distanceTo(t)*.5,r=-this.direction.dot(ct),a=de.dot(this.direction),l=-de.dot(ct),o=de.lengthSq(),c=Math.abs(1-r*r),u,f,d,h;if(c>0)if(u=r*l-a,f=r*a-l,h=s*c,u>=0)if(f>=-h)if(f<=h){let m=1/c;u*=m,f*=m,d=u*(u+r*f+2*a)+f*(r*u+f+2*l)+o}else f=s,u=Math.max(0,-(r*f+a)),d=-u*u+f*(f+2*l)+o;else f=-s,u=Math.max(0,-(r*f+a)),d=-u*u+f*(f+2*l)+o;else f<=-h?(u=Math.max(0,-(-r*s+a)),f=u>0?-s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+o):f<=h?(u=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+o):(u=Math.max(0,-(r*s+a)),f=u>0?s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+o);else f=r>0?-s:s,u=Math.max(0,-(r*f+a)),d=-u*u+f*(f+2*l)+o;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Xt).addScaledVector(ct,f),d}intersectSphere(e,t){ne.subVectors(e.center,this.origin);let n=ne.dot(this.direction),i=ne.dot(ne)-n*n,s=e.radius*e.radius;if(i>s)return null;let r=Math.sqrt(s-i),a=n-r,l=n+r;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,r,a,l,o=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,f=this.origin;return o>=0?(n=(e.min.x-f.x)*o,i=(e.max.x-f.x)*o):(n=(e.max.x-f.x)*o,i=(e.min.x-f.x)*o),c>=0?(s=(e.min.y-f.y)*c,r=(e.max.y-f.y)*c):(s=(e.max.y-f.y)*c,r=(e.min.y-f.y)*c),n>r||s>i||((s>n||isNaN(n))&&(n=s),(r<i||isNaN(i))&&(i=r),u>=0?(a=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ne)!==null}intersectTriangle(e,t,n,i,s){qt.subVectors(t,e),ht.subVectors(n,e),Yt.crossVectors(qt,ht);let r=this.direction.dot(Yt),a;if(r>0){if(i)return null;a=1}else if(r<0)a=-1,r=-r;else return null;de.subVectors(this.origin,e);let l=a*this.direction.dot(ht.crossVectors(de,ht));if(l<0)return null;let o=a*this.direction.dot(qt.cross(de));if(o<0||l+o>r)return null;let c=-a*de.dot(Yt);return c<0?null:this.at(c/r,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)}},j=class p{constructor(e,t,n,i,s,r,a,l,o,c,u,f,d,h,m,_){p.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,i,s,r,a,l,o,c,u,f,d,h,m,_)}set(e,t,n,i,s,r,a,l,o,c,u,f,d,h,m,_){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=r,g[9]=a,g[13]=l,g[2]=o,g[6]=c,g[10]=u,g[14]=f,g[3]=d,g[7]=h,g[11]=m,g[15]=_,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 p().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Re.setFromMatrixColumn(e,0).length(),s=1/Re.setFromMatrixColumn(e,1).length(),r=1/Re.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,s=e.z,r=Math.cos(n),a=Math.sin(n),l=Math.cos(i),o=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){let f=r*c,d=r*u,h=a*c,m=a*u;t[0]=l*c,t[4]=-l*u,t[8]=o,t[1]=d+h*o,t[5]=f-m*o,t[9]=-a*l,t[2]=m-f*o,t[6]=h+d*o,t[10]=r*l}else if(e.order==="YXZ"){let f=l*c,d=l*u,h=o*c,m=o*u;t[0]=f+m*a,t[4]=h*a-d,t[8]=r*o,t[1]=r*u,t[5]=r*c,t[9]=-a,t[2]=d*a-h,t[6]=m+f*a,t[10]=r*l}else if(e.order==="ZXY"){let f=l*c,d=l*u,h=o*c,m=o*u;t[0]=f-m*a,t[4]=-r*u,t[8]=h+d*a,t[1]=d+h*a,t[5]=r*c,t[9]=m-f*a,t[2]=-r*o,t[6]=a,t[10]=r*l}else if(e.order==="ZYX"){let f=r*c,d=r*u,h=a*c,m=a*u;t[0]=l*c,t[4]=h*o-d,t[8]=f*o+m,t[1]=l*u,t[5]=m*o+f,t[9]=d*o-h,t[2]=-o,t[6]=a*l,t[10]=r*l}else if(e.order==="YZX"){let f=r*l,d=r*o,h=a*l,m=a*o;t[0]=l*c,t[4]=m-f*u,t[8]=h*u+d,t[1]=u,t[5]=r*c,t[9]=-a*c,t[2]=-o*c,t[6]=d*u+h,t[10]=f-m*u}else if(e.order==="XZY"){let f=r*l,d=r*o,h=a*l,m=a*o;t[0]=l*c,t[4]=-u,t[8]=o*c,t[1]=f*u+m,t[5]=r*c,t[9]=d*u-h,t[2]=h*u-d,t[6]=a*c,t[10]=m*u+f}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(Mi,e,Si)}lookAt(e,t,n){let i=this.elements;return q.subVectors(e,t),q.lengthSq()===0&&(q.z=1),q.normalize(),fe.crossVectors(n,q),fe.lengthSq()===0&&(Math.abs(n.z)===1?q.x+=1e-4:q.z+=1e-4,q.normalize(),fe.crossVectors(n,q)),fe.normalize(),ut.crossVectors(q,fe),i[0]=fe.x,i[4]=ut.x,i[8]=q.x,i[1]=fe.y,i[5]=ut.y,i[9]=q.y,i[2]=fe.z,i[6]=ut.z,i[10]=q.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,r=n[0],a=n[4],l=n[8],o=n[12],c=n[1],u=n[5],f=n[9],d=n[13],h=n[2],m=n[6],_=n[10],g=n[14],y=n[3],v=n[7],b=n[11],S=n[15],E=i[0],T=i[4],A=i[8],P=i[12],O=i[1],U=i[5],le=i[9],z=i[13],ce=i[2],je=i[6],et=i[10],tt=i[14],nt=i[3],it=i[7],st=i[11],rt=i[15];return s[0]=r*E+a*O+l*ce+o*nt,s[4]=r*T+a*U+l*je+o*it,s[8]=r*A+a*le+l*et+o*st,s[12]=r*P+a*z+l*tt+o*rt,s[1]=c*E+u*O+f*ce+d*nt,s[5]=c*T+u*U+f*je+d*it,s[9]=c*A+u*le+f*et+d*st,s[13]=c*P+u*z+f*tt+d*rt,s[2]=h*E+m*O+_*ce+g*nt,s[6]=h*T+m*U+_*je+g*it,s[10]=h*A+m*le+_*et+g*st,s[14]=h*P+m*z+_*tt+g*rt,s[3]=y*E+v*O+b*ce+S*nt,s[7]=y*T+v*U+b*je+S*it,s[11]=y*A+v*le+b*et+S*st,s[15]=y*P+v*z+b*tt+S*rt,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],a=e[5],l=e[9],o=e[13],c=e[2],u=e[6],f=e[10],d=e[14],h=e[3],m=e[7],_=e[11],g=e[15],y=l*d-o*f,v=a*d-o*u,b=a*f-l*u,S=r*d-o*c,E=r*f-l*c,T=r*u-a*c;return t*(m*y-_*v+g*b)-n*(h*y-_*S+g*E)+i*(h*v-m*S+g*T)-s*(h*b-m*E+_*T)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],a=e[5],l=e[6],o=e[7],c=e[8],u=e[9],f=e[10],d=e[11],h=e[12],m=e[13],_=e[14],g=e[15],y=u*_*o-m*f*o+m*l*d-a*_*d-u*l*g+a*f*g,v=h*f*o-c*_*o-h*l*d+r*_*d+c*l*g-r*f*g,b=c*m*o-h*u*o+h*a*d-r*m*d-c*a*g+r*u*g,S=h*u*l-c*m*l-h*a*f+r*m*f+c*a*_-r*u*_,E=t*y+n*v+i*b+s*S;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let T=1/E;return e[0]=y*T,e[1]=(m*f*s-u*_*s-m*i*d+n*_*d+u*i*g-n*f*g)*T,e[2]=(a*_*s-m*l*s+m*i*o-n*_*o-a*i*g+n*l*g)*T,e[3]=(u*l*s-a*f*s-u*i*o+n*f*o+a*i*d-n*l*d)*T,e[4]=v*T,e[5]=(c*_*s-h*f*s+h*i*d-t*_*d-c*i*g+t*f*g)*T,e[6]=(h*l*s-r*_*s-h*i*o+t*_*o+r*i*g-t*l*g)*T,e[7]=(r*f*s-c*l*s+c*i*o-t*f*o-r*i*d+t*l*d)*T,e[8]=b*T,e[9]=(h*u*s-c*m*s-h*n*d+t*m*d+c*n*g-t*u*g)*T,e[10]=(r*m*s-h*a*s+h*n*o-t*m*o-r*n*g+t*a*g)*T,e[11]=(c*a*s-r*u*s-c*n*o+t*u*o+r*n*d-t*a*d)*T,e[12]=S*T,e[13]=(c*m*i-h*u*i+h*n*f-t*m*f-c*n*_+t*u*_)*T,e[14]=(h*a*i-r*m*i-h*n*l+t*m*l+r*n*_-t*a*_)*T,e[15]=(r*u*i-c*a*i+c*n*l-t*u*l-r*n*f+t*a*f)*T,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return 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){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,r=e.x,a=e.y,l=e.z,o=s*r,c=s*a;return this.set(o*r+n,o*a-i*l,o*l+i*a,0,o*a+i*l,c*a+n,c*l-i*r,0,o*l-i*a,c*l+i*r,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,r=t._y,a=t._z,l=t._w,o=s+s,c=r+r,u=a+a,f=s*o,d=s*c,h=s*u,m=r*c,_=r*u,g=a*u,y=l*o,v=l*c,b=l*u,S=n.x,E=n.y,T=n.z;return i[0]=(1-(m+g))*S,i[1]=(d+b)*S,i[2]=(h-v)*S,i[3]=0,i[4]=(d-b)*E,i[5]=(1-(f+g))*E,i[6]=(_+y)*E,i[7]=0,i[8]=(h+v)*T,i[9]=(_-y)*T,i[10]=(1-(f+m))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;if(e.x=i[12],e.y=i[13],e.z=i[14],this.determinant()===0)return n.set(1,1,1),t.identity(),this;let s=Re.set(i[0],i[1],i[2]).length(),r=Re.set(i[4],i[5],i[6]).length(),a=Re.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),Q.copy(this);let o=1/s,c=1/r,u=1/a;return Q.elements[0]*=o,Q.elements[1]*=o,Q.elements[2]*=o,Q.elements[4]*=c,Q.elements[5]*=c,Q.elements[6]*=c,Q.elements[8]*=u,Q.elements[9]*=u,Q.elements[10]*=u,t.setFromRotationMatrix(Q),n.x=s,n.y=r,n.z=a,this}makePerspective(e,t,n,i,s,r,a=He,l=!1){let o=this.elements,c=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),d=(n+i)/(n-i),h,m;if(l)h=s/(r-s),m=r*s/(r-s);else if(a===He)h=-(r+s)/(r-s),m=-2*r*s/(r-s);else if(a===dn)h=-r/(r-s),m=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return o[0]=c,o[4]=0,o[8]=f,o[12]=0,o[1]=0,o[5]=u,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=m,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,s,r,a=He,l=!1){let o=this.elements,c=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),d=-(n+i)/(n-i),h,m;if(l)h=1/(r-s),m=r/(r-s);else if(a===He)h=-2/(r-s),m=-(r+s)/(r-s);else if(a===dn)h=-1/(r-s),m=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return o[0]=c,o[4]=0,o[8]=0,o[12]=f,o[1]=0,o[5]=u,o[9]=0,o[13]=d,o[2]=0,o[6]=0,o[10]=h,o[14]=m,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Re=new x,Q=new j,Mi=new x(0,0,0),Si=new x(1,1,1),fe=new x,ut=new x,q=new x,Gn=new j,Hn=new ae,Ye=class p{constructor(e=0,t=0,n=0,i=p.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],r=i[4],a=i[8],l=i[1],o=i[5],c=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(R(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(f,o),this._z=0);break;case"YXZ":this._x=Math.asin(-R(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,o)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(R(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-r,o)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-R(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-r,o));break;case"YZX":this._z=Math.asin(R(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,o),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-R(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(f,o),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,d),this._y=0);break;default:N("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Gn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Gn,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Hn.setFromEuler(this),this.setFromQuaternion(Hn,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}};Ye.DEFAULT_ORDER="XYZ";var Tt=class{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}},bi=0,Wn=new x,Ie=new ae,ie=new j,dt=new x,Ve=new x,Ai=new x,Ti=new ae,Xn=new x(1,0,0),qn=new x(0,1,0),Yn=new x(0,0,1),Zn={type:"added"},Ei={type:"removed"},Pe={type:"childadded",child:null},Zt={type:"childremoved",child:null},ge=class p extends Se{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:bi++}),this.uuid=Qe(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=p.DEFAULT_UP.clone();let e=new x,t=new Ye,n=new ae,i=new x(1,1,1);function s(){n.setFromEuler(t,!1)}function r(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(r),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:i},modelViewMatrix:{value:new j},normalMatrix:{value:new w}}),this.matrix=new j,this.matrixWorld=new j,this.matrixAutoUpdate=p.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=p.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Tt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(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 Ie.setFromAxisAngle(e,t),this.quaternion.multiply(Ie),this}rotateOnWorldAxis(e,t){return Ie.setFromAxisAngle(e,t),this.quaternion.premultiply(Ie),this}rotateX(e){return this.rotateOnAxis(Xn,e)}rotateY(e){return this.rotateOnAxis(qn,e)}rotateZ(e){return this.rotateOnAxis(Yn,e)}translateOnAxis(e,t){return Wn.copy(e).applyQuaternion(this.quaternion),this.position.add(Wn.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Xn,e)}translateY(e){return this.translateOnAxis(qn,e)}translateZ(e){return this.translateOnAxis(Yn,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ie.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?dt.copy(e):dt.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Ve.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ie.lookAt(Ve,dt,this.up):ie.lookAt(dt,Ve,this.up),this.quaternion.setFromRotationMatrix(ie),i&&(ie.extractRotation(i.matrixWorld),Ie.setFromRotationMatrix(ie),this.quaternion.premultiply(Ie.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(L("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(Zn),Pe.child=e,this.dispatchEvent(Pe),Pe.child=null):L("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}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ei),Zt.child=e,this.dispatchEvent(Zt),Zt.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ie.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ie.multiply(e.parent.matrixWorld)),e.applyMatrix4(ie),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Zn),Pe.child=e,this.dispatchEvent(Pe),Pe.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,i=this.children.length;n<i;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;s++)i[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(Ve,e,Ai),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ve,Ti,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let 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);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let 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){let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let o=0,c=l.length;o<c;o++){let u=l[o];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,o=this.material.length;l<o;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=r(e.geometries),l=r(e.materials),o=r(e.textures),c=r(e.images),u=r(e.shapes),f=r(e.skeletons),d=r(e.animations),h=r(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),o.length>0&&(n.textures=o),c.length>0&&(n.images=c),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),h.length>0&&(n.nodes=h)}return n.object=i,n;function r(a){let l=[];for(let o in a){let c=a[o];delete c.metadata,l.push(c)}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++){let i=e.children[n];this.add(i.clone())}return this}};ge.DEFAULT_UP=new x(0,1,0);ge.DEFAULT_MATRIX_AUTO_UPDATE=!0;ge.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var hi={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},pe={h:0,s:0,l:0},ft={h:0,s:0,l:0};function Jt(p,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?p+(e-p)*6*t:t<1/2?e:t<2/3?p+(e-p)*6*(2/3-t):p}var D=class{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){let i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=G){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,\$.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=\$.workingColorSpace){return this.r=e,this.g=t,this.b=n,\$.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=\$.workingColorSpace){if(e=gi(e,1),t=R(t,0,1),n=R(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=Jt(r,s,e+1/3),this.g=Jt(r,s,e),this.b=Jt(r,s,e-1/3)}return \$.colorSpaceToWorking(this,i),this}setStyle(e,t=G){function n(s){s!==void 0&&parseFloat(s)<1&&N("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\\w+)\\(([^\\)]*)\\)/.exec(e)){let s,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?\$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?\$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,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(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:N("Color: Unknown color model "+e)}}else if(i=/^\\#([A-Fa-f\\d]+)\$/.exec(e)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(s,16),t);N("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=G){let n=hi[e.toLowerCase()];return n!==void 0?this.setHex(n,t):N("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=re(e.r),this.g=re(e.g),this.b=re(e.b),this}copyLinearToSRGB(e){return this.r=De(e.r),this.g=De(e.g),this.b=De(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=G){return \$.workingToColorSpace(k.copy(this),e),Math.round(R(k.r*255,0,255))*65536+Math.round(R(k.g*255,0,255))*256+Math.round(R(k.b*255,0,255))}getHexString(e=G){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=\$.workingColorSpace){\$.workingToColorSpace(k.copy(this),t);let n=k.r,i=k.g,s=k.b,r=Math.max(n,i,s),a=Math.min(n,i,s),l,o,c=(a+r)/2;if(a===r)l=0,o=0;else{let u=r-a;switch(o=c<=.5?u/(r+a):u/(2-r-a),r){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return e.h=l,e.s=o,e.l=c,e}getRGB(e,t=\$.workingColorSpace){return \$.workingToColorSpace(k.copy(this),t),e.r=k.r,e.g=k.g,e.b=k.b,e}getStyle(e=G){\$.workingToColorSpace(k.copy(this),e);let t=k.r,n=k.g,i=k.b;return e!==G?\`color(\${e} \${t.toFixed(3)} \${n.toFixed(3)} \${i.toFixed(3)})\`:\`rgb(\${Math.round(t*255)},\${Math.round(n*255)},\${Math.round(i*255)})\`}offsetHSL(e,t,n){return this.getHSL(pe),this.setHSL(pe.h+e,pe.s+t,pe.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(pe),e.getHSL(ft);let n=Bt(pe.h,ft.h,t),i=Bt(pe.s,ft.s,t),s=Bt(pe.l,ft.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,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}},k=new D;D.NAMES=hi;var wi=0,Et=class extends Se{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wi++}),this.uuid=Qe(),this.name="",this.type="Material",this.blending=Qt,this.side=Kt,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=en,this.blendDst=tn,this.blendEquation=jt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new D(0,0,0),this.blendAlpha=0,this.depthFunc=We,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=hn,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Me,this.stencilZFail=Me,this.stencilZPass=Me,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){N(\`Material: parameter '\${t}' has value of undefined.\`);continue}let i=this[t];if(i===void 0){N(\`Material: '\${t}' is not a property of THREE.\${this.type}.\`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),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!==Qt&&(n.blending=this.blending),this.side!==Kt&&(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!==en&&(n.blendSrc=this.blendSrc),this.blendDst!==tn&&(n.blendDst=this.blendDst),this.blendEquation!==jt&&(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!==We&&(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!==hn&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Me&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Me&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Me&&(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.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){let r=[];for(let a in s){let l=s[a];delete l.metadata,r.push(l)}return r}if(t){let s=i(e.textures),r=i(e.images);s.length>0&&(n.textures=s),r.length>0&&(n.images=r)}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;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,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++}};var F=new x,pt=new H,Ci=0,ee=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Ci++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=un,this.updateRanges=[],this.gpuType=oi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}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 i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];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++)pt.fromBufferAttribute(this,t),pt.applyMatrix3(e),this.setXY(t,pt.x,pt.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)F.fromBufferAttribute(this,t),F.applyMatrix3(e),this.setXYZ(t,F.x,F.y,F.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)F.fromBufferAttribute(this,t),F.applyMatrix4(e),this.setXYZ(t,F.x,F.y,F.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)F.fromBufferAttribute(this,t),F.applyNormalMatrix(e),this.setXYZ(t,F.x,F.y,F.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)F.fromBufferAttribute(this,t),F.transformDirection(e),this.setXYZ(t,F.x,F.y,F.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=Oe(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=X(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Oe(t,this.array)),t}setX(e,t){return this.normalized&&(t=X(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Oe(t,this.array)),t}setY(e,t){return this.normalized&&(t=X(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=Oe(t,this.array)),t}setZ(e,t){return this.normalized&&(t=X(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=Oe(t,this.array)),t}setW(e,t){return this.normalized&&(t=X(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=X(t,this.array),n=X(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=X(t,this.array),n=X(n,this.array),i=X(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=X(t,this.array),n=X(n,this.array),i=X(i,this.array),s=X(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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(){let 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!==un&&(e.usage=this.usage),e}};var wt=class extends ee{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Ze=class extends ee{constructor(e,t,n){super(new Int32Array(e),t,n)}},Ct=class extends ee{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var oe=class extends ee{constructor(e,t,n){super(new Float32Array(e),t,n)}},Ri=0,J=new j,\$t=new ge,Le=new x,Y=new me,ke=new me,B=new x,Ne=class p extends Se{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ri++}),this.uuid=Qe(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ci(e)?Ct:wt)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new w().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return J.makeRotationFromQuaternion(e),this.applyMatrix4(J),this}rotateX(e){return J.makeRotationX(e),this.applyMatrix4(J),this}rotateY(e){return J.makeRotationY(e),this.applyMatrix4(J),this}rotateZ(e){return J.makeRotationZ(e),this.applyMatrix4(J),this}translate(e,t,n){return J.makeTranslation(e,t,n),this.applyMatrix4(J),this}scale(e,t,n){return J.makeScale(e,t,n),this.applyMatrix4(J),this}lookAt(e){return \$t.lookAt(e),\$t.updateMatrix(),this.applyMatrix4(\$t.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Le).negate(),this.translate(Le.x,Le.y,Le.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,s=e.length;i<s;i++){let r=e[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new oe(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&N("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new me);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){L("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new x(-1/0,-1/0,-1/0),new x(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];Y.setFromBufferAttribute(s),this.morphTargetsRelative?(B.addVectors(this.boundingBox.min,Y.min),this.boundingBox.expandByPoint(B),B.addVectors(this.boundingBox.max,Y.max),this.boundingBox.expandByPoint(B)):(this.boundingBox.expandByPoint(Y.min),this.boundingBox.expandByPoint(Y.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&L('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 qe);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){L("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new x,1/0);return}if(e){let n=this.boundingSphere.center;if(Y.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){let a=t[s];ke.setFromBufferAttribute(a),this.morphTargetsRelative?(B.addVectors(Y.min,ke.min),Y.expandByPoint(B),B.addVectors(Y.max,ke.max),Y.expandByPoint(B)):(Y.expandByPoint(ke.min),Y.expandByPoint(ke.max))}Y.getCenter(n);let i=0;for(let s=0,r=e.count;s<r;s++)B.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(B));if(t)for(let s=0,r=t.length;s<r;s++){let a=t[s],l=this.morphTargetsRelative;for(let o=0,c=a.count;o<c;o++)B.fromBufferAttribute(a,o),l&&(Le.fromBufferAttribute(e,o),B.add(Le)),i=Math.max(i,n.distanceToSquared(B))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&L('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){L("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ee(new Float32Array(4*n.count),4));let r=this.getAttribute("tangent"),a=[],l=[];for(let A=0;A<n.count;A++)a[A]=new x,l[A]=new x;let o=new x,c=new x,u=new x,f=new H,d=new H,h=new H,m=new x,_=new x;function g(A,P,O){o.fromBufferAttribute(n,A),c.fromBufferAttribute(n,P),u.fromBufferAttribute(n,O),f.fromBufferAttribute(s,A),d.fromBufferAttribute(s,P),h.fromBufferAttribute(s,O),c.sub(o),u.sub(o),d.sub(f),h.sub(f);let U=1/(d.x*h.y-h.x*d.y);isFinite(U)&&(m.copy(c).multiplyScalar(h.y).addScaledVector(u,-d.y).multiplyScalar(U),_.copy(u).multiplyScalar(d.x).addScaledVector(c,-h.x).multiplyScalar(U),a[A].add(m),a[P].add(m),a[O].add(m),l[A].add(_),l[P].add(_),l[O].add(_))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let A=0,P=y.length;A<P;++A){let O=y[A],U=O.start,le=O.count;for(let z=U,ce=U+le;z<ce;z+=3)g(e.getX(z+0),e.getX(z+1),e.getX(z+2))}let v=new x,b=new x,S=new x,E=new x;function T(A){S.fromBufferAttribute(i,A),E.copy(S);let P=a[A];v.copy(P),v.sub(S.multiplyScalar(S.dot(P))).normalize(),b.crossVectors(E,P);let U=b.dot(l[A])<0?-1:1;r.setXYZW(A,v.x,v.y,v.z,U)}for(let A=0,P=y.length;A<P;++A){let O=y[A],U=O.start,le=O.count;for(let z=U,ce=U+le;z<ce;z+=3)T(e.getX(z+0)),T(e.getX(z+1)),T(e.getX(z+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ee(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);let i=new x,s=new x,r=new x,a=new x,l=new x,o=new x,c=new x,u=new x;if(e)for(let f=0,d=e.count;f<d;f+=3){let h=e.getX(f+0),m=e.getX(f+1),_=e.getX(f+2);i.fromBufferAttribute(t,h),s.fromBufferAttribute(t,m),r.fromBufferAttribute(t,_),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),a.fromBufferAttribute(n,h),l.fromBufferAttribute(n,m),o.fromBufferAttribute(n,_),a.add(c),l.add(c),o.add(c),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(m,l.x,l.y,l.z),n.setXYZ(_,o.x,o.y,o.z)}else for(let f=0,d=t.count;f<d;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),r.fromBufferAttribute(t,f+2),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),n.setXYZ(f+0,c.x,c.y,c.z),n.setXYZ(f+1,c.x,c.y,c.z),n.setXYZ(f+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)B.fromBufferAttribute(e,t),B.normalize(),e.setXYZ(t,B.x,B.y,B.z)}toNonIndexed(){function e(a,l){let o=a.array,c=a.itemSize,u=a.normalized,f=new o.constructor(l.length*c),d=0,h=0;for(let m=0,_=l.length;m<_;m++){a.isInterleavedBufferAttribute?d=l[m]*a.data.stride+a.offset:d=l[m]*c;for(let g=0;g<c;g++)f[h++]=o[d++]}return new ee(f,c,u)}if(this.index===null)return N("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new p,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],o=e(l,n);t.setAttribute(a,o)}let s=this.morphAttributes;for(let a in s){let l=[],o=s[a];for(let c=0,u=o.length;c<u;c++){let f=o[c],d=e(f,n);l.push(d)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let a=0,l=r.length;a<l;a++){let o=r[a];t.addGroup(o.start,o.count,o.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,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){let l=this.parameters;for(let o in l)l[o]!==void 0&&(e[o]=l[o]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let o=n[l];e.data.attributes[l]=o.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let o=this.morphAttributes[l],c=[];for(let u=0,f=o.length;u<f;u++){let d=o[u];c.push(d.toJSON(e.data))}c.length>0&&(i[l]=c,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let i=e.attributes;for(let o in i){let c=i[o];this.setAttribute(o,c.clone(t))}let s=e.morphAttributes;for(let o in s){let c=[],u=s[o];for(let f=0,d=u.length;f<d;f++)c.push(u[f].clone(t));this.morphAttributes[o]=c}this.morphTargetsRelative=e.morphTargetsRelative;let r=e.groups;for(let o=0,c=r.length;o<c;o++){let u=r[o];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let 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"})}};function ui(p){let e={};for(let t in p){e[t]={};for(let n in p[t]){let i=p[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(N("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function W(p){let e={};for(let t=0;t<p.length;t++){let n=ui(p[t]);for(let i in n)e[i]=n[i]}return e}var Fe=class extends Et{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new D(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}},Jn=new j,mn=new At,mt=new qe,gt=new x,Je=class extends ge{constructor(e=new Ne,t=new Fe){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,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){let n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,r=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),mt.copy(n.boundingSphere),mt.applyMatrix4(i),mt.radius+=s,e.ray.intersectsSphere(mt)===!1)return;Jn.copy(i).invert(),mn.copy(e.ray).applyMatrix4(Jn);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,o=n.index,u=n.attributes.position;if(o!==null){let f=Math.max(0,r.start),d=Math.min(o.count,r.start+r.count);for(let h=f,m=d;h<m;h++){let _=o.getX(h);gt.fromBufferAttribute(u,_),\$n(gt,_,l,i,e,t,this)}}else{let f=Math.max(0,r.start),d=Math.min(u.count,r.start+r.count);for(let h=f,m=d;h<m;h++)gt.fromBufferAttribute(u,h),\$n(gt,h,l,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function \$n(p,e,t,n,i,s,r){let a=mn.distanceSqToPoint(p);if(a<t){let l=new x;mn.closestPointToPoint(p,l),l.applyMatrix4(n);let o=i.ray.origin.distanceTo(l);if(o<i.near||o>i.far)return;s.push({distance:o,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:r})}}function _t(p,e){return!p||p.constructor===e?p:typeof e.BYTES_PER_ELEMENT=="number"?new e(p):Array.prototype.slice.call(p)}var be=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let r;t:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}r=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}r=n,n=0;break t}break n}for(;n<r;){let a=n+r>>>1;e<t[a]?r=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let r=0;r!==i;++r)t[r]=n[s+r];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Rt=class extends be{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:rn,endingEnd:rn}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,r=e+1,a=i[s],l=i[r];if(a===void 0)switch(this.getSettings_().endingStart){case an:s=e,a=2*t-n;break;case on:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case an:r=e,l=2*n-t;break;case on:r=1,l=n+i[1]-i[0];break;default:r=e-1,l=t}let o=(n-t)*.5,c=this.valueSize;this._weightPrev=o/(t-a),this._weightNext=o/(l-n),this._offsetPrev=s*c,this._offsetNext=r*c}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=e*a,o=l-a,c=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,h=(n-t)/(i-t),m=h*h,_=m*h,g=-f*_+2*f*m-f*h,y=(1+f)*_+(-1.5-2*f)*m+(-.5+f)*h+1,v=(-1-d)*_+(1.5+d)*m+.5*h,b=d*_-d*m;for(let S=0;S!==a;++S)s[S]=g*r[c+S]+y*r[o+S]+v*r[l+S]+b*r[u+S];return s}},It=class extends be{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=e*a,o=l-a,c=(n-t)/(i-t),u=1-c;for(let f=0;f!==a;++f)s[f]=r[o+f]*u+r[l+f]*c;return s}},Pt=class extends be{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Z=class{constructor(e,t,n,i){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=_t(t,this.TimeBufferType),this.values=_t(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:_t(e.times,Array),values:_t(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Pt(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new It(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Rt(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Xe:t=this.InterpolantFactoryMethodDiscrete;break;case yt:t=this.InterpolantFactoryMethodLinear;break;case xt:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let 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 N("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Xe;case this.InterpolantFactoryMethodLinear:return yt;case this.InterpolantFactoryMethodSmooth:return xt}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,r=i-1;for(;s!==i&&n[s]<e;)++s;for(;r!==-1&&n[r]>t;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);let a=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*a,r*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(L("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(L("KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){L("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(r!==null&&r>l){L("KeyframeTrack: Out of order keys.",this,a,l,r),e=!1;break}r=l}if(i!==void 0&&pi(i))for(let a=0,l=i.length;a!==l;++a){let o=i[a];if(isNaN(o)){L("KeyframeTrack: Value is not a valid number.",this,a,o),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===xt,s=e.length-1,r=1;for(let a=1;a<s;++a){let l=!1,o=e[a],c=e[a+1];if(o!==c&&(a!==1||o!==e[0]))if(i)l=!0;else{let u=a*n,f=u-n,d=u+n;for(let h=0;h!==n;++h){let m=t[u+h];if(m!==t[f+h]||m!==t[d+h]){l=!0;break}}}if(l){if(a!==r){e[r]=e[a];let u=a*n,f=r*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++r}}if(s>0){e[r]=e[s];for(let a=s*n,l=r*n,o=0;o!==n;++o)t[l+o]=t[a+o];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Z.prototype.ValueTypeName="";Z.prototype.TimeBufferType=Float32Array;Z.prototype.ValueBufferType=Float32Array;Z.prototype.DefaultInterpolation=yt;var _e=class extends Z{constructor(e,t,n){super(e,t,n)}};_e.prototype.ValueTypeName="bool";_e.prototype.ValueBufferType=Array;_e.prototype.DefaultInterpolation=Xe;_e.prototype.InterpolantFactoryMethodLinear=void 0;_e.prototype.InterpolantFactoryMethodSmooth=void 0;var Lt=class extends Z{constructor(e,t,n,i){super(e,t,n,i)}};Lt.prototype.ValueTypeName="color";var Dt=class extends Z{constructor(e,t,n,i){super(e,t,n,i)}};Dt.prototype.ValueTypeName="number";var Ut=class extends be{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),o=e*a;for(let c=o+a;o!==c;o+=4)ae.slerpFlat(s,0,r,o-a,r,o,l);return s}},\$e=class extends Z{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Ut(this.times,this.values,this.getValueSize(),e)}};\$e.prototype.ValueTypeName="quaternion";\$e.prototype.InterpolantFactoryMethodSmooth=void 0;var xe=class extends Z{constructor(e,t,n){super(e,t,n)}};xe.prototype.ValueTypeName="string";xe.prototype.ValueBufferType=Array;xe.prototype.DefaultInterpolation=Xe;xe.prototype.InterpolantFactoryMethodLinear=void 0;xe.prototype.InterpolantFactoryMethodSmooth=void 0;var Nt=class extends Z{constructor(e,t,n,i){super(e,t,n,i)}};Nt.prototype.ValueTypeName="vector";var gn={enabled:!1,files:{},add:function(p,e){this.enabled!==!1&&(this.files[p]=e)},get:function(p){if(this.enabled!==!1)return this.files[p]},remove:function(p){delete this.files[p]},clear:function(){this.files={}}},Ft=class{constructor(e,t,n){let i=this,s=!1,r=0,a=0,l,o=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,r,a),s=!0},this.itemEnd=function(c){r++,i.onProgress!==void 0&&i.onProgress(c,r,a),r===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,u){return o.push(c,u),this},this.removeHandler=function(c){let u=o.indexOf(c);return u!==-1&&o.splice(u,2),this},this.getHandler=function(c){for(let u=0,f=o.length;u<f;u+=2){let d=o[u],h=o[u+1];if(d.global&&(d.lastIndex=0),d.test(c))return h}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},di=new Ft,Ae=class{constructor(e){this.manager=e!==void 0?e:di,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,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}abort(){return this}};Ae.DEFAULT_MATERIAL_NAME="__DEFAULT";var se={},_n=class extends Error{constructor(e,t){super(e),this.response=t}},Ke=class extends Ae{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=gn.get(\`file:\${e}\`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(se[e]!==void 0){se[e].push({onLoad:t,onProgress:n,onError:i});return}se[e]=[],se[e].push({onLoad:t,onProgress:n,onError:i});let r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(r).then(o=>{if(o.status===200||o.status===0){if(o.status===0&&N("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||o.body===void 0||o.body.getReader===void 0)return o;let c=se[e],u=o.body.getReader(),f=o.headers.get("X-File-Size")||o.headers.get("Content-Length"),d=f?parseInt(f):0,h=d!==0,m=0,_=new ReadableStream({start(g){y();function y(){u.read().then(({done:v,value:b})=>{if(v)g.close();else{m+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:h,loaded:m,total:d});for(let E=0,T=c.length;E<T;E++){let A=c[E];A.onProgress&&A.onProgress(S)}g.enqueue(b),y()}},v=>{g.error(v)})}}});return new Response(_)}else throw new _n(\`fetch for "\${o.url}" responded with \${o.status}: \${o.statusText}\`,o)}).then(o=>{switch(l){case"arraybuffer":return o.arrayBuffer();case"blob":return o.blob();case"document":return o.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return o.json();default:if(a==="")return o.text();{let u=/charset="?([^;"\\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return o.arrayBuffer().then(h=>d.decode(h))}}}).then(o=>{gn.add(\`file:\${e}\`,o);let c=se[e];delete se[e];for(let u=0,f=c.length;u<f;u++){let d=c[u];d.onLoad&&d.onLoad(o)}}).catch(o=>{let c=se[e];if(c===void 0)throw this.manager.itemError(e),o;delete se[e];for(let u=0,f=c.length;u<f;u++){let d=c[u];d.onError&&d.onError(o)}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}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var Fn="\\\\[\\\\]\\\\.:\\\\/",Ii=new RegExp("["+Fn+"]","g"),On="[^"+Fn+"]",Pi="[^"+Fn.replace("\\\\.","")+"]",Li=/((?:WC+[\\/:])*)/.source.replace("WC",On),Di=/(WCOD+)?/.source.replace("WCOD",Pi),Ui=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",On),Ni=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",On),Fi=new RegExp("^"+Li+Di+Ui+Ni+"\$"),Oi=["material","materials","bones","map"],xn=class{constructor(e,t,n){let i=n||I.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},I=class p{constructor(e,t,n){this.path=t,this.parsedPath=n||p.parseTrackName(t),this.node=p.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 p.Composite(e,t,n):new p(e,t,n)}static sanitizeNodeName(e){return e.replace(/\\s/g,"_").replace(Ii,"")}static parseTrackName(e){let t=Fi.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);Oi.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let r=0;r<s.length;r++){let a=s[r];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_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){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=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,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=p.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){N("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let o=t.objectIndex;switch(n){case"materials":if(!e.material){L("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){L("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){L("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===o){o=c;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){L("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){L("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){L("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(o!==void 0){if(e[o]===void 0){L("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[o]}}let r=e[i];if(r===void 0){let o=t.nodeName;L("PropertyBinding: Trying to update property for track: "+o+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){L("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){L("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=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(l=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};I.Composite=xn;I.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};I.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};I.prototype.GetterByBindingType=[I.prototype._getValue_direct,I.prototype._getValue_array,I.prototype._getValue_arrayElement,I.prototype._getValue_toArray];I.prototype.SetterByBindingTypeAndVersioning=[[I.prototype._setValue_direct,I.prototype._setValue_direct_setNeedsUpdate,I.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[I.prototype._setValue_array,I.prototype._setValue_array_setNeedsUpdate,I.prototype._setValue_array_setMatrixWorldNeedsUpdate],[I.prototype._setValue_arrayElement,I.prototype._setValue_arrayElement_setNeedsUpdate,I.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[I.prototype._setValue_fromArray,I.prototype._setValue_fromArray_setNeedsUpdate,I.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var va=new Float32Array(1);typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"182"}}));typeof window<"u"&&(window.__THREE__?N("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="182");var Bi=\`#ifdef USE_ALPHAHASH
3
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
4
+ #endif\`,zi=\`#ifdef USE_ALPHAHASH
5
+ const float ALPHA_HASH_SCALE = 0.05;
6
+ float hash2D( vec2 value ) {
7
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
8
+ }
9
+ float hash3D( vec3 value ) {
10
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
11
+ }
12
+ float getAlphaHashThreshold( vec3 position ) {
13
+ float maxDeriv = max(
14
+ length( dFdx( position.xyz ) ),
15
+ length( dFdy( position.xyz ) )
16
+ );
17
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
18
+ vec2 pixScales = vec2(
19
+ exp2( floor( log2( pixScale ) ) ),
20
+ exp2( ceil( log2( pixScale ) ) )
21
+ );
22
+ vec2 alpha = vec2(
23
+ hash3D( floor( pixScales.x * position.xyz ) ),
24
+ hash3D( floor( pixScales.y * position.xyz ) )
25
+ );
26
+ float lerpFactor = fract( log2( pixScale ) );
27
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
28
+ float a = min( lerpFactor, 1.0 - lerpFactor );
29
+ vec3 cases = vec3(
30
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
31
+ ( x - 0.5 * a ) / ( 1.0 - a ),
32
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
33
+ );
34
+ float threshold = ( x < ( 1.0 - a ) )
35
+ ? ( ( x < a ) ? cases.x : cases.y )
36
+ : cases.z;
37
+ return clamp( threshold , 1.0e-6, 1.0 );
38
+ }
39
+ #endif\`,Vi=\`#ifdef USE_ALPHAMAP
40
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
41
+ #endif\`,ki=\`#ifdef USE_ALPHAMAP
42
+ uniform sampler2D alphaMap;
43
+ #endif\`,Gi=\`#ifdef USE_ALPHATEST
44
+ #ifdef ALPHA_TO_COVERAGE
45
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
46
+ if ( diffuseColor.a == 0.0 ) discard;
47
+ #else
48
+ if ( diffuseColor.a < alphaTest ) discard;
49
+ #endif
50
+ #endif\`,Hi=\`#ifdef USE_ALPHATEST
51
+ uniform float alphaTest;
52
+ #endif\`,Wi=\`#ifdef USE_AOMAP
53
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
54
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
55
+ #if defined( USE_CLEARCOAT )
56
+ clearcoatSpecularIndirect *= ambientOcclusion;
57
+ #endif
58
+ #if defined( USE_SHEEN )
59
+ sheenSpecularIndirect *= ambientOcclusion;
60
+ #endif
61
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
62
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
63
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
64
+ #endif
65
+ #endif\`,Xi=\`#ifdef USE_AOMAP
66
+ uniform sampler2D aoMap;
67
+ uniform float aoMapIntensity;
68
+ #endif\`,qi=\`#ifdef USE_BATCHING
69
+ #if ! defined( GL_ANGLE_multi_draw )
70
+ #define gl_DrawID _gl_DrawID
71
+ uniform int _gl_DrawID;
72
+ #endif
73
+ uniform highp sampler2D batchingTexture;
74
+ uniform highp usampler2D batchingIdTexture;
75
+ mat4 getBatchingMatrix( const in float i ) {
76
+ int size = textureSize( batchingTexture, 0 ).x;
77
+ int j = int( i ) * 4;
78
+ int x = j % size;
79
+ int y = j / size;
80
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
81
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
82
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
83
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
84
+ return mat4( v1, v2, v3, v4 );
85
+ }
86
+ float getIndirectIndex( const in int i ) {
87
+ int size = textureSize( batchingIdTexture, 0 ).x;
88
+ int x = i % size;
89
+ int y = i / size;
90
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
91
+ }
92
+ #endif
93
+ #ifdef USE_BATCHING_COLOR
94
+ uniform sampler2D batchingColorTexture;
95
+ vec3 getBatchingColor( const in float i ) {
96
+ int size = textureSize( batchingColorTexture, 0 ).x;
97
+ int j = int( i );
98
+ int x = j % size;
99
+ int y = j / size;
100
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
101
+ }
102
+ #endif\`,Yi=\`#ifdef USE_BATCHING
103
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
104
+ #endif\`,Zi=\`vec3 transformed = vec3( position );
105
+ #ifdef USE_ALPHAHASH
106
+ vPosition = vec3( position );
107
+ #endif\`,Ji=\`vec3 objectNormal = vec3( normal );
108
+ #ifdef USE_TANGENT
109
+ vec3 objectTangent = vec3( tangent.xyz );
110
+ #endif\`,\$i=\`float G_BlinnPhong_Implicit( ) {
111
+ return 0.25;
112
+ }
113
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
114
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
115
+ }
116
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
117
+ vec3 halfDir = normalize( lightDir + viewDir );
118
+ float dotNH = saturate( dot( normal, halfDir ) );
119
+ float dotVH = saturate( dot( viewDir, halfDir ) );
120
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
121
+ float G = G_BlinnPhong_Implicit( );
122
+ float D = D_BlinnPhong( shininess, dotNH );
123
+ return F * ( G * D );
124
+ } // validated\`,Ki=\`#ifdef USE_IRIDESCENCE
125
+ const mat3 XYZ_TO_REC709 = mat3(
126
+ 3.2404542, -0.9692660, 0.0556434,
127
+ -1.5371385, 1.8760108, -0.2040259,
128
+ -0.4985314, 0.0415560, 1.0572252
129
+ );
130
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
131
+ vec3 sqrtF0 = sqrt( fresnel0 );
132
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
133
+ }
134
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
135
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
136
+ }
137
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
138
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
139
+ }
140
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
141
+ float phase = 2.0 * PI * OPD * 1.0e-9;
142
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
143
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
144
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
145
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
146
+ 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 ) );
147
+ xyz /= 1.0685e-7;
148
+ vec3 rgb = XYZ_TO_REC709 * xyz;
149
+ return rgb;
150
+ }
151
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
152
+ vec3 I;
153
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
154
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
155
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
156
+ if ( cosTheta2Sq < 0.0 ) {
157
+ return vec3( 1.0 );
158
+ }
159
+ float cosTheta2 = sqrt( cosTheta2Sq );
160
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
161
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
162
+ float T121 = 1.0 - R12;
163
+ float phi12 = 0.0;
164
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
165
+ float phi21 = PI - phi12;
166
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
167
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
168
+ vec3 phi23 = vec3( 0.0 );
169
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
170
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
171
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
172
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
173
+ vec3 phi = vec3( phi21 ) + phi23;
174
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
175
+ vec3 r123 = sqrt( R123 );
176
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
177
+ vec3 C0 = R12 + Rs;
178
+ I = C0;
179
+ vec3 Cm = Rs - T121;
180
+ for ( int m = 1; m <= 2; ++ m ) {
181
+ Cm *= r123;
182
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
183
+ I += Cm * Sm;
184
+ }
185
+ return max( I, vec3( 0.0 ) );
186
+ }
187
+ #endif\`,Qi=\`#ifdef USE_BUMPMAP
188
+ uniform sampler2D bumpMap;
189
+ uniform float bumpScale;
190
+ vec2 dHdxy_fwd() {
191
+ vec2 dSTdx = dFdx( vBumpMapUv );
192
+ vec2 dSTdy = dFdy( vBumpMapUv );
193
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
194
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
195
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
196
+ return vec2( dBx, dBy );
197
+ }
198
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
199
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
200
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
201
+ vec3 vN = surf_norm;
202
+ vec3 R1 = cross( vSigmaY, vN );
203
+ vec3 R2 = cross( vN, vSigmaX );
204
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
205
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
206
+ return normalize( abs( fDet ) * surf_norm - vGrad );
207
+ }
208
+ #endif\`,ji=\`#if NUM_CLIPPING_PLANES > 0
209
+ vec4 plane;
210
+ #ifdef ALPHA_TO_COVERAGE
211
+ float distanceToPlane, distanceGradient;
212
+ float clipOpacity = 1.0;
213
+ #pragma unroll_loop_start
214
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
215
+ plane = clippingPlanes[ i ];
216
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
217
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
218
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
219
+ if ( clipOpacity == 0.0 ) discard;
220
+ }
221
+ #pragma unroll_loop_end
222
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
223
+ float unionClipOpacity = 1.0;
224
+ #pragma unroll_loop_start
225
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
226
+ plane = clippingPlanes[ i ];
227
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
228
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
229
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
230
+ }
231
+ #pragma unroll_loop_end
232
+ clipOpacity *= 1.0 - unionClipOpacity;
233
+ #endif
234
+ diffuseColor.a *= clipOpacity;
235
+ if ( diffuseColor.a == 0.0 ) discard;
236
+ #else
237
+ #pragma unroll_loop_start
238
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
239
+ plane = clippingPlanes[ i ];
240
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
241
+ }
242
+ #pragma unroll_loop_end
243
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
244
+ bool clipped = true;
245
+ #pragma unroll_loop_start
246
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
247
+ plane = clippingPlanes[ i ];
248
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
249
+ }
250
+ #pragma unroll_loop_end
251
+ if ( clipped ) discard;
252
+ #endif
253
+ #endif
254
+ #endif\`,es=\`#if NUM_CLIPPING_PLANES > 0
255
+ varying vec3 vClipPosition;
256
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
257
+ #endif\`,ts=\`#if NUM_CLIPPING_PLANES > 0
258
+ varying vec3 vClipPosition;
259
+ #endif\`,ns=\`#if NUM_CLIPPING_PLANES > 0
260
+ vClipPosition = - mvPosition.xyz;
261
+ #endif\`,is=\`#if defined( USE_COLOR_ALPHA )
262
+ diffuseColor *= vColor;
263
+ #elif defined( USE_COLOR )
264
+ diffuseColor.rgb *= vColor;
265
+ #endif\`,ss=\`#if defined( USE_COLOR_ALPHA )
266
+ varying vec4 vColor;
267
+ #elif defined( USE_COLOR )
268
+ varying vec3 vColor;
269
+ #endif\`,rs=\`#if defined( USE_COLOR_ALPHA )
270
+ varying vec4 vColor;
271
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
272
+ varying vec3 vColor;
273
+ #endif\`,as=\`#if defined( USE_COLOR_ALPHA )
274
+ vColor = vec4( 1.0 );
275
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
276
+ vColor = vec3( 1.0 );
277
+ #endif
278
+ #ifdef USE_COLOR
279
+ vColor *= color;
280
+ #endif
281
+ #ifdef USE_INSTANCING_COLOR
282
+ vColor.xyz *= instanceColor.xyz;
283
+ #endif
284
+ #ifdef USE_BATCHING_COLOR
285
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
286
+ vColor.xyz *= batchingColor.xyz;
287
+ #endif\`,os=\`#define PI 3.141592653589793
288
+ #define PI2 6.283185307179586
289
+ #define PI_HALF 1.5707963267948966
290
+ #define RECIPROCAL_PI 0.3183098861837907
291
+ #define RECIPROCAL_PI2 0.15915494309189535
292
+ #define EPSILON 1e-6
293
+ #ifndef saturate
294
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
295
+ #endif
296
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
297
+ float pow2( const in float x ) { return x*x; }
298
+ vec3 pow2( const in vec3 x ) { return x*x; }
299
+ float pow3( const in float x ) { return x*x*x; }
300
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
301
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
302
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
303
+ highp float rand( const in vec2 uv ) {
304
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
305
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
306
+ return fract( sin( sn ) * c );
307
+ }
308
+ #ifdef HIGH_PRECISION
309
+ float precisionSafeLength( vec3 v ) { return length( v ); }
310
+ #else
311
+ float precisionSafeLength( vec3 v ) {
312
+ float maxComponent = max3( abs( v ) );
313
+ return length( v / maxComponent ) * maxComponent;
314
+ }
315
+ #endif
316
+ struct IncidentLight {
317
+ vec3 color;
318
+ vec3 direction;
319
+ bool visible;
320
+ };
321
+ struct ReflectedLight {
322
+ vec3 directDiffuse;
323
+ vec3 directSpecular;
324
+ vec3 indirectDiffuse;
325
+ vec3 indirectSpecular;
326
+ };
327
+ #ifdef USE_ALPHAHASH
328
+ varying vec3 vPosition;
329
+ #endif
330
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
331
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
332
+ }
333
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
334
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
335
+ }
336
+ bool isPerspectiveMatrix( mat4 m ) {
337
+ return m[ 2 ][ 3 ] == - 1.0;
338
+ }
339
+ vec2 equirectUv( in vec3 dir ) {
340
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
341
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
342
+ return vec2( u, v );
343
+ }
344
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
345
+ return RECIPROCAL_PI * diffuseColor;
346
+ }
347
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
348
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
349
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
350
+ }
351
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
352
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
353
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
354
+ } // validated\`,ls=\`#ifdef ENVMAP_TYPE_CUBE_UV
355
+ #define cubeUV_minMipLevel 4.0
356
+ #define cubeUV_minTileSize 16.0
357
+ float getFace( vec3 direction ) {
358
+ vec3 absDirection = abs( direction );
359
+ float face = - 1.0;
360
+ if ( absDirection.x > absDirection.z ) {
361
+ if ( absDirection.x > absDirection.y )
362
+ face = direction.x > 0.0 ? 0.0 : 3.0;
363
+ else
364
+ face = direction.y > 0.0 ? 1.0 : 4.0;
365
+ } else {
366
+ if ( absDirection.z > absDirection.y )
367
+ face = direction.z > 0.0 ? 2.0 : 5.0;
368
+ else
369
+ face = direction.y > 0.0 ? 1.0 : 4.0;
370
+ }
371
+ return face;
372
+ }
373
+ vec2 getUV( vec3 direction, float face ) {
374
+ vec2 uv;
375
+ if ( face == 0.0 ) {
376
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
377
+ } else if ( face == 1.0 ) {
378
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
379
+ } else if ( face == 2.0 ) {
380
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
381
+ } else if ( face == 3.0 ) {
382
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
383
+ } else if ( face == 4.0 ) {
384
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
385
+ } else {
386
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
387
+ }
388
+ return 0.5 * ( uv + 1.0 );
389
+ }
390
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
391
+ float face = getFace( direction );
392
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
393
+ mipInt = max( mipInt, cubeUV_minMipLevel );
394
+ float faceSize = exp2( mipInt );
395
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
396
+ if ( face > 2.0 ) {
397
+ uv.y += faceSize;
398
+ face -= 3.0;
399
+ }
400
+ uv.x += face * faceSize;
401
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
402
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
403
+ uv.x *= CUBEUV_TEXEL_WIDTH;
404
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
405
+ #ifdef texture2DGradEXT
406
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
407
+ #else
408
+ return texture2D( envMap, uv ).rgb;
409
+ #endif
410
+ }
411
+ #define cubeUV_r0 1.0
412
+ #define cubeUV_m0 - 2.0
413
+ #define cubeUV_r1 0.8
414
+ #define cubeUV_m1 - 1.0
415
+ #define cubeUV_r4 0.4
416
+ #define cubeUV_m4 2.0
417
+ #define cubeUV_r5 0.305
418
+ #define cubeUV_m5 3.0
419
+ #define cubeUV_r6 0.21
420
+ #define cubeUV_m6 4.0
421
+ float roughnessToMip( float roughness ) {
422
+ float mip = 0.0;
423
+ if ( roughness >= cubeUV_r1 ) {
424
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
425
+ } else if ( roughness >= cubeUV_r4 ) {
426
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
427
+ } else if ( roughness >= cubeUV_r5 ) {
428
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
429
+ } else if ( roughness >= cubeUV_r6 ) {
430
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
431
+ } else {
432
+ mip = - 2.0 * log2( 1.16 * roughness ); }
433
+ return mip;
434
+ }
435
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
436
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
437
+ float mipF = fract( mip );
438
+ float mipInt = floor( mip );
439
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
440
+ if ( mipF == 0.0 ) {
441
+ return vec4( color0, 1.0 );
442
+ } else {
443
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
444
+ return vec4( mix( color0, color1, mipF ), 1.0 );
445
+ }
446
+ }
447
+ #endif\`,cs=\`vec3 transformedNormal = objectNormal;
448
+ #ifdef USE_TANGENT
449
+ vec3 transformedTangent = objectTangent;
450
+ #endif
451
+ #ifdef USE_BATCHING
452
+ mat3 bm = mat3( batchingMatrix );
453
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
454
+ transformedNormal = bm * transformedNormal;
455
+ #ifdef USE_TANGENT
456
+ transformedTangent = bm * transformedTangent;
457
+ #endif
458
+ #endif
459
+ #ifdef USE_INSTANCING
460
+ mat3 im = mat3( instanceMatrix );
461
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
462
+ transformedNormal = im * transformedNormal;
463
+ #ifdef USE_TANGENT
464
+ transformedTangent = im * transformedTangent;
465
+ #endif
466
+ #endif
467
+ transformedNormal = normalMatrix * transformedNormal;
468
+ #ifdef FLIP_SIDED
469
+ transformedNormal = - transformedNormal;
470
+ #endif
471
+ #ifdef USE_TANGENT
472
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
473
+ #ifdef FLIP_SIDED
474
+ transformedTangent = - transformedTangent;
475
+ #endif
476
+ #endif\`,hs=\`#ifdef USE_DISPLACEMENTMAP
477
+ uniform sampler2D displacementMap;
478
+ uniform float displacementScale;
479
+ uniform float displacementBias;
480
+ #endif\`,us=\`#ifdef USE_DISPLACEMENTMAP
481
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
482
+ #endif\`,ds=\`#ifdef USE_EMISSIVEMAP
483
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
484
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
485
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
486
+ #endif
487
+ totalEmissiveRadiance *= emissiveColor.rgb;
488
+ #endif\`,fs=\`#ifdef USE_EMISSIVEMAP
489
+ uniform sampler2D emissiveMap;
490
+ #endif\`,ps="gl_FragColor = linearToOutputTexel( gl_FragColor );",ms=\`vec4 LinearTransferOETF( in vec4 value ) {
491
+ return value;
492
+ }
493
+ vec4 sRGBTransferEOTF( in vec4 value ) {
494
+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
495
+ }
496
+ vec4 sRGBTransferOETF( in vec4 value ) {
497
+ 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 );
498
+ }\`,gs=\`#ifdef USE_ENVMAP
499
+ #ifdef ENV_WORLDPOS
500
+ vec3 cameraToFrag;
501
+ if ( isOrthographic ) {
502
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
503
+ } else {
504
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
505
+ }
506
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
507
+ #ifdef ENVMAP_MODE_REFLECTION
508
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
509
+ #else
510
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
511
+ #endif
512
+ #else
513
+ vec3 reflectVec = vReflect;
514
+ #endif
515
+ #ifdef ENVMAP_TYPE_CUBE
516
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
517
+ #else
518
+ vec4 envColor = vec4( 0.0 );
519
+ #endif
520
+ #ifdef ENVMAP_BLENDING_MULTIPLY
521
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
522
+ #elif defined( ENVMAP_BLENDING_MIX )
523
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
524
+ #elif defined( ENVMAP_BLENDING_ADD )
525
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
526
+ #endif
527
+ #endif\`,_s=\`#ifdef USE_ENVMAP
528
+ uniform float envMapIntensity;
529
+ uniform float flipEnvMap;
530
+ uniform mat3 envMapRotation;
531
+ #ifdef ENVMAP_TYPE_CUBE
532
+ uniform samplerCube envMap;
533
+ #else
534
+ uniform sampler2D envMap;
535
+ #endif
536
+ #endif\`,xs=\`#ifdef USE_ENVMAP
537
+ uniform float reflectivity;
538
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
539
+ #define ENV_WORLDPOS
540
+ #endif
541
+ #ifdef ENV_WORLDPOS
542
+ varying vec3 vWorldPosition;
543
+ uniform float refractionRatio;
544
+ #else
545
+ varying vec3 vReflect;
546
+ #endif
547
+ #endif\`,vs=\`#ifdef USE_ENVMAP
548
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
549
+ #define ENV_WORLDPOS
550
+ #endif
551
+ #ifdef ENV_WORLDPOS
552
+
553
+ varying vec3 vWorldPosition;
554
+ #else
555
+ varying vec3 vReflect;
556
+ uniform float refractionRatio;
557
+ #endif
558
+ #endif\`,ys=\`#ifdef USE_ENVMAP
559
+ #ifdef ENV_WORLDPOS
560
+ vWorldPosition = worldPosition.xyz;
561
+ #else
562
+ vec3 cameraToVertex;
563
+ if ( isOrthographic ) {
564
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
565
+ } else {
566
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
567
+ }
568
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
569
+ #ifdef ENVMAP_MODE_REFLECTION
570
+ vReflect = reflect( cameraToVertex, worldNormal );
571
+ #else
572
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
573
+ #endif
574
+ #endif
575
+ #endif\`,Ms=\`#ifdef USE_FOG
576
+ vFogDepth = - mvPosition.z;
577
+ #endif\`,Ss=\`#ifdef USE_FOG
578
+ varying float vFogDepth;
579
+ #endif\`,bs=\`#ifdef USE_FOG
580
+ #ifdef FOG_EXP2
581
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
582
+ #else
583
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
584
+ #endif
585
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
586
+ #endif\`,As=\`#ifdef USE_FOG
587
+ uniform vec3 fogColor;
588
+ varying float vFogDepth;
589
+ #ifdef FOG_EXP2
590
+ uniform float fogDensity;
591
+ #else
592
+ uniform float fogNear;
593
+ uniform float fogFar;
594
+ #endif
595
+ #endif\`,Ts=\`#ifdef USE_GRADIENTMAP
596
+ uniform sampler2D gradientMap;
597
+ #endif
598
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
599
+ float dotNL = dot( normal, lightDirection );
600
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
601
+ #ifdef USE_GRADIENTMAP
602
+ return vec3( texture2D( gradientMap, coord ).r );
603
+ #else
604
+ vec2 fw = fwidth( coord ) * 0.5;
605
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
606
+ #endif
607
+ }\`,Es=\`#ifdef USE_LIGHTMAP
608
+ uniform sampler2D lightMap;
609
+ uniform float lightMapIntensity;
610
+ #endif\`,ws=\`LambertMaterial material;
611
+ material.diffuseColor = diffuseColor.rgb;
612
+ material.specularStrength = specularStrength;\`,Cs=\`varying vec3 vViewPosition;
613
+ struct LambertMaterial {
614
+ vec3 diffuseColor;
615
+ float specularStrength;
616
+ };
617
+ 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 ) {
618
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
619
+ vec3 irradiance = dotNL * directLight.color;
620
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
621
+ }
622
+ 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 ) {
623
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
624
+ }
625
+ #define RE_Direct RE_Direct_Lambert
626
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert\`,Rs=\`uniform bool receiveShadow;
627
+ uniform vec3 ambientLightColor;
628
+ #if defined( USE_LIGHT_PROBES )
629
+ uniform vec3 lightProbe[ 9 ];
630
+ #endif
631
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
632
+ float x = normal.x, y = normal.y, z = normal.z;
633
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
634
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
635
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
636
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
637
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
638
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
639
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
640
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
641
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
642
+ return result;
643
+ }
644
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
645
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
646
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
647
+ return irradiance;
648
+ }
649
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
650
+ vec3 irradiance = ambientLightColor;
651
+ return irradiance;
652
+ }
653
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
654
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
655
+ if ( cutoffDistance > 0.0 ) {
656
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
657
+ }
658
+ return distanceFalloff;
659
+ }
660
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
661
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
662
+ }
663
+ #if NUM_DIR_LIGHTS > 0
664
+ struct DirectionalLight {
665
+ vec3 direction;
666
+ vec3 color;
667
+ };
668
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
669
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
670
+ light.color = directionalLight.color;
671
+ light.direction = directionalLight.direction;
672
+ light.visible = true;
673
+ }
674
+ #endif
675
+ #if NUM_POINT_LIGHTS > 0
676
+ struct PointLight {
677
+ vec3 position;
678
+ vec3 color;
679
+ float distance;
680
+ float decay;
681
+ };
682
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
683
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
684
+ vec3 lVector = pointLight.position - geometryPosition;
685
+ light.direction = normalize( lVector );
686
+ float lightDistance = length( lVector );
687
+ light.color = pointLight.color;
688
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
689
+ light.visible = ( light.color != vec3( 0.0 ) );
690
+ }
691
+ #endif
692
+ #if NUM_SPOT_LIGHTS > 0
693
+ struct SpotLight {
694
+ vec3 position;
695
+ vec3 direction;
696
+ vec3 color;
697
+ float distance;
698
+ float decay;
699
+ float coneCos;
700
+ float penumbraCos;
701
+ };
702
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
703
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
704
+ vec3 lVector = spotLight.position - geometryPosition;
705
+ light.direction = normalize( lVector );
706
+ float angleCos = dot( light.direction, spotLight.direction );
707
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
708
+ if ( spotAttenuation > 0.0 ) {
709
+ float lightDistance = length( lVector );
710
+ light.color = spotLight.color * spotAttenuation;
711
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
712
+ light.visible = ( light.color != vec3( 0.0 ) );
713
+ } else {
714
+ light.color = vec3( 0.0 );
715
+ light.visible = false;
716
+ }
717
+ }
718
+ #endif
719
+ #if NUM_RECT_AREA_LIGHTS > 0
720
+ struct RectAreaLight {
721
+ vec3 color;
722
+ vec3 position;
723
+ vec3 halfWidth;
724
+ vec3 halfHeight;
725
+ };
726
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
727
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
728
+ #endif
729
+ #if NUM_HEMI_LIGHTS > 0
730
+ struct HemisphereLight {
731
+ vec3 direction;
732
+ vec3 skyColor;
733
+ vec3 groundColor;
734
+ };
735
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
736
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
737
+ float dotNL = dot( normal, hemiLight.direction );
738
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
739
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
740
+ return irradiance;
741
+ }
742
+ #endif\`,Is=\`#ifdef USE_ENVMAP
743
+ vec3 getIBLIrradiance( const in vec3 normal ) {
744
+ #ifdef ENVMAP_TYPE_CUBE_UV
745
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
746
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
747
+ return PI * envMapColor.rgb * envMapIntensity;
748
+ #else
749
+ return vec3( 0.0 );
750
+ #endif
751
+ }
752
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
753
+ #ifdef ENVMAP_TYPE_CUBE_UV
754
+ vec3 reflectVec = reflect( - viewDir, normal );
755
+ reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
756
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
757
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
758
+ return envMapColor.rgb * envMapIntensity;
759
+ #else
760
+ return vec3( 0.0 );
761
+ #endif
762
+ }
763
+ #ifdef USE_ANISOTROPY
764
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
765
+ #ifdef ENVMAP_TYPE_CUBE_UV
766
+ vec3 bentNormal = cross( bitangent, viewDir );
767
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
768
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
769
+ return getIBLRadiance( viewDir, bentNormal, roughness );
770
+ #else
771
+ return vec3( 0.0 );
772
+ #endif
773
+ }
774
+ #endif
775
+ #endif\`,Ps=\`ToonMaterial material;
776
+ material.diffuseColor = diffuseColor.rgb;\`,Ls=\`varying vec3 vViewPosition;
777
+ struct ToonMaterial {
778
+ vec3 diffuseColor;
779
+ };
780
+ 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 ) {
781
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
782
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
783
+ }
784
+ 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 ) {
785
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
786
+ }
787
+ #define RE_Direct RE_Direct_Toon
788
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\`,Ds=\`BlinnPhongMaterial material;
789
+ material.diffuseColor = diffuseColor.rgb;
790
+ material.specularColor = specular;
791
+ material.specularShininess = shininess;
792
+ material.specularStrength = specularStrength;\`,Us=\`varying vec3 vViewPosition;
793
+ struct BlinnPhongMaterial {
794
+ vec3 diffuseColor;
795
+ vec3 specularColor;
796
+ float specularShininess;
797
+ float specularStrength;
798
+ };
799
+ 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 ) {
800
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
801
+ vec3 irradiance = dotNL * directLight.color;
802
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
803
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
804
+ }
805
+ 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 ) {
806
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
807
+ }
808
+ #define RE_Direct RE_Direct_BlinnPhong
809
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\`,Ns=\`PhysicalMaterial material;
810
+ material.diffuseColor = diffuseColor.rgb;
811
+ material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
812
+ material.metalness = metalnessFactor;
813
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
814
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
815
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
816
+ material.roughness = min( material.roughness, 1.0 );
817
+ #ifdef IOR
818
+ material.ior = ior;
819
+ #ifdef USE_SPECULAR
820
+ float specularIntensityFactor = specularIntensity;
821
+ vec3 specularColorFactor = specularColor;
822
+ #ifdef USE_SPECULAR_COLORMAP
823
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
824
+ #endif
825
+ #ifdef USE_SPECULAR_INTENSITYMAP
826
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
827
+ #endif
828
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
829
+ #else
830
+ float specularIntensityFactor = 1.0;
831
+ vec3 specularColorFactor = vec3( 1.0 );
832
+ material.specularF90 = 1.0;
833
+ #endif
834
+ material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
835
+ material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
836
+ #else
837
+ material.specularColor = vec3( 0.04 );
838
+ material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
839
+ material.specularF90 = 1.0;
840
+ #endif
841
+ #ifdef USE_CLEARCOAT
842
+ material.clearcoat = clearcoat;
843
+ material.clearcoatRoughness = clearcoatRoughness;
844
+ material.clearcoatF0 = vec3( 0.04 );
845
+ material.clearcoatF90 = 1.0;
846
+ #ifdef USE_CLEARCOATMAP
847
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
848
+ #endif
849
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
850
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
851
+ #endif
852
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
853
+ material.clearcoatRoughness += geometryRoughness;
854
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
855
+ #endif
856
+ #ifdef USE_DISPERSION
857
+ material.dispersion = dispersion;
858
+ #endif
859
+ #ifdef USE_IRIDESCENCE
860
+ material.iridescence = iridescence;
861
+ material.iridescenceIOR = iridescenceIOR;
862
+ #ifdef USE_IRIDESCENCEMAP
863
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
864
+ #endif
865
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
866
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
867
+ #else
868
+ material.iridescenceThickness = iridescenceThicknessMaximum;
869
+ #endif
870
+ #endif
871
+ #ifdef USE_SHEEN
872
+ material.sheenColor = sheenColor;
873
+ #ifdef USE_SHEEN_COLORMAP
874
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
875
+ #endif
876
+ material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
877
+ #ifdef USE_SHEEN_ROUGHNESSMAP
878
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
879
+ #endif
880
+ #endif
881
+ #ifdef USE_ANISOTROPY
882
+ #ifdef USE_ANISOTROPYMAP
883
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
884
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
885
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
886
+ #else
887
+ vec2 anisotropyV = anisotropyVector;
888
+ #endif
889
+ material.anisotropy = length( anisotropyV );
890
+ if( material.anisotropy == 0.0 ) {
891
+ anisotropyV = vec2( 1.0, 0.0 );
892
+ } else {
893
+ anisotropyV /= material.anisotropy;
894
+ material.anisotropy = saturate( material.anisotropy );
895
+ }
896
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
897
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
898
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
899
+ #endif\`,Fs=\`uniform sampler2D dfgLUT;
900
+ struct PhysicalMaterial {
901
+ vec3 diffuseColor;
902
+ vec3 diffuseContribution;
903
+ vec3 specularColor;
904
+ vec3 specularColorBlended;
905
+ float roughness;
906
+ float metalness;
907
+ float specularF90;
908
+ float dispersion;
909
+ #ifdef USE_CLEARCOAT
910
+ float clearcoat;
911
+ float clearcoatRoughness;
912
+ vec3 clearcoatF0;
913
+ float clearcoatF90;
914
+ #endif
915
+ #ifdef USE_IRIDESCENCE
916
+ float iridescence;
917
+ float iridescenceIOR;
918
+ float iridescenceThickness;
919
+ vec3 iridescenceFresnel;
920
+ vec3 iridescenceF0;
921
+ vec3 iridescenceFresnelDielectric;
922
+ vec3 iridescenceFresnelMetallic;
923
+ #endif
924
+ #ifdef USE_SHEEN
925
+ vec3 sheenColor;
926
+ float sheenRoughness;
927
+ #endif
928
+ #ifdef IOR
929
+ float ior;
930
+ #endif
931
+ #ifdef USE_TRANSMISSION
932
+ float transmission;
933
+ float transmissionAlpha;
934
+ float thickness;
935
+ float attenuationDistance;
936
+ vec3 attenuationColor;
937
+ #endif
938
+ #ifdef USE_ANISOTROPY
939
+ float anisotropy;
940
+ float alphaT;
941
+ vec3 anisotropyT;
942
+ vec3 anisotropyB;
943
+ #endif
944
+ };
945
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
946
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
947
+ vec3 sheenSpecularDirect = vec3( 0.0 );
948
+ vec3 sheenSpecularIndirect = vec3(0.0 );
949
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
950
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
951
+ float x2 = x * x;
952
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
953
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
954
+ }
955
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
956
+ float a2 = pow2( alpha );
957
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
958
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
959
+ return 0.5 / max( gv + gl, EPSILON );
960
+ }
961
+ float D_GGX( const in float alpha, const in float dotNH ) {
962
+ float a2 = pow2( alpha );
963
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
964
+ return RECIPROCAL_PI * a2 / pow2( denom );
965
+ }
966
+ #ifdef USE_ANISOTROPY
967
+ 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 ) {
968
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
969
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
970
+ float v = 0.5 / ( gv + gl );
971
+ return v;
972
+ }
973
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
974
+ float a2 = alphaT * alphaB;
975
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
976
+ highp float v2 = dot( v, v );
977
+ float w2 = a2 / v2;
978
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
979
+ }
980
+ #endif
981
+ #ifdef USE_CLEARCOAT
982
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
983
+ vec3 f0 = material.clearcoatF0;
984
+ float f90 = material.clearcoatF90;
985
+ float roughness = material.clearcoatRoughness;
986
+ float alpha = pow2( roughness );
987
+ vec3 halfDir = normalize( lightDir + viewDir );
988
+ float dotNL = saturate( dot( normal, lightDir ) );
989
+ float dotNV = saturate( dot( normal, viewDir ) );
990
+ float dotNH = saturate( dot( normal, halfDir ) );
991
+ float dotVH = saturate( dot( viewDir, halfDir ) );
992
+ vec3 F = F_Schlick( f0, f90, dotVH );
993
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
994
+ float D = D_GGX( alpha, dotNH );
995
+ return F * ( V * D );
996
+ }
997
+ #endif
998
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
999
+ vec3 f0 = material.specularColorBlended;
1000
+ float f90 = material.specularF90;
1001
+ float roughness = material.roughness;
1002
+ float alpha = pow2( roughness );
1003
+ vec3 halfDir = normalize( lightDir + viewDir );
1004
+ float dotNL = saturate( dot( normal, lightDir ) );
1005
+ float dotNV = saturate( dot( normal, viewDir ) );
1006
+ float dotNH = saturate( dot( normal, halfDir ) );
1007
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1008
+ vec3 F = F_Schlick( f0, f90, dotVH );
1009
+ #ifdef USE_IRIDESCENCE
1010
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1011
+ #endif
1012
+ #ifdef USE_ANISOTROPY
1013
+ float dotTL = dot( material.anisotropyT, lightDir );
1014
+ float dotTV = dot( material.anisotropyT, viewDir );
1015
+ float dotTH = dot( material.anisotropyT, halfDir );
1016
+ float dotBL = dot( material.anisotropyB, lightDir );
1017
+ float dotBV = dot( material.anisotropyB, viewDir );
1018
+ float dotBH = dot( material.anisotropyB, halfDir );
1019
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1020
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1021
+ #else
1022
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1023
+ float D = D_GGX( alpha, dotNH );
1024
+ #endif
1025
+ return F * ( V * D );
1026
+ }
1027
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1028
+ const float LUT_SIZE = 64.0;
1029
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1030
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1031
+ float dotNV = saturate( dot( N, V ) );
1032
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1033
+ uv = uv * LUT_SCALE + LUT_BIAS;
1034
+ return uv;
1035
+ }
1036
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1037
+ float l = length( f );
1038
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1039
+ }
1040
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1041
+ float x = dot( v1, v2 );
1042
+ float y = abs( x );
1043
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1044
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1045
+ float v = a / b;
1046
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1047
+ return cross( v1, v2 ) * theta_sintheta;
1048
+ }
1049
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1050
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1051
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1052
+ vec3 lightNormal = cross( v1, v2 );
1053
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1054
+ vec3 T1, T2;
1055
+ T1 = normalize( V - N * dot( V, N ) );
1056
+ T2 = - cross( N, T1 );
1057
+ mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
1058
+ vec3 coords[ 4 ];
1059
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1060
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1061
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1062
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1063
+ coords[ 0 ] = normalize( coords[ 0 ] );
1064
+ coords[ 1 ] = normalize( coords[ 1 ] );
1065
+ coords[ 2 ] = normalize( coords[ 2 ] );
1066
+ coords[ 3 ] = normalize( coords[ 3 ] );
1067
+ vec3 vectorFormFactor = vec3( 0.0 );
1068
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1069
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1070
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1071
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1072
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1073
+ return vec3( result );
1074
+ }
1075
+ #if defined( USE_SHEEN )
1076
+ float D_Charlie( float roughness, float dotNH ) {
1077
+ float alpha = pow2( roughness );
1078
+ float invAlpha = 1.0 / alpha;
1079
+ float cos2h = dotNH * dotNH;
1080
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1081
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1082
+ }
1083
+ float V_Neubelt( float dotNV, float dotNL ) {
1084
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1085
+ }
1086
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1087
+ vec3 halfDir = normalize( lightDir + viewDir );
1088
+ float dotNL = saturate( dot( normal, lightDir ) );
1089
+ float dotNV = saturate( dot( normal, viewDir ) );
1090
+ float dotNH = saturate( dot( normal, halfDir ) );
1091
+ float D = D_Charlie( sheenRoughness, dotNH );
1092
+ float V = V_Neubelt( dotNV, dotNL );
1093
+ return sheenColor * ( D * V );
1094
+ }
1095
+ #endif
1096
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1097
+ float dotNV = saturate( dot( normal, viewDir ) );
1098
+ float r2 = roughness * roughness;
1099
+ float rInv = 1.0 / ( roughness + 0.1 );
1100
+ float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
1101
+ float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
1102
+ float DG = exp( a * dotNV + b );
1103
+ return saturate( DG );
1104
+ }
1105
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1106
+ float dotNV = saturate( dot( normal, viewDir ) );
1107
+ vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
1108
+ return specularColor * fab.x + specularF90 * fab.y;
1109
+ }
1110
+ #ifdef USE_IRIDESCENCE
1111
+ 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 ) {
1112
+ #else
1113
+ 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 ) {
1114
+ #endif
1115
+ float dotNV = saturate( dot( normal, viewDir ) );
1116
+ vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
1117
+ #ifdef USE_IRIDESCENCE
1118
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1119
+ #else
1120
+ vec3 Fr = specularColor;
1121
+ #endif
1122
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1123
+ float Ess = fab.x + fab.y;
1124
+ float Ems = 1.0 - Ess;
1125
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1126
+ singleScatter += FssEss;
1127
+ multiScatter += Fms * Ems;
1128
+ }
1129
+ vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1130
+ vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
1131
+ float dotNL = saturate( dot( normal, lightDir ) );
1132
+ float dotNV = saturate( dot( normal, viewDir ) );
1133
+ vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
1134
+ vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
1135
+ vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
1136
+ vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
1137
+ float Ess_V = dfgV.x + dfgV.y;
1138
+ float Ess_L = dfgL.x + dfgL.y;
1139
+ float Ems_V = 1.0 - Ess_V;
1140
+ float Ems_L = 1.0 - Ess_L;
1141
+ vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
1142
+ vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
1143
+ float compensationFactor = Ems_V * Ems_L;
1144
+ vec3 multiScatter = Fms * compensationFactor;
1145
+ return singleScatter + multiScatter;
1146
+ }
1147
+ #if NUM_RECT_AREA_LIGHTS > 0
1148
+ 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 ) {
1149
+ vec3 normal = geometryNormal;
1150
+ vec3 viewDir = geometryViewDir;
1151
+ vec3 position = geometryPosition;
1152
+ vec3 lightPos = rectAreaLight.position;
1153
+ vec3 halfWidth = rectAreaLight.halfWidth;
1154
+ vec3 halfHeight = rectAreaLight.halfHeight;
1155
+ vec3 lightColor = rectAreaLight.color;
1156
+ float roughness = material.roughness;
1157
+ vec3 rectCoords[ 4 ];
1158
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1159
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1160
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1161
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1162
+ vec4 t1 = texture2D( ltc_1, uv );
1163
+ vec4 t2 = texture2D( ltc_2, uv );
1164
+ mat3 mInv = mat3(
1165
+ vec3( t1.x, 0, t1.y ),
1166
+ vec3( 0, 1, 0 ),
1167
+ vec3( t1.z, 0, t1.w )
1168
+ );
1169
+ vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
1170
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1171
+ reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1172
+ }
1173
+ #endif
1174
+ 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 ) {
1175
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1176
+ vec3 irradiance = dotNL * directLight.color;
1177
+ #ifdef USE_CLEARCOAT
1178
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1179
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1180
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1181
+ #endif
1182
+ #ifdef USE_SHEEN
1183
+
1184
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1185
+
1186
+ float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1187
+ float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
1188
+
1189
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
1190
+
1191
+ irradiance *= sheenEnergyComp;
1192
+
1193
+ #endif
1194
+ reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
1195
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
1196
+ }
1197
+ 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 ) {
1198
+ vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
1199
+ #ifdef USE_SHEEN
1200
+ float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1201
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
1202
+ diffuse *= sheenEnergyComp;
1203
+ #endif
1204
+ reflectedLight.indirectDiffuse += diffuse;
1205
+ }
1206
+ 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) {
1207
+ #ifdef USE_CLEARCOAT
1208
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1209
+ #endif
1210
+ #ifdef USE_SHEEN
1211
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
1212
+ #endif
1213
+ vec3 singleScatteringDielectric = vec3( 0.0 );
1214
+ vec3 multiScatteringDielectric = vec3( 0.0 );
1215
+ vec3 singleScatteringMetallic = vec3( 0.0 );
1216
+ vec3 multiScatteringMetallic = vec3( 0.0 );
1217
+ #ifdef USE_IRIDESCENCE
1218
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
1219
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
1220
+ #else
1221
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
1222
+ computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
1223
+ #endif
1224
+ vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
1225
+ vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
1226
+ vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
1227
+ vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
1228
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1229
+ vec3 indirectSpecular = radiance * singleScattering;
1230
+ indirectSpecular += multiScattering * cosineWeightedIrradiance;
1231
+ vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
1232
+ #ifdef USE_SHEEN
1233
+ float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1234
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
1235
+ indirectSpecular *= sheenEnergyComp;
1236
+ indirectDiffuse *= sheenEnergyComp;
1237
+ #endif
1238
+ reflectedLight.indirectSpecular += indirectSpecular;
1239
+ reflectedLight.indirectDiffuse += indirectDiffuse;
1240
+ }
1241
+ #define RE_Direct RE_Direct_Physical
1242
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1243
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1244
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1245
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1246
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1247
+ }\`,Os=\`
1248
+ vec3 geometryPosition = - vViewPosition;
1249
+ vec3 geometryNormal = normal;
1250
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1251
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1252
+ #ifdef USE_CLEARCOAT
1253
+ geometryClearcoatNormal = clearcoatNormal;
1254
+ #endif
1255
+ #ifdef USE_IRIDESCENCE
1256
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1257
+ if ( material.iridescenceThickness == 0.0 ) {
1258
+ material.iridescence = 0.0;
1259
+ } else {
1260
+ material.iridescence = saturate( material.iridescence );
1261
+ }
1262
+ if ( material.iridescence > 0.0 ) {
1263
+ material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1264
+ material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
1265
+ material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
1266
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1267
+ }
1268
+ #endif
1269
+ IncidentLight directLight;
1270
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1271
+ PointLight pointLight;
1272
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1273
+ PointLightShadow pointLightShadow;
1274
+ #endif
1275
+ #pragma unroll_loop_start
1276
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1277
+ pointLight = pointLights[ i ];
1278
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1279
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
1280
+ pointLightShadow = pointLightShadows[ i ];
1281
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1282
+ #endif
1283
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1284
+ }
1285
+ #pragma unroll_loop_end
1286
+ #endif
1287
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1288
+ SpotLight spotLight;
1289
+ vec4 spotColor;
1290
+ vec3 spotLightCoord;
1291
+ bool inSpotLightMap;
1292
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1293
+ SpotLightShadow spotLightShadow;
1294
+ #endif
1295
+ #pragma unroll_loop_start
1296
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1297
+ spotLight = spotLights[ i ];
1298
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1299
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1300
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1301
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1302
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1303
+ #else
1304
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1305
+ #endif
1306
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1307
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1308
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1309
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1310
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1311
+ #endif
1312
+ #undef SPOT_LIGHT_MAP_INDEX
1313
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1314
+ spotLightShadow = spotLightShadows[ i ];
1315
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1316
+ #endif
1317
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1318
+ }
1319
+ #pragma unroll_loop_end
1320
+ #endif
1321
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1322
+ DirectionalLight directionalLight;
1323
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1324
+ DirectionalLightShadow directionalLightShadow;
1325
+ #endif
1326
+ #pragma unroll_loop_start
1327
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1328
+ directionalLight = directionalLights[ i ];
1329
+ getDirectionalLightInfo( directionalLight, directLight );
1330
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1331
+ directionalLightShadow = directionalLightShadows[ i ];
1332
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1333
+ #endif
1334
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1335
+ }
1336
+ #pragma unroll_loop_end
1337
+ #endif
1338
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1339
+ RectAreaLight rectAreaLight;
1340
+ #pragma unroll_loop_start
1341
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1342
+ rectAreaLight = rectAreaLights[ i ];
1343
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1344
+ }
1345
+ #pragma unroll_loop_end
1346
+ #endif
1347
+ #if defined( RE_IndirectDiffuse )
1348
+ vec3 iblIrradiance = vec3( 0.0 );
1349
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1350
+ #if defined( USE_LIGHT_PROBES )
1351
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1352
+ #endif
1353
+ #if ( NUM_HEMI_LIGHTS > 0 )
1354
+ #pragma unroll_loop_start
1355
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1356
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1357
+ }
1358
+ #pragma unroll_loop_end
1359
+ #endif
1360
+ #endif
1361
+ #if defined( RE_IndirectSpecular )
1362
+ vec3 radiance = vec3( 0.0 );
1363
+ vec3 clearcoatRadiance = vec3( 0.0 );
1364
+ #endif\`,Bs=\`#if defined( RE_IndirectDiffuse )
1365
+ #ifdef USE_LIGHTMAP
1366
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1367
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1368
+ irradiance += lightMapIrradiance;
1369
+ #endif
1370
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1371
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1372
+ #endif
1373
+ #endif
1374
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1375
+ #ifdef USE_ANISOTROPY
1376
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1377
+ #else
1378
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1379
+ #endif
1380
+ #ifdef USE_CLEARCOAT
1381
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1382
+ #endif
1383
+ #endif\`,zs=\`#if defined( RE_IndirectDiffuse )
1384
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1385
+ #endif
1386
+ #if defined( RE_IndirectSpecular )
1387
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1388
+ #endif\`,Vs=\`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1389
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1390
+ #endif\`,ks=\`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1391
+ uniform float logDepthBufFC;
1392
+ varying float vFragDepth;
1393
+ varying float vIsPerspective;
1394
+ #endif\`,Gs=\`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1395
+ varying float vFragDepth;
1396
+ varying float vIsPerspective;
1397
+ #endif\`,Hs=\`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1398
+ vFragDepth = 1.0 + gl_Position.w;
1399
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1400
+ #endif\`,Ws=\`#ifdef USE_MAP
1401
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1402
+ #ifdef DECODE_VIDEO_TEXTURE
1403
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1404
+ #endif
1405
+ diffuseColor *= sampledDiffuseColor;
1406
+ #endif\`,Xs=\`#ifdef USE_MAP
1407
+ uniform sampler2D map;
1408
+ #endif\`,qs=\`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1409
+ #if defined( USE_POINTS_UV )
1410
+ vec2 uv = vUv;
1411
+ #else
1412
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1413
+ #endif
1414
+ #endif
1415
+ #ifdef USE_MAP
1416
+ diffuseColor *= texture2D( map, uv );
1417
+ #endif
1418
+ #ifdef USE_ALPHAMAP
1419
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1420
+ #endif\`,Ys=\`#if defined( USE_POINTS_UV )
1421
+ varying vec2 vUv;
1422
+ #else
1423
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1424
+ uniform mat3 uvTransform;
1425
+ #endif
1426
+ #endif
1427
+ #ifdef USE_MAP
1428
+ uniform sampler2D map;
1429
+ #endif
1430
+ #ifdef USE_ALPHAMAP
1431
+ uniform sampler2D alphaMap;
1432
+ #endif\`,Zs=\`float metalnessFactor = metalness;
1433
+ #ifdef USE_METALNESSMAP
1434
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1435
+ metalnessFactor *= texelMetalness.b;
1436
+ #endif\`,Js=\`#ifdef USE_METALNESSMAP
1437
+ uniform sampler2D metalnessMap;
1438
+ #endif\`,\$s=\`#ifdef USE_INSTANCING_MORPH
1439
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1440
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1441
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1442
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1443
+ }
1444
+ #endif\`,Ks=\`#if defined( USE_MORPHCOLORS )
1445
+ vColor *= morphTargetBaseInfluence;
1446
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1447
+ #if defined( USE_COLOR_ALPHA )
1448
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1449
+ #elif defined( USE_COLOR )
1450
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1451
+ #endif
1452
+ }
1453
+ #endif\`,Qs=\`#ifdef USE_MORPHNORMALS
1454
+ objectNormal *= morphTargetBaseInfluence;
1455
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1457
+ }
1458
+ #endif\`,js=\`#ifdef USE_MORPHTARGETS
1459
+ #ifndef USE_INSTANCING_MORPH
1460
+ uniform float morphTargetBaseInfluence;
1461
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1462
+ #endif
1463
+ uniform sampler2DArray morphTargetsTexture;
1464
+ uniform ivec2 morphTargetsTextureSize;
1465
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1466
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1467
+ int y = texelIndex / morphTargetsTextureSize.x;
1468
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1469
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1470
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1471
+ }
1472
+ #endif\`,er=\`#ifdef USE_MORPHTARGETS
1473
+ transformed *= morphTargetBaseInfluence;
1474
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1475
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1476
+ }
1477
+ #endif\`,tr=\`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1478
+ #ifdef FLAT_SHADED
1479
+ vec3 fdx = dFdx( vViewPosition );
1480
+ vec3 fdy = dFdy( vViewPosition );
1481
+ vec3 normal = normalize( cross( fdx, fdy ) );
1482
+ #else
1483
+ vec3 normal = normalize( vNormal );
1484
+ #ifdef DOUBLE_SIDED
1485
+ normal *= faceDirection;
1486
+ #endif
1487
+ #endif
1488
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1489
+ #ifdef USE_TANGENT
1490
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1491
+ #else
1492
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1493
+ #if defined( USE_NORMALMAP )
1494
+ vNormalMapUv
1495
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1496
+ vClearcoatNormalMapUv
1497
+ #else
1498
+ vUv
1499
+ #endif
1500
+ );
1501
+ #endif
1502
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1503
+ tbn[0] *= faceDirection;
1504
+ tbn[1] *= faceDirection;
1505
+ #endif
1506
+ #endif
1507
+ #ifdef USE_CLEARCOAT_NORMALMAP
1508
+ #ifdef USE_TANGENT
1509
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1510
+ #else
1511
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1512
+ #endif
1513
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1514
+ tbn2[0] *= faceDirection;
1515
+ tbn2[1] *= faceDirection;
1516
+ #endif
1517
+ #endif
1518
+ vec3 nonPerturbedNormal = normal;\`,nr=\`#ifdef USE_NORMALMAP_OBJECTSPACE
1519
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1520
+ #ifdef FLIP_SIDED
1521
+ normal = - normal;
1522
+ #endif
1523
+ #ifdef DOUBLE_SIDED
1524
+ normal = normal * faceDirection;
1525
+ #endif
1526
+ normal = normalize( normalMatrix * normal );
1527
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1528
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1529
+ mapN.xy *= normalScale;
1530
+ normal = normalize( tbn * mapN );
1531
+ #elif defined( USE_BUMPMAP )
1532
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1533
+ #endif\`,ir=\`#ifndef FLAT_SHADED
1534
+ varying vec3 vNormal;
1535
+ #ifdef USE_TANGENT
1536
+ varying vec3 vTangent;
1537
+ varying vec3 vBitangent;
1538
+ #endif
1539
+ #endif\`,sr=\`#ifndef FLAT_SHADED
1540
+ varying vec3 vNormal;
1541
+ #ifdef USE_TANGENT
1542
+ varying vec3 vTangent;
1543
+ varying vec3 vBitangent;
1544
+ #endif
1545
+ #endif\`,rr=\`#ifndef FLAT_SHADED
1546
+ vNormal = normalize( transformedNormal );
1547
+ #ifdef USE_TANGENT
1548
+ vTangent = normalize( transformedTangent );
1549
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1550
+ #endif
1551
+ #endif\`,ar=\`#ifdef USE_NORMALMAP
1552
+ uniform sampler2D normalMap;
1553
+ uniform vec2 normalScale;
1554
+ #endif
1555
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1556
+ uniform mat3 normalMatrix;
1557
+ #endif
1558
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1559
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1560
+ vec3 q0 = dFdx( eye_pos.xyz );
1561
+ vec3 q1 = dFdy( eye_pos.xyz );
1562
+ vec2 st0 = dFdx( uv.st );
1563
+ vec2 st1 = dFdy( uv.st );
1564
+ vec3 N = surf_norm;
1565
+ vec3 q1perp = cross( q1, N );
1566
+ vec3 q0perp = cross( N, q0 );
1567
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1568
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1569
+ float det = max( dot( T, T ), dot( B, B ) );
1570
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1571
+ return mat3( T * scale, B * scale, N );
1572
+ }
1573
+ #endif\`,or=\`#ifdef USE_CLEARCOAT
1574
+ vec3 clearcoatNormal = nonPerturbedNormal;
1575
+ #endif\`,lr=\`#ifdef USE_CLEARCOAT_NORMALMAP
1576
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1577
+ clearcoatMapN.xy *= clearcoatNormalScale;
1578
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1579
+ #endif\`,cr=\`#ifdef USE_CLEARCOATMAP
1580
+ uniform sampler2D clearcoatMap;
1581
+ #endif
1582
+ #ifdef USE_CLEARCOAT_NORMALMAP
1583
+ uniform sampler2D clearcoatNormalMap;
1584
+ uniform vec2 clearcoatNormalScale;
1585
+ #endif
1586
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1587
+ uniform sampler2D clearcoatRoughnessMap;
1588
+ #endif\`,hr=\`#ifdef USE_IRIDESCENCEMAP
1589
+ uniform sampler2D iridescenceMap;
1590
+ #endif
1591
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1592
+ uniform sampler2D iridescenceThicknessMap;
1593
+ #endif\`,ur=\`#ifdef OPAQUE
1594
+ diffuseColor.a = 1.0;
1595
+ #endif
1596
+ #ifdef USE_TRANSMISSION
1597
+ diffuseColor.a *= material.transmissionAlpha;
1598
+ #endif
1599
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );\`,dr=\`vec3 packNormalToRGB( const in vec3 normal ) {
1600
+ return normalize( normal ) * 0.5 + 0.5;
1601
+ }
1602
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1603
+ return 2.0 * rgb.xyz - 1.0;
1604
+ }
1605
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1606
+ const float Inv255 = 1. / 255.;
1607
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1608
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1609
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1610
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1611
+ vec4 packDepthToRGBA( const in float v ) {
1612
+ if( v <= 0.0 )
1613
+ return vec4( 0., 0., 0., 0. );
1614
+ if( v >= 1.0 )
1615
+ return vec4( 1., 1., 1., 1. );
1616
+ float vuf;
1617
+ float af = modf( v * PackFactors.a, vuf );
1618
+ float bf = modf( vuf * ShiftRight8, vuf );
1619
+ float gf = modf( vuf * ShiftRight8, vuf );
1620
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1621
+ }
1622
+ vec3 packDepthToRGB( const in float v ) {
1623
+ if( v <= 0.0 )
1624
+ return vec3( 0., 0., 0. );
1625
+ if( v >= 1.0 )
1626
+ return vec3( 1., 1., 1. );
1627
+ float vuf;
1628
+ float bf = modf( v * PackFactors.b, vuf );
1629
+ float gf = modf( vuf * ShiftRight8, vuf );
1630
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1631
+ }
1632
+ vec2 packDepthToRG( const in float v ) {
1633
+ if( v <= 0.0 )
1634
+ return vec2( 0., 0. );
1635
+ if( v >= 1.0 )
1636
+ return vec2( 1., 1. );
1637
+ float vuf;
1638
+ float gf = modf( v * 256., vuf );
1639
+ return vec2( vuf * Inv255, gf );
1640
+ }
1641
+ float unpackRGBAToDepth( const in vec4 v ) {
1642
+ return dot( v, UnpackFactors4 );
1643
+ }
1644
+ float unpackRGBToDepth( const in vec3 v ) {
1645
+ return dot( v, UnpackFactors3 );
1646
+ }
1647
+ float unpackRGToDepth( const in vec2 v ) {
1648
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1649
+ }
1650
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1651
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1652
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1653
+ }
1654
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1655
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1656
+ }
1657
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1658
+ return ( viewZ + near ) / ( near - far );
1659
+ }
1660
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1661
+ return depth * ( near - far ) - near;
1662
+ }
1663
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1664
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1665
+ }
1666
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1667
+ return ( near * far ) / ( ( far - near ) * depth - far );
1668
+ }\`,fr=\`#ifdef PREMULTIPLIED_ALPHA
1669
+ gl_FragColor.rgb *= gl_FragColor.a;
1670
+ #endif\`,pr=\`vec4 mvPosition = vec4( transformed, 1.0 );
1671
+ #ifdef USE_BATCHING
1672
+ mvPosition = batchingMatrix * mvPosition;
1673
+ #endif
1674
+ #ifdef USE_INSTANCING
1675
+ mvPosition = instanceMatrix * mvPosition;
1676
+ #endif
1677
+ mvPosition = modelViewMatrix * mvPosition;
1678
+ gl_Position = projectionMatrix * mvPosition;\`,mr=\`#ifdef DITHERING
1679
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1680
+ #endif\`,gr=\`#ifdef DITHERING
1681
+ vec3 dithering( vec3 color ) {
1682
+ float grid_position = rand( gl_FragCoord.xy );
1683
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1684
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1685
+ return color + dither_shift_RGB;
1686
+ }
1687
+ #endif\`,_r=\`float roughnessFactor = roughness;
1688
+ #ifdef USE_ROUGHNESSMAP
1689
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1690
+ roughnessFactor *= texelRoughness.g;
1691
+ #endif\`,xr=\`#ifdef USE_ROUGHNESSMAP
1692
+ uniform sampler2D roughnessMap;
1693
+ #endif\`,vr=\`#if NUM_SPOT_LIGHT_COORDS > 0
1694
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1695
+ #endif
1696
+ #if NUM_SPOT_LIGHT_MAPS > 0
1697
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1698
+ #endif
1699
+ #ifdef USE_SHADOWMAP
1700
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1701
+ #if defined( SHADOWMAP_TYPE_PCF )
1702
+ uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1703
+ #else
1704
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1705
+ #endif
1706
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1707
+ struct DirectionalLightShadow {
1708
+ float shadowIntensity;
1709
+ float shadowBias;
1710
+ float shadowNormalBias;
1711
+ float shadowRadius;
1712
+ vec2 shadowMapSize;
1713
+ };
1714
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1715
+ #endif
1716
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1717
+ #if defined( SHADOWMAP_TYPE_PCF )
1718
+ uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1719
+ #else
1720
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1721
+ #endif
1722
+ struct SpotLightShadow {
1723
+ float shadowIntensity;
1724
+ float shadowBias;
1725
+ float shadowNormalBias;
1726
+ float shadowRadius;
1727
+ vec2 shadowMapSize;
1728
+ };
1729
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1730
+ #endif
1731
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1732
+ #if defined( SHADOWMAP_TYPE_PCF )
1733
+ uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1734
+ #elif defined( SHADOWMAP_TYPE_BASIC )
1735
+ uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1736
+ #endif
1737
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1738
+ struct PointLightShadow {
1739
+ float shadowIntensity;
1740
+ float shadowBias;
1741
+ float shadowNormalBias;
1742
+ float shadowRadius;
1743
+ vec2 shadowMapSize;
1744
+ float shadowCameraNear;
1745
+ float shadowCameraFar;
1746
+ };
1747
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1748
+ #endif
1749
+ #if defined( SHADOWMAP_TYPE_PCF )
1750
+ float interleavedGradientNoise( vec2 position ) {
1751
+ return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
1752
+ }
1753
+ vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
1754
+ const float goldenAngle = 2.399963229728653;
1755
+ float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
1756
+ float theta = float( sampleIndex ) * goldenAngle + phi;
1757
+ return vec2( cos( theta ), sin( theta ) ) * r;
1758
+ }
1759
+ #endif
1760
+ #if defined( SHADOWMAP_TYPE_PCF )
1761
+ float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1762
+ float shadow = 1.0;
1763
+ shadowCoord.xyz /= shadowCoord.w;
1764
+ shadowCoord.z += shadowBias;
1765
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1766
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1767
+ if ( frustumTest ) {
1768
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1769
+ float radius = shadowRadius * texelSize.x;
1770
+ float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
1771
+ shadow = (
1772
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
1773
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
1774
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
1775
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
1776
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
1777
+ ) * 0.2;
1778
+ }
1779
+ return mix( 1.0, shadow, shadowIntensity );
1780
+ }
1781
+ #elif defined( SHADOWMAP_TYPE_VSM )
1782
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1783
+ float shadow = 1.0;
1784
+ shadowCoord.xyz /= shadowCoord.w;
1785
+ shadowCoord.z += shadowBias;
1786
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1787
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1788
+ if ( frustumTest ) {
1789
+ vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
1790
+ float mean = distribution.x;
1791
+ float variance = distribution.y * distribution.y;
1792
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1793
+ float hard_shadow = step( mean, shadowCoord.z );
1794
+ #else
1795
+ float hard_shadow = step( shadowCoord.z, mean );
1796
+ #endif
1797
+ if ( hard_shadow == 1.0 ) {
1798
+ shadow = 1.0;
1799
+ } else {
1800
+ variance = max( variance, 0.0000001 );
1801
+ float d = shadowCoord.z - mean;
1802
+ float p_max = variance / ( variance + d * d );
1803
+ p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
1804
+ shadow = max( hard_shadow, p_max );
1805
+ }
1806
+ }
1807
+ return mix( 1.0, shadow, shadowIntensity );
1808
+ }
1809
+ #else
1810
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1811
+ float shadow = 1.0;
1812
+ shadowCoord.xyz /= shadowCoord.w;
1813
+ shadowCoord.z += shadowBias;
1814
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1815
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1816
+ if ( frustumTest ) {
1817
+ float depth = texture2D( shadowMap, shadowCoord.xy ).r;
1818
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1819
+ shadow = step( depth, shadowCoord.z );
1820
+ #else
1821
+ shadow = step( shadowCoord.z, depth );
1822
+ #endif
1823
+ }
1824
+ return mix( 1.0, shadow, shadowIntensity );
1825
+ }
1826
+ #endif
1827
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1828
+ #if defined( SHADOWMAP_TYPE_PCF )
1829
+ float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1830
+ float shadow = 1.0;
1831
+ vec3 lightToPosition = shadowCoord.xyz;
1832
+ vec3 bd3D = normalize( lightToPosition );
1833
+ vec3 absVec = abs( lightToPosition );
1834
+ float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
1835
+ if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
1836
+ float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1837
+ dp += shadowBias;
1838
+ float texelSize = shadowRadius / shadowMapSize.x;
1839
+ vec3 absDir = abs( bd3D );
1840
+ vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
1841
+ tangent = normalize( cross( bd3D, tangent ) );
1842
+ vec3 bitangent = cross( bd3D, tangent );
1843
+ float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
1844
+ shadow = (
1845
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
1846
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
1847
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
1848
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
1849
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
1850
+ ) * 0.2;
1851
+ }
1852
+ return mix( 1.0, shadow, shadowIntensity );
1853
+ }
1854
+ #elif defined( SHADOWMAP_TYPE_BASIC )
1855
+ float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1856
+ float shadow = 1.0;
1857
+ vec3 lightToPosition = shadowCoord.xyz;
1858
+ vec3 bd3D = normalize( lightToPosition );
1859
+ vec3 absVec = abs( lightToPosition );
1860
+ float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
1861
+ if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
1862
+ float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1863
+ dp += shadowBias;
1864
+ float depth = textureCube( shadowMap, bd3D ).r;
1865
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1866
+ shadow = step( depth, dp );
1867
+ #else
1868
+ shadow = step( dp, depth );
1869
+ #endif
1870
+ }
1871
+ return mix( 1.0, shadow, shadowIntensity );
1872
+ }
1873
+ #endif
1874
+ #endif
1875
+ #endif\`,yr=\`#if NUM_SPOT_LIGHT_COORDS > 0
1876
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1877
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1878
+ #endif
1879
+ #ifdef USE_SHADOWMAP
1880
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1881
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1882
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1883
+ struct DirectionalLightShadow {
1884
+ float shadowIntensity;
1885
+ float shadowBias;
1886
+ float shadowNormalBias;
1887
+ float shadowRadius;
1888
+ vec2 shadowMapSize;
1889
+ };
1890
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1891
+ #endif
1892
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1893
+ struct SpotLightShadow {
1894
+ float shadowIntensity;
1895
+ float shadowBias;
1896
+ float shadowNormalBias;
1897
+ float shadowRadius;
1898
+ vec2 shadowMapSize;
1899
+ };
1900
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1901
+ #endif
1902
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1903
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1904
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1905
+ struct PointLightShadow {
1906
+ float shadowIntensity;
1907
+ float shadowBias;
1908
+ float shadowNormalBias;
1909
+ float shadowRadius;
1910
+ vec2 shadowMapSize;
1911
+ float shadowCameraNear;
1912
+ float shadowCameraFar;
1913
+ };
1914
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1915
+ #endif
1916
+ #endif\`,Mr=\`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1917
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1918
+ vec4 shadowWorldPosition;
1919
+ #endif
1920
+ #if defined( USE_SHADOWMAP )
1921
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1922
+ #pragma unroll_loop_start
1923
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1924
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1925
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1926
+ }
1927
+ #pragma unroll_loop_end
1928
+ #endif
1929
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1930
+ #pragma unroll_loop_start
1931
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1932
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1933
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1934
+ }
1935
+ #pragma unroll_loop_end
1936
+ #endif
1937
+ #endif
1938
+ #if NUM_SPOT_LIGHT_COORDS > 0
1939
+ #pragma unroll_loop_start
1940
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1941
+ shadowWorldPosition = worldPosition;
1942
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1943
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1944
+ #endif
1945
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1946
+ }
1947
+ #pragma unroll_loop_end
1948
+ #endif\`,Sr=\`float getShadowMask() {
1949
+ float shadow = 1.0;
1950
+ #ifdef USE_SHADOWMAP
1951
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1952
+ DirectionalLightShadow directionalLight;
1953
+ #pragma unroll_loop_start
1954
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1955
+ directionalLight = directionalLightShadows[ i ];
1956
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1957
+ }
1958
+ #pragma unroll_loop_end
1959
+ #endif
1960
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1961
+ SpotLightShadow spotLight;
1962
+ #pragma unroll_loop_start
1963
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1964
+ spotLight = spotLightShadows[ i ];
1965
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1966
+ }
1967
+ #pragma unroll_loop_end
1968
+ #endif
1969
+ #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
1970
+ PointLightShadow pointLight;
1971
+ #pragma unroll_loop_start
1972
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1973
+ pointLight = pointLightShadows[ i ];
1974
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1975
+ }
1976
+ #pragma unroll_loop_end
1977
+ #endif
1978
+ #endif
1979
+ return shadow;
1980
+ }\`,br=\`#ifdef USE_SKINNING
1981
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1982
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1983
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1984
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1985
+ #endif\`,Ar=\`#ifdef USE_SKINNING
1986
+ uniform mat4 bindMatrix;
1987
+ uniform mat4 bindMatrixInverse;
1988
+ uniform highp sampler2D boneTexture;
1989
+ mat4 getBoneMatrix( const in float i ) {
1990
+ int size = textureSize( boneTexture, 0 ).x;
1991
+ int j = int( i ) * 4;
1992
+ int x = j % size;
1993
+ int y = j / size;
1994
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
1995
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
1996
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
1997
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
1998
+ return mat4( v1, v2, v3, v4 );
1999
+ }
2000
+ #endif\`,Tr=\`#ifdef USE_SKINNING
2001
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2002
+ vec4 skinned = vec4( 0.0 );
2003
+ skinned += boneMatX * skinVertex * skinWeight.x;
2004
+ skinned += boneMatY * skinVertex * skinWeight.y;
2005
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2006
+ skinned += boneMatW * skinVertex * skinWeight.w;
2007
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2008
+ #endif\`,Er=\`#ifdef USE_SKINNING
2009
+ mat4 skinMatrix = mat4( 0.0 );
2010
+ skinMatrix += skinWeight.x * boneMatX;
2011
+ skinMatrix += skinWeight.y * boneMatY;
2012
+ skinMatrix += skinWeight.z * boneMatZ;
2013
+ skinMatrix += skinWeight.w * boneMatW;
2014
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2015
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2016
+ #ifdef USE_TANGENT
2017
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2018
+ #endif
2019
+ #endif\`,wr=\`float specularStrength;
2020
+ #ifdef USE_SPECULARMAP
2021
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2022
+ specularStrength = texelSpecular.r;
2023
+ #else
2024
+ specularStrength = 1.0;
2025
+ #endif\`,Cr=\`#ifdef USE_SPECULARMAP
2026
+ uniform sampler2D specularMap;
2027
+ #endif\`,Rr=\`#if defined( TONE_MAPPING )
2028
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2029
+ #endif\`,Ir=\`#ifndef saturate
2030
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2031
+ #endif
2032
+ uniform float toneMappingExposure;
2033
+ vec3 LinearToneMapping( vec3 color ) {
2034
+ return saturate( toneMappingExposure * color );
2035
+ }
2036
+ vec3 ReinhardToneMapping( vec3 color ) {
2037
+ color *= toneMappingExposure;
2038
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2039
+ }
2040
+ vec3 CineonToneMapping( vec3 color ) {
2041
+ color *= toneMappingExposure;
2042
+ color = max( vec3( 0.0 ), color - 0.004 );
2043
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2044
+ }
2045
+ vec3 RRTAndODTFit( vec3 v ) {
2046
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2047
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2048
+ return a / b;
2049
+ }
2050
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2051
+ const mat3 ACESInputMat = mat3(
2052
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2053
+ vec3( 0.04823, 0.01566, 0.83777 )
2054
+ );
2055
+ const mat3 ACESOutputMat = mat3(
2056
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2057
+ vec3( -0.07367, -0.00605, 1.07602 )
2058
+ );
2059
+ color *= toneMappingExposure / 0.6;
2060
+ color = ACESInputMat * color;
2061
+ color = RRTAndODTFit( color );
2062
+ color = ACESOutputMat * color;
2063
+ return saturate( color );
2064
+ }
2065
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2066
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2067
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2068
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2069
+ );
2070
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2071
+ vec3( 0.6274, 0.0691, 0.0164 ),
2072
+ vec3( 0.3293, 0.9195, 0.0880 ),
2073
+ vec3( 0.0433, 0.0113, 0.8956 )
2074
+ );
2075
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2076
+ vec3 x2 = x * x;
2077
+ vec3 x4 = x2 * x2;
2078
+ return + 15.5 * x4 * x2
2079
+ - 40.14 * x4 * x
2080
+ + 31.96 * x4
2081
+ - 6.868 * x2 * x
2082
+ + 0.4298 * x2
2083
+ + 0.1191 * x
2084
+ - 0.00232;
2085
+ }
2086
+ vec3 AgXToneMapping( vec3 color ) {
2087
+ const mat3 AgXInsetMatrix = mat3(
2088
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2089
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2090
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2091
+ );
2092
+ const mat3 AgXOutsetMatrix = mat3(
2093
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2094
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2095
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2096
+ );
2097
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2098
+ color *= toneMappingExposure;
2099
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2100
+ color = AgXInsetMatrix * color;
2101
+ color = max( color, 1e-10 ); color = log2( color );
2102
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2103
+ color = clamp( color, 0.0, 1.0 );
2104
+ color = agxDefaultContrastApprox( color );
2105
+ color = AgXOutsetMatrix * color;
2106
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2107
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2108
+ color = clamp( color, 0.0, 1.0 );
2109
+ return color;
2110
+ }
2111
+ vec3 NeutralToneMapping( vec3 color ) {
2112
+ const float StartCompression = 0.8 - 0.04;
2113
+ const float Desaturation = 0.15;
2114
+ color *= toneMappingExposure;
2115
+ float x = min( color.r, min( color.g, color.b ) );
2116
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2117
+ color -= offset;
2118
+ float peak = max( color.r, max( color.g, color.b ) );
2119
+ if ( peak < StartCompression ) return color;
2120
+ float d = 1. - StartCompression;
2121
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2122
+ color *= newPeak / peak;
2123
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2124
+ return mix( color, vec3( newPeak ), g );
2125
+ }
2126
+ vec3 CustomToneMapping( vec3 color ) { return color; }\`,Pr=\`#ifdef USE_TRANSMISSION
2127
+ material.transmission = transmission;
2128
+ material.transmissionAlpha = 1.0;
2129
+ material.thickness = thickness;
2130
+ material.attenuationDistance = attenuationDistance;
2131
+ material.attenuationColor = attenuationColor;
2132
+ #ifdef USE_TRANSMISSIONMAP
2133
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2134
+ #endif
2135
+ #ifdef USE_THICKNESSMAP
2136
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2137
+ #endif
2138
+ vec3 pos = vWorldPosition;
2139
+ vec3 v = normalize( cameraPosition - pos );
2140
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2141
+ vec4 transmitted = getIBLVolumeRefraction(
2142
+ n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
2143
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2144
+ material.attenuationColor, material.attenuationDistance );
2145
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2146
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2147
+ #endif\`,Lr=\`#ifdef USE_TRANSMISSION
2148
+ uniform float transmission;
2149
+ uniform float thickness;
2150
+ uniform float attenuationDistance;
2151
+ uniform vec3 attenuationColor;
2152
+ #ifdef USE_TRANSMISSIONMAP
2153
+ uniform sampler2D transmissionMap;
2154
+ #endif
2155
+ #ifdef USE_THICKNESSMAP
2156
+ uniform sampler2D thicknessMap;
2157
+ #endif
2158
+ uniform vec2 transmissionSamplerSize;
2159
+ uniform sampler2D transmissionSamplerMap;
2160
+ uniform mat4 modelMatrix;
2161
+ uniform mat4 projectionMatrix;
2162
+ varying vec3 vWorldPosition;
2163
+ float w0( float a ) {
2164
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2165
+ }
2166
+ float w1( float a ) {
2167
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2168
+ }
2169
+ float w2( float a ){
2170
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2171
+ }
2172
+ float w3( float a ) {
2173
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2174
+ }
2175
+ float g0( float a ) {
2176
+ return w0( a ) + w1( a );
2177
+ }
2178
+ float g1( float a ) {
2179
+ return w2( a ) + w3( a );
2180
+ }
2181
+ float h0( float a ) {
2182
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2183
+ }
2184
+ float h1( float a ) {
2185
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2186
+ }
2187
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2188
+ uv = uv * texelSize.zw + 0.5;
2189
+ vec2 iuv = floor( uv );
2190
+ vec2 fuv = fract( uv );
2191
+ float g0x = g0( fuv.x );
2192
+ float g1x = g1( fuv.x );
2193
+ float h0x = h0( fuv.x );
2194
+ float h1x = h1( fuv.x );
2195
+ float h0y = h0( fuv.y );
2196
+ float h1y = h1( fuv.y );
2197
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2198
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2199
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2200
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2201
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2202
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2203
+ }
2204
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2205
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2206
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2207
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2208
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2209
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2210
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2211
+ return mix( fSample, cSample, fract( lod ) );
2212
+ }
2213
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2214
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2215
+ vec3 modelScale;
2216
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2217
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2218
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2219
+ return normalize( refractionVector ) * thickness * modelScale;
2220
+ }
2221
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2222
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2223
+ }
2224
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2225
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2226
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2227
+ }
2228
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2229
+ if ( isinf( attenuationDistance ) ) {
2230
+ return vec3( 1.0 );
2231
+ } else {
2232
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2233
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2234
+ }
2235
+ }
2236
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2237
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2238
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2239
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2240
+ vec4 transmittedLight;
2241
+ vec3 transmittance;
2242
+ #ifdef USE_DISPERSION
2243
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2244
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2245
+ for ( int i = 0; i < 3; i ++ ) {
2246
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2247
+ vec3 refractedRayExit = position + transmissionRay;
2248
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2249
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2250
+ refractionCoords += 1.0;
2251
+ refractionCoords /= 2.0;
2252
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2253
+ transmittedLight[ i ] = transmissionSample[ i ];
2254
+ transmittedLight.a += transmissionSample.a;
2255
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2256
+ }
2257
+ transmittedLight.a /= 3.0;
2258
+ #else
2259
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2260
+ vec3 refractedRayExit = position + transmissionRay;
2261
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2262
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2263
+ refractionCoords += 1.0;
2264
+ refractionCoords /= 2.0;
2265
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2266
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2267
+ #endif
2268
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2269
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2270
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2271
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2272
+ }
2273
+ #endif\`,Dr=\`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2274
+ varying vec2 vUv;
2275
+ #endif
2276
+ #ifdef USE_MAP
2277
+ varying vec2 vMapUv;
2278
+ #endif
2279
+ #ifdef USE_ALPHAMAP
2280
+ varying vec2 vAlphaMapUv;
2281
+ #endif
2282
+ #ifdef USE_LIGHTMAP
2283
+ varying vec2 vLightMapUv;
2284
+ #endif
2285
+ #ifdef USE_AOMAP
2286
+ varying vec2 vAoMapUv;
2287
+ #endif
2288
+ #ifdef USE_BUMPMAP
2289
+ varying vec2 vBumpMapUv;
2290
+ #endif
2291
+ #ifdef USE_NORMALMAP
2292
+ varying vec2 vNormalMapUv;
2293
+ #endif
2294
+ #ifdef USE_EMISSIVEMAP
2295
+ varying vec2 vEmissiveMapUv;
2296
+ #endif
2297
+ #ifdef USE_METALNESSMAP
2298
+ varying vec2 vMetalnessMapUv;
2299
+ #endif
2300
+ #ifdef USE_ROUGHNESSMAP
2301
+ varying vec2 vRoughnessMapUv;
2302
+ #endif
2303
+ #ifdef USE_ANISOTROPYMAP
2304
+ varying vec2 vAnisotropyMapUv;
2305
+ #endif
2306
+ #ifdef USE_CLEARCOATMAP
2307
+ varying vec2 vClearcoatMapUv;
2308
+ #endif
2309
+ #ifdef USE_CLEARCOAT_NORMALMAP
2310
+ varying vec2 vClearcoatNormalMapUv;
2311
+ #endif
2312
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2313
+ varying vec2 vClearcoatRoughnessMapUv;
2314
+ #endif
2315
+ #ifdef USE_IRIDESCENCEMAP
2316
+ varying vec2 vIridescenceMapUv;
2317
+ #endif
2318
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2319
+ varying vec2 vIridescenceThicknessMapUv;
2320
+ #endif
2321
+ #ifdef USE_SHEEN_COLORMAP
2322
+ varying vec2 vSheenColorMapUv;
2323
+ #endif
2324
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2325
+ varying vec2 vSheenRoughnessMapUv;
2326
+ #endif
2327
+ #ifdef USE_SPECULARMAP
2328
+ varying vec2 vSpecularMapUv;
2329
+ #endif
2330
+ #ifdef USE_SPECULAR_COLORMAP
2331
+ varying vec2 vSpecularColorMapUv;
2332
+ #endif
2333
+ #ifdef USE_SPECULAR_INTENSITYMAP
2334
+ varying vec2 vSpecularIntensityMapUv;
2335
+ #endif
2336
+ #ifdef USE_TRANSMISSIONMAP
2337
+ uniform mat3 transmissionMapTransform;
2338
+ varying vec2 vTransmissionMapUv;
2339
+ #endif
2340
+ #ifdef USE_THICKNESSMAP
2341
+ uniform mat3 thicknessMapTransform;
2342
+ varying vec2 vThicknessMapUv;
2343
+ #endif\`,Ur=\`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2344
+ varying vec2 vUv;
2345
+ #endif
2346
+ #ifdef USE_MAP
2347
+ uniform mat3 mapTransform;
2348
+ varying vec2 vMapUv;
2349
+ #endif
2350
+ #ifdef USE_ALPHAMAP
2351
+ uniform mat3 alphaMapTransform;
2352
+ varying vec2 vAlphaMapUv;
2353
+ #endif
2354
+ #ifdef USE_LIGHTMAP
2355
+ uniform mat3 lightMapTransform;
2356
+ varying vec2 vLightMapUv;
2357
+ #endif
2358
+ #ifdef USE_AOMAP
2359
+ uniform mat3 aoMapTransform;
2360
+ varying vec2 vAoMapUv;
2361
+ #endif
2362
+ #ifdef USE_BUMPMAP
2363
+ uniform mat3 bumpMapTransform;
2364
+ varying vec2 vBumpMapUv;
2365
+ #endif
2366
+ #ifdef USE_NORMALMAP
2367
+ uniform mat3 normalMapTransform;
2368
+ varying vec2 vNormalMapUv;
2369
+ #endif
2370
+ #ifdef USE_DISPLACEMENTMAP
2371
+ uniform mat3 displacementMapTransform;
2372
+ varying vec2 vDisplacementMapUv;
2373
+ #endif
2374
+ #ifdef USE_EMISSIVEMAP
2375
+ uniform mat3 emissiveMapTransform;
2376
+ varying vec2 vEmissiveMapUv;
2377
+ #endif
2378
+ #ifdef USE_METALNESSMAP
2379
+ uniform mat3 metalnessMapTransform;
2380
+ varying vec2 vMetalnessMapUv;
2381
+ #endif
2382
+ #ifdef USE_ROUGHNESSMAP
2383
+ uniform mat3 roughnessMapTransform;
2384
+ varying vec2 vRoughnessMapUv;
2385
+ #endif
2386
+ #ifdef USE_ANISOTROPYMAP
2387
+ uniform mat3 anisotropyMapTransform;
2388
+ varying vec2 vAnisotropyMapUv;
2389
+ #endif
2390
+ #ifdef USE_CLEARCOATMAP
2391
+ uniform mat3 clearcoatMapTransform;
2392
+ varying vec2 vClearcoatMapUv;
2393
+ #endif
2394
+ #ifdef USE_CLEARCOAT_NORMALMAP
2395
+ uniform mat3 clearcoatNormalMapTransform;
2396
+ varying vec2 vClearcoatNormalMapUv;
2397
+ #endif
2398
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2399
+ uniform mat3 clearcoatRoughnessMapTransform;
2400
+ varying vec2 vClearcoatRoughnessMapUv;
2401
+ #endif
2402
+ #ifdef USE_SHEEN_COLORMAP
2403
+ uniform mat3 sheenColorMapTransform;
2404
+ varying vec2 vSheenColorMapUv;
2405
+ #endif
2406
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2407
+ uniform mat3 sheenRoughnessMapTransform;
2408
+ varying vec2 vSheenRoughnessMapUv;
2409
+ #endif
2410
+ #ifdef USE_IRIDESCENCEMAP
2411
+ uniform mat3 iridescenceMapTransform;
2412
+ varying vec2 vIridescenceMapUv;
2413
+ #endif
2414
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2415
+ uniform mat3 iridescenceThicknessMapTransform;
2416
+ varying vec2 vIridescenceThicknessMapUv;
2417
+ #endif
2418
+ #ifdef USE_SPECULARMAP
2419
+ uniform mat3 specularMapTransform;
2420
+ varying vec2 vSpecularMapUv;
2421
+ #endif
2422
+ #ifdef USE_SPECULAR_COLORMAP
2423
+ uniform mat3 specularColorMapTransform;
2424
+ varying vec2 vSpecularColorMapUv;
2425
+ #endif
2426
+ #ifdef USE_SPECULAR_INTENSITYMAP
2427
+ uniform mat3 specularIntensityMapTransform;
2428
+ varying vec2 vSpecularIntensityMapUv;
2429
+ #endif
2430
+ #ifdef USE_TRANSMISSIONMAP
2431
+ uniform mat3 transmissionMapTransform;
2432
+ varying vec2 vTransmissionMapUv;
2433
+ #endif
2434
+ #ifdef USE_THICKNESSMAP
2435
+ uniform mat3 thicknessMapTransform;
2436
+ varying vec2 vThicknessMapUv;
2437
+ #endif\`,Nr=\`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2438
+ vUv = vec3( uv, 1 ).xy;
2439
+ #endif
2440
+ #ifdef USE_MAP
2441
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2442
+ #endif
2443
+ #ifdef USE_ALPHAMAP
2444
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2445
+ #endif
2446
+ #ifdef USE_LIGHTMAP
2447
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2448
+ #endif
2449
+ #ifdef USE_AOMAP
2450
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2451
+ #endif
2452
+ #ifdef USE_BUMPMAP
2453
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2454
+ #endif
2455
+ #ifdef USE_NORMALMAP
2456
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2457
+ #endif
2458
+ #ifdef USE_DISPLACEMENTMAP
2459
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2460
+ #endif
2461
+ #ifdef USE_EMISSIVEMAP
2462
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2463
+ #endif
2464
+ #ifdef USE_METALNESSMAP
2465
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2466
+ #endif
2467
+ #ifdef USE_ROUGHNESSMAP
2468
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2469
+ #endif
2470
+ #ifdef USE_ANISOTROPYMAP
2471
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2472
+ #endif
2473
+ #ifdef USE_CLEARCOATMAP
2474
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2475
+ #endif
2476
+ #ifdef USE_CLEARCOAT_NORMALMAP
2477
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2478
+ #endif
2479
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2480
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2481
+ #endif
2482
+ #ifdef USE_IRIDESCENCEMAP
2483
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2484
+ #endif
2485
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2486
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2487
+ #endif
2488
+ #ifdef USE_SHEEN_COLORMAP
2489
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2490
+ #endif
2491
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2492
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2493
+ #endif
2494
+ #ifdef USE_SPECULARMAP
2495
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2496
+ #endif
2497
+ #ifdef USE_SPECULAR_COLORMAP
2498
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2499
+ #endif
2500
+ #ifdef USE_SPECULAR_INTENSITYMAP
2501
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2502
+ #endif
2503
+ #ifdef USE_TRANSMISSIONMAP
2504
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2505
+ #endif
2506
+ #ifdef USE_THICKNESSMAP
2507
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2508
+ #endif\`,Fr=\`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2509
+ vec4 worldPosition = vec4( transformed, 1.0 );
2510
+ #ifdef USE_BATCHING
2511
+ worldPosition = batchingMatrix * worldPosition;
2512
+ #endif
2513
+ #ifdef USE_INSTANCING
2514
+ worldPosition = instanceMatrix * worldPosition;
2515
+ #endif
2516
+ worldPosition = modelMatrix * worldPosition;
2517
+ #endif\`,Or=\`varying vec2 vUv;
2518
+ uniform mat3 uvTransform;
2519
+ void main() {
2520
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2521
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2522
+ }\`,Br=\`uniform sampler2D t2D;
2523
+ uniform float backgroundIntensity;
2524
+ varying vec2 vUv;
2525
+ void main() {
2526
+ vec4 texColor = texture2D( t2D, vUv );
2527
+ #ifdef DECODE_VIDEO_TEXTURE
2528
+ 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 );
2529
+ #endif
2530
+ texColor.rgb *= backgroundIntensity;
2531
+ gl_FragColor = texColor;
2532
+ #include <tonemapping_fragment>
2533
+ #include <colorspace_fragment>
2534
+ }\`,zr=\`varying vec3 vWorldDirection;
2535
+ #include <common>
2536
+ void main() {
2537
+ vWorldDirection = transformDirection( position, modelMatrix );
2538
+ #include <begin_vertex>
2539
+ #include <project_vertex>
2540
+ gl_Position.z = gl_Position.w;
2541
+ }\`,Vr=\`#ifdef ENVMAP_TYPE_CUBE
2542
+ uniform samplerCube envMap;
2543
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2544
+ uniform sampler2D envMap;
2545
+ #endif
2546
+ uniform float flipEnvMap;
2547
+ uniform float backgroundBlurriness;
2548
+ uniform float backgroundIntensity;
2549
+ uniform mat3 backgroundRotation;
2550
+ varying vec3 vWorldDirection;
2551
+ #include <cube_uv_reflection_fragment>
2552
+ void main() {
2553
+ #ifdef ENVMAP_TYPE_CUBE
2554
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2555
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2556
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2557
+ #else
2558
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2559
+ #endif
2560
+ texColor.rgb *= backgroundIntensity;
2561
+ gl_FragColor = texColor;
2562
+ #include <tonemapping_fragment>
2563
+ #include <colorspace_fragment>
2564
+ }\`,kr=\`varying vec3 vWorldDirection;
2565
+ #include <common>
2566
+ void main() {
2567
+ vWorldDirection = transformDirection( position, modelMatrix );
2568
+ #include <begin_vertex>
2569
+ #include <project_vertex>
2570
+ gl_Position.z = gl_Position.w;
2571
+ }\`,Gr=\`uniform samplerCube tCube;
2572
+ uniform float tFlip;
2573
+ uniform float opacity;
2574
+ varying vec3 vWorldDirection;
2575
+ void main() {
2576
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2577
+ gl_FragColor = texColor;
2578
+ gl_FragColor.a *= opacity;
2579
+ #include <tonemapping_fragment>
2580
+ #include <colorspace_fragment>
2581
+ }\`,Hr=\`#include <common>
2582
+ #include <batching_pars_vertex>
2583
+ #include <uv_pars_vertex>
2584
+ #include <displacementmap_pars_vertex>
2585
+ #include <morphtarget_pars_vertex>
2586
+ #include <skinning_pars_vertex>
2587
+ #include <logdepthbuf_pars_vertex>
2588
+ #include <clipping_planes_pars_vertex>
2589
+ varying vec2 vHighPrecisionZW;
2590
+ void main() {
2591
+ #include <uv_vertex>
2592
+ #include <batching_vertex>
2593
+ #include <skinbase_vertex>
2594
+ #include <morphinstance_vertex>
2595
+ #ifdef USE_DISPLACEMENTMAP
2596
+ #include <beginnormal_vertex>
2597
+ #include <morphnormal_vertex>
2598
+ #include <skinnormal_vertex>
2599
+ #endif
2600
+ #include <begin_vertex>
2601
+ #include <morphtarget_vertex>
2602
+ #include <skinning_vertex>
2603
+ #include <displacementmap_vertex>
2604
+ #include <project_vertex>
2605
+ #include <logdepthbuf_vertex>
2606
+ #include <clipping_planes_vertex>
2607
+ vHighPrecisionZW = gl_Position.zw;
2608
+ }\`,Wr=\`#if DEPTH_PACKING == 3200
2609
+ uniform float opacity;
2610
+ #endif
2611
+ #include <common>
2612
+ #include <packing>
2613
+ #include <uv_pars_fragment>
2614
+ #include <map_pars_fragment>
2615
+ #include <alphamap_pars_fragment>
2616
+ #include <alphatest_pars_fragment>
2617
+ #include <alphahash_pars_fragment>
2618
+ #include <logdepthbuf_pars_fragment>
2619
+ #include <clipping_planes_pars_fragment>
2620
+ varying vec2 vHighPrecisionZW;
2621
+ void main() {
2622
+ vec4 diffuseColor = vec4( 1.0 );
2623
+ #include <clipping_planes_fragment>
2624
+ #if DEPTH_PACKING == 3200
2625
+ diffuseColor.a = opacity;
2626
+ #endif
2627
+ #include <map_fragment>
2628
+ #include <alphamap_fragment>
2629
+ #include <alphatest_fragment>
2630
+ #include <alphahash_fragment>
2631
+ #include <logdepthbuf_fragment>
2632
+ #ifdef USE_REVERSED_DEPTH_BUFFER
2633
+ float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
2634
+ #else
2635
+ float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
2636
+ #endif
2637
+ #if DEPTH_PACKING == 3200
2638
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2639
+ #elif DEPTH_PACKING == 3201
2640
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2641
+ #elif DEPTH_PACKING == 3202
2642
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2643
+ #elif DEPTH_PACKING == 3203
2644
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2645
+ #endif
2646
+ }\`,Xr=\`#define DISTANCE
2647
+ varying vec3 vWorldPosition;
2648
+ #include <common>
2649
+ #include <batching_pars_vertex>
2650
+ #include <uv_pars_vertex>
2651
+ #include <displacementmap_pars_vertex>
2652
+ #include <morphtarget_pars_vertex>
2653
+ #include <skinning_pars_vertex>
2654
+ #include <clipping_planes_pars_vertex>
2655
+ void main() {
2656
+ #include <uv_vertex>
2657
+ #include <batching_vertex>
2658
+ #include <skinbase_vertex>
2659
+ #include <morphinstance_vertex>
2660
+ #ifdef USE_DISPLACEMENTMAP
2661
+ #include <beginnormal_vertex>
2662
+ #include <morphnormal_vertex>
2663
+ #include <skinnormal_vertex>
2664
+ #endif
2665
+ #include <begin_vertex>
2666
+ #include <morphtarget_vertex>
2667
+ #include <skinning_vertex>
2668
+ #include <displacementmap_vertex>
2669
+ #include <project_vertex>
2670
+ #include <worldpos_vertex>
2671
+ #include <clipping_planes_vertex>
2672
+ vWorldPosition = worldPosition.xyz;
2673
+ }\`,qr=\`#define DISTANCE
2674
+ uniform vec3 referencePosition;
2675
+ uniform float nearDistance;
2676
+ uniform float farDistance;
2677
+ varying vec3 vWorldPosition;
2678
+ #include <common>
2679
+ #include <uv_pars_fragment>
2680
+ #include <map_pars_fragment>
2681
+ #include <alphamap_pars_fragment>
2682
+ #include <alphatest_pars_fragment>
2683
+ #include <alphahash_pars_fragment>
2684
+ #include <clipping_planes_pars_fragment>
2685
+ void main () {
2686
+ vec4 diffuseColor = vec4( 1.0 );
2687
+ #include <clipping_planes_fragment>
2688
+ #include <map_fragment>
2689
+ #include <alphamap_fragment>
2690
+ #include <alphatest_fragment>
2691
+ #include <alphahash_fragment>
2692
+ float dist = length( vWorldPosition - referencePosition );
2693
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2694
+ dist = saturate( dist );
2695
+ gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2696
+ }\`,Yr=\`varying vec3 vWorldDirection;
2697
+ #include <common>
2698
+ void main() {
2699
+ vWorldDirection = transformDirection( position, modelMatrix );
2700
+ #include <begin_vertex>
2701
+ #include <project_vertex>
2702
+ }\`,Zr=\`uniform sampler2D tEquirect;
2703
+ varying vec3 vWorldDirection;
2704
+ #include <common>
2705
+ void main() {
2706
+ vec3 direction = normalize( vWorldDirection );
2707
+ vec2 sampleUV = equirectUv( direction );
2708
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2709
+ #include <tonemapping_fragment>
2710
+ #include <colorspace_fragment>
2711
+ }\`,Jr=\`uniform float scale;
2712
+ attribute float lineDistance;
2713
+ varying float vLineDistance;
2714
+ #include <common>
2715
+ #include <uv_pars_vertex>
2716
+ #include <color_pars_vertex>
2717
+ #include <fog_pars_vertex>
2718
+ #include <morphtarget_pars_vertex>
2719
+ #include <logdepthbuf_pars_vertex>
2720
+ #include <clipping_planes_pars_vertex>
2721
+ void main() {
2722
+ vLineDistance = scale * lineDistance;
2723
+ #include <uv_vertex>
2724
+ #include <color_vertex>
2725
+ #include <morphinstance_vertex>
2726
+ #include <morphcolor_vertex>
2727
+ #include <begin_vertex>
2728
+ #include <morphtarget_vertex>
2729
+ #include <project_vertex>
2730
+ #include <logdepthbuf_vertex>
2731
+ #include <clipping_planes_vertex>
2732
+ #include <fog_vertex>
2733
+ }\`,\$r=\`uniform vec3 diffuse;
2734
+ uniform float opacity;
2735
+ uniform float dashSize;
2736
+ uniform float totalSize;
2737
+ varying float vLineDistance;
2738
+ #include <common>
2739
+ #include <color_pars_fragment>
2740
+ #include <uv_pars_fragment>
2741
+ #include <map_pars_fragment>
2742
+ #include <fog_pars_fragment>
2743
+ #include <logdepthbuf_pars_fragment>
2744
+ #include <clipping_planes_pars_fragment>
2745
+ void main() {
2746
+ vec4 diffuseColor = vec4( diffuse, opacity );
2747
+ #include <clipping_planes_fragment>
2748
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2749
+ discard;
2750
+ }
2751
+ vec3 outgoingLight = vec3( 0.0 );
2752
+ #include <logdepthbuf_fragment>
2753
+ #include <map_fragment>
2754
+ #include <color_fragment>
2755
+ outgoingLight = diffuseColor.rgb;
2756
+ #include <opaque_fragment>
2757
+ #include <tonemapping_fragment>
2758
+ #include <colorspace_fragment>
2759
+ #include <fog_fragment>
2760
+ #include <premultiplied_alpha_fragment>
2761
+ }\`,Kr=\`#include <common>
2762
+ #include <batching_pars_vertex>
2763
+ #include <uv_pars_vertex>
2764
+ #include <envmap_pars_vertex>
2765
+ #include <color_pars_vertex>
2766
+ #include <fog_pars_vertex>
2767
+ #include <morphtarget_pars_vertex>
2768
+ #include <skinning_pars_vertex>
2769
+ #include <logdepthbuf_pars_vertex>
2770
+ #include <clipping_planes_pars_vertex>
2771
+ void main() {
2772
+ #include <uv_vertex>
2773
+ #include <color_vertex>
2774
+ #include <morphinstance_vertex>
2775
+ #include <morphcolor_vertex>
2776
+ #include <batching_vertex>
2777
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2778
+ #include <beginnormal_vertex>
2779
+ #include <morphnormal_vertex>
2780
+ #include <skinbase_vertex>
2781
+ #include <skinnormal_vertex>
2782
+ #include <defaultnormal_vertex>
2783
+ #endif
2784
+ #include <begin_vertex>
2785
+ #include <morphtarget_vertex>
2786
+ #include <skinning_vertex>
2787
+ #include <project_vertex>
2788
+ #include <logdepthbuf_vertex>
2789
+ #include <clipping_planes_vertex>
2790
+ #include <worldpos_vertex>
2791
+ #include <envmap_vertex>
2792
+ #include <fog_vertex>
2793
+ }\`,Qr=\`uniform vec3 diffuse;
2794
+ uniform float opacity;
2795
+ #ifndef FLAT_SHADED
2796
+ varying vec3 vNormal;
2797
+ #endif
2798
+ #include <common>
2799
+ #include <dithering_pars_fragment>
2800
+ #include <color_pars_fragment>
2801
+ #include <uv_pars_fragment>
2802
+ #include <map_pars_fragment>
2803
+ #include <alphamap_pars_fragment>
2804
+ #include <alphatest_pars_fragment>
2805
+ #include <alphahash_pars_fragment>
2806
+ #include <aomap_pars_fragment>
2807
+ #include <lightmap_pars_fragment>
2808
+ #include <envmap_common_pars_fragment>
2809
+ #include <envmap_pars_fragment>
2810
+ #include <fog_pars_fragment>
2811
+ #include <specularmap_pars_fragment>
2812
+ #include <logdepthbuf_pars_fragment>
2813
+ #include <clipping_planes_pars_fragment>
2814
+ void main() {
2815
+ vec4 diffuseColor = vec4( diffuse, opacity );
2816
+ #include <clipping_planes_fragment>
2817
+ #include <logdepthbuf_fragment>
2818
+ #include <map_fragment>
2819
+ #include <color_fragment>
2820
+ #include <alphamap_fragment>
2821
+ #include <alphatest_fragment>
2822
+ #include <alphahash_fragment>
2823
+ #include <specularmap_fragment>
2824
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2825
+ #ifdef USE_LIGHTMAP
2826
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2827
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2828
+ #else
2829
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2830
+ #endif
2831
+ #include <aomap_fragment>
2832
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2833
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2834
+ #include <envmap_fragment>
2835
+ #include <opaque_fragment>
2836
+ #include <tonemapping_fragment>
2837
+ #include <colorspace_fragment>
2838
+ #include <fog_fragment>
2839
+ #include <premultiplied_alpha_fragment>
2840
+ #include <dithering_fragment>
2841
+ }\`,jr=\`#define LAMBERT
2842
+ varying vec3 vViewPosition;
2843
+ #include <common>
2844
+ #include <batching_pars_vertex>
2845
+ #include <uv_pars_vertex>
2846
+ #include <displacementmap_pars_vertex>
2847
+ #include <envmap_pars_vertex>
2848
+ #include <color_pars_vertex>
2849
+ #include <fog_pars_vertex>
2850
+ #include <normal_pars_vertex>
2851
+ #include <morphtarget_pars_vertex>
2852
+ #include <skinning_pars_vertex>
2853
+ #include <shadowmap_pars_vertex>
2854
+ #include <logdepthbuf_pars_vertex>
2855
+ #include <clipping_planes_pars_vertex>
2856
+ void main() {
2857
+ #include <uv_vertex>
2858
+ #include <color_vertex>
2859
+ #include <morphinstance_vertex>
2860
+ #include <morphcolor_vertex>
2861
+ #include <batching_vertex>
2862
+ #include <beginnormal_vertex>
2863
+ #include <morphnormal_vertex>
2864
+ #include <skinbase_vertex>
2865
+ #include <skinnormal_vertex>
2866
+ #include <defaultnormal_vertex>
2867
+ #include <normal_vertex>
2868
+ #include <begin_vertex>
2869
+ #include <morphtarget_vertex>
2870
+ #include <skinning_vertex>
2871
+ #include <displacementmap_vertex>
2872
+ #include <project_vertex>
2873
+ #include <logdepthbuf_vertex>
2874
+ #include <clipping_planes_vertex>
2875
+ vViewPosition = - mvPosition.xyz;
2876
+ #include <worldpos_vertex>
2877
+ #include <envmap_vertex>
2878
+ #include <shadowmap_vertex>
2879
+ #include <fog_vertex>
2880
+ }\`,ea=\`#define LAMBERT
2881
+ uniform vec3 diffuse;
2882
+ uniform vec3 emissive;
2883
+ uniform float opacity;
2884
+ #include <common>
2885
+ #include <dithering_pars_fragment>
2886
+ #include <color_pars_fragment>
2887
+ #include <uv_pars_fragment>
2888
+ #include <map_pars_fragment>
2889
+ #include <alphamap_pars_fragment>
2890
+ #include <alphatest_pars_fragment>
2891
+ #include <alphahash_pars_fragment>
2892
+ #include <aomap_pars_fragment>
2893
+ #include <lightmap_pars_fragment>
2894
+ #include <emissivemap_pars_fragment>
2895
+ #include <envmap_common_pars_fragment>
2896
+ #include <envmap_pars_fragment>
2897
+ #include <fog_pars_fragment>
2898
+ #include <bsdfs>
2899
+ #include <lights_pars_begin>
2900
+ #include <normal_pars_fragment>
2901
+ #include <lights_lambert_pars_fragment>
2902
+ #include <shadowmap_pars_fragment>
2903
+ #include <bumpmap_pars_fragment>
2904
+ #include <normalmap_pars_fragment>
2905
+ #include <specularmap_pars_fragment>
2906
+ #include <logdepthbuf_pars_fragment>
2907
+ #include <clipping_planes_pars_fragment>
2908
+ void main() {
2909
+ vec4 diffuseColor = vec4( diffuse, opacity );
2910
+ #include <clipping_planes_fragment>
2911
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2912
+ vec3 totalEmissiveRadiance = emissive;
2913
+ #include <logdepthbuf_fragment>
2914
+ #include <map_fragment>
2915
+ #include <color_fragment>
2916
+ #include <alphamap_fragment>
2917
+ #include <alphatest_fragment>
2918
+ #include <alphahash_fragment>
2919
+ #include <specularmap_fragment>
2920
+ #include <normal_fragment_begin>
2921
+ #include <normal_fragment_maps>
2922
+ #include <emissivemap_fragment>
2923
+ #include <lights_lambert_fragment>
2924
+ #include <lights_fragment_begin>
2925
+ #include <lights_fragment_maps>
2926
+ #include <lights_fragment_end>
2927
+ #include <aomap_fragment>
2928
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2929
+ #include <envmap_fragment>
2930
+ #include <opaque_fragment>
2931
+ #include <tonemapping_fragment>
2932
+ #include <colorspace_fragment>
2933
+ #include <fog_fragment>
2934
+ #include <premultiplied_alpha_fragment>
2935
+ #include <dithering_fragment>
2936
+ }\`,ta=\`#define MATCAP
2937
+ varying vec3 vViewPosition;
2938
+ #include <common>
2939
+ #include <batching_pars_vertex>
2940
+ #include <uv_pars_vertex>
2941
+ #include <color_pars_vertex>
2942
+ #include <displacementmap_pars_vertex>
2943
+ #include <fog_pars_vertex>
2944
+ #include <normal_pars_vertex>
2945
+ #include <morphtarget_pars_vertex>
2946
+ #include <skinning_pars_vertex>
2947
+ #include <logdepthbuf_pars_vertex>
2948
+ #include <clipping_planes_pars_vertex>
2949
+ void main() {
2950
+ #include <uv_vertex>
2951
+ #include <color_vertex>
2952
+ #include <morphinstance_vertex>
2953
+ #include <morphcolor_vertex>
2954
+ #include <batching_vertex>
2955
+ #include <beginnormal_vertex>
2956
+ #include <morphnormal_vertex>
2957
+ #include <skinbase_vertex>
2958
+ #include <skinnormal_vertex>
2959
+ #include <defaultnormal_vertex>
2960
+ #include <normal_vertex>
2961
+ #include <begin_vertex>
2962
+ #include <morphtarget_vertex>
2963
+ #include <skinning_vertex>
2964
+ #include <displacementmap_vertex>
2965
+ #include <project_vertex>
2966
+ #include <logdepthbuf_vertex>
2967
+ #include <clipping_planes_vertex>
2968
+ #include <fog_vertex>
2969
+ vViewPosition = - mvPosition.xyz;
2970
+ }\`,na=\`#define MATCAP
2971
+ uniform vec3 diffuse;
2972
+ uniform float opacity;
2973
+ uniform sampler2D matcap;
2974
+ varying vec3 vViewPosition;
2975
+ #include <common>
2976
+ #include <dithering_pars_fragment>
2977
+ #include <color_pars_fragment>
2978
+ #include <uv_pars_fragment>
2979
+ #include <map_pars_fragment>
2980
+ #include <alphamap_pars_fragment>
2981
+ #include <alphatest_pars_fragment>
2982
+ #include <alphahash_pars_fragment>
2983
+ #include <fog_pars_fragment>
2984
+ #include <normal_pars_fragment>
2985
+ #include <bumpmap_pars_fragment>
2986
+ #include <normalmap_pars_fragment>
2987
+ #include <logdepthbuf_pars_fragment>
2988
+ #include <clipping_planes_pars_fragment>
2989
+ void main() {
2990
+ vec4 diffuseColor = vec4( diffuse, opacity );
2991
+ #include <clipping_planes_fragment>
2992
+ #include <logdepthbuf_fragment>
2993
+ #include <map_fragment>
2994
+ #include <color_fragment>
2995
+ #include <alphamap_fragment>
2996
+ #include <alphatest_fragment>
2997
+ #include <alphahash_fragment>
2998
+ #include <normal_fragment_begin>
2999
+ #include <normal_fragment_maps>
3000
+ vec3 viewDir = normalize( vViewPosition );
3001
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3002
+ vec3 y = cross( viewDir, x );
3003
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3004
+ #ifdef USE_MATCAP
3005
+ vec4 matcapColor = texture2D( matcap, uv );
3006
+ #else
3007
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3008
+ #endif
3009
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3010
+ #include <opaque_fragment>
3011
+ #include <tonemapping_fragment>
3012
+ #include <colorspace_fragment>
3013
+ #include <fog_fragment>
3014
+ #include <premultiplied_alpha_fragment>
3015
+ #include <dithering_fragment>
3016
+ }\`,ia=\`#define NORMAL
3017
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3018
+ varying vec3 vViewPosition;
3019
+ #endif
3020
+ #include <common>
3021
+ #include <batching_pars_vertex>
3022
+ #include <uv_pars_vertex>
3023
+ #include <displacementmap_pars_vertex>
3024
+ #include <normal_pars_vertex>
3025
+ #include <morphtarget_pars_vertex>
3026
+ #include <skinning_pars_vertex>
3027
+ #include <logdepthbuf_pars_vertex>
3028
+ #include <clipping_planes_pars_vertex>
3029
+ void main() {
3030
+ #include <uv_vertex>
3031
+ #include <batching_vertex>
3032
+ #include <beginnormal_vertex>
3033
+ #include <morphinstance_vertex>
3034
+ #include <morphnormal_vertex>
3035
+ #include <skinbase_vertex>
3036
+ #include <skinnormal_vertex>
3037
+ #include <defaultnormal_vertex>
3038
+ #include <normal_vertex>
3039
+ #include <begin_vertex>
3040
+ #include <morphtarget_vertex>
3041
+ #include <skinning_vertex>
3042
+ #include <displacementmap_vertex>
3043
+ #include <project_vertex>
3044
+ #include <logdepthbuf_vertex>
3045
+ #include <clipping_planes_vertex>
3046
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3047
+ vViewPosition = - mvPosition.xyz;
3048
+ #endif
3049
+ }\`,sa=\`#define NORMAL
3050
+ uniform float opacity;
3051
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3052
+ varying vec3 vViewPosition;
3053
+ #endif
3054
+ #include <uv_pars_fragment>
3055
+ #include <normal_pars_fragment>
3056
+ #include <bumpmap_pars_fragment>
3057
+ #include <normalmap_pars_fragment>
3058
+ #include <logdepthbuf_pars_fragment>
3059
+ #include <clipping_planes_pars_fragment>
3060
+ void main() {
3061
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3062
+ #include <clipping_planes_fragment>
3063
+ #include <logdepthbuf_fragment>
3064
+ #include <normal_fragment_begin>
3065
+ #include <normal_fragment_maps>
3066
+ gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
3067
+ #ifdef OPAQUE
3068
+ gl_FragColor.a = 1.0;
3069
+ #endif
3070
+ }\`,ra=\`#define PHONG
3071
+ varying vec3 vViewPosition;
3072
+ #include <common>
3073
+ #include <batching_pars_vertex>
3074
+ #include <uv_pars_vertex>
3075
+ #include <displacementmap_pars_vertex>
3076
+ #include <envmap_pars_vertex>
3077
+ #include <color_pars_vertex>
3078
+ #include <fog_pars_vertex>
3079
+ #include <normal_pars_vertex>
3080
+ #include <morphtarget_pars_vertex>
3081
+ #include <skinning_pars_vertex>
3082
+ #include <shadowmap_pars_vertex>
3083
+ #include <logdepthbuf_pars_vertex>
3084
+ #include <clipping_planes_pars_vertex>
3085
+ void main() {
3086
+ #include <uv_vertex>
3087
+ #include <color_vertex>
3088
+ #include <morphcolor_vertex>
3089
+ #include <batching_vertex>
3090
+ #include <beginnormal_vertex>
3091
+ #include <morphinstance_vertex>
3092
+ #include <morphnormal_vertex>
3093
+ #include <skinbase_vertex>
3094
+ #include <skinnormal_vertex>
3095
+ #include <defaultnormal_vertex>
3096
+ #include <normal_vertex>
3097
+ #include <begin_vertex>
3098
+ #include <morphtarget_vertex>
3099
+ #include <skinning_vertex>
3100
+ #include <displacementmap_vertex>
3101
+ #include <project_vertex>
3102
+ #include <logdepthbuf_vertex>
3103
+ #include <clipping_planes_vertex>
3104
+ vViewPosition = - mvPosition.xyz;
3105
+ #include <worldpos_vertex>
3106
+ #include <envmap_vertex>
3107
+ #include <shadowmap_vertex>
3108
+ #include <fog_vertex>
3109
+ }\`,aa=\`#define PHONG
3110
+ uniform vec3 diffuse;
3111
+ uniform vec3 emissive;
3112
+ uniform vec3 specular;
3113
+ uniform float shininess;
3114
+ uniform float opacity;
3115
+ #include <common>
3116
+ #include <dithering_pars_fragment>
3117
+ #include <color_pars_fragment>
3118
+ #include <uv_pars_fragment>
3119
+ #include <map_pars_fragment>
3120
+ #include <alphamap_pars_fragment>
3121
+ #include <alphatest_pars_fragment>
3122
+ #include <alphahash_pars_fragment>
3123
+ #include <aomap_pars_fragment>
3124
+ #include <lightmap_pars_fragment>
3125
+ #include <emissivemap_pars_fragment>
3126
+ #include <envmap_common_pars_fragment>
3127
+ #include <envmap_pars_fragment>
3128
+ #include <fog_pars_fragment>
3129
+ #include <bsdfs>
3130
+ #include <lights_pars_begin>
3131
+ #include <normal_pars_fragment>
3132
+ #include <lights_phong_pars_fragment>
3133
+ #include <shadowmap_pars_fragment>
3134
+ #include <bumpmap_pars_fragment>
3135
+ #include <normalmap_pars_fragment>
3136
+ #include <specularmap_pars_fragment>
3137
+ #include <logdepthbuf_pars_fragment>
3138
+ #include <clipping_planes_pars_fragment>
3139
+ void main() {
3140
+ vec4 diffuseColor = vec4( diffuse, opacity );
3141
+ #include <clipping_planes_fragment>
3142
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3143
+ vec3 totalEmissiveRadiance = emissive;
3144
+ #include <logdepthbuf_fragment>
3145
+ #include <map_fragment>
3146
+ #include <color_fragment>
3147
+ #include <alphamap_fragment>
3148
+ #include <alphatest_fragment>
3149
+ #include <alphahash_fragment>
3150
+ #include <specularmap_fragment>
3151
+ #include <normal_fragment_begin>
3152
+ #include <normal_fragment_maps>
3153
+ #include <emissivemap_fragment>
3154
+ #include <lights_phong_fragment>
3155
+ #include <lights_fragment_begin>
3156
+ #include <lights_fragment_maps>
3157
+ #include <lights_fragment_end>
3158
+ #include <aomap_fragment>
3159
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3160
+ #include <envmap_fragment>
3161
+ #include <opaque_fragment>
3162
+ #include <tonemapping_fragment>
3163
+ #include <colorspace_fragment>
3164
+ #include <fog_fragment>
3165
+ #include <premultiplied_alpha_fragment>
3166
+ #include <dithering_fragment>
3167
+ }\`,oa=\`#define STANDARD
3168
+ varying vec3 vViewPosition;
3169
+ #ifdef USE_TRANSMISSION
3170
+ varying vec3 vWorldPosition;
3171
+ #endif
3172
+ #include <common>
3173
+ #include <batching_pars_vertex>
3174
+ #include <uv_pars_vertex>
3175
+ #include <displacementmap_pars_vertex>
3176
+ #include <color_pars_vertex>
3177
+ #include <fog_pars_vertex>
3178
+ #include <normal_pars_vertex>
3179
+ #include <morphtarget_pars_vertex>
3180
+ #include <skinning_pars_vertex>
3181
+ #include <shadowmap_pars_vertex>
3182
+ #include <logdepthbuf_pars_vertex>
3183
+ #include <clipping_planes_pars_vertex>
3184
+ void main() {
3185
+ #include <uv_vertex>
3186
+ #include <color_vertex>
3187
+ #include <morphinstance_vertex>
3188
+ #include <morphcolor_vertex>
3189
+ #include <batching_vertex>
3190
+ #include <beginnormal_vertex>
3191
+ #include <morphnormal_vertex>
3192
+ #include <skinbase_vertex>
3193
+ #include <skinnormal_vertex>
3194
+ #include <defaultnormal_vertex>
3195
+ #include <normal_vertex>
3196
+ #include <begin_vertex>
3197
+ #include <morphtarget_vertex>
3198
+ #include <skinning_vertex>
3199
+ #include <displacementmap_vertex>
3200
+ #include <project_vertex>
3201
+ #include <logdepthbuf_vertex>
3202
+ #include <clipping_planes_vertex>
3203
+ vViewPosition = - mvPosition.xyz;
3204
+ #include <worldpos_vertex>
3205
+ #include <shadowmap_vertex>
3206
+ #include <fog_vertex>
3207
+ #ifdef USE_TRANSMISSION
3208
+ vWorldPosition = worldPosition.xyz;
3209
+ #endif
3210
+ }\`,la=\`#define STANDARD
3211
+ #ifdef PHYSICAL
3212
+ #define IOR
3213
+ #define USE_SPECULAR
3214
+ #endif
3215
+ uniform vec3 diffuse;
3216
+ uniform vec3 emissive;
3217
+ uniform float roughness;
3218
+ uniform float metalness;
3219
+ uniform float opacity;
3220
+ #ifdef IOR
3221
+ uniform float ior;
3222
+ #endif
3223
+ #ifdef USE_SPECULAR
3224
+ uniform float specularIntensity;
3225
+ uniform vec3 specularColor;
3226
+ #ifdef USE_SPECULAR_COLORMAP
3227
+ uniform sampler2D specularColorMap;
3228
+ #endif
3229
+ #ifdef USE_SPECULAR_INTENSITYMAP
3230
+ uniform sampler2D specularIntensityMap;
3231
+ #endif
3232
+ #endif
3233
+ #ifdef USE_CLEARCOAT
3234
+ uniform float clearcoat;
3235
+ uniform float clearcoatRoughness;
3236
+ #endif
3237
+ #ifdef USE_DISPERSION
3238
+ uniform float dispersion;
3239
+ #endif
3240
+ #ifdef USE_IRIDESCENCE
3241
+ uniform float iridescence;
3242
+ uniform float iridescenceIOR;
3243
+ uniform float iridescenceThicknessMinimum;
3244
+ uniform float iridescenceThicknessMaximum;
3245
+ #endif
3246
+ #ifdef USE_SHEEN
3247
+ uniform vec3 sheenColor;
3248
+ uniform float sheenRoughness;
3249
+ #ifdef USE_SHEEN_COLORMAP
3250
+ uniform sampler2D sheenColorMap;
3251
+ #endif
3252
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3253
+ uniform sampler2D sheenRoughnessMap;
3254
+ #endif
3255
+ #endif
3256
+ #ifdef USE_ANISOTROPY
3257
+ uniform vec2 anisotropyVector;
3258
+ #ifdef USE_ANISOTROPYMAP
3259
+ uniform sampler2D anisotropyMap;
3260
+ #endif
3261
+ #endif
3262
+ varying vec3 vViewPosition;
3263
+ #include <common>
3264
+ #include <dithering_pars_fragment>
3265
+ #include <color_pars_fragment>
3266
+ #include <uv_pars_fragment>
3267
+ #include <map_pars_fragment>
3268
+ #include <alphamap_pars_fragment>
3269
+ #include <alphatest_pars_fragment>
3270
+ #include <alphahash_pars_fragment>
3271
+ #include <aomap_pars_fragment>
3272
+ #include <lightmap_pars_fragment>
3273
+ #include <emissivemap_pars_fragment>
3274
+ #include <iridescence_fragment>
3275
+ #include <cube_uv_reflection_fragment>
3276
+ #include <envmap_common_pars_fragment>
3277
+ #include <envmap_physical_pars_fragment>
3278
+ #include <fog_pars_fragment>
3279
+ #include <lights_pars_begin>
3280
+ #include <normal_pars_fragment>
3281
+ #include <lights_physical_pars_fragment>
3282
+ #include <transmission_pars_fragment>
3283
+ #include <shadowmap_pars_fragment>
3284
+ #include <bumpmap_pars_fragment>
3285
+ #include <normalmap_pars_fragment>
3286
+ #include <clearcoat_pars_fragment>
3287
+ #include <iridescence_pars_fragment>
3288
+ #include <roughnessmap_pars_fragment>
3289
+ #include <metalnessmap_pars_fragment>
3290
+ #include <logdepthbuf_pars_fragment>
3291
+ #include <clipping_planes_pars_fragment>
3292
+ void main() {
3293
+ vec4 diffuseColor = vec4( diffuse, opacity );
3294
+ #include <clipping_planes_fragment>
3295
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3296
+ vec3 totalEmissiveRadiance = emissive;
3297
+ #include <logdepthbuf_fragment>
3298
+ #include <map_fragment>
3299
+ #include <color_fragment>
3300
+ #include <alphamap_fragment>
3301
+ #include <alphatest_fragment>
3302
+ #include <alphahash_fragment>
3303
+ #include <roughnessmap_fragment>
3304
+ #include <metalnessmap_fragment>
3305
+ #include <normal_fragment_begin>
3306
+ #include <normal_fragment_maps>
3307
+ #include <clearcoat_normal_fragment_begin>
3308
+ #include <clearcoat_normal_fragment_maps>
3309
+ #include <emissivemap_fragment>
3310
+ #include <lights_physical_fragment>
3311
+ #include <lights_fragment_begin>
3312
+ #include <lights_fragment_maps>
3313
+ #include <lights_fragment_end>
3314
+ #include <aomap_fragment>
3315
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3316
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3317
+ #include <transmission_fragment>
3318
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3319
+ #ifdef USE_SHEEN
3320
+
3321
+ outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
3322
+
3323
+ #endif
3324
+ #ifdef USE_CLEARCOAT
3325
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3326
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3327
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3328
+ #endif
3329
+ #include <opaque_fragment>
3330
+ #include <tonemapping_fragment>
3331
+ #include <colorspace_fragment>
3332
+ #include <fog_fragment>
3333
+ #include <premultiplied_alpha_fragment>
3334
+ #include <dithering_fragment>
3335
+ }\`,ca=\`#define TOON
3336
+ varying vec3 vViewPosition;
3337
+ #include <common>
3338
+ #include <batching_pars_vertex>
3339
+ #include <uv_pars_vertex>
3340
+ #include <displacementmap_pars_vertex>
3341
+ #include <color_pars_vertex>
3342
+ #include <fog_pars_vertex>
3343
+ #include <normal_pars_vertex>
3344
+ #include <morphtarget_pars_vertex>
3345
+ #include <skinning_pars_vertex>
3346
+ #include <shadowmap_pars_vertex>
3347
+ #include <logdepthbuf_pars_vertex>
3348
+ #include <clipping_planes_pars_vertex>
3349
+ void main() {
3350
+ #include <uv_vertex>
3351
+ #include <color_vertex>
3352
+ #include <morphinstance_vertex>
3353
+ #include <morphcolor_vertex>
3354
+ #include <batching_vertex>
3355
+ #include <beginnormal_vertex>
3356
+ #include <morphnormal_vertex>
3357
+ #include <skinbase_vertex>
3358
+ #include <skinnormal_vertex>
3359
+ #include <defaultnormal_vertex>
3360
+ #include <normal_vertex>
3361
+ #include <begin_vertex>
3362
+ #include <morphtarget_vertex>
3363
+ #include <skinning_vertex>
3364
+ #include <displacementmap_vertex>
3365
+ #include <project_vertex>
3366
+ #include <logdepthbuf_vertex>
3367
+ #include <clipping_planes_vertex>
3368
+ vViewPosition = - mvPosition.xyz;
3369
+ #include <worldpos_vertex>
3370
+ #include <shadowmap_vertex>
3371
+ #include <fog_vertex>
3372
+ }\`,ha=\`#define TOON
3373
+ uniform vec3 diffuse;
3374
+ uniform vec3 emissive;
3375
+ uniform float opacity;
3376
+ #include <common>
3377
+ #include <dithering_pars_fragment>
3378
+ #include <color_pars_fragment>
3379
+ #include <uv_pars_fragment>
3380
+ #include <map_pars_fragment>
3381
+ #include <alphamap_pars_fragment>
3382
+ #include <alphatest_pars_fragment>
3383
+ #include <alphahash_pars_fragment>
3384
+ #include <aomap_pars_fragment>
3385
+ #include <lightmap_pars_fragment>
3386
+ #include <emissivemap_pars_fragment>
3387
+ #include <gradientmap_pars_fragment>
3388
+ #include <fog_pars_fragment>
3389
+ #include <bsdfs>
3390
+ #include <lights_pars_begin>
3391
+ #include <normal_pars_fragment>
3392
+ #include <lights_toon_pars_fragment>
3393
+ #include <shadowmap_pars_fragment>
3394
+ #include <bumpmap_pars_fragment>
3395
+ #include <normalmap_pars_fragment>
3396
+ #include <logdepthbuf_pars_fragment>
3397
+ #include <clipping_planes_pars_fragment>
3398
+ void main() {
3399
+ vec4 diffuseColor = vec4( diffuse, opacity );
3400
+ #include <clipping_planes_fragment>
3401
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3402
+ vec3 totalEmissiveRadiance = emissive;
3403
+ #include <logdepthbuf_fragment>
3404
+ #include <map_fragment>
3405
+ #include <color_fragment>
3406
+ #include <alphamap_fragment>
3407
+ #include <alphatest_fragment>
3408
+ #include <alphahash_fragment>
3409
+ #include <normal_fragment_begin>
3410
+ #include <normal_fragment_maps>
3411
+ #include <emissivemap_fragment>
3412
+ #include <lights_toon_fragment>
3413
+ #include <lights_fragment_begin>
3414
+ #include <lights_fragment_maps>
3415
+ #include <lights_fragment_end>
3416
+ #include <aomap_fragment>
3417
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3418
+ #include <opaque_fragment>
3419
+ #include <tonemapping_fragment>
3420
+ #include <colorspace_fragment>
3421
+ #include <fog_fragment>
3422
+ #include <premultiplied_alpha_fragment>
3423
+ #include <dithering_fragment>
3424
+ }\`,ua=\`uniform float size;
3425
+ uniform float scale;
3426
+ #include <common>
3427
+ #include <color_pars_vertex>
3428
+ #include <fog_pars_vertex>
3429
+ #include <morphtarget_pars_vertex>
3430
+ #include <logdepthbuf_pars_vertex>
3431
+ #include <clipping_planes_pars_vertex>
3432
+ #ifdef USE_POINTS_UV
3433
+ varying vec2 vUv;
3434
+ uniform mat3 uvTransform;
3435
+ #endif
3436
+ void main() {
3437
+ #ifdef USE_POINTS_UV
3438
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3439
+ #endif
3440
+ #include <color_vertex>
3441
+ #include <morphinstance_vertex>
3442
+ #include <morphcolor_vertex>
3443
+ #include <begin_vertex>
3444
+ #include <morphtarget_vertex>
3445
+ #include <project_vertex>
3446
+ gl_PointSize = size;
3447
+ #ifdef USE_SIZEATTENUATION
3448
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3449
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3450
+ #endif
3451
+ #include <logdepthbuf_vertex>
3452
+ #include <clipping_planes_vertex>
3453
+ #include <worldpos_vertex>
3454
+ #include <fog_vertex>
3455
+ }\`,da=\`uniform vec3 diffuse;
3456
+ uniform float opacity;
3457
+ #include <common>
3458
+ #include <color_pars_fragment>
3459
+ #include <map_particle_pars_fragment>
3460
+ #include <alphatest_pars_fragment>
3461
+ #include <alphahash_pars_fragment>
3462
+ #include <fog_pars_fragment>
3463
+ #include <logdepthbuf_pars_fragment>
3464
+ #include <clipping_planes_pars_fragment>
3465
+ void main() {
3466
+ vec4 diffuseColor = vec4( diffuse, opacity );
3467
+ #include <clipping_planes_fragment>
3468
+ vec3 outgoingLight = vec3( 0.0 );
3469
+ #include <logdepthbuf_fragment>
3470
+ #include <map_particle_fragment>
3471
+ #include <color_fragment>
3472
+ #include <alphatest_fragment>
3473
+ #include <alphahash_fragment>
3474
+ outgoingLight = diffuseColor.rgb;
3475
+ #include <opaque_fragment>
3476
+ #include <tonemapping_fragment>
3477
+ #include <colorspace_fragment>
3478
+ #include <fog_fragment>
3479
+ #include <premultiplied_alpha_fragment>
3480
+ }\`,fa=\`#include <common>
3481
+ #include <batching_pars_vertex>
3482
+ #include <fog_pars_vertex>
3483
+ #include <morphtarget_pars_vertex>
3484
+ #include <skinning_pars_vertex>
3485
+ #include <logdepthbuf_pars_vertex>
3486
+ #include <shadowmap_pars_vertex>
3487
+ void main() {
3488
+ #include <batching_vertex>
3489
+ #include <beginnormal_vertex>
3490
+ #include <morphinstance_vertex>
3491
+ #include <morphnormal_vertex>
3492
+ #include <skinbase_vertex>
3493
+ #include <skinnormal_vertex>
3494
+ #include <defaultnormal_vertex>
3495
+ #include <begin_vertex>
3496
+ #include <morphtarget_vertex>
3497
+ #include <skinning_vertex>
3498
+ #include <project_vertex>
3499
+ #include <logdepthbuf_vertex>
3500
+ #include <worldpos_vertex>
3501
+ #include <shadowmap_vertex>
3502
+ #include <fog_vertex>
3503
+ }\`,pa=\`uniform vec3 color;
3504
+ uniform float opacity;
3505
+ #include <common>
3506
+ #include <fog_pars_fragment>
3507
+ #include <bsdfs>
3508
+ #include <lights_pars_begin>
3509
+ #include <logdepthbuf_pars_fragment>
3510
+ #include <shadowmap_pars_fragment>
3511
+ #include <shadowmask_pars_fragment>
3512
+ void main() {
3513
+ #include <logdepthbuf_fragment>
3514
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3515
+ #include <tonemapping_fragment>
3516
+ #include <colorspace_fragment>
3517
+ #include <fog_fragment>
3518
+ }\`,ma=\`uniform float rotation;
3519
+ uniform vec2 center;
3520
+ #include <common>
3521
+ #include <uv_pars_vertex>
3522
+ #include <fog_pars_vertex>
3523
+ #include <logdepthbuf_pars_vertex>
3524
+ #include <clipping_planes_pars_vertex>
3525
+ void main() {
3526
+ #include <uv_vertex>
3527
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3528
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3529
+ #ifndef USE_SIZEATTENUATION
3530
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3531
+ if ( isPerspective ) scale *= - mvPosition.z;
3532
+ #endif
3533
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3534
+ vec2 rotatedPosition;
3535
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3536
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3537
+ mvPosition.xy += rotatedPosition;
3538
+ gl_Position = projectionMatrix * mvPosition;
3539
+ #include <logdepthbuf_vertex>
3540
+ #include <clipping_planes_vertex>
3541
+ #include <fog_vertex>
3542
+ }\`,ga=\`uniform vec3 diffuse;
3543
+ uniform float opacity;
3544
+ #include <common>
3545
+ #include <uv_pars_fragment>
3546
+ #include <map_pars_fragment>
3547
+ #include <alphamap_pars_fragment>
3548
+ #include <alphatest_pars_fragment>
3549
+ #include <alphahash_pars_fragment>
3550
+ #include <fog_pars_fragment>
3551
+ #include <logdepthbuf_pars_fragment>
3552
+ #include <clipping_planes_pars_fragment>
3553
+ void main() {
3554
+ vec4 diffuseColor = vec4( diffuse, opacity );
3555
+ #include <clipping_planes_fragment>
3556
+ vec3 outgoingLight = vec3( 0.0 );
3557
+ #include <logdepthbuf_fragment>
3558
+ #include <map_fragment>
3559
+ #include <alphamap_fragment>
3560
+ #include <alphatest_fragment>
3561
+ #include <alphahash_fragment>
3562
+ outgoingLight = diffuseColor.rgb;
3563
+ #include <opaque_fragment>
3564
+ #include <tonemapping_fragment>
3565
+ #include <colorspace_fragment>
3566
+ #include <fog_fragment>
3567
+ }\`,C={alphahash_fragment:Bi,alphahash_pars_fragment:zi,alphamap_fragment:Vi,alphamap_pars_fragment:ki,alphatest_fragment:Gi,alphatest_pars_fragment:Hi,aomap_fragment:Wi,aomap_pars_fragment:Xi,batching_pars_vertex:qi,batching_vertex:Yi,begin_vertex:Zi,beginnormal_vertex:Ji,bsdfs:\$i,iridescence_fragment:Ki,bumpmap_pars_fragment:Qi,clipping_planes_fragment:ji,clipping_planes_pars_fragment:es,clipping_planes_pars_vertex:ts,clipping_planes_vertex:ns,color_fragment:is,color_pars_fragment:ss,color_pars_vertex:rs,color_vertex:as,common:os,cube_uv_reflection_fragment:ls,defaultnormal_vertex:cs,displacementmap_pars_vertex:hs,displacementmap_vertex:us,emissivemap_fragment:ds,emissivemap_pars_fragment:fs,colorspace_fragment:ps,colorspace_pars_fragment:ms,envmap_fragment:gs,envmap_common_pars_fragment:_s,envmap_pars_fragment:xs,envmap_pars_vertex:vs,envmap_physical_pars_fragment:Is,envmap_vertex:ys,fog_vertex:Ms,fog_pars_vertex:Ss,fog_fragment:bs,fog_pars_fragment:As,gradientmap_pars_fragment:Ts,lightmap_pars_fragment:Es,lights_lambert_fragment:ws,lights_lambert_pars_fragment:Cs,lights_pars_begin:Rs,lights_toon_fragment:Ps,lights_toon_pars_fragment:Ls,lights_phong_fragment:Ds,lights_phong_pars_fragment:Us,lights_physical_fragment:Ns,lights_physical_pars_fragment:Fs,lights_fragment_begin:Os,lights_fragment_maps:Bs,lights_fragment_end:zs,logdepthbuf_fragment:Vs,logdepthbuf_pars_fragment:ks,logdepthbuf_pars_vertex:Gs,logdepthbuf_vertex:Hs,map_fragment:Ws,map_pars_fragment:Xs,map_particle_fragment:qs,map_particle_pars_fragment:Ys,metalnessmap_fragment:Zs,metalnessmap_pars_fragment:Js,morphinstance_vertex:\$s,morphcolor_vertex:Ks,morphnormal_vertex:Qs,morphtarget_pars_vertex:js,morphtarget_vertex:er,normal_fragment_begin:tr,normal_fragment_maps:nr,normal_pars_fragment:ir,normal_pars_vertex:sr,normal_vertex:rr,normalmap_pars_fragment:ar,clearcoat_normal_fragment_begin:or,clearcoat_normal_fragment_maps:lr,clearcoat_pars_fragment:cr,iridescence_pars_fragment:hr,opaque_fragment:ur,packing:dr,premultiplied_alpha_fragment:fr,project_vertex:pr,dithering_fragment:mr,dithering_pars_fragment:gr,roughnessmap_fragment:_r,roughnessmap_pars_fragment:xr,shadowmap_pars_fragment:vr,shadowmap_pars_vertex:yr,shadowmap_vertex:Mr,shadowmask_pars_fragment:Sr,skinbase_vertex:br,skinning_pars_vertex:Ar,skinning_vertex:Tr,skinnormal_vertex:Er,specularmap_fragment:wr,specularmap_pars_fragment:Cr,tonemapping_fragment:Rr,tonemapping_pars_fragment:Ir,transmission_fragment:Pr,transmission_pars_fragment:Lr,uv_pars_fragment:Dr,uv_pars_vertex:Ur,uv_vertex:Nr,worldpos_vertex:Fr,background_vert:Or,background_frag:Br,backgroundCube_vert:zr,backgroundCube_frag:Vr,cube_vert:kr,cube_frag:Gr,depth_vert:Hr,depth_frag:Wr,distance_vert:Xr,distance_frag:qr,equirect_vert:Yr,equirect_frag:Zr,linedashed_vert:Jr,linedashed_frag:\$r,meshbasic_vert:Kr,meshbasic_frag:Qr,meshlambert_vert:jr,meshlambert_frag:ea,meshmatcap_vert:ta,meshmatcap_frag:na,meshnormal_vert:ia,meshnormal_frag:sa,meshphong_vert:ra,meshphong_frag:aa,meshphysical_vert:oa,meshphysical_frag:la,meshtoon_vert:ca,meshtoon_frag:ha,points_vert:ua,points_frag:da,shadow_vert:fa,shadow_frag:pa,sprite_vert:ma,sprite_frag:ga},M={common:{diffuse:{value:new D(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new w},alphaMap:{value:null},alphaMapTransform:{value:new w},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new w}},envmap:{envMap:{value:null},envMapRotation:{value:new w},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new w}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new w}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new w},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new w},normalScale:{value:new H(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new w},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new w}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new w}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new w}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new D(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 D(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new w},alphaTest:{value:0},uvTransform:{value:new w}},sprite:{diffuse:{value:new D(16777215)},opacity:{value:1},center:{value:new H(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new w},alphaMap:{value:null},alphaMapTransform:{value:new w},alphaTest:{value:0}}},fi={basic:{uniforms:W([M.common,M.specularmap,M.envmap,M.aomap,M.lightmap,M.fog]),vertexShader:C.meshbasic_vert,fragmentShader:C.meshbasic_frag},lambert:{uniforms:W([M.common,M.specularmap,M.envmap,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.fog,M.lights,{emissive:{value:new D(0)}}]),vertexShader:C.meshlambert_vert,fragmentShader:C.meshlambert_frag},phong:{uniforms:W([M.common,M.specularmap,M.envmap,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.fog,M.lights,{emissive:{value:new D(0)},specular:{value:new D(1118481)},shininess:{value:30}}]),vertexShader:C.meshphong_vert,fragmentShader:C.meshphong_frag},standard:{uniforms:W([M.common,M.envmap,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.roughnessmap,M.metalnessmap,M.fog,M.lights,{emissive:{value:new D(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:C.meshphysical_vert,fragmentShader:C.meshphysical_frag},toon:{uniforms:W([M.common,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.gradientmap,M.fog,M.lights,{emissive:{value:new D(0)}}]),vertexShader:C.meshtoon_vert,fragmentShader:C.meshtoon_frag},matcap:{uniforms:W([M.common,M.bumpmap,M.normalmap,M.displacementmap,M.fog,{matcap:{value:null}}]),vertexShader:C.meshmatcap_vert,fragmentShader:C.meshmatcap_frag},points:{uniforms:W([M.points,M.fog]),vertexShader:C.points_vert,fragmentShader:C.points_frag},dashed:{uniforms:W([M.common,M.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:C.linedashed_vert,fragmentShader:C.linedashed_frag},depth:{uniforms:W([M.common,M.displacementmap]),vertexShader:C.depth_vert,fragmentShader:C.depth_frag},normal:{uniforms:W([M.common,M.bumpmap,M.normalmap,M.displacementmap,{opacity:{value:1}}]),vertexShader:C.meshnormal_vert,fragmentShader:C.meshnormal_frag},sprite:{uniforms:W([M.sprite,M.fog]),vertexShader:C.sprite_vert,fragmentShader:C.sprite_frag},background:{uniforms:{uvTransform:{value:new w},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:C.background_vert,fragmentShader:C.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new w}},vertexShader:C.backgroundCube_vert,fragmentShader:C.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:C.cube_vert,fragmentShader:C.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:C.equirect_vert,fragmentShader:C.equirect_frag},distance:{uniforms:W([M.common,M.displacementmap,{referencePosition:{value:new x},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:C.distance_vert,fragmentShader:C.distance_frag},shadow:{uniforms:W([M.lights,M.fog,{color:{value:new D(0)},opacity:{value:1}}]),vertexShader:C.shadow_vert,fragmentShader:C.shadow_frag}};fi.physical={uniforms:W([fi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new w},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new w},clearcoatNormalScale:{value:new H(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new w},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new w},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new w},sheen:{value:0},sheenColor:{value:new D(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new w},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new w},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new w},transmissionSamplerSize:{value:new H},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new w},attenuationDistance:{value:0},attenuationColor:{value:new D(0)},specularColor:{value:new D(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new w},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new w},anisotropyVector:{value:new H},anisotropyMap:{value:null},anisotropyMapTransform:{value:new w}}]),vertexShader:C.meshphysical_vert,fragmentShader:C.meshphysical_frag};var Ld={[En]:"LINEAR_TONE_MAPPING",[wn]:"REINHARD_TONE_MAPPING",[Cn]:"CINEON_TONE_MAPPING",[Rn]:"ACES_FILMIC_TONE_MAPPING",[Pn]:"AGX_TONE_MAPPING",[Ln]:"NEUTRAL_TONE_MAPPING",[In]:"CUSTOM_TONE_MAPPING"};var Dd=new Float32Array(16),Ud=new Float32Array(9),Nd=new Float32Array(4);var Fd={[En]:"Linear",[wn]:"Reinhard",[Cn]:"Cineon",[Rn]:"ACESFilmic",[Pn]:"AgX",[Ln]:"Neutral",[In]:"Custom"};var Od={[Kn]:"SHADOWMAP_TYPE_PCF",[Qn]:"SHADOWMAP_TYPE_VSM"};var Bd={[ni]:"ENVMAP_TYPE_CUBE",[Un]:"ENVMAP_TYPE_CUBE",[ii]:"ENVMAP_TYPE_CUBE_UV"};var zd={[Un]:"ENVMAP_MODE_REFRACTION"};var Vd={[jn]:"ENVMAP_BLENDING_MULTIPLY",[ei]:"ENVMAP_BLENDING_MIX",[ti]:"ENVMAP_BLENDING_ADD"};var kd={[vn]:yn,[Mn]:An,[Sn]:Tn,[We]:bn,[yn]:vn,[An]:Mn,[Tn]:Sn,[bn]:We};var Gd=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);var Ot=class extends Ae{constructor(e){super(e),this.littleEndian=!0}load(e,t,n,i){let s=this,r=new Ke(s.manager);r.setPath(s.path),r.setResponseType("arraybuffer"),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}_getDataView(e,t,n,i){switch(n){case"F":return i===8?e.getFloat64(t,this.littleEndian):e.getFloat32(t,this.littleEndian);case"I":return i===1?e.getInt8(t):i===2?e.getInt16(t,this.littleEndian):e.getInt32(t,this.littleEndian);case"U":return i===1?e.getUint8(t):i===2?e.getUint16(t,this.littleEndian):e.getUint32(t,this.littleEndian)}}parse(e){function t(d,h){let m=d.length,_=new Uint8Array(h),g=0,y=0,v,b,S;do if(v=d[g++],v<32){if(v++,y+v>h)throw new Error("Output buffer is not large enough");if(g+v>m)throw new Error("Invalid compressed data");do _[y++]=d[g++];while(--v)}else{if(b=v>>5,S=y-((v&31)<<8)-1,g>=m)throw new Error("Invalid compressed data");if(b===7&&(b+=d[g++],g>=m))throw new Error("Invalid compressed data");if(S-=d[g++],y+b+2>h)throw new Error("Output buffer is not large enough");if(S<0)throw new Error("Invalid compressed data");if(S>=y)throw new Error("Invalid compressed data");do _[y++]=_[S++];while(--b+2)}while(g<m);return _}function n(d){let h={},m=new Uint8Array(d),_="",g="",y=0,v=!1,b=m.length;for(;y<b&&v===!1;){let A=String.fromCharCode(m[y++]);A===\`
3568
+ \`||A==="\\r"?(g.trim().toLowerCase().startsWith("data")&&(v=!0),g=""):g+=A,_+=A}let S=_.search(/[\\r\\n]DATA\\s(\\S*)\\s/i),E=/[\\r\\n]DATA\\s(\\S*)\\s/i.exec(_.slice(S-1));if(h.data=E[1],h.headerLen=E[0].length+S,h.str=_.slice(0,h.headerLen),h.str=h.str.replace(/#.*/gi,""),h.version=/^VERSION (.*)/im.exec(h.str),h.fields=/^FIELDS (.*)/im.exec(h.str),h.size=/^SIZE (.*)/im.exec(h.str),h.type=/^TYPE (.*)/im.exec(h.str),h.count=/^COUNT (.*)/im.exec(h.str),h.width=/^WIDTH (.*)/im.exec(h.str),h.height=/^HEIGHT (.*)/im.exec(h.str),h.viewpoint=/^VIEWPOINT (.*)/im.exec(h.str),h.points=/^POINTS (.*)/im.exec(h.str),h.version!==null&&(h.version=parseFloat(h.version[1])),h.fields=h.fields!==null?h.fields[1].split(" "):[],h.type!==null&&(h.type=h.type[1].split(" ")),h.width!==null&&(h.width=parseInt(h.width[1])),h.height!==null&&(h.height=parseInt(h.height[1])),h.viewpoint!==null&&(h.viewpoint=h.viewpoint[1]),h.points!==null&&(h.points=parseInt(h.points[1],10)),h.points===null&&(h.points=h.width*h.height),h.size!==null&&(h.size=h.size[1].split(" ").map(function(A){return parseInt(A,10)})),h.count!==null)h.count=h.count[1].split(" ").map(function(A){return parseInt(A,10)});else{h.count=[];for(let A=0,P=h.fields.length;A<P;A++)h.count.push(1)}h.offset={};let T=0;for(let A=0,P=h.fields.length;A<P;A++)h.data==="ascii"?h.offset[h.fields[A]]=A:(h.offset[h.fields[A]]=T,T+=h.size[A]*h.count[A]);return h.rowSize=T,h}let i=n(e),s=[],r=[],a=[],l=[],o=[],c=new D;if(i.data==="ascii"){let d=i.offset,_=new TextDecoder().decode(e).slice(i.headerLen).split(\`
3569
+ \`);for(let g=0,y=_.length;g<y;g++){if(_[g]==="")continue;let v=_[g].split(" ");if(d.x!==void 0&&(s.push(parseFloat(v[d.x])),s.push(parseFloat(v[d.y])),s.push(parseFloat(v[d.z]))),d.rgb!==void 0){let b=i.fields.findIndex(U=>U==="rgb"),S=i.type[b],E=parseFloat(v[d.rgb]),T=E;if(S==="F"){let U=new Float32Array(1);U[0]=E,T=new Int32Array(U.buffer)[0]}let A=(T>>16&255)/255,P=(T>>8&255)/255,O=(T>>0&255)/255;c.setRGB(A,P,O,G),a.push(c.r,c.g,c.b)}d.normal_x!==void 0&&(r.push(parseFloat(v[d.normal_x])),r.push(parseFloat(v[d.normal_y])),r.push(parseFloat(v[d.normal_z]))),d.intensity!==void 0&&l.push(parseFloat(v[d.intensity])),d.label!==void 0&&o.push(parseInt(v[d.label]))}}if(i.data==="binary_compressed"){let d=new Uint32Array(e.slice(i.headerLen,i.headerLen+8)),h=d[0],m=d[1],_=t(new Uint8Array(e,i.headerLen+8,h),m),g=new DataView(_.buffer),y=i.offset;for(let v=0;v<i.points;v++){if(y.x!==void 0){let b=i.fields.indexOf("x"),S=i.fields.indexOf("y"),E=i.fields.indexOf("z");s.push(this._getDataView(g,i.points*y.x+i.size[b]*v,i.type[b],i.size[b])),s.push(this._getDataView(g,i.points*y.y+i.size[S]*v,i.type[S],i.size[S])),s.push(this._getDataView(g,i.points*y.z+i.size[E]*v,i.type[E],i.size[E]))}if(y.rgb!==void 0){let b=i.fields.indexOf("rgb"),S=g.getUint8(i.points*y.rgb+i.size[b]*v+2)/255,E=g.getUint8(i.points*y.rgb+i.size[b]*v+1)/255,T=g.getUint8(i.points*y.rgb+i.size[b]*v+0)/255;c.setRGB(S,E,T,G),a.push(c.r,c.g,c.b)}if(y.normal_x!==void 0){let b=i.fields.indexOf("normal_x"),S=i.fields.indexOf("normal_y"),E=i.fields.indexOf("normal_z");r.push(this._getDataView(g,i.points*y.normal_x+i.size[b]*v,i.type[b],i.size[b])),r.push(this._getDataView(g,i.points*y.normal_y+i.size[S]*v,i.type[S],i.size[S])),r.push(this._getDataView(g,i.points*y.normal_z+i.size[E]*v,i.type[E],i.size[E]))}if(y.intensity!==void 0){let b=i.fields.indexOf("intensity");l.push(this._getDataView(g,i.points*y.intensity+i.size[b]*v,i.type[b],i.size[b]))}if(y.label!==void 0){let b=i.fields.indexOf("label");o.push(g.getInt32(i.points*y.label+i.size[b]*v,this.littleEndian))}}}if(i.data==="binary"){let d=new DataView(e,i.headerLen),h=i.offset;for(let m=0,_=0;m<i.points;m++,_+=i.rowSize){if(h.x!==void 0){let g=i.fields.indexOf("x"),y=i.fields.indexOf("y"),v=i.fields.indexOf("z");s.push(this._getDataView(d,_+h.x,i.type[g],i.size[g])),s.push(this._getDataView(d,_+h.y,i.type[y],i.size[y])),s.push(this._getDataView(d,_+h.z,i.type[v],i.size[v]))}if(h.rgb!==void 0){let g=d.getUint8(_+h.rgb+2)/255,y=d.getUint8(_+h.rgb+1)/255,v=d.getUint8(_+h.rgb+0)/255;c.setRGB(g,y,v,G),a.push(c.r,c.g,c.b)}if(h.normal_x!==void 0){let g=i.fields.indexOf("normal_x"),y=i.fields.indexOf("normal_y"),v=i.fields.indexOf("normal_z");r.push(this._getDataView(d,_+h.normal_x,i.type[g],i.size[g])),r.push(this._getDataView(d,_+h.normal_y,i.type[y],i.size[y])),r.push(this._getDataView(d,_+h.normal_z,i.type[v],i.size[v]))}if(h.intensity!==void 0){let g=i.fields.indexOf("intensity");l.push(this._getDataView(d,_+h.intensity,i.type[g],i.size[g]))}h.label!==void 0&&o.push(d.getInt32(_+h.label,this.littleEndian))}}let u=new Ne;s.length>0&&u.setAttribute("position",new oe(s,3)),r.length>0&&u.setAttribute("normal",new oe(r,3)),a.length>0&&u.setAttribute("color",new oe(a,3)),l.length>0&&u.setAttribute("intensity",new oe(l,1)),o.length>0&&u.setAttribute("label",new Ze(o,1)),u.computeBoundingSphere();let f=new Fe({size:.005});return a.length>0&&(f.vertexColors=!0),new Je(u,f)}};var _a=new Ot;self.onmessage=async p=>{let{data:e,id:t}=p.data;if(!(e instanceof Uint8Array)){postMessage({id:t,error:"Invalid data format"});return}try{let n=_a.parse(e.buffer);if(n.geometry){let i=n.geometry.attributes.position?.array??new Float32Array(0),s=n.geometry.attributes.color?.array??null,r=s?new Uint8Array(s.length):null;if(r)for(let a=0,l=s.length;a<l;a++)r[a]=Math.round(s[a]*255);postMessage({positions:i,colors:r,id:t},r?[i.buffer,r.buffer]:[i.buffer])}else postMessage({id:t,error:"Failed to extract geometry"})}catch(n){postMessage({id:t,error:n.message})}};})();
3570
+ /*! Bundled license information:
3571
+
3572
+ three/build/three.core.js:
3573
+ three/build/three.module.js:
3574
+ (**
3575
+ * @license
3576
+ * Copyright 2010-2025 Three.js Authors
3577
+ * SPDX-License-Identifier: MIT
3578
+ *)
3579
+ */
3580
+ `;